Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.inject.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.inject.xml;
   15   
   16   import java.lang.annotation.Annotation;
   17   import java.lang.reflect.Method;
   18   import java.util.ArrayList;
   19   import java.util.Iterator;
   20   import java.util.List;
   21   
   22   import javax.enterprise.context.spi.CreationalContext;
   23   
   24   import org.apache.webbeans.component.AbstractBean;
   25   import org.apache.webbeans.inject.InjectableMethods;
   26   
   27   public class XMLInjectableMethods<T> extends InjectableMethods<T>
   28   {
   29       private List<XMLInjectionPointModel> injectionPointModelList = new ArrayList<XMLInjectionPointModel>();
   30   
   31       public XMLInjectableMethods(Method m, Object instance, AbstractBean<?> owner, List<XMLInjectionPointModel> injectionPointModelList,CreationalContext<?> creationalContext)
   32       {
   33           super(m, instance, owner,creationalContext);
   34           this.injectionPointModelList = injectionPointModelList;
   35       }
   36   
   37       /*
   38        * (non-Javadoc)
   39        * @see org.apache.webbeans.inject.InjectableMethods#doInjection()
   40        */
   41       @Override
   42       @SuppressWarnings("unchecked")
   43       public T doInjection()
   44       {
   45           List<Object> list = new ArrayList<Object>();
   46   
   47           Iterator<XMLInjectionPointModel> it = this.injectionPointModelList.iterator();
   48           while (it.hasNext())
   49           {
   50               XMLInjectionPointModel model = it.next();
   51               Annotation[] anns = new Annotation[model.getBindingTypes().size()];
   52               anns = model.getBindingTypes().toArray(anns);
   53   
   54               //list.add(inject(model.getInjectionGenericType(), anns));
   55           }
   56   
   57           try
   58           {
   59               if (!method.isAccessible())
   60               {
   61                   method.setAccessible(true);
   62               }
   63   
   64               return (T) method.invoke(instance, list.toArray());
   65   
   66           }
   67           catch (Exception e)
   68           {
   69               // no-op
   70               e.printStackTrace();
   71           }
   72           return null;
   73       }
   74   }

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