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.naming.deployment; 20 21 import java.util.Map; 22 23 import javax.xml.namespace.QName; 24 25 import org.apache.geronimo.j2ee.deployment.NamingBuilder; 26 import org.apache.geronimo.j2ee.deployment.Module; 27 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; 28 import org.apache.geronimo.kernel.repository.Environment; 29 import org.apache.geronimo.kernel.config.Configuration; 30 import org.apache.geronimo.common.DeploymentException; 31 import org.apache.geronimo.gbean.GBeanInfo; 32 import org.apache.geronimo.gbean.GBeanInfoBuilder; 33 import org.apache.xmlbeans.XmlObject; 34 import org.apache.xmlbeans.QNameSet; 35 36 /** 37 * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $ 38 */ 39 public class UnavailableRefBuilder implements NamingBuilder { 40 private final QNameSet unavailableQNameSet; 41 private QName unavailableQName; 42 43 public UnavailableRefBuilder(String namespaceURI, String localPart) { 44 unavailableQName = new QName(namespaceURI, localPart); 45 unavailableQNameSet = QNameSet.singleton(unavailableQName); 46 } 47 public void buildEnvironment(XmlObject specDD, XmlObject plan, Environment environment) throws DeploymentException { 48 checkUnavailable(specDD); 49 } 50 51 private void checkUnavailable(XmlObject specDD) throws DeploymentException { 52 XmlObject[] specRefs = specDD.selectChildren(unavailableQNameSet); 53 if (specRefs.length > 0) { 54 throw new DeploymentException("This server cannot deploy references of type " + unavailableQName); 55 } 56 } 57 58 public void initContext(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module) throws DeploymentException { 59 checkUnavailable(specDD); 60 } 61 62 public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException { 63 checkUnavailable(specDD); 64 } 65 66 public QNameSet getSpecQNameSet() { 67 return unavailableQNameSet; 68 } 69 70 public QNameSet getPlanQNameSet() { 71 return QNameSet.EMPTY; 72 } 73 74 public static final GBeanInfo GBEAN_INFO; 75 76 static { 77 GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(UnavailableRefBuilder.class, NameFactory.MODULE_BUILDER); 78 infoBuilder.addAttribute("specNamespaceURI", String.class, true, true); 79 infoBuilder.addAttribute("specLocalPart", String.class, true, true); 80 81 infoBuilder.setConstructor(new String[] {"specNamespaceURI", "specLocalPart"}); 82 83 GBEAN_INFO = infoBuilder.getBeanInfo(); 84 } 85 86 public static GBeanInfo getGBeanInfo() { 87 return GBEAN_INFO; 88 } 89 }