Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.spi.deployer » [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   package org.apache.webbeans.spi.deployer;
   18   
   19   
   20   import java.net.URL;
   21   import java.util.Collections;
   22   import java.util.HashSet;
   23   import java.util.Map;
   24   import java.util.Set;
   25   
   26   import org.apache.webbeans.exception.WebBeansConfigurationException;
   27   import org.apache.webbeans.exception.WebBeansDeploymentException;
   28   import org.scannotation.AnnotationDB;
   29   
   30   public abstract class AbstractMetaDataDiscovery implements MetaDataDiscoveryService
   31   {
   32       /** Location of the beans.xml files. */
   33       private Set<URL> webBeansXmlLocations = new HashSet<URL>();
   34   
   35       //private Map<String, InputStream> EJB_XML_LOCATIONS = new HashMap<String, InputStream>();
   36   
   37       /** Annotation Database */
   38       private AnnotationDB annotationDB = null;
   39   
   40       protected AbstractMetaDataDiscovery()
   41       {
   42           try
   43           {
   44               if (annotationDB == null)
   45               {
   46                   annotationDB = new AnnotationDB();
   47                   annotationDB.setScanClassAnnotations(true);
   48                   annotationDB.crossReferenceMetaAnnotations();    
   49                   annotationDB.setScanFieldAnnotations(false);
   50                   annotationDB.setScanMethodAnnotations(false);
   51                   annotationDB.setScanParameterAnnotations(false);
   52               }            
   53               
   54           }
   55           catch(Exception e)
   56           {
   57               throw new WebBeansDeploymentException(e);
   58           }                
   59       }
   60       
   61       /**
   62        * Configure the Web Beans Container with deployment information and fills
   63        * annotation database and beans.xml stream database.
   64        * 
   65        * @throws WebBeansConfigurationException if any run time exception occurs
   66        */
   67       public void scan() throws WebBeansDeploymentException
   68       {
   69           try
   70           {
   71               configure();
   72           }
   73           catch (Exception e)
   74           {
   75               throw new WebBeansDeploymentException(e);
   76           }
   77       }
   78       
   79       
   80       abstract protected void configure() throws Exception;
   81       
   82       public void init(Object object)
   83       {
   84           
   85       }
   86       
   87       /**
   88        * @return the wEBBEANS_XML_LOCATIONS
   89        */
   90       public Set<URL> getWebBeansXmlLocations()
   91       {
   92           return Collections.unmodifiableSet(webBeansXmlLocations);
   93       }
   94   
   95       /**
   96        * @return the aNNOTATION_DB
   97        */
   98       protected AnnotationDB getAnnotationDB()
   99       {
  100           return annotationDB;
  101       }
  102       
  103       public Map<String, Set<String>> getAnnotationIndex()
  104       {
  105           return annotationDB.getAnnotationIndex();
  106       }
  107   
  108       public Map<String, Set<String>> getClassIndex()
  109       {
  110           return annotationDB.getClassIndex();
  111       }
  112   
  113       /**
  114        * add the given beans.xml path to the locations list 
  115        * @param file location path
  116        */
  117       protected void addWebBeansXmlLocation(URL file)
  118       {
  119           webBeansXmlLocations.add(file);
  120       }
  121   
  122   }

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