]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/registry/connection/class_ConnectionRegistry.php
Continued with refactoring:
[hub.git] / application / hub / main / registry / connection / class_ConnectionRegistry.php
index 32b4382023239d7069ca9460c75cfadf891116f0..e6aa06d7fd77995850db631f2ff229c20c63a49f 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -58,19 +58,25 @@ class ConnectionRegistry extends BaseRegistry implements Register, RegisterableC
 
        /**
         * "Getter" to get a string respresentation for a key for the sub-registry
-        * in this format: class:protocol:port
+        * in this format: class:type:port
         *
         * @param       $connectionInstance             An instance of a ConnectionHelper class
         * @return      $key                                    A string representation of the socket for the registry
         */
        private function getSubRegistryKey (ConnectionHelper $connectionInstance) {
-               // Get protocol and port number and add both together
-               $key = sprintf("%s:%s:%s",
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: connectionInstance=' . $connectionInstance->__toString() . ' CALLED!');
+
+               // Get connection type and port number and add both together
+               $key = sprintf('%s:%s:%s',
                        $connectionInstance->__toString(),
-                       $connectionInstance->getProtocolName(),
-                       $connectionInstance->getPort()
+                       $connectionInstance->getConnectionType(),
+                       $connectionInstance->getConnectionPort()
                );
 
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ' - EXIT!');
+
                // Return resulting key
                return $key;
        }
@@ -78,12 +84,12 @@ class ConnectionRegistry extends BaseRegistry implements Register, RegisterableC
        /**
         * "Getter" to get a string respresentation of the protocol
         *
-        * @param       $connectionInstance     An instance of a ConnectionHelper class
+        * @param       $infoInstance           An instance of a ShareableInfo class
         * @return      $key                            A string representation of the protocol for the registry
         */
-       private function getRegistryKeyFromProtocol (ConnectionHelper $connectionInstance) {
+       private function getRegistryKeyFromInfo (ShareableInfo $infoInstance) {
                // Get the key
-               $key = $connectionInstance->getProtocolName();
+               $key = $infoInstance->getProtocolName();
 
                // Return resulting key
                return $key;
@@ -92,12 +98,12 @@ class ConnectionRegistry extends BaseRegistry implements Register, RegisterableC
        /**
         * Checks whether the given protocol is registered
         *
-        * @param       $connectionInstance     An instance of a ConnectionHelper class
-        * @return      $isRegistered           Whether the protocol is registered
+        * @param       $connectionInstance             An instance of a ConnectionHelper class
+        * @return      $isRegistered                   Whether the protocol is registered
         */
-       private function isProtocolRegistered (ConnectionHelper $connectionInstance) {
+       private function isConnectionRegistered (ConnectionHelper $connectionInstance) {
                // Get the key
-               $key = $this->getRegistryKeyFromProtocol($connectionInstance);
+               $key = $this->getRegistryKeyFromInfo($connectionInstance);
 
                // Determine it
                $isRegistered = $this->instanceExists($key);
@@ -119,9 +125,9 @@ class ConnectionRegistry extends BaseRegistry implements Register, RegisterableC
                $isRegistered = FALSE;
 
                // First, check for the instance, there can be only once
-               if ($this->isProtocolRegistered($connectionInstance)) {
+               if ($this->isConnectionRegistered($connectionInstance)) {
                        // That one is found so "get" a registry key from it
-                       $key = $this->getRegistryKeyFromProtocol($connectionInstance);
+                       $key = $this->getRegistryKeyFromInfo($connectionInstance);
 
                        // Get the registry
                        $registryInstance = $this->getInstance($key);
@@ -154,15 +160,15 @@ class ConnectionRegistry extends BaseRegistry implements Register, RegisterableC
                } // END - if
 
                // Does the instance exist?
-               if (!$this->isProtocolRegistered($connectionInstance)) {
+               if (!$this->isConnectionRegistered($connectionInstance)) {
                        // No, not found so we create a sub registry (not needed to configure!)
                        $registryInstance = SubRegistry::createSubRegistry();
 
                        // Now we can create the sub-registry for this protocol
-                       $this->addInstance($this->getRegistryKeyFromProtocol($connectionInstance), $registryInstance);
+                       $this->addInstance($this->getRegistryKeyFromInfo($connectionInstance), $registryInstance);
                } else {
                        // Get the sub-registry back
-                       $registryInstance = $this->getInstance($this->getRegistryKeyFromProtocol($connectionInstance));
+                       $registryInstance = $this->getInstance($this->getRegistryKeyFromInfo($connectionInstance));
                }
 
                // Get a key for sub-registries
@@ -191,7 +197,7 @@ class ConnectionRegistry extends BaseRegistry implements Register, RegisterableC
                } // END - if
 
                // Now get the key from the protocol
-               $key = $this->getRegistryKeyFromProtocol($connectionInstance);
+               $key = $this->getRegistryKeyFromInfo($connectionInstance);
 
                // And get the registry
                $registryInstance = $this->getInstance($key);
@@ -218,6 +224,9 @@ class ConnectionRegistry extends BaseRegistry implements Register, RegisterableC
 
                // Get all keys and check them
                foreach ($this->getInstanceRegistry() as $key => $registryInstance) {
+                       // Debug message
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',registryInstance=' . $registryInstance->__toString());
+
                        // This is always a SubRegistry instance
                        foreach ($registryInstance->getInstanceRegistry() as $subKey => $containerInstance) {
                                // Debug message