Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.plugins » [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.plugins;
   15   
   16   import java.lang.annotation.Annotation;
   17   import java.lang.reflect.Type;
   18   
   19   import org.apache.webbeans.exception.WebBeansConfigurationException;
   20   
   21   /**
   22    * <p>Interface which all OpenWebBeans plugins has to implement to 
   23    * extend the webbeans-core with additional IOC functionality.</p>
   24    * 
   25    * <p>There are 4 different types of functions for this interface:
   26    * <ol>
   27    *  <li>
   28    *    plugin lifecycle like {@code #startUp()} and {@code #shutDown()}
   29    *  </li>
   30    *  <li>
   31    *    check functions which will be called when a class is scanned
   32    *    like {@code #isSimpleBeanClass(Class)}
   33    *  </li>
   34    *  <li>
   35    *    injection preparation functions will be called once when
   36    *    the bean is being scanned like TODO
   37    *  </li>
   38    *  <li>
   39    *    injection execution will be called every time a been get's
   40    *    injected like {@code #injectResource(Type, Annotation[])}
   41    *  </li>
   42    * </ol> 
   43    * @see PluginLoader for documentation of the whole mechanism
   44    */
   45   public interface OpenWebBeansPlugin
   46   {
   47       /**
   48        * initialise the plugin.
   49        * This is called once after the very plugin has been loaded.
   50        * @throws WebBeansConfigurationException
   51        */
   52       public void startUp() throws WebBeansConfigurationException;
   53   
   54       /**
   55        * At shutdown, the plugin must release all locked resources.
   56        * This is called once before the very plugin gets destroyed.
   57        * This is usually the case when the WebApplication gets stopped.
   58        * @throws WebBeansConfigurationException
   59        */
   60       public void shutDown() throws WebBeansConfigurationException;
   61       
   62   
   63       /**
   64        * Make sure that the given class is ok for simple web bean conditions, 
   65        * otherwise throw a {@code WebBeansConfigurationException}
   66        * @param clazz the class to check
   67        * @throws WebBeansConfigurationException if the given clazz cannot be used as simple web bean.
   68        */
   69       public void isManagedBean(Class<?> clazz) throws WebBeansConfigurationException;
   70       
   71   
   72       /**
   73        * Check whether the given annotation class represents a resource which
   74        * can be injected by this plugin.
   75        * @param annotationClass which should be ckecked
   76        * @return <code>true</code> if this plugin handles the resource represented by this annotation
   77        */
   78       public boolean isResourceAnnotation(Class<? extends Annotation> annotationClass);
   79   
   80       /**
   81        * Check conditions for the resources.
   82        * 
   83        * @param type
   84        * @param clazz
   85        * @param name
   86        * @param annotations annotations
   87        * @throws WebBeansConfigurationException if resource annotations exists and do not fit to the fields type, etc.
   88        * @see #isResourceAnnotation(Class)
   89        */
   90       
   91       public void checkForValidResources(Type type, Class<?> clazz, String name, Annotation[] annotations);
   92       
   93       /**
   94        * Get a resource to inject.
   95        * A resource is not a usual bean but one predefined one like 
   96        * javax.persistence.PersistenceUnit, javax.persistence.PersistenceContext
   97        * etc.
   98        * @param type the bean type
   99        * @param annotations all the annotations which are defined on the member. 
  100        * @return the bean to inject or <code>null</code> if non found.  
  101        */
  102       public Object injectResource(Type type, Annotation[] annotations);
  103   
  104   
  105   }

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