+
+ /**
+ * Returns a singleton protocol handler instance from given HubHelper
+ * 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 $helperInstance An instance of a HubHelper class
+ * @return $handlerInstance A protocol handler instance
+ */
+ public static final function createProtocolHandlerFromRecipientHelper (HubHelper $helperInstance) {
+ // Get the protocol type from given helper instance
+ $protocolType = $helperInstance->determineProtocolType();
+
+ // Call super factory method
+ return self::createProtocolHandlerByType($protocolType);
+ }
+
+ /**
+ * Creates an instance of a protocol handler from given (raw) package data
+ *
+ * @param $packageData An array with raw package data
+ * @return $handlerInstance A protocol handler instance
+ */
+ public static final function createProtocolHandlerFromPackageData (array $packageData) {
+ // Now that there is no direct node instance available, a protocol discovery class is required
+ $discoveryInstance = ObjectFactory::createObjectByConfiguredName('protocol_discovery_class');
+
+ // "Discover" the protocol type
+ $protocolType = $discoveryInstance->discoverProtocolByPackageData($packageData);
+
+ // Call super factory method
+ return self::createProtocolHandlerByType($protocolType);
+ }