View Javadoc
1 package org.smartcomps.twister.engine.priv.messaging; 2 3 import org.smartcomps.twister.engine.priv.messaging.impl.MessageControllerImpl; 4 import org.smartcomps.twister.engine.priv.Constants; 5 import org.smartcomps.twister.common.util.logger.Logger; 6 import org.smartcomps.twister.common.configuration.EngineConfiguration; 7 8 /*** 9 * A factory for MessageBroker and MessageController interfaces 10 * @see MessageBroker 11 * @see MessageController 12 */ 13 public class MessagingFactory { 14 15 private static Logger log = Logger.getLogger(MessagingFactory.class); 16 17 private static MessageController controller = null; 18 private static MessageBroker broker = null; 19 20 /*** 21 * This method is the factory method of the MessageBroker interface. The default implementation 22 * for this interface does nothing interesting so to customize your MessageBroker just redefine 23 * your own one and declare it as the implementation in the twister-implementations.properties 24 * file. 25 * @return a MessageBroker implementation 26 */ 27 public static MessageBroker getMessageBroker() { 28 if (broker == null) { 29 try { 30 String brokerClassName = EngineConfiguration.getMessageBroker(); 31 broker = (MessageBroker) Class.forName(brokerClassName).newInstance(); 32 } catch (ClassNotFoundException e) { 33 log.error("Could not instantiate a MessageBroker, could not find the broker class as defined "+ 34 "in file " + Constants.IMPL_PROPERTY); 35 } catch (InstantiationException e) { 36 log.error("Could not instantiate a MessageBroker", e); 37 } catch (IllegalAccessException e) { 38 log.error("Could not access the implementation class of a MessageBroker", e); 39 } 40 } 41 return broker; 42 } 43 44 /*** 45 * @return the MessageController implementation 46 */ 47 public static MessageController getMessageController() { 48 if (controller== null) { 49 controller = new MessageControllerImpl(); 50 } 51 return controller; 52 } 53 }

This page was automatically generated by Maven