org.sca4j.introspection
Interface IntrospectionHelper


public interface IntrospectionHelper

Helper service that provides support methods to simplify introspection.

Version:
$Rev: 4286 $ $Date: 2008-05-21 20:56:34 +0100 (Wed, 21 May 2008) $

Method Summary
 java.lang.reflect.Type getBaseType(java.lang.reflect.Type type, TypeMapping typeMapping)
          Returns the base type for the supplied type.
 java.lang.reflect.Type getGenericType(java.lang.reflect.Constructor<?> constructor, int index)
          Returns the generic type of a constructor parameter.
 java.lang.reflect.Type getGenericType(java.lang.reflect.Method setter)
          Returns the generic type of a setter method.
 java.lang.reflect.Type getGenericType(java.lang.reflect.Method method, int index)
          Returns the generic type of a method parameter.
 java.util.Set<java.lang.Class<?>> getImplementedInterfaces(java.lang.Class<?> type)
          Returns all service interfaces directly implemented by a class or any superclass.
 java.util.Set<java.lang.reflect.Field> getInjectionFields(java.lang.Class<?> type)
          Returns method injection sites provided by a class or any superclass.
 java.util.Set<java.lang.reflect.Method> getInjectionMethods(java.lang.Class<?> type, java.util.Collection<org.sca4j.scdl.ServiceDefinition> services)
          Returns method injection sites provided by a class or any superclass.
 java.lang.String getSiteName(java.lang.reflect.Constructor<?> constructor, int index, java.lang.String override)
          Derive the name of an injection site from a setter method.
 java.lang.String getSiteName(java.lang.reflect.Field field, java.lang.String override)
          Derive the name of an injection site from a field.
 java.lang.String getSiteName(java.lang.reflect.Method setter, java.lang.String override)
          Derive the name of an injection site from a setter method.
 org.sca4j.scdl.InjectableAttributeType inferType(java.lang.reflect.Type type, TypeMapping typeMapping)
           
 boolean isAnnotationPresent(java.lang.Class<?> type, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
          Determine if an annotation is present on this interface or any superinterface.
 boolean isManyValued(TypeMapping typeMapping, java.lang.reflect.Type type)
          Returns true if the supplied type should be treated as many-valued.
 java.lang.Class<?> loadClass(java.lang.String name, java.lang.ClassLoader cl)
          Load the class using the supplied ClassLoader.
 TypeMapping mapTypeParameters(java.lang.Class<?> type)
          Map the formal parameters of a type, its superclass and superinterfaces to the actual parameters of the class.
 

Method Detail

loadClass

java.lang.Class<?> loadClass(java.lang.String name,
                             java.lang.ClassLoader cl)
                             throws ImplementationNotFoundException
Load the class using the supplied ClassLoader. The class will be defined so any initializers present will be fired. As the class is being loaded, the Thread context ClassLoader will be set to the supplied classloader.

Parameters:
name - the name of the class to load
cl - the classloader to use to load it
Returns:
the class
Throws:
ImplementationNotFoundException - if the class could not be found

getSiteName

java.lang.String getSiteName(java.lang.reflect.Field field,
                             java.lang.String override)
Derive the name of an injection site from a field.

Parameters:
field - the field to inspect
override - an override specified in an annotation
Returns:
the name of the injection site

getSiteName

java.lang.String getSiteName(java.lang.reflect.Method setter,
                             java.lang.String override)
Derive the name of an injection site from a setter method.

Parameters:
setter - the setter method to inspect
override - an override specified in an annotation
Returns:
the name of the injection site

getSiteName

java.lang.String getSiteName(java.lang.reflect.Constructor<?> constructor,
                             int index,
                             java.lang.String override)
Derive the name of an injection site from a setter method.

Parameters:
constructor - the constructor to inspect
index - the index of the constructor parameter to inspect
override - an override specified in an annotation
Returns:
the name of the injection site

getGenericType

java.lang.reflect.Type getGenericType(java.lang.reflect.Method setter)
Returns the generic type of a setter method.

Parameters:
setter - the method to inspect
Returns:
the type of value the setter method injects

getGenericType

java.lang.reflect.Type getGenericType(java.lang.reflect.Method method,
                                      int index)
Returns the generic type of a method parameter.

Parameters:
method - the method to inspect
index - the parameter index
Returns:
the type of value the method injects

getGenericType

java.lang.reflect.Type getGenericType(java.lang.reflect.Constructor<?> constructor,
                                      int index)
Returns the generic type of a constructor parameter.

Parameters:
constructor - the constructor to inspect
index - the parameter index
Returns:
the type of value the constructor injects

isManyValued

boolean isManyValued(TypeMapping typeMapping,
                     java.lang.reflect.Type type)
Returns true if the supplied type should be treated as many-valued.

This is generally true for arrays, Collection or Map types.

Parameters:
typeMapping - the mapping to use to resolve any formal types
type - the type to check
Returns:
true if the type should be treated as many-valued

inferType

org.sca4j.scdl.InjectableAttributeType inferType(java.lang.reflect.Type type,
                                                 TypeMapping typeMapping)

isAnnotationPresent

boolean isAnnotationPresent(java.lang.Class<?> type,
                            java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Determine if an annotation is present on this interface or any superinterface.

This is similar to the use of @Inherited on classes (given @Inherited does not apply to interfaces).

Parameters:
type - the interface to check
annotationType - the annotation to look for
Returns:
true if the annotation is present

mapTypeParameters

TypeMapping mapTypeParameters(java.lang.Class<?> type)
Map the formal parameters of a type, its superclass and superinterfaces to the actual parameters of the class.

Parameters:
type - the class whose parameters should be mapped
Returns:
a mapping of formal type parameters to actual types

getBaseType

java.lang.reflect.Type getBaseType(java.lang.reflect.Type type,
                                   TypeMapping typeMapping)
Returns the base type for the supplied type.

The base type is the actual type of a property or reference having removed any decoration for arrays or collections.

Parameters:
type - the type of a field or parameter
typeMapping - the mapping to use to resolve any formal types
Returns:
the actual type of the property or reference corresponding to the parameter

getImplementedInterfaces

java.util.Set<java.lang.Class<?>> getImplementedInterfaces(java.lang.Class<?> type)
Returns all service interfaces directly implemented by a class or any superclass.

Class#getInterfaces only returns interfaces directly implemented by the class. This method returns all interfaces including those implemented by any superclasses. It excludes interfaces that are super-interfaces of those implemented by subclasses.

Parameters:
type - the class whose interfaces should be returned
Returns:
the unique interfaces immplemented by that class

getInjectionMethods

java.util.Set<java.lang.reflect.Method> getInjectionMethods(java.lang.Class<?> type,
                                                            java.util.Collection<org.sca4j.scdl.ServiceDefinition> services)
Returns method injection sites provided by a class or any superclass.

Methods that are part of any service contract are excluded.

Parameters:
type - the class whose method sites should be returned
services - the services implemented by the class
Returns:
the method injection sites for the class

getInjectionFields

java.util.Set<java.lang.reflect.Field> getInjectionFields(java.lang.Class<?> type)
Returns method injection sites provided by a class or any superclass.

Methods that are part of any service contract are excluded.

Parameters:
type - the class whose field injection sites should be returned
Returns:
the setter injection sites for the class


Copyright © 2008-2011 Service Symphony. All Rights Reserved.