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.http;
23:
24: import java.util.Properties;
25:
26: import javax.jms.JMSException;
27:
28: import org.jboss.logging.Logger;
29:
30: import org.jboss.mq.il.ServerIL;
31: import org.jboss.mq.il.ServerILFactory;
32:
33: /**
34: * The HTTP/S implementation of the ServerILFactory object.
35: *
36: * @author Nathan Phelps (nathan@jboss.org)
37: * @version $Revision: 57198 $
38: * @created January 15, 2003
39: */
40: public class HTTPServerILFactory implements ServerILFactory {
41:
42: public static final String SERVER_IL_FACTORY = HTTPServerILFactory.class
43: .getName();
44: public static final String CLIENT_IL_SERVICE = HTTPClientILService.class
45: .getName();
46: public static final String SERVER_URL_KEY = "org.jboss.mq.il.http.url";
47: public static final String TIMEOUT_KEY = "org.jboss.mq.il.http.timeout";
48: public static final String REST_INTERVAL_KEY = "org.jboss.mq.il.http.restinterval";
49:
50: private static Logger log = Logger
51: .getLogger(HTTPServerILFactory.class);
52:
53: private HTTPServerIL serverIL;
54:
55: public HTTPServerILFactory() {
56: if (log.isTraceEnabled()) {
57: log.trace("created");
58: }
59: }
60:
61: public ServerIL getServerIL() throws Exception {
62: if (log.isTraceEnabled()) {
63: log.trace("getServerIL()");
64: }
65: return this .serverIL;
66: }
67:
68: public void init(Properties props) throws Exception {
69: if (log.isTraceEnabled()) {
70: log.trace("init(Properties " + props.toString() + ")");
71: }
72: if (!props.containsKey(SERVER_URL_KEY)) {
73: if (log.isDebugEnabled()) {
74: log
75: .debug("The supplied properties don't include a server URL entry. Now checking to see if it is specified in the system properties.");
76: }
77: if (System.getProperties().containsKey(SERVER_URL_KEY)) {
78: if (log.isDebugEnabled()) {
79: log
80: .debug("The server URL property was found in the system properties. Will use it.");
81: }
82: props.setProperty(SERVER_URL_KEY, System
83: .getProperty(SERVER_URL_KEY));
84: } else {
85: throw new JMSException(
86: "A required connection property was not set: "
87: + SERVER_URL_KEY);
88: }
89: }
90: this .serverIL = new HTTPServerIL(props
91: .getProperty(SERVER_URL_KEY));
92:
93: }
94:
95: }
|