Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.xml » [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 this
    4    * work for additional information regarding copyright ownership. The ASF
    5    * licenses this file to You under the Apache License, Version 2.0 (the
    6    * "License"); you may not use this file except in compliance with the License.
    7    * You may obtain a copy of the License at
    8    * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
    9    * or agreed to in writing, software distributed under the License is
   10    * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   11    * KIND, either express or implied. See the License for the specific language
   12    * governing permissions and limitations under the License.
   13    */
   14   package org.apache.webbeans.xml;
   15   
   16   import java.lang.annotation.Annotation;
   17   import java.util.Collections;
   18   import java.util.HashSet;
   19   import java.util.Map;
   20   import java.util.Set;
   21   import java.util.concurrent.ConcurrentHashMap;
   22   import java.util.concurrent.CopyOnWriteArraySet;
   23   
   24   import org.apache.webbeans.config.WebBeansFinder;
   25   import org.apache.webbeans.deployment.StereoTypeManager;
   26   import org.apache.webbeans.deployment.XMLStereoTypeModel;
   27   import org.apache.webbeans.util.WebBeansUtil;
   28   import org.dom4j.Element;
   29   
   30   public class XMLAnnotationTypeManager
   31   {
   32       private Set<Class<? extends Annotation>> xmlBindingTypes = new CopyOnWriteArraySet<Class<? extends Annotation>>();
   33       
   34       private Set<Class<? extends Annotation>> xmlResources = new CopyOnWriteArraySet<Class<? extends Annotation>>();
   35   
   36       private Map<Class<? extends Annotation>, Set<Annotation>> xmlInterceptorBindingTypes = new ConcurrentHashMap<Class<? extends Annotation>, Set<Annotation>>();
   37   
   38       private Set<Class<? extends Annotation>> xmlStereoTypes = new CopyOnWriteArraySet<Class<? extends Annotation>>();
   39   
   40       public XMLAnnotationTypeManager()
   41       {
   42   
   43       }
   44   
   45       public static XMLAnnotationTypeManager getInstance()
   46       {
   47           XMLAnnotationTypeManager manager = (XMLAnnotationTypeManager) WebBeansFinder.getSingletonInstance(WebBeansFinder.SINGLETON_XML_ANNOTATION_TYPE_MANAGER);
   48           return manager;
   49       }
   50   
   51       public void addBindingType(Class<? extends Annotation> bindingType)
   52       {
   53           xmlBindingTypes.add(bindingType);
   54       }
   55   
   56       public void addResource(Class<? extends Annotation> resource)
   57       {
   58           xmlResources.add(resource);
   59       }
   60   
   61       public boolean isBindingTypeExist(Class<? extends Annotation> bindingType)
   62       {
   63           if (xmlBindingTypes.contains(bindingType))
   64           {
   65               return true;
   66           }
   67   
   68           return false;
   69       }
   70   
   71       public boolean isResourceExist(Class<? extends Annotation> resource)
   72       {
   73           if (xmlResources.contains(resource))
   74           {
   75               return true;
   76           }
   77   
   78           return false;
   79       }
   80   
   81       public void addStereoType(Class<? extends Annotation> stereoType, Element decleration, String name, String errorMessage)
   82       {
   83           WebBeansUtil.checkStereoTypeClass(stereoType);
   84   
   85           StereoTypeManager manager = StereoTypeManager.getInstance();
   86   
   87           XMLStereoTypeModel model = new XMLStereoTypeModel(decleration, name, errorMessage);
   88           manager.addStereoTypeModel(model);
   89   
   90           xmlStereoTypes.add(stereoType);
   91       }
   92   
   93       public boolean isStereoTypeExist(Class<? extends Annotation> stereoType)
   94       {
   95           if (xmlStereoTypes.contains(stereoType))
   96           {
   97               return true;
   98           }
   99   
  100           return false;
  101       }
  102   
  103       public void addInterceotorBindingTypeInheritAnnotation(Class<? extends Annotation> bindingType, Annotation inherit)
  104       {
  105           Set<Annotation> inherits = xmlInterceptorBindingTypes.get(bindingType);
  106           if (inherits == null)
  107           {
  108               inherits = new HashSet<Annotation>();
  109               inherits.add(inherit);
  110               xmlInterceptorBindingTypes.put(bindingType, inherits);
  111           }
  112           else
  113           {
  114               inherits.add(inherit);
  115           }
  116       }
  117   
  118       public boolean isInterceptorBindingTypeExist(Class<? extends Annotation> bindingType)
  119       {
  120           if (xmlInterceptorBindingTypes.keySet().contains(bindingType))
  121           {
  122               return true;
  123           }
  124   
  125           return false;
  126       }
  127   
  128       public Set<Class<? extends Annotation>> getBindingTypes()
  129       {
  130           return Collections.unmodifiableSet(xmlBindingTypes);
  131       }
  132   
  133       public Set<Class<? extends Annotation>> getResources()
  134       {
  135           return Collections.unmodifiableSet(xmlResources);
  136       }
  137   
  138       public Set<Annotation> getInterceptorBindingTypeInherites(Class<? extends Annotation> interceptorBindingType)
  139       {
  140           return Collections.unmodifiableSet(xmlInterceptorBindingTypes.get(interceptorBindingType));
  141       }
  142   
  143       public Set<Class<? extends Annotation>> getInterceptorBindingTypes()
  144       {
  145           return Collections.unmodifiableSet(xmlInterceptorBindingTypes.keySet());
  146       }
  147   
  148       public Set<Class<? extends Annotation>> getStereotypes()
  149       {
  150           return Collections.unmodifiableSet(xmlStereoTypes);
  151       }
  152   
  153   }

Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.xml » [javadoc | source]