KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mq > il > http > HTTPServerILFactory


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.http;
23
24 import java.util.Properties JavaDoc;
25
26 import javax.jms.JMSException JavaDoc;
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: 37459 $
38  * @created January 15, 2003
39  */

40 public class HTTPServerILFactory implements ServerILFactory
41 {
42     
43     public static final String JavaDoc SERVER_IL_FACTORY = HTTPServerILFactory.class.getName();
44     public static final String JavaDoc CLIENT_IL_SERVICE = HTTPClientILService.class.getName();
45     public static final String JavaDoc SERVER_URL_KEY = "org.jboss.mq.il.http.url";
46     public static final String JavaDoc TIMEOUT_KEY = "org.jboss.mq.il.http.timeout";
47     public static final String JavaDoc REST_INTERVAL_KEY = "org.jboss.mq.il.http.restinterval";
48     
49     private static Logger log = Logger.getLogger(HTTPServerILFactory.class);
50     
51     private HTTPServerIL serverIL;
52     
53     public HTTPServerILFactory()
54     {
55         if(log.isTraceEnabled())
56         {
57             log.trace("created");
58         }
59     }
60     
61     public ServerIL getServerIL() throws Exception JavaDoc
62     {
63         if (log.isTraceEnabled())
64         {
65             log.trace("getServerIL()");
66         }
67         return this.serverIL;
68     }
69     
70     public void init(Properties JavaDoc props) throws Exception JavaDoc
71     {
72         if (log.isTraceEnabled())
73         {
74             log.trace("init(Properties " + props.toString() + ")");
75         }
76         if (!props.containsKey(SERVER_URL_KEY))
77         {
78             if (log.isDebugEnabled())
79             {
80                 log.debug("The supplied properties don't include a server URL entry. Now checking to see if it is specified in the system properties.");
81             }
82             if (System.getProperties().containsKey(SERVER_URL_KEY))
83             {
84                 if (log.isDebugEnabled())
85                 {
86                     log.debug("The server URL property was found in the system properties. Will use it.");
87                 }
88                 props.setProperty(SERVER_URL_KEY, System.getProperty(SERVER_URL_KEY));
89             }
90             else
91             {
92                 throw new JMSException JavaDoc("A required connection property was not set: " + SERVER_URL_KEY);
93             }
94         }
95         this.serverIL = new HTTPServerIL(props.getProperty(SERVER_URL_KEY));
96         
97     }
98     
99 }
Popular Tags