001 /**
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one or more
004 * contributor license agreements. See the NOTICE file distributed with
005 * this work for additional information regarding copyright ownership.
006 * The ASF licenses this file to You under the Apache License, Version 2.0
007 * (the "License"); you may not use this file except in compliance with
008 * the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019 package org.apache.geronimo.web.deployment;
020
021 import javax.enterprise.deploy.model.DDBean;
022 import javax.enterprise.deploy.spi.DConfigBean;
023 import javax.enterprise.deploy.spi.exceptions.BeanNotFoundException;
024 import javax.enterprise.deploy.spi.exceptions.ConfigurationException;
025
026 import org.apache.geronimo.deployment.plugin.DConfigBeanSupport;
027 import org.apache.geronimo.naming.deployment.ENCHelper;
028 import org.apache.geronimo.xbeans.geronimo.web.GerWebAppType;
029 import org.apache.xmlbeans.SchemaTypeLoader;
030
031 /**
032 * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $
033 */
034 public class WebAppDConfigBean extends DConfigBeanSupport {
035 private final ENCHelper encHelper;
036
037 WebAppDConfigBean(DDBean ddBean, GerWebAppType webApp) {
038 super(ddBean, webApp);
039
040 ENCHelper.XmlEnvRefs envRefs = new ENCHelper.XmlEnvRefs(webApp.getEjbRefArray(), webApp.getEjbLocalRefArray(), webApp.getResourceRefArray(), webApp.getResourceEnvRefArray());
041
042 //which version are we dealing with?
043 String version = ddBean.getRoot().getAttributeValue("version");
044 if ("2.4".equals(version)) {
045 encHelper = new ENCHelper(ddBean, envRefs, getXPathsForJ2ee_1_4(ENCHelper.ENC_XPATHS), getXPathsForJ2ee_1_4(ENCHelper.NAME_XPATHS));
046 } else {
047 encHelper = new ENCHelper(ddBean, envRefs, getXPathsWithPrefix(null, ENCHelper.ENC_XPATHS), getXPathsWithPrefix(null, ENCHelper.NAME_XPATHS));
048 }
049
050 }
051
052 GerWebAppType getWebApp() {
053 return (GerWebAppType) getXmlObject();
054 }
055
056 public String getContextRoot() {
057 return getWebApp().getContextRoot();
058 }
059
060 public void setContextRoot(String contextRoot) {
061 pcs.firePropertyChange("contextRoot", getContextRoot(), contextRoot);
062 getWebApp().setContextRoot(contextRoot);
063 }
064
065 public DConfigBean getDConfigBean(DDBean ddBean) throws ConfigurationException {
066 return encHelper.getDConfigBean(ddBean);
067 }
068
069 public void removeDConfigBean(DConfigBean dcBean) throws BeanNotFoundException {
070 encHelper.removeDConfigBean(dcBean);
071 }
072
073 public String[] getXpaths() {
074 return getXPathsForJ2ee_1_4(ENCHelper.ENC_XPATHS);
075 }
076
077 protected SchemaTypeLoader getSchemaTypeLoader() {
078 return WebAppDConfigRoot.SCHEMA_TYPE_LOADER;
079 }
080
081 }