Save This Page
Home » geronimo-2.2-source-release » org.apache.geronimo.naming.deployment » [javadoc | source]
    1   /**
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  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.naming.deployment;
   19   
   20   import java.util.Map;
   21   
   22   import javax.xml.namespace.QName;
   23   
   24   import org.apache.geronimo.j2ee.deployment.NamingBuilder;
   25   import org.apache.geronimo.j2ee.deployment.Module;
   26   import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
   27   import org.apache.geronimo.kernel.repository.Environment;
   28   import org.apache.geronimo.common.DeploymentException;
   29   import org.apache.geronimo.gbean.GBeanInfo;
   30   import org.apache.geronimo.gbean.GBeanInfoBuilder;
   31   import org.apache.xmlbeans.XmlObject;
   32   import org.apache.xmlbeans.QNameSet;
   33   
   34   /**
   35    * @version $Rev: 741679 $ $Date: 2009-02-06 11:07:17 -0800 (Fri, 06 Feb 2009) $
   36    */
   37   public class UnavailableRefBuilder implements NamingBuilder {
   38       private final QNameSet unavailableQNameSet;
   39       private QName unavailableQName;
   40   
   41       public UnavailableRefBuilder(String namespaceURI, String localPart) {
   42           unavailableQName = new QName(namespaceURI, localPart);
   43           unavailableQNameSet = QNameSet.singleton(unavailableQName);
   44       }
   45       public void buildEnvironment(XmlObject specDD, XmlObject plan, Environment environment) throws DeploymentException {
   46           if (specDD != null) {
   47               checkUnavailable(specDD);
   48           }
   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, Module module) throws DeploymentException {
   59           checkUnavailable(specDD);
   60       }
   61   
   62       public void buildNaming(XmlObject specDD, XmlObject plan, Module module, Map componentContext) throws DeploymentException {
   63           checkUnavailable(specDD);
   64       }
   65   
   66       public int getPriority() {
   67           return NORMAL_PRIORITY;
   68       }
   69       
   70       public QNameSet getSpecQNameSet() {
   71           return unavailableQNameSet;
   72       }
   73   
   74       public QNameSet getPlanQNameSet() {
   75           return QNameSet.EMPTY;
   76       }
   77   
   78       public QName getBaseQName() {
   79           return AbstractNamingBuilder.BASE_NAMING_QNAME;
   80       }
   81   
   82       public static final GBeanInfo GBEAN_INFO;
   83   
   84       static {
   85           GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(UnavailableRefBuilder.class, NameFactory.MODULE_BUILDER);
   86           infoBuilder.addAttribute("specNamespaceURI", String.class, true, true);
   87           infoBuilder.addAttribute("specLocalPart", String.class, true, true);
   88   
   89           infoBuilder.setConstructor(new String[] {"specNamespaceURI", "specLocalPart"});
   90   
   91           GBEAN_INFO = infoBuilder.getBeanInfo();
   92       }
   93   
   94       public static GBeanInfo getGBeanInfo() {
   95           return GBEAN_INFO;
   96       }
   97   }

Save This Page
Home » geronimo-2.2-source-release » org.apache.geronimo.naming.deployment » [javadoc | source]