Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.portable.creation » [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.portable.creation;
   15   
   16   import javax.enterprise.context.spi.CreationalContext;
   17   import javax.enterprise.inject.spi.InjectionTarget;
   18   
   19   import org.apache.webbeans.component.AbstractInjectionTargetBean;
   20   import org.apache.webbeans.component.InjectionTargetBean;
   21   
   22   /**
   23    * InjectionTargetProducer implementation.
   24    * 
   25    * @version $Rev: 791166 $ $Date: 2009-07-04 22:00:12 +0300 (Sat, 04 Jul 2009) $
   26    *
   27    * @param <T> bean type info
   28    */
   29   public class InjectionTargetProducer<T> extends AbstractProducer<T> implements InjectionTarget<T>
   30   {
   31       public InjectionTargetProducer(AbstractInjectionTargetBean<T> bean)
   32       {
   33           super(bean);
   34       }
   35       
   36       @Override
   37       public void inject(T instance, CreationalContext<T> ctx)
   38       {
   39           @SuppressWarnings("unchecked")
   40           InjectionTargetBean<T> bean = getBean(InjectionTargetBean.class);
   41           
   42           bean.injectResources(instance, ctx);
   43           bean.injectFields(instance, ctx);
   44           bean.injectMethods(instance, ctx);
   45       }
   46   
   47       @Override
   48       public void postConstruct(T instance)
   49       {
   50           @SuppressWarnings("unchecked")
   51           InjectionTargetBean<T> bean = getBean(InjectionTargetBean.class);
   52           
   53           bean.postConstruct(instance);
   54       }
   55   
   56       @Override
   57       public void preDestroy(T instance)
   58       {
   59           @SuppressWarnings("unchecked")
   60           InjectionTargetBean<T> bean = getBean(InjectionTargetBean.class);
   61           
   62           bean.preDestroy(instance);
   63       }
   64   
   65   }

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