1 /**
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one or more
4 * contributor license agreements. See the NOTICE file distributed with
5 * this work for additional information regarding copyright ownership.
6 * The ASF licenses this file to You under the Apache License, Version 2.0
7 * (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package org.apache.geronimo.web.deployment;
20
21 import javax.enterprise.deploy.model.DDBean;
22 import javax.enterprise.deploy.spi.DConfigBean;
23 import javax.enterprise.deploy.spi.exceptions.BeanNotFoundException;
24 import javax.enterprise.deploy.spi.exceptions.ConfigurationException;
25
26 import org.apache.geronimo.deployment.plugin.DConfigBeanSupport;
27 import org.apache.geronimo.naming.deployment.ENCHelper;
28 import org.apache.geronimo.xbeans.geronimo.web.GerWebAppType;
29 import org.apache.xmlbeans.SchemaTypeLoader;
30
31 /**
32 * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $
33 */
34 public class WebAppDConfigBean extends DConfigBeanSupport {
35 private final ENCHelper encHelper;
36
37 WebAppDConfigBean(DDBean ddBean, GerWebAppType webApp) {
38 super(ddBean, webApp);
39
40 ENCHelper.XmlEnvRefs envRefs = new ENCHelper.XmlEnvRefs(webApp.getEjbRefArray(), webApp.getEjbLocalRefArray(), webApp.getResourceRefArray(), webApp.getResourceEnvRefArray());
41
42
43 String version = ddBean.getRoot().getAttributeValue("version");
44 if ("2.4".equals(version)) {
45 encHelper = new ENCHelper(ddBean, envRefs, getXPathsForJ2ee_1_4(ENCHelper.ENC_XPATHS), getXPathsForJ2ee_1_4(ENCHelper.NAME_XPATHS));
46 } else {
47 encHelper = new ENCHelper(ddBean, envRefs, getXPathsWithPrefix(null, ENCHelper.ENC_XPATHS), getXPathsWithPrefix(null, ENCHelper.NAME_XPATHS));
48 }
49
50 }
51
52 GerWebAppType getWebApp() {
53 return (GerWebAppType) getXmlObject();
54 }
55
56 public String getContextRoot() {
57 return getWebApp().getContextRoot();
58 }
59
60 public void setContextRoot(String contextRoot) {
61 pcs.firePropertyChange("contextRoot", getContextRoot(), contextRoot);
62 getWebApp().setContextRoot(contextRoot);
63 }
64
65 public DConfigBean getDConfigBean(DDBean ddBean) throws ConfigurationException {
66 return encHelper.getDConfigBean(ddBean);
67 }
68
69 public void removeDConfigBean(DConfigBean dcBean) throws BeanNotFoundException {
70 encHelper.removeDConfigBean(dcBean);
71 }
72
73 public String[] getXpaths() {
74 return getXPathsForJ2ee_1_4(ENCHelper.ENC_XPATHS);
75 }
76
77 protected SchemaTypeLoader getSchemaTypeLoader() {
78 return WebAppDConfigRoot.SCHEMA_TYPE_LOADER;
79 }
80
81 }