KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mq > il > oil > OILServerILFactory


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.mq.il.oil;
8
9 import java.util.Properties JavaDoc;
10
11 import org.jboss.mq.il.ServerIL;
12 import org.jboss.mq.il.ServerILFactory;
13 import java.net.InetAddress JavaDoc;
14
15 /**
16  * Factory class to produce OILServerIL objects.
17  *
18  * @author <a HREF="mailto:hiram.chirino@jboss.org">Hiram Chirino</a>
19  * @version $Revision: 1.5 $
20  */

21 public final class OILServerILFactory
22    implements ServerILFactory
23 {
24
25    final public static String JavaDoc SERVER_IL_FACTORY = OILServerILFactory.class.getName();
26    final public static String JavaDoc CLIENT_IL_SERVICE = OILClientILService.class.getName();
27    final public static String JavaDoc OIL_ADDRESS_KEY = "OIL_ADDRESS_KEY";
28    final public static String JavaDoc OIL_PORT_KEY = "OIL_PORT_KEY";
29    final public static String JavaDoc OIL_TCPNODELAY_KEY = "OIL_TCPNODELAY_KEY";
30
31    private ServerIL serverIL;
32
33    /**
34     * @see ServerILFactory#init(Properties)
35     */

36    public void init(Properties JavaDoc props)
37       throws Exception JavaDoc
38    {
39     
40       String JavaDoc t = props.getProperty(OIL_ADDRESS_KEY);
41       if (t == null)
42          throw new javax.jms.JMSException JavaDoc("A required connection property was not set: " + OIL_ADDRESS_KEY);
43       InetAddress JavaDoc address = InetAddress.getByName(t);
44
45       t = props.getProperty(OIL_PORT_KEY);
46       if (t == null)
47          throw new javax.jms.JMSException JavaDoc("A required connection property was not set: " + OIL_PORT_KEY);
48       int port = Integer.parseInt(t);
49       
50       boolean enableTcpNoDelay=false;
51       t = props.getProperty(OIL_TCPNODELAY_KEY);
52       if (t != null)
53          enableTcpNoDelay = t.equals("yes");
54
55       String JavaDoc clientSocketFactoryName = null;
56       serverIL = new OILServerIL(address, port, clientSocketFactoryName, enableTcpNoDelay);
57
58    }
59
60    /**
61     * @see ServerILFactory#getServerIL()
62     */

63    public ServerIL getServerIL()
64       throws Exception JavaDoc
65    {
66       return serverIL;
67    }
68
69 }
70
Popular Tags