]> git.mxchange.org Git - hub.git/commitdiff
ListenerPool added with Poolable interface (should we change the name of the interface?)
authorRoland Häder <roland@mxchange.org>
Tue, 7 Jul 2009 18:47:12 +0000 (18:47 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 7 Jul 2009 18:47:12 +0000 (18:47 +0000)
12 files changed:
.gitattributes
application/hub/config.php
application/hub/interfaces/pool/.htaccess [new file with mode: 0644]
application/hub/interfaces/pool/class_Poolable.php [new file with mode: 0644]
application/hub/main/listener/class_
application/hub/main/listener/pool/.htaccess [deleted file]
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/pools/.htaccess [new file with mode: 0644]
application/hub/main/pools/class_ [new file with mode: 0644]
application/hub/main/pools/class_BasePool.php [new file with mode: 0644]
application/hub/main/pools/listener/.htaccess [new file with mode: 0644]
application/hub/main/pools/listener/class_DefaultListenerPool.php [new file with mode: 0644]

index ef90428068c894ebe6725aea8b3d9782667c471b..9f1b7ac6a0232209c38dff42fbca77161ebb17f6 100644 (file)
@@ -14,6 +14,8 @@ application/hub/interfaces/connectors/.htaccess -text
 application/hub/interfaces/connectors/class_Connectable.php -text
 application/hub/interfaces/nodes/.htaccess -text
 application/hub/interfaces/nodes/class_NodeHelper.php -text
+application/hub/interfaces/pool/.htaccess -text
+application/hub/interfaces/pool/class_Poolable.php -text
 application/hub/interfaces/query/.htaccess -text
 application/hub/interfaces/query/class_Queryable.php -text
 application/hub/interfaces/queues/.htaccess -text
@@ -39,7 +41,6 @@ application/hub/main/database/wrapper/class_NodeInformationDatabaseWrapper.php -
 application/hub/main/listener/.htaccess -text
 application/hub/main/listener/class_ -text
 application/hub/main/listener/class_BaseListener.php -text
-application/hub/main/listener/pool/.htaccess -text
 application/hub/main/listener/tcp/.htaccess -text
 application/hub/main/listener/udp/.htaccess -text
 application/hub/main/nodes/.htaccess -text
@@ -53,6 +54,11 @@ application/hub/main/nodes/master/.htaccess -text
 application/hub/main/nodes/master/class_HubMasterNode.php -text
 application/hub/main/nodes/regular/.htaccess -text
 application/hub/main/nodes/regular/class_HubRegularNode.php -text
+application/hub/main/pools/.htaccess -text
+application/hub/main/pools/class_ -text
+application/hub/main/pools/class_BasePool.php -text
+application/hub/main/pools/listener/.htaccess -text
+application/hub/main/pools/listener/class_DefaultListenerPool.php -text
 application/hub/starter.php -text
 /clear-cache.sh -text
 db/.htaccess -text
index b1bac59bc29729068e31b76bd936963f2b8b1114..243bd3ac4e5b851f5b789650c77cbcfa64b8647a 100644 (file)
@@ -58,7 +58,7 @@ $cfg->setConfigEntry('query_connector_class', "LocalQueryConnector");
 $cfg->setConfigEntry('queue_connector_class', "LocalQueueConnector");
 
 // CFG: LISTENER-POOL-CLAS
-$cfg->setConfigEntry('listener_pool_class', "ListenerPool");
+$cfg->setConfigEntry('listener_pool_class', "DefaultListenerPool");
 
 // CFG: TCP-LISTENER-CLASS
 $cfg->setConfigEntry('tcp_listener_class', "TcpListener");
diff --git a/application/hub/interfaces/pool/.htaccess b/application/hub/interfaces/pool/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/pool/class_Poolable.php b/application/hub/interfaces/pool/class_Poolable.php
new file mode 100644 (file)
index 0000000..966673b
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/**
+ * An interface for pools
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface Poolable extends FrameworkInterface {
+}
+
+//
+?>
index 6eb013c3cbf87cc6d864a285d60f7acc0bc1c75b..996f6750eaebc13ee26dbd7249e641808e971077 100644 (file)
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-class ???Listener extends BaseListener implements Listenerable {
+class ???Listener extends BaseListener implements Listenable {
        /**
         * Protected constructor
         *
diff --git a/application/hub/main/listener/pool/.htaccess b/application/hub/main/listener/pool/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
index a52541a2e8e8119cb2d1ed7a61875f3d17cf3e0a..77c80e084f97e909ef22fd3fee1f42cdb15205b4 100644 (file)
@@ -334,10 +334,18 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                $this->listenerPoolInstance = ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this));
 
                // Initialize the TCP listener
-               $tcpListenerInstance = ObjectFactory::createObjectByConfiguredName('tcp_listener_class', array($this));
+               $listenerInstance = ObjectFactory::createObjectByConfiguredName('tcp_listener_class', array($this));
+
+               // Setup address and port
+               $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
+               $listenerInstance->setListenPortByConfiguration('node_tcp_listen_port');
 
                // Initialize the UDP listener
-               $udpListenerInstance = ObjectFactory::createObjectByConfiguredName('udp_listener_class', array($this));
+               $listenerInstance = ObjectFactory::createObjectByConfiguredName('udp_listener_class', array($this));
+
+               // Setup address and port
+               $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
+               $listenerInstance->setListenPortByConfiguration('node_udp_listen_port');
        }
 }
 
diff --git a/application/hub/main/pools/.htaccess b/application/hub/main/pools/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/pools/class_ b/application/hub/main/pools/class_
new file mode 100644 (file)
index 0000000..06299cc
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/**
+ * 
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???Pool extends BasePool implements Poolable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $nodeInstance           A NodeHelper instance
+        * @return      $listenerInstance       An instance a prepared listener class
+        */
+       public final static function create???Pool (NodeHelper $nodeInstance) {
+               // Get new instance
+               $listenerInstance = new ???Pool();
+
+               // Set the application instance
+               $listenerInstance->setNodeInstance($nodeInstance);
+
+               // Return the prepared instance
+               return $listenerInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/pools/class_BasePool.php b/application/hub/main/pools/class_BasePool.php
new file mode 100644 (file)
index 0000000..4c0d949
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * A general pool class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class BasePool extends BaseHubSystem {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/pools/listener/.htaccess b/application/hub/main/pools/listener/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/pools/listener/class_DefaultListenerPool.php b/application/hub/main/pools/listener/class_DefaultListenerPool.php
new file mode 100644 (file)
index 0000000..3448cea
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/**
+ * A default listener pool
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class DefaultListenerPool extends BasePool implements Poolable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $nodeInstance           A NodeHelper instance
+        * @return      $listenerInstance       An instance a prepared listener class
+        */
+       public final static function createDefaultListenerPool (NodeHelper $nodeInstance) {
+               // Get new instance
+               $listenerInstance = new DefaultListenerPool();
+
+               // Set the application instance
+               $listenerInstance->setNodeInstance($nodeInstance);
+
+               // Return the prepared instance
+               return $listenerInstance;
+       }
+}
+
+// [EOF]
+?>