01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.mq.il.oil2;
23:
24: import java.util.Properties;
25:
26: import org.jboss.logging.Logger;
27: import org.jboss.mq.il.ServerIL;
28: import org.jboss.mq.il.ServerILFactory;
29:
30: /**
31: * Factory class to produce OIL2ServerIL objects.
32: *
33: * @author <a href="mailto:hiram.chirino@jboss.org">Hiram Chirino</a>
34: * @version $Revision: $
35: */
36: public final class OIL2ServerILFactory implements ServerILFactory {
37: private final static Logger log = Logger
38: .getLogger(OIL2ServerILFactory.class);
39:
40: final public static String SERVER_IL_FACTORY = OIL2ServerILFactory.class
41: .getName();
42: final public static String CLIENT_IL_SERVICE = OIL2ClientILService.class
43: .getName();
44: final public static String OIL2_ADDRESS_KEY = "OIL2_ADDRESS_KEY";
45: final public static String OIL2_PORT_KEY = "OIL2_PORT_KEY";
46: final public static String OIL2_TCPNODELAY_KEY = "OIL2_TCPNODELAY_KEY";
47:
48: private ServerIL serverIL;
49:
50: /**
51: * @see ServerILFactory#init(Properties)
52: */
53: public void init(Properties props) throws Exception {
54:
55: String address = props.getProperty(OIL2_ADDRESS_KEY);
56: if (address == null)
57: throw new javax.jms.JMSException(
58: "A required connection property was not set: "
59: + OIL2_ADDRESS_KEY);
60:
61: String t = props.getProperty(OIL2_PORT_KEY);
62: if (t == null)
63: throw new javax.jms.JMSException(
64: "A required connection property was not set: "
65: + OIL2_PORT_KEY);
66: int port = Integer.parseInt(t);
67:
68: boolean enableTcpNoDelay = false;
69: t = props.getProperty(OIL2_TCPNODELAY_KEY);
70: if (t != null)
71: enableTcpNoDelay = t.equals("yes");
72:
73: String clientSocketFactoryName = null;
74: serverIL = new OIL2ServerIL(address, port,
75: clientSocketFactoryName, enableTcpNoDelay);
76:
77: }
78:
79: /**
80: * @see ServerILFactory#getServerIL()
81: */
82: public ServerIL getServerIL() throws Exception {
83: if (log.isTraceEnabled())
84: log.trace("Providing ServerIL: " + serverIL);
85: return serverIL;
86: }
87:
88: }
|