KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > tomcat > deployment > WebAppDConfigBean


1 /**
2  *
3  * Copyright 2003-2004 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.tomcat.deployment;
19
20 import javax.enterprise.deploy.model.DDBean JavaDoc;
21 import javax.enterprise.deploy.spi.DConfigBean JavaDoc;
22 import javax.enterprise.deploy.spi.exceptions.BeanNotFoundException JavaDoc;
23 import javax.enterprise.deploy.spi.exceptions.ConfigurationException JavaDoc;
24
25 import org.apache.geronimo.deployment.plugin.DConfigBeanSupport;
26 import org.apache.geronimo.naming.deployment.ENCHelper;
27 import org.apache.geronimo.xbeans.geronimo.tomcat.TomcatWebAppType;
28 import org.apache.xmlbeans.SchemaTypeLoader;
29
30 /**
31  * @version $Rev: 56771 $ $Date: 2004-11-06 12:58:54 -0700 (Sat, 06 Nov 2004) $
32  */

33 public class WebAppDConfigBean extends DConfigBeanSupport {
34     private final ENCHelper encHelper;
35
36     WebAppDConfigBean(DDBean JavaDoc ddBean, TomcatWebAppType webApp) {
37         super(ddBean, webApp);
38
39         ENCHelper.XmlEnvRefs envRefs = new ENCHelper.XmlEnvRefs(webApp.getEjbRefArray(), webApp.getEjbLocalRefArray(), webApp.getResourceRefArray(), webApp.getResourceEnvRefArray());
40
41         //which version are we dealing with?
42
String JavaDoc version = ddBean.getRoot().getAttributeValue("version");
43         if ("2.4".equals(version)) {
44             encHelper = new ENCHelper(ddBean, envRefs, getXPathsForJ2ee_1_4(ENCHelper.ENC_XPATHS), getXPathsForJ2ee_1_4(ENCHelper.NAME_XPATHS));
45         } else {
46             encHelper = new ENCHelper(ddBean, envRefs, getXPathsWithPrefix(null, ENCHelper.ENC_XPATHS), getXPathsWithPrefix(null, ENCHelper.NAME_XPATHS));
47         }
48
49     }
50
51     TomcatWebAppType getWebApp() {
52         return (TomcatWebAppType) getXmlObject();
53     }
54
55     public String JavaDoc getContextRoot() {
56         return getWebApp().getContextRoot();
57     }
58
59     public void setContextRoot(String JavaDoc contextRoot) {
60         pcs.firePropertyChange("contextRoot", getContextRoot(), contextRoot);
61         getWebApp().setContextRoot(contextRoot);
62     }
63
64     /**
65      * getContextPriorityClassLoader.
66      *
67      * @return True if this context should give web application class in preference over the containers
68      * classes, as per the servlet specification recommendations.
69      */

70     public boolean getContextPriorityClassLoader() {
71         return getWebApp().getContextPriorityClassloader();
72     }
73
74     /**
75      * setContextPriorityClassLoader.
76      *
77      * @param contextPriority True if this context should give web application class in preference over the containers
78      * classes, as per the servlet specification recommendations.
79      */

80     public void setContextPriorityClassLoader(boolean contextPriority) {
81         pcs.firePropertyChange("contextPriorityClassLoader", getContextPriorityClassLoader(), contextPriority);
82         getWebApp().setContextPriorityClassloader(contextPriority);
83     }
84
85     public DConfigBean JavaDoc getDConfigBean(DDBean JavaDoc ddBean) throws ConfigurationException JavaDoc {
86         return encHelper.getDConfigBean(ddBean);
87     }
88
89     public void removeDConfigBean(DConfigBean JavaDoc dcBean) throws BeanNotFoundException JavaDoc {
90         encHelper.removeDConfigBean(dcBean);
91     }
92
93     public String JavaDoc[] getXpaths() {
94         return getXPathsForJ2ee_1_4(ENCHelper.ENC_XPATHS);
95     }
96
97     protected SchemaTypeLoader getSchemaTypeLoader() {
98         return WebAppDConfigRoot.SCHEMA_TYPE_LOADER;
99     }
100
101 }
102
Popular Tags