private static List<ParameterAttributeName> getParameterAttributeNames(
     final List<Extension.Instrumentation.Pointcut.Method> methods) {
   final List<ParameterAttributeName> reportedParams =
       (List<ParameterAttributeName>) Lists.newArrayList();
   for (final Extension.Instrumentation.Pointcut.Method m : methods) {
     if (m.getParameters() != null && m.getParameters().getType() != null) {
       for (int i = 0; i < m.getParameters().getType().size(); ++i) {
         final Extension.Instrumentation.Pointcut.Method.Parameters.Type t =
             m.getParameters().getType().get(i);
         if (t.getAttributeName() != null) {
           try {
             final MethodMatcher methodMatcher =
                 MethodMatcherUtility.createMethodMatcher(
                     "DummyClassName", m, (Map<String, MethodMapper>) Maps.newHashMap(), "");
             final ParameterAttributeName reportedParam =
                 new ParameterAttributeName(i, t.getAttributeName(), methodMatcher);
             reportedParams.add(reportedParam);
           } catch (Exception e) {
             Agent.LOG.log(Level.FINEST, (Throwable) e, e.getMessage(), new Object[0]);
           }
         }
       }
     }
   }
   return reportedParams;
 }
Exemple #2
0
 public ReflectionHelper() {
   this.classes = (Map<String, ClassReflector>) Maps.newHashMap();
   for (final java.lang.reflect.Method m : ClassReflection.class.getMethods()) {
     final Method staticMethod = Method.getMethod(m);
     if (m.getDeclaringClass().equals(ClassReflection.class)
         && staticMethod.getArgumentTypes().length > 0) {
       final Type targetClass = staticMethod.getArgumentTypes()[0];
       final Class<?>[] args = (Class<?>[]) new Class[m.getParameterTypes().length - 1];
       System.arraycopy(
           m.getParameterTypes(), 1, args, 0, staticMethod.getArgumentTypes().length - 1);
       try {
         m.getParameterTypes()[0].getMethod(m.getName(), args);
         ClassReflector classReflector = this.classes.get(targetClass.getInternalName());
         if (classReflector == null) {
           classReflector = new ClassReflector();
           this.classes.put(targetClass.getInternalName(), classReflector);
         }
         final Type[] argumentTypes = new Type[staticMethod.getArgumentTypes().length - 1];
         System.arraycopy(
             staticMethod.getArgumentTypes(),
             1,
             argumentTypes,
             0,
             staticMethod.getArgumentTypes().length - 1);
         final Method targetMethod =
             new Method(m.getName(), staticMethod.getReturnType(), argumentTypes);
         classReflector.methods.put(targetMethod, staticMethod);
       } catch (NoSuchMethodException ex) {
       }
     }
   }
 }
Exemple #3
0
 Multimap<String, Object> getOrCreateAttributes() {
   if (this.attributes == null) {
     this.attributes =
         Multimaps.newListMultimap(
             Maps.<String, Collection<Object>>newHashMap(),
             new Supplier<List<Object>>() {
               public List<Object> get() {
                 return Lists.newArrayList();
               }
             });
   }
   return this.attributes;
 }
Exemple #4
0
 public ClassReflector() {
   this.methods = (Map<Method, Method>) Maps.newHashMap();
 }