1 19 20 package org.apache.cayenne.event; 21 22 import java.util.Collection ; 23 import java.util.Map ; 24 25 import org.apache.cayenne.CayenneRuntimeException; 26 27 34 public class XMPPBridgeFactory implements EventBridgeFactory { 35 36 public static final String XMPP_HOST_PROPERTY = "cayenne.XMPPBridge.xmppHost"; 37 38 41 public static final String XMPP_PORT_PROPERTY = "cayenne.XMPPBridge.xmppPort"; 42 43 46 public static final String XMPP_CHAT_SERVICE_PROPERTY = "cayenne.XMPPBridge.xmppChatService"; 47 48 public static final String XMPP_SECURE_CONNECTION_PROPERTY = "cayenne.XMPPBridge.xmppSecure"; 49 public static final String XMPP_LOGIN_PROPERTY = "cayenne.XMPPBridge.xmppLogin"; 50 public static final String XMPP_PASSWORD_PROPERTY = "cayenne.XMPPBridge.xmppPassword"; 51 52 public EventBridge createEventBridge( 53 Collection localSubjects, 54 String externalSubject, 55 Map properties) { 56 57 String chatService = (String ) properties.get(XMPP_CHAT_SERVICE_PROPERTY); 58 String host = (String ) properties.get(XMPP_HOST_PROPERTY); 59 60 String loginId = (String ) properties.get(XMPP_LOGIN_PROPERTY); 61 String password = (String ) properties.get(XMPP_PASSWORD_PROPERTY); 62 63 String secureConnectionString = (String ) properties 64 .get(XMPP_SECURE_CONNECTION_PROPERTY); 65 boolean secureConnection = "true".equalsIgnoreCase(secureConnectionString); 66 67 String portString = (String ) properties.get(XMPP_PORT_PROPERTY); 68 int port = -1; 69 if (portString != null) { 70 71 try { 72 port = Integer.parseInt(portString); 73 } 74 catch (NumberFormatException e) { 75 throw new CayenneRuntimeException("Invalid port: " + portString); 76 } 77 } 78 79 XMPPBridge bridge = new XMPPBridge(localSubjects, externalSubject); 80 81 bridge.setXmppHost(host); 82 bridge.setXmppPort(port); 83 bridge.setChatService(chatService); 84 bridge.setSecureConnection(secureConnection); 85 bridge.setLoginId(loginId); 86 bridge.setPassword(password); 87 88 return bridge; 89 } 90 } 91 | Popular Tags |