3 * A ShutdownNode filter for shutting down the node. This filter should be the
4 * last one in 'shutdown' chain so the hub is shutted down at the very end of
5 * its life... R.I.P. little hub...
7 * @author Roland Haeder <webmaster@ship-simu.org>
9 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
10 * @license GNU GPL 3.0 or any newer version
11 * @link http://www.ship-simu.org
13 * This program is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 class HubShutdownShutdownNodeFilter extends BaseFilter implements Filterable {
28 * Protected constructor
32 protected function __construct () {
33 // Call parent constructor
34 parent::__construct(__CLASS__);
38 * Creates an instance of this filter class
40 * @return $filterInstance An instance of this filter class
42 public final static function createHubShutdownShutdownNodeFilter () {
44 $filterInstance = new HubShutdownShutdownNodeFilter();
46 // Return the instance
47 return $filterInstance;
51 * Executes the filter with given request and response objects
53 * @param $requestInstance An instance of a class with an Requestable interface
54 * @param $responseInstance An instance of a class with an Responseable interface
56 * @throws FilterChainException If $nodeInstance is null (no NullPointerException please)
58 public function execute (Requestable $requestInstance, Responseable $responseInstance) {
60 $nodeInstance = Registry::getRegistry()->getInstance('node');
63 if (is_null($nodeInstance)) {
64 // Throws a FilterChainException to stop further processing
65 throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
68 // Shutdown the node. This should be the last line
69 $nodeInstance->doShutdown();
77 * A ShutdownNode filter for shutting down the node. This filter should be the
78 * last one in 'shutdown' chain so the hub is shutted down at the very end of
79 * its life... R.I.P. little hub...
81 * @author Roland Haeder <webmaster@ship-simu.org>
83 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
84 * @license GNU GPL 3.0 or any newer version
85 * @link http://www.ship-simu.org
87 * This program is free software: you can redistribute it and/or modify
88 * it under the terms of the GNU General Public License as published by
89 * the Free Software Foundation, either version 3 of the License, or
90 * (at your option) any later version.
92 * This program is distributed in the hope that it will be useful,
93 * but WITHOUT ANY WARRANTY; without even the implied warranty of
94 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
95 * GNU General Public License for more details.
97 * You should have received a copy of the GNU General Public License
98 * along with this program. If not, see <http://www.gnu.org/licenses/>.
100 class HubShutdownShutdownNodeFilter extends BaseFilter implements Filterable {
102 * Protected constructor
106 protected function __construct () {
107 // Call parent constructor
108 parent::__construct(__CLASS__);
112 * Creates an instance of this filter class
114 * @return $filterInstance An instance of this filter class
116 public final static function createHubShutdownShutdownNodeFilter () {
117 // Get a new instance
118 $filterInstance = new HubShutdownShutdownNodeFilter();
120 // Return the instance
121 return $filterInstance;
125 * Executes the filter with given request and response objects
127 * @param $requestInstance An instance of a class with an Requestable interface
128 * @param $responseInstance An instance of a class with an Responseable interface
130 * @throws FilterChainException If $nodeInstance is null (no NullPointerException please)
132 public function execute (Requestable $requestInstance, Responseable $responseInstance) {
134 $nodeInstance = Registry::getRegistry()->getInstance('node');
136 // Sanity-check on it
137 if (is_null($nodeInstance)) {
138 // Throws a FilterChainException to stop further processing
139 throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
142 // Shutdown the node. This should be the last line
143 $nodeInstance->doShutdown();