KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mq > il > uil2 > UILServerILFactory


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * 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.uil2;
23
24 import java.util.Properties JavaDoc;
25
26 import org.jboss.mq.il.ServerIL;
27 import org.jboss.mq.il.ServerILFactory;
28 import java.net.InetAddress JavaDoc;
29
30 /**
31  * Factory class to produce UILServerIL objects.
32  *
33  * @author <a HREF="mailto:hiram.chirino@jboss.org">Hiram Chirino</a>
34  * @version $Revision: 37459 $
35  */

36 public class UILServerILFactory implements ServerILFactory {
37
38    final public static String JavaDoc SERVER_IL_FACTORY = UILServerILFactory.class.getName();
39    final public static String JavaDoc CLIENT_IL_SERVICE = UILClientILService.class.getName();
40    final public static String JavaDoc UIL_ADDRESS_KEY = "UIL_ADDRESS_KEY";
41    final public static String JavaDoc UIL_PORT_KEY = "UIL_PORT_KEY";
42    final public static String JavaDoc UIL_TCPNODELAY_KEY = "UIL_TCPNODELAY_KEY";
43    final public static String JavaDoc UIL_BUFFERSIZE_KEY = "UIL_BUFFERSIZE_KEY";
44    final public static String JavaDoc UIL_CHUNKSIZE_KEY = "UIL_CHUNKSIZE_KEY";
45    final public static String JavaDoc UIL_RECEIVE_REPLIES_KEY = "UIL_RECEIVE_REPLIES_KEY";
46    final public static String JavaDoc UIL_SOTIMEOUT_KEY = "UIL_SOTIMEOUT_KEY";
47    final public static String JavaDoc UIL_CONNECTADDRESS_KEY = "UIL_CONNECTADDRESS_KEY";
48    final public static String JavaDoc UIL_CONNECTPORT_KEY = "UIL_CONNECTPORT_KEY";
49    
50    private ServerIL serverIL;
51
52    /**
53     * @see ServerILFactory#init(Properties)
54     */

55    public void init(Properties JavaDoc props) throws Exception JavaDoc {
56     
57       String JavaDoc t = props.getProperty(UIL_ADDRESS_KEY);
58       if (t == null)
59          throw new javax.jms.JMSException JavaDoc("A required connection property was not set: " + UIL_ADDRESS_KEY);
60       InetAddress JavaDoc address = InetAddress.getByName(t);
61
62       t = props.getProperty(UIL_PORT_KEY);
63       if (t == null)
64          throw new javax.jms.JMSException JavaDoc("A required connection property was not set: " + UIL_PORT_KEY);
65       int port = Integer.parseInt(t);
66       
67       boolean enableTcpNoDelay=false;
68       t = props.getProperty(UIL_TCPNODELAY_KEY);
69       if (t != null)
70          enableTcpNoDelay = t.equals("yes");
71
72       int bufferSize = 1; // 1 byte == no buffering
73
t = props.getProperty(UIL_BUFFERSIZE_KEY);
74       if (t != null)
75          bufferSize = Integer.parseInt(t);
76
77       int chunkSize = 0x40000000; // 2^30 bytes
78
t = props.getProperty(UIL_CHUNKSIZE_KEY);
79       if (t != null)
80          chunkSize = Integer.parseInt(t);
81
82       int soTimeout = 0;
83       t = props.getProperty(UIL_SOTIMEOUT_KEY);
84       if (t != null)
85          soTimeout = Integer.parseInt(t);
86
87       String JavaDoc connectAddress = props.getProperty(UIL_CONNECTADDRESS_KEY);
88
89       int connectPort = 0;
90       t = props.getProperty(UIL_CONNECTPORT_KEY);
91       if (t != null)
92          connectPort = Integer.parseInt(t);
93       
94       String JavaDoc clientSocketFactoryName = null;
95
96       serverIL = new UILServerIL(address, port, clientSocketFactoryName, enableTcpNoDelay, bufferSize, chunkSize, soTimeout, connectAddress, connectPort);
97
98    }
99
100    /**
101     * @see ServerILFactory#getServerIL()
102     */

103    public ServerIL getServerIL() throws Exception JavaDoc {
104       return serverIL;
105    }
106
107 }
Popular Tags