java.beans.MethodDescriptor#getMethod ( )源码实例Demo

下面列出了java.beans.MethodDescriptor#getMethod ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lams   文件: ExtendedBeanInfo.java
private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescriptors) {
	List<Method> matches = new ArrayList<Method>();
	for (MethodDescriptor methodDescriptor : methodDescriptors) {
		Method method = methodDescriptor.getMethod();
		if (isCandidateWriteMethod(method)) {
			matches.add(method);
		}
	}
	// Sort non-void returning write methods to guard against the ill effects of
	// non-deterministic sorting of methods returned from Class#getDeclaredMethods
	// under JDK 7. See http://bugs.sun.com/view_bug.do?bug_id=7023180
	Collections.sort(matches, new Comparator<Method>() {
		@Override
		public int compare(Method m1, Method m2) {
			return m2.toString().compareTo(m1.toString());
		}
	});
	return matches;
}
 
源代码2 项目: blog_demos   文件: ExtendedBeanInfo.java
private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescriptors) {
	List<Method> matches = new ArrayList<Method>();
	for (MethodDescriptor methodDescriptor : methodDescriptors) {
		Method method = methodDescriptor.getMethod();
		if (isCandidateWriteMethod(method)) {
			matches.add(method);
		}
	}
	// sort non-void returning write methods to guard against the ill effects of
	// non-deterministic sorting of methods returned from Class#getDeclaredMethods
	// under JDK 7. See http://bugs.sun.com/view_bug.do?bug_id=7023180
	Collections.sort(matches, new Comparator<Method>() {
		@Override
		public int compare(Method m1, Method m2) {
			return m2.toString().compareTo(m1.toString());
		}
	});
	return matches;
}
 
源代码3 项目: spring4-understanding   文件: ExtendedBeanInfo.java
private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescriptors) {
	List<Method> matches = new ArrayList<Method>();
	for (MethodDescriptor methodDescriptor : methodDescriptors) {
		Method method = methodDescriptor.getMethod();
		if (isCandidateWriteMethod(method)) {
			matches.add(method);
		}
	}
	// Sort non-void returning write methods to guard against the ill effects of
	// non-deterministic sorting of methods returned from Class#getDeclaredMethods
	// under JDK 7. See http://bugs.sun.com/view_bug.do?bug_id=7023180
	Collections.sort(matches, new Comparator<Method>() {
		@Override
		public int compare(Method m1, Method m2) {
			return m2.toString().compareTo(m1.toString());
		}
	});
	return matches;
}
 
源代码4 项目: lucene-solr   文件: SolrPluginUtils.java
private static Method findSetter(Class<?> clazz, String setterName, String key, Class<?> paramClazz, boolean lenient) {
  BeanInfo beanInfo;
  try {
    beanInfo = Introspector.getBeanInfo(clazz);
  } catch (IntrospectionException ie) {
    if (lenient) {
      return null;
    }
    throw new RuntimeException("Error getting bean info for class : " + clazz.getName(), ie);
  }
  for (final boolean matchParamClazz: new boolean[]{true, false}) {
    for (final MethodDescriptor desc : beanInfo.getMethodDescriptors()) {
      final Method m = desc.getMethod();
      final Class<?> p[] = m.getParameterTypes();
      if (m.getName().equals(setterName) && p.length == 1 &&
          (!matchParamClazz || paramClazz.equals(p[0]))) {
        return m;
      }
    }
  }
  if (lenient) {
    return null;
  }
  throw new RuntimeException("No setter corrresponding to '" + key + "' in " + clazz.getName());
}
 
源代码5 项目: spring-analysis-note   文件: ExtendedBeanInfo.java
private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescriptors) {
	List<Method> matches = new ArrayList<>();
	for (MethodDescriptor methodDescriptor : methodDescriptors) {
		Method method = methodDescriptor.getMethod();
		if (isCandidateWriteMethod(method)) {
			matches.add(method);
		}
	}
	// Sort non-void returning write methods to guard against the ill effects of
	// non-deterministic sorting of methods returned from Class#getDeclaredMethods
	// under JDK 7. See https://bugs.java.com/view_bug.do?bug_id=7023180
	matches.sort((m1, m2) -> m2.toString().compareTo(m1.toString()));
	return matches;
}
 
源代码6 项目: dragonwell8_jdk   文件: Test6277246.java
public static void main(String[] args) throws IntrospectionException {
    Class type = BASE64Encoder.class;
    System.setSecurityManager(new SecurityManager());
    BeanInfo info = Introspector.getBeanInfo(type);
    for (MethodDescriptor md : info.getMethodDescriptors()) {
        Method method = md.getMethod();
        System.out.println(method);

        String name = method.getDeclaringClass().getName();
        if (name.startsWith("sun.misc.")) {
            throw new Error("found inaccessible method");
        }
    }
}
 
源代码7 项目: TencentKona-8   文件: Test6277246.java
public static void main(String[] args) throws IntrospectionException {
    Class type = BASE64Encoder.class;
    System.setSecurityManager(new SecurityManager());
    BeanInfo info = Introspector.getBeanInfo(type);
    for (MethodDescriptor md : info.getMethodDescriptors()) {
        Method method = md.getMethod();
        System.out.println(method);

        String name = method.getDeclaringClass().getName();
        if (name.startsWith("sun.misc.")) {
            throw new Error("found inaccessible method");
        }
    }
}
 
源代码8 项目: jdk8u-dev-jdk   文件: Test6277246.java
public static void main(String[] args) throws IntrospectionException {
    Class type = BASE64Encoder.class;
    System.setSecurityManager(new SecurityManager());
    BeanInfo info = Introspector.getBeanInfo(type);
    for (MethodDescriptor md : info.getMethodDescriptors()) {
        Method method = md.getMethod();
        System.out.println(method);

        String name = method.getDeclaringClass().getName();
        if (name.startsWith("sun.misc.")) {
            throw new Error("found inaccessible method");
        }
    }
}
 
源代码9 项目: jdk8u60   文件: Test6277246.java
public static void main(String[] args) throws IntrospectionException {
    Class type = BASE64Encoder.class;
    System.setSecurityManager(new SecurityManager());
    BeanInfo info = Introspector.getBeanInfo(type);
    for (MethodDescriptor md : info.getMethodDescriptors()) {
        Method method = md.getMethod();
        System.out.println(method);

        String name = method.getDeclaringClass().getName();
        if (name.startsWith("sun.misc.")) {
            throw new Error("found inaccessible method");
        }
    }
}
 
源代码10 项目: openjdk-jdk8u   文件: Test6277246.java
public static void main(String[] args) throws IntrospectionException {
    Class type = BASE64Encoder.class;
    System.setSecurityManager(new SecurityManager());
    BeanInfo info = Introspector.getBeanInfo(type);
    for (MethodDescriptor md : info.getMethodDescriptors()) {
        Method method = md.getMethod();
        System.out.println(method);

        String name = method.getDeclaringClass().getName();
        if (name.startsWith("sun.misc.")) {
            throw new Error("found inaccessible method");
        }
    }
}
 
源代码11 项目: openjdk-jdk8u-backup   文件: Test6277246.java
public static void main(String[] args) throws IntrospectionException {
    Class type = BASE64Encoder.class;
    System.setSecurityManager(new SecurityManager());
    BeanInfo info = Introspector.getBeanInfo(type);
    for (MethodDescriptor md : info.getMethodDescriptors()) {
        Method method = md.getMethod();
        System.out.println(method);

        String name = method.getDeclaringClass().getName();
        if (name.startsWith("sun.misc.")) {
            throw new Error("found inaccessible method");
        }
    }
}
 
源代码12 项目: jdk8u-jdk   文件: Test6277246.java
public static void main(String[] args) throws IntrospectionException {
    Class type = BASE64Encoder.class;
    System.setSecurityManager(new SecurityManager());
    BeanInfo info = Introspector.getBeanInfo(type);
    for (MethodDescriptor md : info.getMethodDescriptors()) {
        Method method = md.getMethod();
        System.out.println(method);

        String name = method.getDeclaringClass().getName();
        if (name.startsWith("sun.misc.")) {
            throw new Error("found inaccessible method");
        }
    }
}
 
源代码13 项目: jdk8u-jdk   文件: Test6277246.java
public static void main(String[] args) throws IntrospectionException {
    Class type = BASE64Encoder.class;
    System.setSecurityManager(new SecurityManager());
    BeanInfo info = Introspector.getBeanInfo(type);
    for (MethodDescriptor md : info.getMethodDescriptors()) {
        Method method = md.getMethod();
        System.out.println(method);

        String name = method.getDeclaringClass().getName();
        if (name.startsWith("sun.misc.")) {
            throw new Error("found inaccessible method");
        }
    }
}
 
源代码14 项目: hottub   文件: Test6277246.java
public static void main(String[] args) throws IntrospectionException {
    Class type = BASE64Encoder.class;
    System.setSecurityManager(new SecurityManager());
    BeanInfo info = Introspector.getBeanInfo(type);
    for (MethodDescriptor md : info.getMethodDescriptors()) {
        Method method = md.getMethod();
        System.out.println(method);

        String name = method.getDeclaringClass().getName();
        if (name.startsWith("sun.misc.")) {
            throw new Error("found inaccessible method");
        }
    }
}
 
源代码15 项目: openjdk-8-source   文件: Test6277246.java
public static void main(String[] args) throws IntrospectionException {
    Class type = BASE64Encoder.class;
    System.setSecurityManager(new SecurityManager());
    BeanInfo info = Introspector.getBeanInfo(type);
    for (MethodDescriptor md : info.getMethodDescriptors()) {
        Method method = md.getMethod();
        System.out.println(method);

        String name = method.getDeclaringClass().getName();
        if (name.startsWith("sun.misc.")) {
            throw new Error("found inaccessible method");
        }
    }
}
 
源代码16 项目: openjdk-8   文件: Test6277246.java
public static void main(String[] args) throws IntrospectionException {
    Class type = BASE64Encoder.class;
    System.setSecurityManager(new SecurityManager());
    BeanInfo info = Introspector.getBeanInfo(type);
    for (MethodDescriptor md : info.getMethodDescriptors()) {
        Method method = md.getMethod();
        System.out.println(method);

        String name = method.getDeclaringClass().getName();
        if (name.startsWith("sun.misc.")) {
            throw new Error("found inaccessible method");
        }
    }
}
 
源代码17 项目: jdk8u_jdk   文件: Test6277246.java
public static void main(String[] args) throws IntrospectionException {
    Class type = BASE64Encoder.class;
    System.setSecurityManager(new SecurityManager());
    BeanInfo info = Introspector.getBeanInfo(type);
    for (MethodDescriptor md : info.getMethodDescriptors()) {
        Method method = md.getMethod();
        System.out.println(method);

        String name = method.getDeclaringClass().getName();
        if (name.startsWith("sun.misc.")) {
            throw new Error("found inaccessible method");
        }
    }
}
 
源代码18 项目: mdw   文件: TaskNotifier.java
private Method getIncidentSetter(String name) throws IntrospectionException {
    if (incidentBeanInfo == null) {
        incidentBeanInfo = Introspector.getBeanInfo(Incident.class);
    }
    for (MethodDescriptor md : incidentBeanInfo.getMethodDescriptors()) {
        if (name.equals(md.getName()))
            return md.getMethod();
    }
    return null;
}
 
源代码19 项目: uyuni   文件: Acl.java
/** Register an AclHandler.
 * All methods with the valid signature will be registered.
 * <pre>
 *     public boolean aclXXX(Object, String[])
 * </pre>
 * or
 * <pre>
 *     public static boolean aclXXX(Object, String[])
 * </pre>
 * Methods without the "acl" prefix are ignored. If a method begins
 * with the "acl" prefix but the method signature is invalid, a
 * warning is logged and the method is ignored.
 *
 * @param aclHandler AclHandler
 */
public void registerHandler(AclHandler aclHandler) {

    try {
        Class clazz = aclHandler.getClass();
        // find all the acl* methods. and store them
        BeanInfo info = Introspector.getBeanInfo(clazz);
        MethodDescriptor[] methodDescriptors = info.getMethodDescriptors();

        for (int i = 0; i < methodDescriptors.length; ++i) {

            MethodDescriptor methodDescriptor = methodDescriptors[i];
            String methodName = methodDescriptor.getName();

            // we only care about methods with signatures:
            // public boolean aclXXX(Object obj, String[] params);
            if (!methodName.startsWith(ACL_PREFIX)) {
                continue;
            }
            Method method = methodDescriptor.getMethod();
            Class[] params = method.getParameterTypes();
            if (!method.getReturnType().equals(Boolean.TYPE) ||
               method.getExceptionTypes().length > 0 ||
               params.length != 2 ||
               !params[0].equals(Object.class) ||
               !params[1].equals(String[].class)) {
               log.warn(LocalizationService.getInstance().getMessage(
                            "bad-signature", method.toString()));

               continue;

            }

            String aclName = methodNameToAclName(methodName);
            handlers.put(aclName,
                    new InstanceMethodPair(aclHandler, method));
        }
    }
    // from reading the javadocs for IntrospectionException,
    // dont' really expect to get this one
    catch (IntrospectionException e) {
        IllegalArgumentException exc = new IllegalArgumentException();
        exc.initCause(e);
        throw exc;
    }

}
 
源代码20 项目: spacewalk   文件: Acl.java
/** Register an AclHandler.
 * All methods with the valid signature will be registered.
 * <pre>
 *     public boolean aclXXX(Object, String[])
 * </pre>
 * or
 * <pre>
 *     public static boolean aclXXX(Object, String[])
 * </pre>
 * Methods without the "acl" prefix are ignored. If a method begins
 * with the "acl" prefix but the method signature is invalid, a
 * warning is logged and the method is ignored.
 *
 * @param aclHandler AclHandler
 */
public void registerHandler(AclHandler aclHandler) {

    try {
        Class clazz = aclHandler.getClass();
        // find all the acl* methods. and store them
        BeanInfo info = Introspector.getBeanInfo(clazz);
        MethodDescriptor[] methodDescriptors = info.getMethodDescriptors();

        for (int i = 0; i < methodDescriptors.length; ++i) {

            MethodDescriptor methodDescriptor = methodDescriptors[i];
            String methodName = methodDescriptor.getName();

            // we only care about methods with signatures:
            // public boolean aclXXX(Object obj, String[] params);
            if (!methodName.startsWith(ACL_PREFIX)) {
                continue;
            }
            Method method = methodDescriptor.getMethod();
            Class[] params = method.getParameterTypes();
            if (!method.getReturnType().equals(Boolean.TYPE) ||
               method.getExceptionTypes().length > 0 ||
               params.length != 2 ||
               !params[0].equals(Object.class) ||
               !params[1].equals(String[].class)) {
               log.warn(LocalizationService.getInstance().getMessage(
                            "bad-signature", method.toString()));

               continue;

            }

            String aclName = methodNameToAclName(methodName);
            handlers.put(aclName,
                    new InstanceMethodPair(aclHandler, method));
        }
    }
    // from reading the javadocs for IntrospectionException,
    // dont' really expect to get this one
    catch (IntrospectionException e) {
        IllegalArgumentException exc = new IllegalArgumentException();
        exc.initCause(e);
        throw exc;
    }

}