當前位置: 首頁>>代碼示例>>Java>>正文


Java BeanInfo.getMethodDescriptors方法代碼示例

本文整理匯總了Java中java.beans.BeanInfo.getMethodDescriptors方法的典型用法代碼示例。如果您正苦於以下問題:Java BeanInfo.getMethodDescriptors方法的具體用法?Java BeanInfo.getMethodDescriptors怎麽用?Java BeanInfo.getMethodDescriptors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.beans.BeanInfo的用法示例。


在下文中一共展示了BeanInfo.getMethodDescriptors方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findMethod

import java.beans.BeanInfo; //導入方法依賴的package包/類
private static Method findMethod(Class<?> targetType, String methodName,
        Class<?>[] argTypes) throws IntrospectionException {
    BeanInfo beanInfo = Introspector.getBeanInfo(targetType);
    if (beanInfo != null) {
        for(MethodDescriptor methodDesc: beanInfo.getMethodDescriptors()) {
            Method method = methodDesc.getMethod();
            Class<?>[] parameterTypes = method.getParameterTypes();
            if (methodName.equals(method.getName()) && argTypes.length == parameterTypes.length) {
                boolean matchedArgTypes = true;
                for (int i = 0; i < argTypes.length; i++) { 
                    if (getWrapperIfPrimitive(argTypes[i]) != parameterTypes[i]) {
                        matchedArgTypes = false;
                        break;
                    }
                }
                if (matchedArgTypes) {
                    return method;
                }
            }
        }
    }
    return null;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:QuartzSchedulerMBeanImpl.java

示例2: ExtendedBeanInfo

import java.beans.BeanInfo; //導入方法依賴的package包/類
/**
 * Wrap the given {@link BeanInfo} instance; copy all its existing property descriptors
 * locally, wrapping each in a custom {@link SimpleIndexedPropertyDescriptor indexed}
 * or {@link SimplePropertyDescriptor non-indexed} {@code PropertyDescriptor}
 * variant that bypasses default JDK weak/soft reference management; then search
 * through its method descriptors to find any non-void returning write methods and
 * update or create the corresponding {@link PropertyDescriptor} for each one found.
 * @param delegate the wrapped {@code BeanInfo}, which is never modified
 * @throws IntrospectionException if any problems occur creating and adding new
 * property descriptors
 * @see #getPropertyDescriptors()
 */
public ExtendedBeanInfo(BeanInfo delegate) throws IntrospectionException {
	this.delegate = delegate;
	for (PropertyDescriptor pd : delegate.getPropertyDescriptors()) {
		this.propertyDescriptors.add(pd instanceof IndexedPropertyDescriptor ?
				new SimpleIndexedPropertyDescriptor((IndexedPropertyDescriptor) pd) :
				new SimplePropertyDescriptor(pd));
	}
	MethodDescriptor[] methodDescriptors = delegate.getMethodDescriptors();
	if (methodDescriptors != null) {
		for (Method method : findCandidateWriteMethods(methodDescriptors)) {
			handleCandidateWriteMethod(method);
		}
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:ExtendedBeanInfo.java

示例3: main

import java.beans.BeanInfo; //導入方法依賴的package包/類
public static void main(final String[] args) throws Exception {
    Class cl = getStub();
    System.out.println("cl.getClassLoader() = " + cl.getClassLoader());
    final BeanInfo beanInfo = Introspector.getBeanInfo(cl, Object.class);
    MethodDescriptor[] mds = beanInfo.getMethodDescriptors();
    System.out.println("mds = " + Arrays.toString(mds));
    loader.close();
    loader=null;
    cl=null;
    Util.generateOOME();
    mds = beanInfo.getMethodDescriptors();
    System.out.println("mds = " + Arrays.toString(mds));
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:14,代碼來源:UnloadClassBeanInfo.java

示例4: main

import java.beans.BeanInfo; //導入方法依賴的package包/類
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");
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:15,代碼來源:Test6277246.java

示例5: main

import java.beans.BeanInfo; //導入方法依賴的package包/類
public static void main(String[] args) throws IntrospectionException {
    Class type = sun.security.x509.X509CertInfo.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.")) {
            throw new Error("found inaccessible method");
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:Test6277246.java

示例6: instantiate

import java.beans.BeanInfo; //導入方法依賴的package包/類
@Override
protected BeanInfo instantiate(Class<?> type, String prefix, String name) {
    if (DEFAULT.equals(prefix)) {
        prefix = DEFAULT_NEW;
    }
    // this optimization will only use the BeanInfo search path
    // if is has changed from the original
    // or trying to get the ComponentBeanInfo
    BeanInfo info = !DEFAULT_NEW.equals(prefix) || "ComponentBeanInfo".equals(name)
            ? super.instantiate(type, prefix, name)
            : null;

    if (info != null) {
        // make sure that the returned BeanInfo matches the class
        BeanDescriptor bd = info.getBeanDescriptor();
        if (bd != null) {
            if (type.equals(bd.getBeanClass())) {
                return info;
            }
        }
        else {
            PropertyDescriptor[] pds = info.getPropertyDescriptors();
            if (pds != null) {
                for (PropertyDescriptor pd : pds) {
                    Method method = pd.getReadMethod();
                    if (method == null) {
                        method = pd.getWriteMethod();
                    }
                    if (isValid(type, method)) {
                        return info;
                    }
                }
            }
            else {
                MethodDescriptor[] mds = info.getMethodDescriptors();
                if (mds != null) {
                    for (MethodDescriptor md : mds) {
                        if (isValid(type, md.getMethod())) {
                            return info;
                        }
                    }
                }
            }
        }
    }
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:48,代碼來源:BeanInfoFinder.java


注:本文中的java.beans.BeanInfo.getMethodDescriptors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。