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.oil;
23:
24: import java.util.Properties;
25:
26: import org.jboss.mq.il.ServerIL;
27: import org.jboss.mq.il.ServerILFactory;
28: import java.net.InetAddress;
29:
30: /**
31: * Factory class to produce OILServerIL objects.
32: *
33: * @author <a href="mailto:hiram.chirino@jboss.org">Hiram Chirino</a>
34: * @version $Revision: 57198 $
35: */
36: public final class OILServerILFactory implements ServerILFactory {
37:
38: final public static String SERVER_IL_FACTORY = OILServerILFactory.class
39: .getName();
40: final public static String CLIENT_IL_SERVICE = OILClientILService.class
41: .getName();
42: final public static String OIL_ADDRESS_KEY = "OIL_ADDRESS_KEY";
43: final public static String OIL_PORT_KEY = "OIL_PORT_KEY";
44: final public static String OIL_TCPNODELAY_KEY = "OIL_TCPNODELAY_KEY";
45:
46: private ServerIL serverIL;
47:
48: /**
49: * @see ServerILFactory#init(Properties)
50: */
51: public void init(Properties props) throws Exception {
52:
53: String t = props.getProperty(OIL_ADDRESS_KEY);
54: if (t == null)
55: throw new javax.jms.JMSException(
56: "A required connection property was not set: "
57: + OIL_ADDRESS_KEY);
58: InetAddress address = InetAddress.getByName(t);
59:
60: t = props.getProperty(OIL_PORT_KEY);
61: if (t == null)
62: throw new javax.jms.JMSException(
63: "A required connection property was not set: "
64: + OIL_PORT_KEY);
65: int port = Integer.parseInt(t);
66:
67: boolean enableTcpNoDelay = false;
68: t = props.getProperty(OIL_TCPNODELAY_KEY);
69: if (t != null)
70: enableTcpNoDelay = t.equals("yes");
71:
72: String clientSocketFactoryName = null;
73: serverIL = new OILServerIL(address, port,
74: clientSocketFactoryName, enableTcpNoDelay);
75:
76: }
77:
78: /**
79: * @see ServerILFactory#getServerIL()
80: */
81: public ServerIL getServerIL() throws Exception {
82: return serverIL;
83: }
84:
85: }
|