KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > carol > util > configuration > CarolDefaultValues


1 /**
2  * Copyright (C) 2002,2005 - INRIA (www.inria.fr)
3  *
4  * CAROL: Common Architecture for RMI ObjectWeb Layer
5  *
6  * This library is developed inside the ObjectWeb Consortium,
7  * http://www.objectweb.org
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22  * USA
23  *
24  * --------------------------------------------------------------------------
25  * $Id: CarolDefaultValues.java,v 1.20 2005/05/14 00:03:58 rhs Exp $
26  * --------------------------------------------------------------------------
27  */

28 package org.objectweb.carol.util.configuration;
29
30 import java.util.Properties JavaDoc;
31 import java.util.StringTokenizer JavaDoc;
32
33 /**
34  * Class <code> DefaultCarolValues </code> get default carol value for the
35  * properties file and get carol properties with defaults from jndi Standard
36  * properties
37  */

38 public class CarolDefaultValues {
39
40     /**
41      * Carol default configuration file
42      */

43     public static final String JavaDoc CAROL_DEFAULT_CONFIGURATION_FILE = "carol-defaults.properties";
44
45     /**
46      * Carol configuration file
47      */

48     public static final String JavaDoc CAROL_CONFIGURATION_FILE = "carol.properties";
49
50     /**
51      * Carol prefix
52      */

53     public static final String JavaDoc CAROL_PREFIX = "carol";
54
55     /**
56      * Server mode property (if true, this means that carol is running in a server which export objects)
57      */

58     public static final String JavaDoc SERVER_MODE = CAROL_PREFIX + ".server.mode";
59
60     /**
61      * Port number to use in server mode case (iiop)
62      */

63     public static final String JavaDoc SERVER_IIOP_PORT = CAROL_PREFIX + ".iiop.server.port";
64
65     /**
66      * Port number to use in server mode case (irmi)
67      */

68     public static final String JavaDoc SERVER_IRMI_PORT = CAROL_PREFIX + ".irmi.server.port";
69
70     /**
71      * Port number to use in server mode case (jrmp)
72      */

73     public static final String JavaDoc SERVER_JRMP_PORT = CAROL_PREFIX + ".jrmp.server.port";
74
75     /**
76      * Port number to use in server mode case (jeremie)
77      */

78     public static final String JavaDoc SERVER_JEREMIE_PORT = CAROL_PREFIX + ".jeremie.server.port";
79
80     /**
81      * Ssl Port number to use in server mode case (iiop)
82      */

83     public static final String JavaDoc SERVER_SSL_IIOP_PORT = CAROL_PREFIX + ".iiop.server.sslport";
84
85     /**
86      * Default ssl port value
87      */

88     public static final int DEFAULT_SSL_PORT = 2003;
89
90     /**
91      * Default hostname
92      */

93     public static final String JavaDoc DEFAULT_HOST = "localhost";
94
95     /**
96      * JNDI Prefix
97      */

98     public static final String JavaDoc JNDI_PREFIX = "jndi";
99
100     /**
101      * JVM Prefix
102      */

103     public static final String JavaDoc JVM_PREFIX = "jvm";
104
105     /**
106      * name service class prefix
107      */

108     public static final String JavaDoc NS_PREFIX = "NameServiceClass";
109
110     /**
111      * portable remote object Prefix
112      */

113     public static final String JavaDoc PRO_PREFIX = "PortableRemoteObjectClass";
114
115     /**
116      * carol url Prefix
117      */

118     public static final String JavaDoc URL_PREFIX = "url";
119
120     /**
121      * carol jrmp local call optimization
122      */

123     public static final String JavaDoc LOCAL_JRMP_PROPERTY = "rmi.local.call";
124
125     /**
126      * carol factory Prefix
127      */

128     public static final String JavaDoc FACTORY_PREFIX = "context.factory";
129
130     /**
131      * start name service Prefix
132      */

133     public static final String JavaDoc START_NS_PREFIX = "start.ns";
134
135     /**
136      * start ns key
137      */

138     public static final String JavaDoc START_NS_KEY = "carol.start.ns";
139
140     /**
141      * start rmi key
142      */

143     public static final String JavaDoc START_RMI_KEY = "carol.start.rmi";
144
145     /**
146      * start jndi key
147      */

148     public static final String JavaDoc START_JNDI_KEY = "carol.start.jndi";
149
150     /**
151      * default activation key
152      */

153     public static final String JavaDoc DEFAULT_PROTOCOLS_KEY = "carol.protocols.default";
154
155     /**
156      * acativation key
157      */

158     public static final String JavaDoc PROTOCOLS_KEY = "carol.protocols";
159
160     /**
161      * start ns key
162      */

163     public static final String JavaDoc MULTI_RMI_PREFIX = "multi";
164
165     /**
166      * start prod key
167      */

168     public static final String JavaDoc MULTI_PROD = "org.objectweb.carol.rmi.multi.MultiPRODelegate";
169
170     /**
171      * start jndi key
172      */

173     public static final String JavaDoc MULTI_JNDI = "org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory";
174
175     /**
176      * interceptor prefix
177      */

178     public static final String JavaDoc INTERCEPTOR_PKGS_PREFIX = "interceptor.pkgs";
179
180     /**
181      * interceptor prefix
182      */

183     public static final String JavaDoc INTERCEPTOR_VALUES_PREFIX = "interceptors";
184
185
186     /**
187      * Hashtable mapping between default en rmi name
188      */

189     private static Properties JavaDoc mapping = new Properties JavaDoc();
190
191     static {
192         mapping.setProperty("rmi", "jrmp");
193         mapping.setProperty("iiop", "iiop");
194         mapping.setProperty("jrmi", "jeremie");
195         mapping.setProperty("cmi", "cmi");
196     }
197
198     /**
199      * return protocol name from url
200      * @return protocol name
201      * @param url protocol jndi url
202      */

203     public static String JavaDoc getRMIProtocol(String JavaDoc url) {
204         if (url != null) {
205             StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(url, "://");
206             if (!st.hasMoreTokens()) {
207                 throw new IllegalArgumentException JavaDoc("The given url '" + url + "' is not on the format protocol://<something>.");
208             }
209             String JavaDoc pref = st.nextToken().trim();
210             return mapping.getProperty(pref, pref);
211         } else {
212             return null;
213         }
214     }
215
216     /**
217      * Utility class, no constructor
218      */

219     private CarolDefaultValues() {
220
221     }
222 }
223
Popular Tags