本文整理汇总了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;
}
示例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);
}
}
}
示例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));
}
示例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");
}
}
}
示例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");
}
}
}
示例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;
}