Save This Page
Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.component » [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.component;
   15   
   16   import java.lang.reflect.Constructor;
   17   
   18   import javax.enterprise.context.spi.CreationalContext;
   19   import javax.enterprise.inject.spi.Bean;
   20   
   21   import org.apache.webbeans.inject.InjectableConstructor;
   22   
   23   /**
   24    * Managed bean implementation of the {@link Bean}.
   25    * 
   26    * @version $Rev: 791957 $ $Date: 2009-07-07 22:46:05 +0300 (Tue, 07 Jul 2009) $
   27    */
   28   public class ManagedBean<T> extends AbstractInjectionTargetBean<T>
   29   {
   30       /** Constructor of the web bean component */
   31       private Constructor<T> constructor;
   32   
   33       public ManagedBean(Class<T> returnType)
   34       {
   35           this(returnType, WebBeansType.MANAGED);
   36       }
   37   
   38       /**
   39        * Creates a new instance.
   40        * 
   41        * @param returnType bean class
   42        * @param type webbeans type
   43        */
   44       public ManagedBean(Class<T> returnType, WebBeansType type)
   45       {
   46           super(type, returnType);
   47           
   48           //Setting inherited meta data instance
   49           setInheritedMetaData();
   50       }
   51       
   52       /**
   53        * {@inheritDoc}
   54        */
   55       @Override
   56       protected T createComponentInstance(CreationalContext<T> creationalContext)
   57       {
   58           Constructor<T> con = getConstructor();
   59           InjectableConstructor<T> ic = new InjectableConstructor<T>(con, this,creationalContext);
   60   
   61           T instance = ic.doInjection();
   62           
   63           return instance;
   64       }
   65   
   66    
   67       /**
   68        * Get constructor.
   69        * 
   70        * @return constructor
   71        */
   72       public Constructor<T> getConstructor()
   73       {
   74           return constructor;
   75       }
   76   
   77       /**
   78        * Set constructor.
   79        * 
   80        * @param constructor constructor instance
   81        */
   82       public void setConstructor(Constructor<T> constructor)
   83       {
   84           this.constructor = constructor;
   85       }    
   86   }

Save This Page
Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.component » [javadoc | source]