예제 #1
0
 public JmxAttributeMetadata(Method method) {
   this(method.getAnnotation(ManagedAttribute.class));
   String methodName = method.getName();
   name = ReflectionUtil.extractFieldName(methodName);
   is = methodName.startsWith("is");
   if (methodName.startsWith("set")) {
     useSetter = true;
     type = method.getParameterTypes()[0].getName();
   } else if (methodName.startsWith("get") || is) {
     // How do we read from/write to this field using reflection?
     Class clazz = method.getDeclaringClass();
     Method setterMethod = ReflectionUtil.findSetterForField(clazz, name);
     type = method.getReturnType().getName();
     useSetter = setterMethod != null || !writable;
   }
 }
  private void setTopDocs(HashMap<UUID, ClusteredTopDocs> topDocsResponses) {
    this.topDocsResponses = topDocsResponses;

    if (sort != null) {
      // reversing sort fields to FieldDocSortedHitQueue work properly
      for (SortField sf : sort.getSort()) {
        boolean reverse = (Boolean) ReflectionUtil.getValue(sf, "reverse");
        ReflectionUtil.setValue(sf, "reverse", !reverse);
      }
      hq =
          ISPNPriorityQueueFactory.getFieldDocSortedHitQueue(
              topDocsResponses.size(), sort.getSort());

    } else hq = ISPNPriorityQueueFactory.getHitQueue(topDocsResponses.size());

    // taking the first value of each queue
    for (ClusteredTopDocs ctp : topDocsResponses.values()) {
      if (ctp.hasNext()) hq.add(ctp.getNext());
    }
  }
  @SuppressWarnings("unchecked")
  protected void invokeInjectionMethod(Object o, Method m) {
    Class[] dependencies = m.getParameterTypes();
    Annotation[][] parameterAnnotations = m.getParameterAnnotations();
    Object[] params = new Object[dependencies.length];
    if (getLog().isTraceEnabled())
      getLog()
          .tracef(
              "Injecting dependencies for method [%s] on an instance of [%s].",
              m, o.getClass().getName());
    for (int i = 0; i < dependencies.length; i++) {
      params[i] =
          getOrCreateComponent(
              dependencies[i], getComponentName(dependencies[i], parameterAnnotations, i));
    }

    ReflectionUtil.invokeAccessibly(o, m, params);
  }
 void invoke() {
   ReflectionUtil.invokeAccessibly(component.instance, method, null);
 }
 public final void registerComponent(Object component, String name) {
   boolean nonVolatile =
       ReflectionUtil.isAnnotationPresent(component.getClass(), SurvivesRestarts.class);
   registerComponentInternal(component, name, nonVolatile);
 }