Save This Page
Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.inject.impl » [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.inject.impl;
   18   
   19   import java.lang.annotation.Annotation;
   20   import java.lang.reflect.Constructor;
   21   import java.lang.reflect.Field;
   22   import java.lang.reflect.Member;
   23   import java.lang.reflect.Method;
   24   import java.lang.reflect.Type;
   25   import java.util.HashSet;
   26   import java.util.Set;
   27   
   28   import javax.enterprise.inject.spi.Annotated;
   29   import javax.enterprise.inject.spi.Bean;
   30   import javax.enterprise.inject.spi.InjectionPoint;
   31   
   32   class InjectionPointImpl implements InjectionPoint
   33   {
   34       private Set<Annotation> qualifierAnnotations = new HashSet<Annotation>();
   35       
   36       private Bean<?> ownerBean;
   37       
   38       private Member injectionMember;
   39       
   40       private Type injectionType;
   41       
   42       private Annotated annotated;
   43   
   44       InjectionPointImpl(Bean<?> ownerBean, Type type, Member member, Annotated annotated)
   45       {
   46           this.ownerBean = ownerBean;
   47           this.injectionMember = member;
   48           this.injectionType = type;
   49           this.annotated = annotated;
   50       }
   51       
   52       void addBindingAnnotation(Annotation qualifierAnnotations)
   53       {
   54           this.qualifierAnnotations.add(qualifierAnnotations);
   55       }
   56       
   57       public Bean<?> getBean()
   58       {
   59           
   60           return this.ownerBean;
   61       }
   62   
   63       public Set<Annotation> getQualifiers()
   64       {
   65           
   66           return this.qualifierAnnotations;
   67       }
   68   
   69       public Member getMember()
   70       {
   71           return this.injectionMember;
   72       }
   73   
   74       public Type getType()
   75       {
   76           
   77           return this.injectionType;
   78       }
   79   
   80       
   81       @Override
   82       public Annotated getAnnotated()
   83       {
   84           return annotated;
   85       }
   86   
   87       @Override
   88       public boolean isDelegate()
   89       {
   90           return false;
   91       }
   92   
   93       @Override
   94       public boolean isTransient()
   95       {
   96           return false;
   97       }
   98       
   99   
  100       public String toString()
  101       {
  102           StringBuffer buffer = new StringBuffer();
  103           if(injectionMember instanceof Constructor)
  104           {
  105               Constructor<?> constructor = (Constructor<?>) this.injectionMember;
  106               buffer.append("Constructor Injection with name :  " + constructor.getName() + ownerBean.toString());
  107           }
  108           else if(injectionMember instanceof Method)
  109           {
  110               Method method = (Method)this.injectionMember;
  111               buffer.append("Method Injection with name :  " + method.getName() + ownerBean.toString());
  112               
  113           }
  114           else if(injectionMember instanceof Field)
  115           {
  116               Field field = (Field) this.injectionMember;
  117               buffer.append("Field Injection with name :  " + field.getName() + ownerBean.toString());            
  118           }
  119           
  120           return buffer.toString();
  121       }
  122   }

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