Package jadex.micro

Class MicroClassReader

  • Direct Known Subclasses:
    BDIClassReader

    public class MicroClassReader
    extends java.lang.Object
    Reads micro agent classes and generates a model from metainfo and annotations.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkAndAddRequiredServiceInfo​(RequiredServiceInfo rsis, java.util.Map<java.lang.String,​java.lang.Object> rsers, java.lang.ClassLoader cl)  
      protected void checkMethodReturnType​(java.lang.Class<? extends java.lang.annotation.Annotation> ann, java.lang.reflect.Method m, java.lang.ClassLoader cl)
      Check, if the return type of the agent method is acceptable.
      static RequiredServiceBinding createBinding​(RequiredService rq)
      Create a service binding.
      protected ComponentInstanceInfo createComponentInstanceInfo​(Component comp)
      Create component instance info from component annotation.
      static ComponentInstanceInfo createComponentInstanceInfo​(CreationInfo comp)
      Create component instance info from creation info annotation.
      static ProvidedServiceImplementation createImplementation​(Implementation impl, java.lang.Class<?> cma)
      Create a service implementation.
      protected static java.util.List<NFRPropertyInfo> createNFRProperties​(NFRProperty[] nfrp)
      Create req service props.
      protected static RequiredServiceInfo createRequiredServiceInfo​(RequiredService rs, java.lang.ClassLoader cl)
      Create a required service info from annotation.
      static UnparsedExpression[] createUnparsedExpressions​(Value[] values)
      Create unparsed expressions.
      protected java.lang.Object evaluateExpression​(java.lang.String exp, java.lang.String[] imports, IValueFetcher fetcher, java.lang.ClassLoader classloader)
      Evaluate an expression string (using "" -> null mapping) as annotations do not support null values.
      protected void fillMicroModelFromAnnotations​(MicroModel micromodel, java.lang.String model, java.lang.Class<?> clazz, java.lang.ClassLoader cl)
      Fill the model details using annotation.
      static void findInjections​(java.lang.Class<?> cma, java.lang.ClassLoader cl, InjectionInfoHolder ii, java.util.Map<java.lang.String,​java.lang.Object> rsers)
      Find injections:
      static <T extends java.lang.annotation.Annotation>
      T
      getAnnotation​(java.lang.Class<?> clazz, java.lang.Class<T> anclazz, java.lang.ClassLoader cl)  
      static <T extends java.lang.annotation.Annotation>
      T
      getAnnotation​(java.lang.Class<?> clazz, java.lang.Class<T> anclazz, java.lang.ClassLoader cl1, java.lang.ClassLoader cl2)  
      static <T extends java.lang.annotation.Annotation>
      T
      getAnnotation​(java.lang.reflect.Constructor<?> c, java.lang.Class<T> anclazz, java.lang.ClassLoader cl)  
      static <T extends java.lang.annotation.Annotation>
      T
      getAnnotation​(java.lang.reflect.Field f, java.lang.Class<T> anclazz, java.lang.ClassLoader cl)  
      static <T extends java.lang.annotation.Annotation>
      T
      getAnnotation​(java.lang.reflect.Method m, java.lang.Class<T> anclazz, java.lang.ClassLoader cl)  
      static java.lang.Class<?> getClass​(java.lang.Class<?> clazz, java.lang.ClassLoader cl)  
      static java.lang.Class<?>[] getClassArray​(java.lang.Class<?>[] clazzes, java.lang.ClassLoader cl)  
      protected java.lang.Class<?> getMicroAgentClass​(java.lang.String clname, java.lang.String[] imports, java.lang.ClassLoader classloader)
      Get the mirco agent class.
      protected java.util.List<java.lang.Object> getOrCreateList​(java.lang.String name, java.util.Map<java.lang.String,​java.lang.Object> map)
      Get or create a list.
      protected java.util.Map<java.lang.String,​java.lang.Object> getOrCreateMap​(java.lang.String name, java.util.Map<java.lang.String,​java.lang.Object> map)
      Get or create a map.
      protected java.util.Set<java.lang.Object> getOrCreateSet​(java.lang.String name, java.util.Map<java.lang.String,​java.lang.Object> map)
      Get or create a set.
      static java.lang.annotation.Annotation[][] getParameterAnnotations​(java.lang.reflect.Constructor c, java.lang.ClassLoader cl)  
      static java.lang.annotation.Annotation[][] getParameterAnnotations​(java.lang.reflect.Method m, java.lang.ClassLoader cl)  
      static <T extends java.lang.annotation.Annotation>
      T
      getProxyAnnotation​(T an, java.lang.ClassLoader cl)
      Gets proxy annotation that can be invoked by corresponding classloader.
      protected static java.lang.String guessName​(java.lang.String methodname)  
      protected static java.lang.Class<?> guessParameterType​(java.lang.Class<?>[] ptypes, java.lang.ClassLoader cl)  
      static boolean isAnnotationPresent​(java.lang.Class<?> clazz, java.lang.Class<? extends java.lang.annotation.Annotation> anclazz, java.lang.ClassLoader cl)  
      static boolean isAnnotationPresent​(java.lang.reflect.Constructor<?> con, java.lang.Class<? extends java.lang.annotation.Annotation> anclazz, java.lang.ClassLoader cl)  
      static boolean isAnnotationPresent​(java.lang.reflect.Field f, java.lang.Class<? extends java.lang.annotation.Annotation> anclazz, java.lang.ClassLoader cl)  
      static boolean isAnnotationPresent​(java.lang.reflect.Method m, java.lang.Class<? extends java.lang.annotation.Annotation> anclazz, java.lang.ClassLoader cl)  
      protected static boolean isClassLoaderCompatible​(java.lang.Class<?> clazz, java.lang.ClassLoader cl)  
      protected MicroModel read​(java.lang.String model, java.lang.Class<?> cma, java.lang.ClassLoader classloader, IResourceIdentifier rid, IComponentIdentifier root, java.util.List<IComponentFeatureFactory> features)
      Load the model.
      MicroModel read​(java.lang.String model, java.lang.String[] imports, java.lang.ClassLoader classloader, IResourceIdentifier rid, IComponentIdentifier root, java.util.List<IComponentFeatureFactory> features)
      Load a model.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MicroClassReader

        public MicroClassReader()
    • Method Detail

      • fillMicroModelFromAnnotations

        protected void fillMicroModelFromAnnotations​(MicroModel micromodel,
                                                     java.lang.String model,
                                                     java.lang.Class<?> clazz,
                                                     java.lang.ClassLoader cl)
        Fill the model details using annotation.
      • checkMethodReturnType

        protected void checkMethodReturnType​(java.lang.Class<? extends java.lang.annotation.Annotation> ann,
                                             java.lang.reflect.Method m,
                                             java.lang.ClassLoader cl)
        Check, if the return type of the agent method is acceptable.
      • createRequiredServiceInfo

        protected static RequiredServiceInfo createRequiredServiceInfo​(RequiredService rs,
                                                                       java.lang.ClassLoader cl)
        Create a required service info from annotation.
      • getOrCreateMap

        protected java.util.Map<java.lang.String,​java.lang.Object> getOrCreateMap​(java.lang.String name,
                                                                                        java.util.Map<java.lang.String,​java.lang.Object> map)
        Get or create a map.
      • getOrCreateList

        protected java.util.List<java.lang.Object> getOrCreateList​(java.lang.String name,
                                                                   java.util.Map<java.lang.String,​java.lang.Object> map)
        Get or create a list.
      • getOrCreateSet

        protected java.util.Set<java.lang.Object> getOrCreateSet​(java.lang.String name,
                                                                 java.util.Map<java.lang.String,​java.lang.Object> map)
        Get or create a set.
      • evaluateExpression

        protected java.lang.Object evaluateExpression​(java.lang.String exp,
                                                      java.lang.String[] imports,
                                                      IValueFetcher fetcher,
                                                      java.lang.ClassLoader classloader)
        Evaluate an expression string (using "" -> null mapping) as annotations do not support null values.
      • createNFRProperties

        protected static java.util.List<NFRPropertyInfo> createNFRProperties​(NFRProperty[] nfrp)
        Create req service props.
      • createComponentInstanceInfo

        protected ComponentInstanceInfo createComponentInstanceInfo​(Component comp)
        Create component instance info from component annotation.
      • createComponentInstanceInfo

        public static ComponentInstanceInfo createComponentInstanceInfo​(CreationInfo comp)
        Create component instance info from creation info annotation.
      • createUnparsedExpressions

        public static UnparsedExpression[] createUnparsedExpressions​(Value[] values)
        Create unparsed expressions.
      • getMicroAgentClass

        protected java.lang.Class<?> getMicroAgentClass​(java.lang.String clname,
                                                        java.lang.String[] imports,
                                                        java.lang.ClassLoader classloader)
        Get the mirco agent class.
      • isAnnotationPresent

        public static boolean isAnnotationPresent​(java.lang.Class<?> clazz,
                                                  java.lang.Class<? extends java.lang.annotation.Annotation> anclazz,
                                                  java.lang.ClassLoader cl)
      • isAnnotationPresent

        public static boolean isAnnotationPresent​(java.lang.reflect.Field f,
                                                  java.lang.Class<? extends java.lang.annotation.Annotation> anclazz,
                                                  java.lang.ClassLoader cl)
      • isAnnotationPresent

        public static boolean isAnnotationPresent​(java.lang.reflect.Method m,
                                                  java.lang.Class<? extends java.lang.annotation.Annotation> anclazz,
                                                  java.lang.ClassLoader cl)
      • isAnnotationPresent

        public static boolean isAnnotationPresent​(java.lang.reflect.Constructor<?> con,
                                                  java.lang.Class<? extends java.lang.annotation.Annotation> anclazz,
                                                  java.lang.ClassLoader cl)
      • getAnnotation

        public static <T extends java.lang.annotation.Annotation> T getAnnotation​(java.lang.Class<?> clazz,
                                                                                  java.lang.Class<T> anclazz,
                                                                                  java.lang.ClassLoader cl)
      • getAnnotation

        public static <T extends java.lang.annotation.Annotation> T getAnnotation​(java.lang.reflect.Field f,
                                                                                  java.lang.Class<T> anclazz,
                                                                                  java.lang.ClassLoader cl)
      • getAnnotation

        public static <T extends java.lang.annotation.Annotation> T getAnnotation​(java.lang.reflect.Method m,
                                                                                  java.lang.Class<T> anclazz,
                                                                                  java.lang.ClassLoader cl)
      • getAnnotation

        public static <T extends java.lang.annotation.Annotation> T getAnnotation​(java.lang.reflect.Constructor<?> c,
                                                                                  java.lang.Class<T> anclazz,
                                                                                  java.lang.ClassLoader cl)
      • getParameterAnnotations

        public static java.lang.annotation.Annotation[][] getParameterAnnotations​(java.lang.reflect.Method m,
                                                                                  java.lang.ClassLoader cl)
      • getParameterAnnotations

        public static java.lang.annotation.Annotation[][] getParameterAnnotations​(java.lang.reflect.Constructor c,
                                                                                  java.lang.ClassLoader cl)
      • getAnnotation

        public static <T extends java.lang.annotation.Annotation> T getAnnotation​(java.lang.Class<?> clazz,
                                                                                  java.lang.Class<T> anclazz,
                                                                                  java.lang.ClassLoader cl1,
                                                                                  java.lang.ClassLoader cl2)
      • getClass

        public static java.lang.Class<?> getClass​(java.lang.Class<?> clazz,
                                                  java.lang.ClassLoader cl)
      • getClassArray

        public static java.lang.Class<?>[] getClassArray​(java.lang.Class<?>[] clazzes,
                                                         java.lang.ClassLoader cl)
      • getProxyAnnotation

        public static <T extends java.lang.annotation.Annotation> T getProxyAnnotation​(T an,
                                                                                       java.lang.ClassLoader cl)
        Gets proxy annotation that can be invoked by corresponding classloader.
        Returns:
        ret
      • isClassLoaderCompatible

        protected static boolean isClassLoaderCompatible​(java.lang.Class<?> clazz,
                                                         java.lang.ClassLoader cl)
      • findInjections

        public static void findInjections​(java.lang.Class<?> cma,
                                          java.lang.ClassLoader cl,
                                          InjectionInfoHolder ii,
                                          java.util.Map<java.lang.String,​java.lang.Object> rsers)
        Find injections:
        Parameters:
        cma -
        cl -
        ii -
        rsers -
      • guessName

        protected static java.lang.String guessName​(java.lang.String methodname)
      • guessParameterType

        protected static java.lang.Class<?> guessParameterType​(java.lang.Class<?>[] ptypes,
                                                               java.lang.ClassLoader cl)
      • checkAndAddRequiredServiceInfo

        public static void checkAndAddRequiredServiceInfo​(RequiredServiceInfo rsis,
                                                          java.util.Map<java.lang.String,​java.lang.Object> rsers,
                                                          java.lang.ClassLoader cl)
        Parameters:
        rsis -
        rsers -
        cl -