KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > serverbeans > ServerXPathHelper


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.config.serverbeans;
25
26 import org.w3c.dom.*;
27 import org.xml.sax.*;
28
29 import java.util.logging.Logger JavaDoc;
30 import java.util.logging.Level JavaDoc;
31 //import com.sun.logging.LogDomains;
32

33 import com.sun.enterprise.config.util.ConfigXPathHelper;
34
35
36 /** A helper class to store valid xpaths for ias7.0 SE.
37  * Helper methods are provided to generate valid xpaths
38  * that are needed by configContext.
39  */

40 public final class ServerXPathHelper {
41
42     //"static" names for milestone 1 only
43
// public static final String DEFAULT_SERVER_MODEL_NAME = "server"; //the same for both instances
44
public static final String JavaDoc DEFAULT_CONFIG_MODEL_NAME = "server-config";
45     public static final String JavaDoc REGEX_DEFAULT_CONFIG_MODEL_NAME = "server\\-config";
46     public static final String JavaDoc DEFAULT_HOST_MODEL_NAME = "host1"; //do we need it?
47

48     
49     
50     public static final String JavaDoc REGEX_ONE_PLUS = "{1,}";
51     
52     public static final String JavaDoc XPATH_SEPARATOR = "/";
53     
54     public static final String JavaDoc XPATH_DOMAIN = XPATH_SEPARATOR + ServerTags.DOMAIN;
55     public static final String JavaDoc REGEX_XPATH_DOMAIN = XPATH_SEPARATOR
56             + REGEX_ONE_PLUS + ServerTags.DOMAIN;
57
58 // public static final String XPATH_SERVER = XPATH_DOMAIN + XPATH_SEPARATOR +
59
// ServerTags.SERVERS + XPATH_SEPARATOR +
60
// ServerTags.SERVER +
61
// "[@" + ServerTags.NAME + "='" + DEFAULT_SERVER_MODEL_NAME + "']";
62

63     public static final String JavaDoc XPATH_CONFIG = XPATH_DOMAIN + XPATH_SEPARATOR +
64                                 ServerTags.CONFIGS + XPATH_SEPARATOR +
65                                 ServerTags.CONFIG +
66                                 "[@" + ServerTags.NAME + "='" + DEFAULT_CONFIG_MODEL_NAME + "']";
67     
68     public static final String JavaDoc REGEX_XPATH_CONFIG = REGEX_XPATH_DOMAIN
69             + XPATH_SEPARATOR + REGEX_ONE_PLUS + ServerTags.CONFIGS
70             + XPATH_SEPARATOR + REGEX_ONE_PLUS + ServerTags.CONFIG
71             + "[@" + ServerTags.NAME + "='" + REGEX_DEFAULT_CONFIG_MODEL_NAME
72             + "']";
73
74     public static final String JavaDoc XPATH_APPLICATIONS = XPATH_DOMAIN + XPATH_SEPARATOR +
75                                 ServerTags.APPLICATIONS;
76     
77     public static final String JavaDoc XPATH_J2EE_APPLICATION = XPATH_APPLICATIONS + XPATH_SEPARATOR +
78                                 ServerTags.J2EE_APPLICATION;
79     
80     public static final String JavaDoc XPATH_EJB_MODULE = XPATH_APPLICATIONS + XPATH_SEPARATOR +
81                                 ServerTags.EJB_MODULE;
82     
83     public static final String JavaDoc XPATH_WEB_MODULE = XPATH_APPLICATIONS + XPATH_SEPARATOR +
84                                 ServerTags.WEB_MODULE;
85     
86     public static final String JavaDoc XPATH_CONNECTOR_MODULE = XPATH_APPLICATIONS + XPATH_SEPARATOR +
87                                 ServerTags.CONNECTOR_MODULE;
88
89     public static final String JavaDoc XPATH_APPCLIENT_MODULE = XPATH_APPLICATIONS + XPATH_SEPARATOR +
90                                 ServerTags.APPCLIENT_MODULE;
91
92     public static final String JavaDoc XPATH_LIFECYCLE_MODULE = XPATH_APPLICATIONS + XPATH_SEPARATOR +
93                                 ServerTags.LIFECYCLE_MODULE;
94
95 /* public static final String XPATH_CONNECTION_GROUP = XPATH_SEPARATOR + ServerTags.SERVER + XPATH_SEPARATOR +
96                                 ServerTags.HTTP_SERVICE + XPATH_SEPARATOR +
97                                 ServerTags.HTTP_LISTENER + XPATH_SEPARATOR +
98                                 ServerTags.CONNECTION_GROUP;
99  */
//FIXME removed
100

101     public static final String JavaDoc XPATH_LOG_SERVICE = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.LOG_SERVICE;
102     public static final String JavaDoc XPATH_SECURITY_SERVICE = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.SECURITY_SERVICE;
103     public static final String JavaDoc XPATH_SECURITY_AUTH_REALM = XPATH_SECURITY_SERVICE + XPATH_SEPARATOR + ServerTags.AUTH_REALM;
104
105     //RESOURCES XPATHes
106
public static final String JavaDoc XPATH_RESOURCES = XPATH_DOMAIN + XPATH_SEPARATOR + ServerTags.RESOURCES;
107     public static final String JavaDoc XPATH_JDBC_RESOURCE = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.JDBC_RESOURCE;
108    // public static final String XPATH_JMS_RESOURCE = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.JMS_RESOURCE;
109
public static final String JavaDoc XPATH_JNDI_RESOURCE = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.EXTERNAL_JNDI_RESOURCE;
110     public static final String JavaDoc XPATH_CUSTOM_RESOURCE = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.CUSTOM_RESOURCE;
111     public static final String JavaDoc XPATH_JDBC_CONNECTION_POOL = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.JDBC_CONNECTION_POOL;
112     public static final String JavaDoc XPATH_PM_FACTORY_RESOURCE = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.PERSISTENCE_MANAGER_FACTORY_RESOURCE;
113     public static final String JavaDoc XPATH_MAIL_RESOURCE = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.MAIL_RESOURCE;
114     public static final String JavaDoc XPATH_ADMIN_OBJECT_RESOURCE = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.ADMIN_OBJECT_RESOURCE;
115     public static final String JavaDoc XPATH_CONNECTOR_RESOURCE = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.CONNECTOR_RESOURCE;
116     public static final String JavaDoc XPATH_CONNECTOR_CONNECTION_POOL = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.CONNECTOR_CONNECTION_POOL;
117     public static final String JavaDoc XPATH_RESOURCE_ADAPTER_CONFIG = XPATH_RESOURCES + XPATH_SEPARATOR + ServerTags.RESOURCE_ADAPTER_CONFIG;
118
119
120     //HTTP_SERVICE XPATHes
121
public static final String JavaDoc XPATH_HTTP_SERVICE = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.HTTP_SERVICE;
122     public static final String JavaDoc XPATH_HTTP_LISTENER = XPATH_HTTP_SERVICE + XPATH_SEPARATOR + ServerTags.HTTP_LISTENER;
123     //public static final String XPATH_HTTP_ACL = XPATH_HTTP_SERVICE + XPATH_SEPARATOR + ServerTags.ACL;
124
//public static final String XPATH_HTTP_MIME = XPATH_HTTP_SERVICE + XPATH_SEPARATOR + ServerTags.MIME;
125

126     //JTS
127
public static final String JavaDoc XPATH_TRANSACTION_SERVICE = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.TRANSACTION_SERVICE;
128     
129     //JMS
130
public static final String JavaDoc XPATH_JMS_SERVICE = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.JMS_SERVICE;
131
132     //VIRTUAL SERVER
133
// public static final String XPATH_VIRTUAL_SERVER_CLASS = XPATH_HTTP_SERVICE + XPATH_SEPARATOR + ServerTags.VIRTUAL_SERVER_CLASS;
134
//IIOP XPATHes
135
public static final String JavaDoc XPATH_IIOP_SERVICE = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.IIOP_SERVICE;
136     public static final String JavaDoc XPATH_ORB = XPATH_IIOP_SERVICE + XPATH_SEPARATOR + ServerTags.ORB;
137     public static final String JavaDoc XPATH_IIOP_LISTENER = XPATH_IIOP_SERVICE + XPATH_SEPARATOR + ServerTags.IIOP_LISTENER;
138
139     //CONTAINERS
140
public static final String JavaDoc XPATH_MDB_CONTAINER = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.MDB_CONTAINER;
141     public static final String JavaDoc XPATH_WEB_CONTAINER = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.WEB_CONTAINER;
142     public static final String JavaDoc XPATH_EJB_CONTAINER = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.EJB_CONTAINER;
143     
144     public static final String JavaDoc XPATH_JAVACONFIG = XPATH_CONFIG + XPATH_SEPARATOR + ServerTags.JAVA_CONFIG;
145     public static final String JavaDoc XPATH_PROFILER = XPATH_JAVACONFIG + XPATH_SEPARATOR + ServerTags.PROFILER;
146
147     //private static final Logger _logger = LogDomains.getLogger(LogDomains.CONFIG_LOGGER);
148

149
150     public static String JavaDoc getServerIdXpath(String JavaDoc serverId) {
151         return XPATH_DOMAIN + XPATH_SEPARATOR +
152                ServerTags.SERVERS + XPATH_SEPARATOR +
153                ServerTags.SERVER +
154                "[@" + ServerTags.NAME + "='" + serverId + "']";
155     }
156     
157     public static String JavaDoc getConfigIdXpath(String JavaDoc configId) {
158         return XPATH_DOMAIN + XPATH_SEPARATOR +
159                ServerTags.CONFIGS + XPATH_SEPARATOR +
160                ServerTags.CONFIG +
161                "[@" + ServerTags.NAME + "='" + configId + "']";
162     }
163
164    /**
165     *
166     * @return */

167     public static String JavaDoc getAppIdXpathExpression(String JavaDoc appId) {
168         return XPATH_J2EE_APPLICATION +"[@" + ServerTags.NAME + "='" + appId + "']";
169     }
170
171     public static String JavaDoc getEjbModuleIdXpathExpression(String JavaDoc moduleId) {
172         return getAbsoluteIdXpathExpression(XPATH_EJB_MODULE,
173                                             ServerTags.NAME,
174                                             moduleId);
175     }
176
177     public static String JavaDoc getWebModuleIdXpathExpression(String JavaDoc moduleId) {
178         return getAbsoluteIdXpathExpression(XPATH_WEB_MODULE,
179                                             ServerTags.NAME,
180                                             moduleId);
181     }
182     
183     public static String JavaDoc getConnectorModuleIdXpathExpression(String JavaDoc moduleId) {
184         /** IASRI 4666602
185         return getAbsoluteIdXpathExpression(XPATH_CONNECTOR_MODULE,
186                                             ServerTags.NAME,
187                                             moduleId);
188          **/

189         // START OF IASRI 4666602
190
return XPATH_CONNECTOR_MODULE + "[@" + ServerTags.NAME + "='" + moduleId + "']";
191         // END OF IASRI 4666602
192
}
193
194     public static String JavaDoc getAppClientModuleIdXpathExpression(String JavaDoc moduleId) {
195         return getAbsoluteIdXpathExpression(XPATH_APPCLIENT_MODULE,
196                                             ServerTags.NAME,
197                                             moduleId);
198     }
199     
200     public static String JavaDoc getLifecycleModuleIdXpath(String JavaDoc moduleId) {
201         return getAbsoluteIdXpathExpression(XPATH_LIFECYCLE_MODULE,
202                                             ServerTags.NAME,
203                                             moduleId);
204     }
205     //RESOURCES
206
public static String JavaDoc getJDBCResourceIdXpath(String JavaDoc jndiId) {
207         return getAbsoluteIdXpathExpression(XPATH_JDBC_RESOURCE, ServerTags.JNDI_NAME, jndiId);
208     }
209    /* public static String getJMSResourceIdXpath(String jndiId) {
210         return getAbsoluteIdXpathExpression(XPATH_JMS_RESOURCE, ServerTags.JNDI_NAME, jndiId);
211     }
212    */

213     public static String JavaDoc getJNDIResourceIdXpath(String JavaDoc jndiId) {
214         return getAbsoluteIdXpathExpression(XPATH_JNDI_RESOURCE, ServerTags.JNDI_NAME, jndiId);
215     }
216     public static String JavaDoc getMailResourceIdXpath(String JavaDoc jndiId) {
217         return getAbsoluteIdXpathExpression(XPATH_MAIL_RESOURCE, ServerTags.JNDI_NAME, jndiId);
218     }
219     public static String JavaDoc getCustomResourceIdXpath(String JavaDoc jndiId) {
220         return getAbsoluteIdXpathExpression(XPATH_CUSTOM_RESOURCE, ServerTags.JNDI_NAME, jndiId);
221     }
222     public static String JavaDoc getJDBCConnectionPoolIdXpath(String JavaDoc poolId) {
223         return getAbsoluteIdXpathExpression(XPATH_JDBC_CONNECTION_POOL, ServerTags.NAME, poolId);
224     }
225     public static String JavaDoc getPMFactoryResourceIdXpath(String JavaDoc jndiId) {
226         return getAbsoluteIdXpathExpression(XPATH_PM_FACTORY_RESOURCE, ServerTags.JNDI_NAME, jndiId);
227     }
228
229     //CONTAINERS
230
public static String JavaDoc getMDBContainerXpath()
231     {
232         return XPATH_MDB_CONTAINER;
233     }
234     public static String JavaDoc getWEBContainerXpath()
235     {
236         return XPATH_WEB_CONTAINER;
237     }
238     public static String JavaDoc getEJBContainerXpath()
239     {
240         return XPATH_EJB_CONTAINER;
241     }
242
243     //TRANSACTION_SERVICE
244
public static String JavaDoc getTransactionServiceXpath() {
245         return XPATH_TRANSACTION_SERVICE;
246     }
247
248     //JMS_SERVICE
249
public static String JavaDoc getJmsServiceXpath() {
250         return XPATH_JMS_SERVICE;
251     }
252
253     //HTTP_SERVICE
254
public static String JavaDoc getHTTPServiceXpath() {
255         return XPATH_HTTP_SERVICE;
256     }
257     public static String JavaDoc getHTTPListenerIdXpath(String JavaDoc id) {
258         return getAbsoluteIdXpathExpression(XPATH_HTTP_LISTENER, ServerTags.ID, id);
259     }
260 /*
261     public static String getHTTPMimeIdXpath(String id) {
262         return getAbsoluteIdXpathExpression(XPATH_HTTP_MIME, ServerTags.ID, id);
263     }
264     public static String getHTTPAclIdXpath(String id) {
265         return getAbsoluteIdXpathExpression(XPATH_HTTP_ACL, ServerTags.ID, id);
266     }
267 */

268     /*
269     public static String getHTTPConnectionGroupIdXpath(String listenerId, String id) {
270         return getAbsoluteIdXpathExpression(
271              getHTTPListenerIdXpath(listenerId)+XPATH_SEPARATOR+ ServerTags.CONNECTION_GROUP,
272                                     ServerTags.ID, id);
273     }
274      */
//FIXME: removed
275

276
277     //VIRTUAL SERVER (CLASS)
278
/* public static String getVirtualServerClassIdXpath(String id) {
279         return getAbsoluteIdXpathExpression(XPATH_VIRTUAL_SERVER_CLASS, ServerTags.ID, id);
280     }
281    */

282     public static String JavaDoc getVirtualServerIdXpath(String JavaDoc classId, String JavaDoc id) {
283         return getAbsoluteIdXpathExpression(
284                             XPATH_HTTP_SERVICE + XPATH_SEPARATOR + ServerTags.VIRTUAL_SERVER,
285                             ServerTags.ID, id);
286     }
287   
288 /*
289     public static String getAuthDbIdXpath(String serverClassId, String serverId, String id) {
290         return getAbsoluteIdXpathExpression(
291                             getVirtualServerIdXpath(serverClassId, serverId) + XPATH_SEPARATOR + ServerTags.AUTH_DB,
292                             ServerTags.ID, id);
293     }
294 */

295
296     //IIOP_SERVICE
297
public static String JavaDoc getIIOPServiceXpath() {
298         return XPATH_IIOP_SERVICE;
299     }
300     public static String JavaDoc getOrbXpath() {
301         return XPATH_ORB;
302     }
303     public static String JavaDoc getIIOPListenerIdXpath(String JavaDoc id) {
304         return getAbsoluteIdXpathExpression(XPATH_IIOP_LISTENER, ServerTags.ID, id);
305     }
306     
307     //LOG_SERVICE
308
public static String JavaDoc getLogServiceXpath() {
309         return XPATH_LOG_SERVICE;
310     }
311
312     //SECURITY_SERVICE
313
public static String JavaDoc getSecurityServiceXpath() {
314         return XPATH_SECURITY_SERVICE;
315     }
316     public static String JavaDoc getSecurityAuthRealmIdXpath(String JavaDoc name) {
317         return getAbsoluteIdXpathExpression(XPATH_SECURITY_AUTH_REALM, ServerTags.NAME, name);
318     }
319
320     //JAVA_CONFIG
321
public static String JavaDoc getJavaConfigXpath() {
322         return XPATH_JAVACONFIG;
323     }
324     public static String JavaDoc getProfilerXpath() {
325         return XPATH_PROFILER;
326     }
327     /**
328      * @param childTagName
329      * @param nameId
330      * @param valueId
331      *
332      */

333     public static String JavaDoc getAbsoluteIdXpathExpression(
334                                 String JavaDoc childTagName,
335                                 String JavaDoc nameId,
336                                 String JavaDoc valueId) {
337                                     
338         return ConfigXPathHelper.getAbsoluteIdXpathExpression(
339                             childTagName,
340                             nameId,
341                             valueId);
342     }
343
344     /*
345      * returns element's tag name extracting from its xpath
346      */

347     public static String JavaDoc getLastNodeName(String JavaDoc xPath) {
348         return ConfigXPathHelper.getLastNodeName(xPath);
349     }
350     
351     /*
352      * returns parent XPath for givend child's xpath
353      * correcly bypasses bracketed values with possible escaping inside of quoted values
354      */

355     public static String JavaDoc getParentXPath(String JavaDoc xPath) {
356         return ConfigXPathHelper.getParentXPath(xPath);
357     }
358 }
359
Popular Tags