]> git.mxchange.org Git - hub.git/commitdiff
Moved setter/getter and attribute itself 'packageTags' to a more generic class BaseHu...
authorRoland Häder <roland@mxchange.org>
Sun, 19 Aug 2012 11:52:42 +0000 (11:52 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 19 Aug 2012 11:52:42 +0000 (11:52 +0000)
application/hub/main/helper/hub/announcement/class_HubAnnouncementHelper.php
application/hub/main/helper/hub/answer/class_BaseHubAnswerHelper.php
application/hub/main/helper/hub/class_
application/hub/main/helper/hub/class_BaseHubHelper.php
application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php
application/hub/main/helper/hub/requests/class_NodeRequestNodeListHelper.php
application/hub/main/states/node/class_BaseNodeState.php
application/hub/templates/xml/object_registry/object_registry.xml

index a250ed0d0cd1ab2df5f654a8123d00f237df21d0..1979194b59bccec62eeec05454b7792181fc2826 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class HubAnnouncementHelper extends BaseHubHelper implements HelpableHub {
-       /**
-        * An array with all tags for network packages
-        */
-       private $packageTags = array('announcement');
-
        /**
         * Protected constructor
         *
@@ -39,6 +34,9 @@ class HubAnnouncementHelper extends BaseHubHelper implements HelpableHub {
 
                // Set recipient type
                $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER_NODES);
+
+               // Set package tags
+               $this->setPackageTags(array('announcement'));
        }
 
        /**
@@ -99,15 +97,6 @@ class HubAnnouncementHelper extends BaseHubHelper implements HelpableHub {
                // Next, feed the content in. The network package class is a pipe-through class.
                $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP);
        }
-
-       /**
-        * Getter for package tags in a simple array
-        *
-        * @return      $tags   An array with all tags for the currently handled package
-        */
-       public final function getPackageTags () {
-               return $this->packageTags;
-       }
 }
 
 // [EOF]
index cfa4d407af9ad0a1894c3413e4e5dd6bf1d638ed..c5850d249f07e166e568194963d42355f37fd73c 100644 (file)
@@ -27,12 +27,6 @@ class BaseHubAnswerHelper extends BaseHubHelper {
         */
        private $messageData = array();
 
-       /**
-        * Package tags
-        */
-       private $packageTags = array();
-
-
        /**
         * Protected constructor
         *
@@ -61,25 +55,6 @@ class BaseHubAnswerHelper extends BaseHubHelper {
        public final function getMessageData () {
                return $this->messageData;
        }
-
-       /**
-        * Getter for package tags in a simple array
-        *
-        * @return      $packageTags    An array with all tags for the currently handled package
-        */
-       public final function getPackageTags () {
-               return $this->packageTags;
-       }
-
-       /**
-        * Setter for package tags in a simple array
-        *
-        * @param       $packageTags    An array with all tags for the currently handled package
-        * @return      void
-        */
-       public final function setPackageTags (array $packageTags) {
-               $this->packageTags = $packageTags;
-       }
 }
 
 // [EOF]
index 8ab8f79d9ea94928c7039f01be7f37b547474b57..337a1d7308b3c43ebf933b18ff4313123a6b0f3e 100644 (file)
@@ -75,7 +75,7 @@ class Hub???Helper extends BaseHubHelper implements HelpableHub {
                $packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
 
                // Next, feed the content in. The network package class is a pipe-through class.
-               $packageInstance->enqueueRawDataFromTemplate($this);
+               $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_|||);
        }
 }
 
index 123baf84ec874e967f3298295688307c6380de6a..0cb1458b896cd324d88620d5f3535a7a88ee8aad 100644 (file)
@@ -27,6 +27,11 @@ class BaseHubHelper extends BaseHubSystem {
         */
        private $recipientType = 'invalid';
 
+       /**
+        * Package tags
+        */
+       private $packageTags = array();
+
        /**
         * Protected constructor
         *
@@ -55,6 +60,25 @@ class BaseHubHelper extends BaseHubSystem {
        public final function getRecipientType () {
                return $this->recipientType;
        }
+
+       /**
+        * Getter for package tags in a simple array
+        *
+        * @return      $packageTags    An array with all tags for the currently handled package
+        */
+       public final function getPackageTags () {
+               return $this->packageTags;
+       }
+
+       /**
+        * Setter for package tags in a simple array
+        *
+        * @param       $packageTags    An array with all tags for the currently handled package
+        * @return      void
+        */
+       public final function setPackageTags (array $packageTags) {
+               $this->packageTags = $packageTags;
+       }
 }
 
 // [EOF]
index e0dd2fe43fe2ab3c1a5dee5de76056bd463d7657..4a5847303f5560482a92c43234e60d7e3b6aa529 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class HubSelfConnectHelper extends BaseHubHelper implements HelpableHub {
-       /**
-        * Package tags
-        */
-       private $packageTags = array('self_connect');
-
        /**
         * Protected constructor
         *
@@ -39,6 +34,9 @@ class HubSelfConnectHelper extends BaseHubHelper implements HelpableHub {
 
                // Set recipient type
                $this->setRecipientType(NetworkPackage::NETWORK_TARGET_SELF);
+
+               // Set package tags
+               $this->setPackageTags(array('self_connect'));
        }
 
        /**
@@ -95,15 +93,6 @@ class HubSelfConnectHelper extends BaseHubHelper implements HelpableHub {
                // Next, feed the content in. The network package class is a pipe-through class.
                $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP);
        }
-
-       /**
-        * Getter for package tags in a simple array
-        *
-        * @return      $tags   An array with all tags for the currently handled package
-        */
-       public final function getPackageTags () {
-               return $this->packageTags;
-       }
 }
 
 // [EOF]
index 900352bd354b3414fa1dda81790f99a4fc7108d3..ed31fac0ae6d6dea1282d6ca3ba3bbaf70b03f82 100644 (file)
@@ -34,6 +34,9 @@ class NodeRequestNodeListHelper extends BaseHubHelper implements HelpableHub {
 
                // Set recipient type
                $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER_NODES);
+
+               // Set package tags
+               $this->setPackageTags(array('request_node_list'));
        }
 
        /**
@@ -79,7 +82,7 @@ class NodeRequestNodeListHelper extends BaseHubHelper implements HelpableHub {
         */
        public function sendPackage (NodeHelper $nodeInstance) {
                // Sanity check: Is the node in the approx. state? (active)
-               $nodeInstance->getStateInstance()->validateNodeStateIsActive();
+               $nodeInstance->getStateInstance()->validateNodeStateIsAnnouncementCompleted();
 
                // Compile the template, this inserts the loaded node data into the gaps.
                $this->getTemplateInstance()->compileTemplate();
@@ -88,7 +91,7 @@ class NodeRequestNodeListHelper extends BaseHubHelper implements HelpableHub {
                $packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
 
                // Next, feed the content in. The network package class is a pipe-through class.
-               $packageInstance->enqueueRawDataFromTemplate($this);
+               $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP);
        }
 }
 
index 2109465ebb63e6c339174d5d1234587dcae15657..5c615e33c709b5e758f942c1876bcbe99d1316b9 100644 (file)
@@ -77,6 +77,21 @@ class BaseNodeState extends BaseState {
                        throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE);
                } // END - if
        }
+
+       /**
+        * Validates if the state is 'announcement_completed' or throws an
+        * exception if it is every other state.
+        *
+        * @return      void
+        * @throws      InvalidStateException   If the state is not 'active' and not 'announced'
+        */
+       public function validateNodeStateIsAnnouncementCompleted () {
+               // Just compare it...
+               if (!$this instanceof NodeAnnouncementCompletedState) {
+                       // Throw the exception
+                       throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE);
+               } // END - if
+       }
 }
 
 // [EOF]
index bdc52c341c783910448a7fe1f8c392e4a3148f05..3ec63ffd848a066778513bab86a775a19edd07dc 100644 (file)
@@ -95,5 +95,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
                        <!-- The recipient type for this type of object //-->
                        <object-recipient-type>hub</object-recipient-type>
                </object-list-entry>
+               <!-- A single object type we want to share. //-->
+               <object-list-entry>
+                       <!-- The actual name, this must be the same as tag names are. //-->
+                       <object-name>request_node_list</object-name>
+                       <!-- Recipient limitation //-->
+                       <object-recipient-limitation>upper</object-recipient-limitation>
+                       <!-- Maximum spread of the object //-->
+                       <object-max-spread>1</object-max-spread>
+                       <!-- The protocol we should use for transmission //-->
+                       <object-protocol>tcp</object-protocol>
+                       <!-- The recipient type for this type of object //-->
+                       <object-recipient-type>hub</object-recipient-type>
+               </object-list-entry>
        </object-list>
 </object-registry>