KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mq > il > oil2 > OIL2ServerILFactory


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.oil2;
8
9 import java.util.Properties JavaDoc;
10
11 import org.jboss.logging.Logger;
12 import org.jboss.mq.il.ServerIL;
13 import org.jboss.mq.il.ServerILFactory;
14
15 /**
16  * Factory class to produce OIL2ServerIL objects.
17  *
18  * @author <a HREF="mailto:hiram.chirino@jboss.org">Hiram Chirino</a>
19  * @version $Revision: $
20  */

21 public final class OIL2ServerILFactory
22    implements ServerILFactory
23 {
24    private final static Logger log = Logger.getLogger(OIL2ServerILFactory.class);
25
26    final public static String JavaDoc SERVER_IL_FACTORY = OIL2ServerILFactory.class.getName();
27    final public static String JavaDoc CLIENT_IL_SERVICE = OIL2ClientILService.class.getName();
28    final public static String JavaDoc OIL2_ADDRESS_KEY = "OIL2_ADDRESS_KEY";
29    final public static String JavaDoc OIL2_PORT_KEY = "OIL2_PORT_KEY";
30    final public static String JavaDoc OIL2_TCPNODELAY_KEY = "OIL2_TCPNODELAY_KEY";
31
32    private ServerIL serverIL;
33
34    /**
35     * @see ServerILFactory#init(Properties)
36     */

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

63    public ServerIL getServerIL()
64       throws Exception JavaDoc
65    {
66       if( log.isTraceEnabled() )
67          log.trace("Providing ServerIL: "+serverIL);
68       return serverIL;
69    }
70
71 }
72
Popular Tags