- Moved some classes to core as they become "generic" (generalized code).
- 'core' updated to latest commit
Signed-off-by: Roland Haeder <roland@mxchange.org>
* - listen-port (TCP/UDP listen port for inbound connections)
*
* @param $messageData An array with all minimum message data
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @param $forceUpdate Optionally force update, don't register (default: register if not found)
* @return void
*/
- function registerNodeByMessageData (array $messageData, Handleable $handlerInstance, $forceUpdate = FALSE);
+ function registerNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance, $forceUpdate = FALSE);
/**
* Queries the local DHT data(base) for a node list with all supported
* object types except the node by given session id.
*
* @param $messageData An array with message data from a node_list request
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @param $excludeKey Array key which should be excluded
* @param $andKey Array of $separator-separated list of elements which all must match
* @param $separator Sepator char (1st parameter for explode() call)
* @return $nodeList An array with all found nodes
*/
- function queryLocalNodeListExceptByMessageData (array $messageData, Handleable $handlerInstance, $excludeKey, $andKey, $separator);
+ function queryLocalNodeListExceptByMessageData (array $messageData, HandleableDataSet $handlerInstance, $excludeKey, $andKey, $separator);
/**
* Inserts given node list array (from earlier database result produced by
* 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 HandleableAnswerStatus extends Handleable {
+interface HandleableAnswerStatus extends HandleableDataSet {
/**
* Handles given message data array
*
<?php
/**
- * Handleable chunks interface
+ * An interface for chunk handlers
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
+++ /dev/null
-<?php
-/**
- * A Handleable interface
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 Handleable extends FrameworkInterface {
- /**
- * Adds all required elements from given array into data set instance
- *
- * @param $dataSetInstance An instance of a StoreableCriteria class
- * @param $messageData An array with all message data
- * @return void
- */
- function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData);
-}
-
-// [EOF]
-?>
<?php
/**
- * Handleable chunks interface
+ * An interface for message handlers
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
* 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 HandleableMessage extends Handleable {
+interface HandleableMessage extends HandleableDataSet {
/**
* Handles data array of the message
*
* 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 Networkable extends Handleable {
+interface Networkable extends HandleableDataSet {
/**
* Processes raw data from given resource. This is mostly useful for TCP
* package handling and is implemented in the TcpListener class
* 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 HandleableTask extends Handleable {
+interface HandleableTask extends HandleableDataSet {
/**
* Searches a task by given instance
*
+++ /dev/null
-<?php
-/**
- * An interface for protocol handlers
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.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 ProtocolHandler extends FrameworkInterface {
- /**
- * Getter for port number to satify ProtocolHandler
- *
- * @return $port The port number
- */
- function getPort ();
-
- /**
- * Getter for protocol name
- *
- * @return $protocol Name of used protocol
- */
- function getProtocolName ();
-}
-
-// [EOF]
-?>
* Registeres a node by given message data.
*
* @param $messageData An array of all message data
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @return void
*/
- function registerNodeByMessageData (array $messageData, Handleable $handlerInstance);
+ function registerNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance);
/**
* Updates an existing entry in node list
*
* @param $messageData An array of all message data
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @param $searchInstance An instance of LocalSearchCriteria class
* @return void
*/
- function updateNodeByMessageData (array $messageData, Handleable $handlerInstance, LocalSearchCriteria $searchInstance);
+ function updateNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance, LocalSearchCriteria $searchInstance);
/**
* Determines whether the given node data is already inserted in the DHT
* - listen-port (TCP/UDP listen port for inbound connections)
*
* @param $messageArray An array with all minimum message data
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @param $forceUpdate Optionally force update, don't register (default: register if not found)
* @return void
* @throws NodeSessionIdVerficationException If the node was not found and update is forced
*/
- public function registerNodeByMessageData (array $messageData, Handleable $handlerInstance, $forceUpdate = FALSE) {
+ public function registerNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance, $forceUpdate = FALSE) {
// Get a search criteria class
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
* object types except the node by given session id.
*
* @param $messageData An array with message data from a node_list request
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @param $excludeKey Array key which should be excluded
* @param $andKey Array of $separator-separated list of elements which all must match
* @param $separator Sepator char (1st parameter for explode() call)
* @return $nodeList An array with all found nodes
*/
- public function queryLocalNodeListExceptByMessageData (array $messageData, Handleable $handlerInstance, $excludeKey, $andKey, $separator) {
+ public function queryLocalNodeListExceptByMessageData (array $messageData, HandleableDataSet $handlerInstance, $excludeKey, $andKey, $separator) {
// Make sure both keys are there
assert((isset($messageData[$excludeKey])) && (isset($messageData[$andKey])));
--- /dev/null
+<?php
+/**
+ * A factory class for protocol handlers
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 ProtocolHandlerFactory extends ObjectFactory {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Returns a singleton protocol handler instance. If an instance is
+ * found in registry, it will be returned, else a new instance is created
+ * and stored in the same registry entry.
+ *
+ * @param $messageType Protocol to create an object from
+ * @return $handlerInstance A protocol handler instance
+ */
+ public static final function createProtocolHandlerInstance ($messageType) {
+ // Do we have an instance in the registry?
+ if (Registry::getRegistry()->instanceExists($messageType . '_protocol_handler')) {
+ // Then use this instance
+ $handlerInstance = Registry::getRegistry()->getInstance($messageType . '_protocol_handler');
+ } else {
+ // Now prepare the tags instance
+ $handlerInstance = self::createObjectByConfiguredName($messageType . '_protocol_handler_class');
+
+ // Set the instance in registry for further use
+ Registry::getRegistry()->addInstance($messageType . '_protocol_handler', $handlerInstance);
+ }
+
+ // Return the instance
+ return $handlerInstance;
+ }
+}
+
+// [EOF]
+?>
* 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 BaseHandler extends BaseHubSystem implements Handleable {
+class BaseHandler extends BaseHubSystem implements HandleableDataSet {
/**
* Handler name
*/
* Registeres a node by given message data.
*
* @param $messageData An array of all message data
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @return void
*/
- public function registerNodeByMessageData (array $messageData, Handleable $handlerInstance) {
+ public function registerNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance) {
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: handlerInstance=' . $handlerInstance->__toString() . ' - CALLED!');
// Get a data set instance
* Updates an existing entry in node list
*
* @param $messageData An array of all message data
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @param $searchInstance An instance of LocalSearchCriteria class
* @return void
*/
- public function updateNodeByMessageData (array $messageData, Handleable $handlerInstance, LocalSearchCriteria $searchInstance) {
+ public function updateNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance, LocalSearchCriteria $searchInstance) {
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
// Get a data set instance
-Subproject commit 68bd2250d706545928c5882c34265ceae3e2f03f
+Subproject commit 25c4a1682a9cd7124fc1a53bf249823bb740a3d5