From 02f5d01514d6dcd9a0b5e2b07aa5b1bc9265ea33 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 4 Aug 2009 23:28:37 +0000 Subject: [PATCH] Exceptions, interfaces and many classes added/rewritten: - Exceptions for lists (Iterator Pattern) added - Interfaces for Visitor Pattern added - Interface Listable (Iterator Pattern) added - Base listener extended with Visitor Pattern method accept() - List and list group classes added (Iterator Pattern) - Shutdown visitor class for listener pool added --- .gitattributes | 26 +++ application/hub/config.php | 12 + application/hub/exceptions/lists/.htaccess | 1 + .../class_ListGroupAlreadyAddedException.php | 45 ++++ .../lists/class_NoListGroupException.php | 45 ++++ .../interfaces/listener/class_Listenable.php | 2 +- application/hub/interfaces/lists/.htaccess | 1 + .../hub/interfaces/lists/class_Listable.php | 65 ++++++ .../interfaces/visitor/class_Visitable.php | 9 +- .../hub/interfaces/visitor/class_Visitor.php | 28 +++ .../hub/interfaces/visitor/pool/.htaccess | 1 + .../visitor/pool/class_PoolVisitor.php | 35 +++ application/hub/main/iterator/.htaccess | 1 + application/hub/main/iterator/class_ | 107 +++++++++ .../hub/main/iterator/class_BaseIterator.php | 62 ++++++ application/hub/main/iterator/pool/.htaccess | 1 + .../pool/class_ShutdownPoolIterator.php | 111 ++++++++++ .../hub/main/listener/class_BaseListener.php | 20 ++ .../listener/class_BaseListenerDecorator.php | 20 ++ application/hub/main/lists/.htaccess | 1 + application/hub/main/lists/class_ | 50 +++++ application/hub/main/lists/class_BaseList.php | 208 ++++++++++++++++++ application/hub/main/lists/groups/.htaccess | 1 + .../main/lists/groups/class_ListGroupList.php | 50 +++++ application/hub/main/lists/pool/.htaccess | 1 + .../main/lists/pool/class_PoolEntriesList.php | 53 +++++ application/hub/main/pools/class_BasePool.php | 59 ++++- .../listener/class_DefaultListenerPool.php | 19 ++ application/hub/main/visitor/.htaccess | 1 + application/hub/main/visitor/class_ | 50 +++++ .../hub/main/visitor/class_BaseVisitor.php | 42 ++++ .../hub/main/visitor/shutdown/.htaccess | 1 + .../hub/main/visitor/shutdown/class_Shutdown | 50 +++++ .../class_ShutdownListenerPoolVisitor.php | 67 ++++++ 34 files changed, 1239 insertions(+), 6 deletions(-) create mode 100644 application/hub/exceptions/lists/.htaccess create mode 100644 application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php create mode 100644 application/hub/exceptions/lists/class_NoListGroupException.php create mode 100644 application/hub/interfaces/lists/.htaccess create mode 100644 application/hub/interfaces/lists/class_Listable.php create mode 100644 application/hub/interfaces/visitor/class_Visitor.php create mode 100644 application/hub/interfaces/visitor/pool/.htaccess create mode 100644 application/hub/interfaces/visitor/pool/class_PoolVisitor.php create mode 100644 application/hub/main/iterator/.htaccess create mode 100644 application/hub/main/iterator/class_ create mode 100644 application/hub/main/iterator/class_BaseIterator.php create mode 100644 application/hub/main/iterator/pool/.htaccess create mode 100644 application/hub/main/iterator/pool/class_ShutdownPoolIterator.php create mode 100644 application/hub/main/lists/.htaccess create mode 100644 application/hub/main/lists/class_ create mode 100644 application/hub/main/lists/class_BaseList.php create mode 100644 application/hub/main/lists/groups/.htaccess create mode 100644 application/hub/main/lists/groups/class_ListGroupList.php create mode 100644 application/hub/main/lists/pool/.htaccess create mode 100644 application/hub/main/lists/pool/class_PoolEntriesList.php create mode 100644 application/hub/main/visitor/.htaccess create mode 100644 application/hub/main/visitor/class_ create mode 100644 application/hub/main/visitor/class_BaseVisitor.php create mode 100644 application/hub/main/visitor/shutdown/.htaccess create mode 100644 application/hub/main/visitor/shutdown/class_Shutdown create mode 100644 application/hub/main/visitor/shutdown/class_ShutdownListenerPoolVisitor.php diff --git a/.gitattributes b/.gitattributes index 7d24211cd..13b2fc17b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,12 +8,17 @@ application/hub/data.php -text application/hub/debug.php -text application/hub/exceptions.php -text application/hub/exceptions/.htaccess -text +application/hub/exceptions/lists/.htaccess -text +application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php -text +application/hub/exceptions/lists/class_NoListGroupException.php -text application/hub/init.php -text application/hub/interfaces/.htaccess -text application/hub/interfaces/connectors/.htaccess -text application/hub/interfaces/connectors/class_Connectable.php -text application/hub/interfaces/listener/.htaccess -text application/hub/interfaces/listener/class_Listenable.php -text +application/hub/interfaces/lists/.htaccess -text +application/hub/interfaces/lists/class_Listable.php -text application/hub/interfaces/nodes/.htaccess -text application/hub/interfaces/nodes/class_NodeHelper.php -text application/hub/interfaces/pool/.htaccess -text @@ -33,6 +38,9 @@ application/hub/interfaces/states/hub/.htaccess -text application/hub/interfaces/states/hub/class_HubStateable.php -text application/hub/interfaces/visitor/.htaccess -text application/hub/interfaces/visitor/class_Visitable.php -text +application/hub/interfaces/visitor/class_Visitor.php -text +application/hub/interfaces/visitor/pool/.htaccess -text +application/hub/interfaces/visitor/pool/class_PoolVisitor.php -text application/hub/loader.php -text application/hub/main/.htaccess -text application/hub/main/class_ -text @@ -84,6 +92,11 @@ application/hub/main/filter/shutdown/class_HubShutdownDeinitQueuesFilter.php -te application/hub/main/filter/shutdown/class_HubShutdownFlushNodeListFilter.php -text application/hub/main/filter/shutdown/class_HubShutdownListenerPoolFilter.php -text application/hub/main/filter/shutdown/class_HubShutdownNodeFilter.php -text +application/hub/main/iterator/.htaccess -text +application/hub/main/iterator/class_ -text +application/hub/main/iterator/class_BaseIterator.php -text +application/hub/main/iterator/pool/.htaccess -text +application/hub/main/iterator/pool/class_ShutdownPoolIterator.php -text application/hub/main/listener/.htaccess -text application/hub/main/listener/class_ -text application/hub/main/listener/class_BaseListener.php -text @@ -100,6 +113,13 @@ application/hub/main/listener/udp/class_UdpListener.php -text application/hub/main/listener/udp/decorators/.htaccess -text application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php -text application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php -text +application/hub/main/lists/.htaccess -text +application/hub/main/lists/class_ -text +application/hub/main/lists/class_BaseList.php -text +application/hub/main/lists/groups/.htaccess -text +application/hub/main/lists/groups/class_ListGroupList.php -text +application/hub/main/lists/pool/.htaccess -text +application/hub/main/lists/pool/class_PoolEntriesList.php -text application/hub/main/nodes/.htaccess -text application/hub/main/nodes/boot/.htaccess -text application/hub/main/nodes/boot/class_HubBootNode.php -text @@ -137,6 +157,12 @@ application/hub/main/states/client/.htaccess -text application/hub/main/states/client/class_BaseClientState.php -text application/hub/main/states/hub/.htaccess -text application/hub/main/states/hub/class_BaseHubState.php -text +application/hub/main/visitor/.htaccess -text +application/hub/main/visitor/class_ -text +application/hub/main/visitor/class_BaseVisitor.php -text +application/hub/main/visitor/shutdown/.htaccess -text +application/hub/main/visitor/shutdown/class_Shutdown -text +application/hub/main/visitor/shutdown/class_ShutdownListenerPoolVisitor.php -text application/hub/starter.php -text /clear-cache.sh -text db/.htaccess -text diff --git a/application/hub/config.php b/application/hub/config.php index 3a549b1ba..e824a2695 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -84,6 +84,18 @@ $cfg->setConfigEntry('client_udp_listener_class', 'ClientUdpListenerDecorator'); // CFG: CLIENT-POOL-CLASS $cfg->setConfigEntry('client_pool_class', 'DefaultClientPool'); +// CFG: POOL-ENTRIES-LIST-CLASS +$cfg->setConfigEntry('pool_entries_list_class', 'PoolEntriesList'); + +// CFG: LISTENER-POOL-VISITOR-CLASS +$cfg->setConfigEntry('listener_pool_visitor_class', 'ShutdownListenerPoolVisitor'); + +// CFG: SHUTDOWN-POOL-ITERATOR-CLASS +$cfg->setConfigEntry('shutdown_pool_iterator_class', 'ShutdownPoolIterator'); + +// CFG: LIST-GROUP-CLASS +$cfg->setConfigEntry('list_group_class', 'ListGroupList'); + // CFG: DEFAULT-CONSOLE-COMMAND $cfg->setConfigEntry('default_console_command', 'main'); diff --git a/application/hub/exceptions/lists/.htaccess b/application/hub/exceptions/lists/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/exceptions/lists/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php b/application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php new file mode 100644 index 000000000..d401037dc --- /dev/null +++ b/application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php @@ -0,0 +1,45 @@ + + * @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 . + */ +class ListGroupAlreadyAddedException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $messageArray, $code) { + // Construct the message + $message = sprintf("[%s] List group %s has already been added.", + $messageArray[0]->__toString(), + $messageArray[1] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/application/hub/exceptions/lists/class_NoListGroupException.php b/application/hub/exceptions/lists/class_NoListGroupException.php new file mode 100644 index 000000000..ee8e28284 --- /dev/null +++ b/application/hub/exceptions/lists/class_NoListGroupException.php @@ -0,0 +1,45 @@ + + * @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 . + */ +class NoListGroupException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $messageArray, $code) { + // Construct the message + $message = sprintf("[%s] List group %s was not found.", + $messageArray[0]->__toString(), + $messageArray[1] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/application/hub/interfaces/listener/class_Listenable.php b/application/hub/interfaces/listener/class_Listenable.php index a8e9ed30b..ede2b555f 100644 --- a/application/hub/interfaces/listener/class_Listenable.php +++ b/application/hub/interfaces/listener/class_Listenable.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface Listenable { +interface Listenable extends FrameworkInterface { /** * Initializes the listener by setting up the required socket server * diff --git a/application/hub/interfaces/lists/.htaccess b/application/hub/interfaces/lists/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/lists/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/lists/class_Listable.php b/application/hub/interfaces/lists/class_Listable.php new file mode 100644 index 000000000..d2b26b911 --- /dev/null +++ b/application/hub/interfaces/lists/class_Listable.php @@ -0,0 +1,65 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 . + */ +interface Listable extends FrameworkInterface, IteratorAggregate { + /** + * Checks wether the given group is set + * + * @param $groupName Group to check if found in list + * @return $isset Wether the group is valid + */ + function isGroupSet ($groupName); + + /** + * Adds the given group or if already added issues a ListGroupAlreadyAddedException + * + * @param $groupName Group to add + * @return void + * @throws ListGroupAlreadyAddedException If the given group is already added + */ + function addGroup ($groupName); + + /** + * Adds the given instance to list group and sub group + * + * @param $groupName Group to add instance to + * @param $subGroup Sub group to add instance to + * @param $instance An instance of Visitable + * @return void + * @throws NoListGroupException If the given group is not found + */ + function addInstance ($groupName, $subGroup, Visitable $instance); + + /** + * Adds the given entry to list group + * + * @param $groupName Group to add instance to + * @param $entry An entry of any type + * @return void + * @throws NoListGroupException If the given group is not found + */ + function addEntry ($groupName, $entry); +} + +// +?> diff --git a/application/hub/interfaces/visitor/class_Visitable.php b/application/hub/interfaces/visitor/class_Visitable.php index f91e448a4..8319c3163 100644 --- a/application/hub/interfaces/visitor/class_Visitable.php +++ b/application/hub/interfaces/visitor/class_Visitable.php @@ -1,6 +1,6 @@ * @version 0.0.0 @@ -22,6 +22,13 @@ * along with this program. If not, see . */ interface Visitable extends FrameworkInterface { + /** + * Accepts the visitor to rpocess the visit "request" + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + function accept (Visitor $visitorInstance); } // diff --git a/application/hub/interfaces/visitor/class_Visitor.php b/application/hub/interfaces/visitor/class_Visitor.php new file mode 100644 index 000000000..e2bce7923 --- /dev/null +++ b/application/hub/interfaces/visitor/class_Visitor.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 . + */ +interface Visitor extends FrameworkInterface { +} + +// +?> diff --git a/application/hub/interfaces/visitor/pool/.htaccess b/application/hub/interfaces/visitor/pool/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/visitor/pool/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/visitor/pool/class_PoolVisitor.php b/application/hub/interfaces/visitor/pool/class_PoolVisitor.php new file mode 100644 index 000000000..f7df6893e --- /dev/null +++ b/application/hub/interfaces/visitor/pool/class_PoolVisitor.php @@ -0,0 +1,35 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 . + */ +interface PoolVisitor extends Visitor { + /** + * Visits the given pool instance + * + * @param $poolInstance A Poolable instance + * @return void + */ + function visitPool (Poolable $poolInstance); +} + +// +?> diff --git a/application/hub/main/iterator/.htaccess b/application/hub/main/iterator/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/iterator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/iterator/class_ b/application/hub/main/iterator/class_ new file mode 100644 index 000000000..a259cea5c --- /dev/null +++ b/application/hub/main/iterator/class_ @@ -0,0 +1,107 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 . + */ +class ???Iterator extends BaseIterator implements Iterator { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $iteratorInstance An instance a Iterator class + */ + public final static function create???Iterator () { + // Get new instance + $iteratorInstance = new ???Iterator(); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value from group or generic + * + * @return $current Current value in iteration + */ + public function current () { + // Default is null + $current = null; + + $this->partialStub('Please implement this method.'); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $key Current key in iteration + */ + public function key () { + // Default is null + $key = null; + + $this->partialStub('Please implement this method.'); + + // Return it + return $key; + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + $this->partialStub('Please implement this method.'); + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + */ + public function rewind () { + $this->partialStub('Please implement this method.'); + } + + /** + * Checks wether the current entry is valid (not at the end of the list) + * + * @return void + */ + public function valid () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/main/iterator/class_BaseIterator.php b/application/hub/main/iterator/class_BaseIterator.php new file mode 100644 index 000000000..bea332d32 --- /dev/null +++ b/application/hub/main/iterator/class_BaseIterator.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 . + */ +class BaseIterator extends BaseHubSystem { + /** + * Instance of the list + */ + private $listInstance = null; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for the list instance + * + * @param $listInstance A list of IteratorAggregate + * @return void + */ + protected final function setListInstance (IteratorAggregate $listInstance) { + $this->listInstance = $listInstance; + } + + /** + * Getter for the list instance + * + * @return $listInstance A list of IteratorAggregate + */ + protected final function getListInstance () { + return $this->listInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/iterator/pool/.htaccess b/application/hub/main/iterator/pool/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/iterator/pool/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/iterator/pool/class_ShutdownPoolIterator.php b/application/hub/main/iterator/pool/class_ShutdownPoolIterator.php new file mode 100644 index 000000000..d6a16f562 --- /dev/null +++ b/application/hub/main/iterator/pool/class_ShutdownPoolIterator.php @@ -0,0 +1,111 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 . + */ +class ShutdownPoolIterator extends BaseIterator implements Iterator { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $listInstance A list of a IteratorAggregate + * @return $iteratorInstance An instance a Iterator class + */ + public final static function createShutdownPoolIterator (IteratorAggregate $listInstance) { + // Get new instance + $iteratorInstance = new ShutdownPoolIterator(); + + // Set the list + $iteratorInstance->setListInstance($listInstance); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value from group or generic + * + * @return $current Current value in iteration + */ + public function current () { + // Default is null + $current = null; + + $this->partialStub('Please implement this method.'); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $key Current key in iteration + */ + public function key () { + // Default is null + $key = null; + + $this->partialStub('Please implement this method.'); + + // Return it + return $key; + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + $this->partialStub('Please implement this method.'); + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + */ + public function rewind () { + $this->partialStub('Please implement this method.'); + } + + /** + * Checks wether the current entry is valid (not at the end of the list) + * + * @return void + */ + public function valid () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/main/listener/class_BaseListener.php b/application/hub/main/listener/class_BaseListener.php index f06b7f259..0fce415d1 100644 --- a/application/hub/main/listener/class_BaseListener.php +++ b/application/hub/main/listener/class_BaseListener.php @@ -199,6 +199,26 @@ class BaseListener extends BaseHubSystem implements Visitable { protected final function getPoolInstance () { return $this->poolInstance; } + + /** + * Accepts the visitor to rpocess the visit "request" + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Debug message + $this->debugOutput('LISTENER: ' . $visitorInstance->__toString() . ' has visited - START'); + + // Visit this listener + $visitorInstance->visitListener($this); + + // Visit the pool + $this->getPoolInstance()->accept($visitor); + + // Debug message + $this->debugOutput('LISTENER: ' . $visitorInstance->__toString() . ' has visited - FINISHED'); + } } // [EOF] diff --git a/application/hub/main/listener/class_BaseListenerDecorator.php b/application/hub/main/listener/class_BaseListenerDecorator.php index fd0a3f2b1..fe412f7aa 100644 --- a/application/hub/main/listener/class_BaseListenerDecorator.php +++ b/application/hub/main/listener/class_BaseListenerDecorator.php @@ -63,6 +63,26 @@ class BaseListenerDecorator extends BaseHubSystem implements Visitable { public final function getProtocol () { return $this->getListenerInstance()->getProtocol(); } + + /** + * Accepts the visitor to rpocess the visit "request" + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Debug message + $this->debugOutput('DECO-LISTENER: ' . $visitorInstance->__toString() . ' has visited - START'); + + // Visit this decorator + $visitorInstance->visitDecorator($this); + + // Visit the covered class + $this->getListenerInstance()->accept($visitorInstance); + + // Debug message + $this->debugOutput('DECO-LISTENER: ' . $visitorInstance->__toString() . ' has visited - FINISHED'); + } } // [EOF] diff --git a/application/hub/main/lists/.htaccess b/application/hub/main/lists/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/lists/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/lists/class_ b/application/hub/main/lists/class_ new file mode 100644 index 000000000..fa8573787 --- /dev/null +++ b/application/hub/main/lists/class_ @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 . + */ +class ???List extends BaseList implements Listable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $listInstance An instance a Listable class + */ + public final static function create???List () { + // Get new instance + $listInstance = new ???List(); + + // Return the prepared instance + return $listInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/lists/class_BaseList.php b/application/hub/main/lists/class_BaseList.php new file mode 100644 index 000000000..c81063933 --- /dev/null +++ b/application/hub/main/lists/class_BaseList.php @@ -0,0 +1,208 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 . + */ +class BaseList extends BaseHubSystem implements IteratorAggregate { + // Exception constants + const EXCEPTION_GROUP_ALREADY_ADDED = 0xf20; + const EXCEPTION_GROUP_NOT_FOUND = 0xf21; + + /** + * List groups array + */ + private $listGroups = array(); + + /** + * List entries array + */ + private $listEntries = array(); + + /** + * List index array + */ + private $listIndex = array(); + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Remove some attributes + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Getter for iterator instance from this list + * + * @return $iteratorInstance An instance of a Iterator class + */ + public function getIterator () { + // Prepare a default iterator + $iteratorInstance = ObjectFactory::createObjectByConfiguredName('default_iterator_class'); + + // And return it + return $iteratorInstance; + } + + /** + * Checks wether the given group is set + * + * @param $groupName Group to check if found in list + * @return $isset Wether the group is valid + */ + public function isGroupSet ($groupName) { + //* DEBUG: */ $this->debugOutput(__METHOD__.': '.$groupName); + return isset($this->listGroups[$groupName]); + } + + /** + * Adds the given group or if already added issues a ListGroupAlreadyAddedException + * + * @param $groupName Group to add + * @return void + * @throws ListGroupAlreadyAddedException If the given group is already added + */ + public function addGroup ($groupName) { + //* DEBUG: */ $this->debugOutput(__METHOD__.': '.$groupName . ' - START'); + // Is the group already added? + if ($this->isGroupSet($groupName)) { + // Throw the exception here + throw new ListGroupAlreadyAddedException(array($this, $groupName), self::EXCEPTION_GROUP_ALREADY_ADDED); + } // END - if + + // Add the group which is a simple array + $this->listGroups[$groupName] = ObjectFactory::createObjectByConfiguredName('list_group_class'); + //* DEBUG: */ $this->debugOutput(__METHOD__.': '.$groupName . ' - FINISHED'); + } + + /** + * Adds the given instance to list group and sub group + * + * @param $groupName Group to add instance to + * @param $subGroup Sub group to add instance to + * @param $instance An instance of Visitable + * @return void + * @throws NoListGroupException If the given group is not found + */ + public function addInstance ($groupName, $subGroup, Visitable $instance) { + //* DEBUG: */ $this->debugOutput(__METHOD__.': '.$groupName . '/' . $subGroup . ' - START'); + // Is the group there? + if (!$this->isGroupSet($groupName)) { + // Throw the exception here + throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND); + } // END - if + + // Is the sub group there? + if (!$this->listGroups[$groupName]->isGroupSet($subGroup)) { + // Automatically add it + $this->listGroups[$groupName]->addGroup($subGroup); + } // END - if + + // Generate the hash + $hash = $this->generateHash($groupName, $subGroup, $instance); + + // Now add it to the group list and hash it + $this->listGroups[$groupName]->addEntry($subGroup, $hash); + + // Add the hash to the index + $this->listIndex[] = $hash; + + // Add the instance itself to the list + $this->listEntries[$hash] = $instance; + //* DEBUG: */ $this->debugOutput(__METHOD__.': '.$groupName . '/' . $subGroup . ' - START'); + } + + /** + * Adds the given entry to list group + * + * @param $groupName Group to add instance to + * @param $entry An entry of any type + * @return void + * @throws NoListGroupException If the given group is not found + */ + public function addEntry ($groupName, $entry) { + //* DEBUG: */ $this->debugOutput(__METHOD__.': '.$groupName . ' - START'); + // Is the group already added? + if (!$this->isGroupSet($groupName)) { + // Throw the exception here + throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND); + } // END - if + + // Generate hash + $hash = $this->generateHash($groupName, $groupName, $entry); + + // Add the hash to the index + $this->listIndex[] = $hash; + + // Now add the entry to the list + $this->listEntries[$hash] = $entry; + //* DEBUG: */ $this->debugOutput(__METHOD__.': '.$groupName . ' - FINISHED'); + } + + /** + * Generates a hash from given group, sub group and entry + * + * @param $groupName Group to add instance to + * @param $subGroup Sub group to add instance to + * @param $entry An entry of any type + * @return $hash The generated + */ + private function generateHash ($groupName, $subGroup, $entry) { + // Created entry, 'null' is default + $entry2 = 'null'; + + // Determine type of entry + if (is_null($entry)) { + // Ignore this + } elseif ($entry instanceof FrameworkInterface) { + // Own instance detected + $entry2 = $entry->hashCode(); + } elseif (!is_array($entry)) { + // Non-array found, use it directly with type + $entry2 = gettype($entry) . ':' . $entry2; + } else { + // Arrays are unsupported at the momement + $this->debugOutut(__METHOD__ . ': entry is an array. UNSUPPORTED!'); + + // @TODO Extend this somehow? + $entry2 = gettype($entry); + } + + // Construct string which we shall hash + $hashString = $groupName . ':' . $subGroup . ':' . $entry2; + + // Hash it with fastest hasher + $hash = crc32($hashString); + + // And return it + return $hash; + } +} + +// +?> diff --git a/application/hub/main/lists/groups/.htaccess b/application/hub/main/lists/groups/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/lists/groups/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/lists/groups/class_ListGroupList.php b/application/hub/main/lists/groups/class_ListGroupList.php new file mode 100644 index 000000000..1cf106252 --- /dev/null +++ b/application/hub/main/lists/groups/class_ListGroupList.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 . + */ +class ListGroupList extends BaseList implements Listable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $listInstance An instance a Listable class + */ + public final static function createListGroupList () { + // Get new instance + $listInstance = new ListGroupList(); + + // Return the prepared instance + return $listInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/lists/pool/.htaccess b/application/hub/main/lists/pool/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/lists/pool/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/lists/pool/class_PoolEntriesList.php b/application/hub/main/lists/pool/class_PoolEntriesList.php new file mode 100644 index 000000000..8fce67eeb --- /dev/null +++ b/application/hub/main/lists/pool/class_PoolEntriesList.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 . + */ +class PoolEntriesList extends BaseList implements Listable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $listInstance An instance a Listable class + */ + public final static function createPoolEntriesList () { + // Get new instance + $listInstance = new PoolEntriesList(); + + // Add generic group + $listInstance->addGroup('generic'); + + // Return the prepared instance + return $listInstance; + } +} + +// +?> diff --git a/application/hub/main/pools/class_BasePool.php b/application/hub/main/pools/class_BasePool.php index b585fc2ca..0a52e4835 100644 --- a/application/hub/main/pools/class_BasePool.php +++ b/application/hub/main/pools/class_BasePool.php @@ -21,11 +21,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BasePool extends BaseHubSystem { +class BasePool extends BaseHubSystem implements Visitable { /** * A list of pool entries */ - private $poolEntries = array(); + private $poolEntriesInstance = null; /** * Protected constructor @@ -36,6 +36,9 @@ class BasePool extends BaseHubSystem { protected function __construct ($className) { // Call parent constructor parent::__construct($className); + + // Init the pool entries + $this->poolEntriesInstance = ObjectFactory::createObjectByConfiguredName('pool_entries_list_class'); } /** @@ -47,7 +50,14 @@ class BasePool extends BaseHubSystem { * @return void */ protected final function addInstance ($group, $poolName, Visitable $instance) { - $this->poolEntries[$group][$poolName][] = $instance; + // Is the pool group there? + if (!$this->poolEntriesInstance->isGroupSet($group)) { + // Create the missing pool group + $this->poolEntriesInstance->addGroup($group); + } // END - if + + // Add it to given pool group + $this->poolEntriesInstance->addInstance($group, $poolName, $instance); } /** @@ -57,7 +67,48 @@ class BasePool extends BaseHubSystem { * @return void */ protected final function addPoolEntry ($poolEntry) { - $this->poolEntries[] = $poolEntry; + $this->poolEntriesInstance->addEntry('generic', $poolEntry); + } + + /** + * Accepts the visitor to rpocess the visit "request" + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Debug message + $this->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - START'); + + // Visit this pool + $visitorInstance->visitPool($this); + + // Get a new iterator instance + $iteratorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_pool_iterator_class', array($this->poolEntriesInstance)); + + // Reset the counter + $iteratorInstance->rewind(); + + // Visit all registered entries + while ($iteratorInstance->valid()) { + // Get current entry + $poolEntry = $iteratorInstance->current(); + + // Is this entry visitable? + if ($poolEntry instanceof Visitable) { + // Visit this entry as well + $poolEntry->accept($visitorInstance); + } else { + // Cannot visit this entry + $this->partialStub('Pool entry with key ' . $iteratorInstance->key() . ' has improper type ' . gettype($poolEntry) . '.'); + } + + // Advance to next entry + $iteratorInstance->next(); + } // END - while + + // Debug message + $this->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - FINISHED'); } } diff --git a/application/hub/main/pools/listener/class_DefaultListenerPool.php b/application/hub/main/pools/listener/class_DefaultListenerPool.php index fce149e50..99579c55c 100644 --- a/application/hub/main/pools/listener/class_DefaultListenerPool.php +++ b/application/hub/main/pools/listener/class_DefaultListenerPool.php @@ -66,6 +66,25 @@ class DefaultListenerPool extends BasePool implements PoolableListener { $listenerInstance->getListenPort() . ' added to listener pool.' ); } + + /** + * Run the shutdown seqeuence by a Visitor Pattern + * + * @return void + */ + public function doShutdown () { + // Debug message + $this->debugOutput('POOL: Shutting down listener pool - START'); + + // Get a new visitor + $visitorInstance = ObjectFactory::createObjectByConfiguredName('listener_pool_visitor_class'); + + // Start visiting + $this->accept($visitorInstance); + + // Debug message + $this->debugOutput('POOL: Shutting down listener pool - FINISHED'); + } } // [EOF] diff --git a/application/hub/main/visitor/.htaccess b/application/hub/main/visitor/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/visitor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/visitor/class_ b/application/hub/main/visitor/class_ new file mode 100644 index 000000000..aa602f20b --- /dev/null +++ b/application/hub/main/visitor/class_ @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 . + */ +class ???Visitor extends BaseVisitor implements Visitor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $visitorInstance An instance a Visitorable class + */ + public final static function create???Visitor () { + // Get new instance + $visitorInstance = new ???Visitor(); + + // Return the prepared instance + return $visitorInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/visitor/class_BaseVisitor.php b/application/hub/main/visitor/class_BaseVisitor.php new file mode 100644 index 000000000..a955ea64c --- /dev/null +++ b/application/hub/main/visitor/class_BaseVisitor.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 . + */ +class BaseVisitor extends BaseHubSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Remove some attributes + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } +} + +// [EOF] +?> diff --git a/application/hub/main/visitor/shutdown/.htaccess b/application/hub/main/visitor/shutdown/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/visitor/shutdown/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/visitor/shutdown/class_Shutdown b/application/hub/main/visitor/shutdown/class_Shutdown new file mode 100644 index 000000000..59511aa7b --- /dev/null +++ b/application/hub/main/visitor/shutdown/class_Shutdown @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 . + */ +class Shutdown???Visitor extends BaseVisitor implements PoolVisitor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $visitorInstance An instance a Visitorable class + */ + public final static function createShutdown???Visitor () { + // Get new instance + $visitorInstance = new Shutdown???Visitor(); + + // Return the prepared instance + return $visitorInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/visitor/shutdown/class_ShutdownListenerPoolVisitor.php b/application/hub/main/visitor/shutdown/class_ShutdownListenerPoolVisitor.php new file mode 100644 index 000000000..d4ca881d8 --- /dev/null +++ b/application/hub/main/visitor/shutdown/class_ShutdownListenerPoolVisitor.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 . + */ +class ShutdownListenerPoolVisitor extends BaseVisitor implements PoolVisitor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $visitorInstance An instance a Visitorable class + */ + public final static function createShutdownListenerPoolVisitor () { + // Get new instance + $visitorInstance = new ShutdownListenerPoolVisitor(); + + // Return the prepared instance + return $visitorInstance; + } + + /** + * Visits the given pool instance + * + * @param $poolInstance A Poolable instance + * @return void + */ + public function visitPool (Poolable $poolInstance) { + // Debug message + $this->debugOutput('VISITOR: Visit of ' . $poolInstance->__toString() . ' - START'); + + // Pre-shutdown the pool + $poolInstance->preShutdown(); + + // Debug message + $this->debugOutput('VISITOR: Visit of ' . $poolInstance->__toString() . ' - FINISHED'); + } +} + +// +?> -- 2.39.5