Package org.jboss.metadata.spi.signature

Examples of org.jboss.metadata.spi.signature.Signature


   public void testMethodParams() throws Exception
   {
      CtClass ctClass = getCtClass(SignatureTester.class);
      CtMethod ctMethod = ctClass.getDeclaredMethod("applyTimeZone", new CtClass[]{getCtClass(Calendar.class), getCtClass(TimeZone.class)});
      Signature sig = new JavassistMethodParametersSignature(ctMethod, 0);
      assertEquals(getClassMethodParametersSignature(), sig);
      assertEquals(getStringMethodParametersSignature(), sig);
      assertEquals(getMethodParametersSignature(), sig);
      assertEquals(getMethodInfoParametersSignature(), sig);
   }
View Full Code Here


   }

   public void testField() throws Exception
   {
      CtClass ctClass = getCtClass(SignatureTester.class);
      Signature sig = JavassistSignatureFactory.getSignature(ctClass.getField("calendar"));     
      assertEquals(getStringFieldSignature(), sig);
      assertEquals(getFieldSignature(), sig);
      assertEquals(getFieldInfoSignature(), sig);
   }
View Full Code Here

   }

   public void testArray() throws Exception
   {
      Method method = getClass().getMethod("method", String.class, byte[].class, Byte[].class, String[][].class);
      Signature s = getSignature(method);
      Class<?>[] parametersTypes = s.getParametersTypes(getClass());
      assertEquals(4, parametersTypes.length);

      String p[] = { String.class.getName(), byte[].class.getName(), Byte[].class.getName(), String[][].class.getName()};
      Signature s2 = new Signature("method", p);
      Class<?>[] parametersTypes2 = s2.getParametersTypes(getClass());
      assertEquals(parametersTypes, parametersTypes2);
   }
View Full Code Here

   {
   }

   protected Signature getSignature(Method method)
   {
      return new Signature(method.getName(), method.getParameterTypes());
   }
View Full Code Here

      Set<ConstructorInfo> constructors = info.getConstructors();
      if (constructors != null && constructors.isEmpty() == false)
      {
         for(ConstructorInfo ci : constructors)
         {
            Signature cis = new ConstructorSignature(ci);
            MetaData cmdr = retrieval.getComponentMetaData(cis);
            if (cmdr != null)
            {
               for(T plugin : getPlugins(ElementType.CONSTRUCTOR, null, annotationClasses))
               {
                  if (isApplyPhase)
                     applyPlugin(plugin, ci, cmdr, handle);
                  else
                     cleanPlugin(plugin, ci, cmdr, handle);
               }
            }
            else if (trace)
               log.trace("No annotations for " + ci);
         }
      }
      else if (trace)
         log.trace("No constructors");

      // properties
      Set<MethodInfo> visitedMethods = new HashSet<MethodInfo>();
      Set<PropertyInfo> properties = info.getProperties();
      if (properties != null && properties.isEmpty() == false)
      {
         for(PropertyInfo pi : properties)
         {
            FieldInfo field = pi.getFieldInfo();
            if (field != null)
            {
               Signature sis = new FieldSignature(field);
               MetaData cmdr = retrieval.getComponentMetaData(sis);
               if (cmdr != null)
               {
                  for(T plugin : getPlugins(ElementType.FIELD, null, annotationClasses))
                  {
                     if (isApplyPhase)
                        applyPlugin(plugin, field, cmdr, handle);
                     else
                        cleanPlugin(plugin, field, cmdr, handle);
                  }
               }
               else if (trace)
                  log.trace("No annotations for field " + field.getName());
            }
            // apply setter and getter as well - if they exist
            handleMethod(retrieval, handle, isApplyPhase, trace, visitedMethods, pi, pi.getSetter(), "setter", annotationClasses);
            handleMethod(retrieval, handle, isApplyPhase, trace, visitedMethods, pi, pi.getGetter(), "getter", annotationClasses);
         }
      }
      else if (trace)
         log.trace("No properties");

      // get Object's class info - it's cached so it shouldn't take much
      TypeInfoFactory tif = classInfo.getTypeInfoFactory();
      TypeInfo objectTI = tif.getTypeInfo(Object.class);

      // method plugins
      Iterable<T> methodPlugins = null;

      // methods
      Set<MethodInfo> methods = info.getMethods();
      if (methods != null && methods.isEmpty() == false)
      {
         for(MethodInfo mi : methods)
         {
            ClassInfo declaringCI = mi.getDeclaringClass();
            // direct == check is OK
            if (declaringCI != objectTI && visitedMethods.contains(mi) == false)
            {
               Signature mis = new MethodSignature(mi);
               MetaData cmdr = retrieval.getComponentMetaData(mis);
               if (cmdr != null)
               {
                  methodPlugins = getPlugins(ElementType.METHOD, METHOD_FILTER, annotationClasses);
                  for(T plugin : methodPlugins)
                  {
                     if (isApplyPhase)
                        applyPlugin(plugin, mi, cmdr, handle);
                     else
                        cleanPlugin(plugin, mi, cmdr, handle);
                  }
               }
               else if (trace)
                  log.trace("No annotations for " + mi);
            }
         }
      }
      else if (trace)
         log.trace("No methods");

      // static methods
      MethodInfo[] staticMethods = getStaticMethods(classInfo);
      if (staticMethods != null && staticMethods.length != 0)
      {
         for(MethodInfo smi : staticMethods)
         {
            if (smi.isStatic() && smi.isPublic())
            {
               Signature mis = new MethodSignature(smi);
               MetaData cmdr = retrieval.getComponentMetaData(mis);
               if (cmdr != null)
               {
                  if (methodPlugins == null)
                     methodPlugins = getPlugins(ElementType.METHOD, METHOD_FILTER, annotationClasses);
View Full Code Here

   {
      if (method == null)
         return;
     
      visitedMethods.add(method);
      Signature sis = new MethodSignature(method);
      MetaData cmdr = retrieval.getComponentMetaData(sis);
      if (cmdr != null)
      {
         for(T plugin : getPlugins(ElementType.METHOD, PROPERTY_FILTER, annotationClasses))
         {
View Full Code Here

    * @param className the className
    * @param commit the commit list
    */
   protected static void handleAnnotations(ElementType type, CtMember member, Object[] annotations, String className, List<CommitElement> commit)
   {
      Signature signature = null;
      if (member != null)
         signature = JavassistSignatureFactory.getSignature(member);
      handleAnnotations(type, signature, annotations, className, commit);
   }
View Full Code Here

   private void updateAnnotations(MutableMetaDataRepository repository, ClassLoader classloader, ComponentMutableMetaData component, KernelControllerContext context, MethodInfo methodInfo, Set<AnnotationMetaData> annotations, boolean add)
   {
      if (annotations == null || annotations.isEmpty())
         return;

      Signature signature = new MethodSignature(methodInfo);
      ScopeKey scope = new ScopeKey(CommonLevels.JOINPOINT_OVERRIDE, methodInfo.getName());
      updateAnnotations(repository, classloader, component, context, signature, scope, annotations, add);
   }
View Full Code Here

   private void updateAnnotations(MutableMetaDataRepository repository, ClassLoader classloader, ComponentMutableMetaData component, KernelControllerContext context, FieldInfo fieldInfo, Set<AnnotationMetaData> annotations, boolean add)
   {
      if (annotations == null || annotations.isEmpty())
         return;

      Signature signature = new FieldSignature(fieldInfo);
      ScopeKey scope = new ScopeKey(CommonLevels.JOINPOINT_OVERRIDE, fieldInfo.getName());
      updateAnnotations(repository, classloader, component, context, signature, scope, annotations, add);
   }
View Full Code Here

      Set<ConstructorInfo> constructors = info.getConstructors();
      if (constructors != null && constructors.isEmpty() == false)
      {
         for(ConstructorInfo ci : constructors)
         {
            Signature cis = new ConstructorSignature(ci);
            MetaData cmdr = retrieval.getComponentMetaData(cis);
            if (cmdr != null)
            {
               for(T plugin : getPlugins(ElementType.CONSTRUCTOR, null, annotationClasses))
               {
                  if (isApplyPhase)
                     applyPlugin(plugin, ci, cmdr, handle);
                  else
                     cleanPlugin(plugin, ci, cmdr, handle);
               }
            }
            else if (trace)
               log.trace("No annotations for " + ci);
         }
      }
      else if (trace)
         log.trace("No constructors");

      // properties
      Set<MethodInfo> visitedMethods = new HashSet<MethodInfo>();
      Set<PropertyInfo> properties = info.getProperties();
      if (properties != null && properties.isEmpty() == false)
      {
         for(PropertyInfo pi : properties)
         {
            FieldInfo field = pi.getFieldInfo();
            if (field != null)
            {
               Signature sis = new FieldSignature(field);
               MetaData cmdr = retrieval.getComponentMetaData(sis);
               if (cmdr != null)
               {
                  for(T plugin : getPlugins(ElementType.FIELD, null, annotationClasses))
                  {
                     if (isApplyPhase)
                        applyPlugin(plugin, field, cmdr, handle);
                     else
                        cleanPlugin(plugin, field, cmdr, handle);
                  }
               }
               else if (trace)
                  log.trace("No annotations for field " + field.getName());
            }
            // apply setter and getter as well - if they exist
            handleMethod(retrieval, handle, isApplyPhase, trace, visitedMethods, pi, pi.getSetter(), "setter", annotationClasses);
            handleMethod(retrieval, handle, isApplyPhase, trace, visitedMethods, pi, pi.getGetter(), "getter", annotationClasses);
         }
      }
      else if (trace)
         log.trace("No properties");

      // get Object's class info - it's cached so it shouldn't take much
      TypeInfoFactory tif = classInfo.getTypeInfoFactory();
      TypeInfo objectTI = tif.getTypeInfo(Object.class);

      // method plugins
      Iterable<T> methodPlugins = null;

      // methods
      Set<MethodInfo> methods = info.getMethods();
      if (methods != null && methods.isEmpty() == false)
      {
         for(MethodInfo mi : methods)
         {
            ClassInfo declaringCI = mi.getDeclaringClass();
            // direct == check is OK
            if (declaringCI != objectTI && visitedMethods.contains(mi) == false)
            {
               Signature mis = new DeclaredMethodSignature(mi);
               MetaData cmdr = retrieval.getComponentMetaData(mis);
               if (cmdr != null)
               {
                  if (methodPlugins == null)
                     methodPlugins = getPlugins(ElementType.METHOD, METHOD_FILTER, annotationClasses);
                 
                  for(T plugin : methodPlugins)
                  {
                     if (isApplyPhase)
                        applyPlugin(plugin, mi, cmdr, handle);
                     else
                        cleanPlugin(plugin, mi, cmdr, handle);
                  }
               }
               else if (trace)
                  log.trace("No annotations for " + mi);
            }
         }
      }
      else if (trace)
         log.trace("No methods");

      // static methods
      MethodInfo[] staticMethods = getStaticMethods(classInfo);
      if (staticMethods != null && staticMethods.length != 0)
      {
         for(MethodInfo smi : staticMethods)
         {
            if (smi.isStatic() && smi.isPublic())
            {
               Signature mis = new DeclaredMethodSignature(smi);
               MetaData cmdr = retrieval.getComponentMetaData(mis);
               if (cmdr != null)
               {
                  if (methodPlugins == null)
                     methodPlugins = getPlugins(ElementType.METHOD, METHOD_FILTER, annotationClasses);
View Full Code Here

TOP

Related Classes of org.jboss.metadata.spi.signature.Signature

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.