001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.mq.il.uil2;
023:
024: import java.util.Properties;
025:
026: import org.jboss.mq.il.ServerIL;
027: import org.jboss.mq.il.ServerILFactory;
028: import java.net.InetAddress;
029:
030: /**
031: * Factory class to produce UILServerIL objects.
032: *
033: * @author <a href="mailto:hiram.chirino@jboss.org">Hiram Chirino</a>
034: * @version $Revision: 57198 $
035: */
036: public class UILServerILFactory implements ServerILFactory {
037:
038: final public static String SERVER_IL_FACTORY = UILServerILFactory.class
039: .getName();
040: final public static String CLIENT_IL_SERVICE = UILClientILService.class
041: .getName();
042: final public static String UIL_ADDRESS_KEY = "UIL_ADDRESS_KEY";
043: final public static String UIL_PORT_KEY = "UIL_PORT_KEY";
044: final public static String UIL_TCPNODELAY_KEY = "UIL_TCPNODELAY_KEY";
045: final public static String UIL_BUFFERSIZE_KEY = "UIL_BUFFERSIZE_KEY";
046: final public static String UIL_CHUNKSIZE_KEY = "UIL_CHUNKSIZE_KEY";
047: final public static String UIL_RECEIVE_REPLIES_KEY = "UIL_RECEIVE_REPLIES_KEY";
048: final public static String UIL_SOTIMEOUT_KEY = "UIL_SOTIMEOUT_KEY";
049: final public static String UIL_CONNECTADDRESS_KEY = "UIL_CONNECTADDRESS_KEY";
050: final public static String UIL_CONNECTPORT_KEY = "UIL_CONNECTPORT_KEY";
051:
052: private ServerIL serverIL;
053:
054: /**
055: * @see ServerILFactory#init(Properties)
056: */
057: public void init(Properties props) throws Exception {
058:
059: String t = props.getProperty(UIL_ADDRESS_KEY);
060: if (t == null)
061: throw new javax.jms.JMSException(
062: "A required connection property was not set: "
063: + UIL_ADDRESS_KEY);
064: InetAddress address = InetAddress.getByName(t);
065:
066: t = props.getProperty(UIL_PORT_KEY);
067: if (t == null)
068: throw new javax.jms.JMSException(
069: "A required connection property was not set: "
070: + UIL_PORT_KEY);
071: int port = Integer.parseInt(t);
072:
073: boolean enableTcpNoDelay = false;
074: t = props.getProperty(UIL_TCPNODELAY_KEY);
075: if (t != null)
076: enableTcpNoDelay = t.equals("yes");
077:
078: int bufferSize = 1; // 1 byte == no buffering
079: t = props.getProperty(UIL_BUFFERSIZE_KEY);
080: if (t != null)
081: bufferSize = Integer.parseInt(t);
082:
083: int chunkSize = 0x40000000; // 2^30 bytes
084: t = props.getProperty(UIL_CHUNKSIZE_KEY);
085: if (t != null)
086: chunkSize = Integer.parseInt(t);
087:
088: int soTimeout = 0;
089: t = props.getProperty(UIL_SOTIMEOUT_KEY);
090: if (t != null)
091: soTimeout = Integer.parseInt(t);
092:
093: String connectAddress = props
094: .getProperty(UIL_CONNECTADDRESS_KEY);
095:
096: int connectPort = 0;
097: t = props.getProperty(UIL_CONNECTPORT_KEY);
098: if (t != null)
099: connectPort = Integer.parseInt(t);
100:
101: String clientSocketFactoryName = null;
102:
103: serverIL = new UILServerIL(address, port,
104: clientSocketFactoryName, enableTcpNoDelay, bufferSize,
105: chunkSize, soTimeout, connectAddress, connectPort);
106:
107: }
108:
109: /**
110: * @see ServerILFactory#getServerIL()
111: */
112: public ServerIL getServerIL() throws Exception {
113: return serverIL;
114: }
115:
116: }
|