Java Code Examples for java.beans.Introspector#getBeanInfoSearchPath()

The following examples show how to use java.beans.Introspector#getBeanInfoSearchPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeanNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Checks whether there is an explicit bean info for given class.
* @param clazz the class to test
* @return true if explicit bean info exists
*/
private boolean hasExplicitBeanInfo(Class<?> clazz) {
    String className = clazz.getName();
    int indx = className.lastIndexOf('.');
    className = className.substring(indx + 1);

    String[] paths = Introspector.getBeanInfoSearchPath();

    for (int i = 0; i < paths.length; i++) {
        String s = paths[i] + '.' + className + "BeanInfo"; // NOI18N

        try {
            // test if such class exists
            Class.forName(s);

            return true;
        } catch (ClassNotFoundException ex) {
            // OK, this is normal.
        }
    }

    return false;
}
 
Example 2
Source File: Test4520754.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a regression test to ensure that 4168475 does not regress.
 */
private static void test4168475(Class type) {
    String[] newPath = {"infos"};
    String[] oldPath = Introspector.getBeanInfoSearchPath();

    Introspector.setBeanInfoSearchPath(newPath);
    BeanInfo info = getBeanInfo(Boolean.TRUE, type);
    Introspector.setBeanInfoSearchPath(oldPath);

    PropertyDescriptor[] pds = info.getPropertyDescriptors();
    if (pds.length != 1) {
        throw new Error("could not find custom BeanInfo for " + type);
    }
    Introspector.flushCaches();
}
 
Example 3
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * The test checks the getBeanDescriptor method
 */
public void testBeanDescriptor() throws Exception {
    String[] oldBeanInfoSearchPath = Introspector.getBeanInfoSearchPath();
    try {
        Introspector
                .setBeanInfoSearchPath(new String[] { "java.beans.infos" });
        BeanInfo info = Introspector.getBeanInfo(SampleBean.class);
        assertNotNull(info);
        BeanDescriptor descriptor = info.getBeanDescriptor();
        assertNotNull(descriptor);
        assertEquals(SampleBean.class, descriptor.getBeanClass());
    } finally {
        Introspector.setBeanInfoSearchPath(oldBeanInfoSearchPath);
    }
}
 
Example 4
Source File: Test4520754.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a regression test to ensure that 4168475 does not regress.
 */
private static void test4168475(Class type) {
    String[] newPath = {"infos"};
    String[] oldPath = Introspector.getBeanInfoSearchPath();

    Introspector.setBeanInfoSearchPath(newPath);
    BeanInfo info = getBeanInfo(Boolean.TRUE, type);
    Introspector.setBeanInfoSearchPath(oldPath);

    PropertyDescriptor[] pds = info.getPropertyDescriptors();
    if (pds.length != 1) {
        throw new Error("could not find custom BeanInfo for " + type);
    }
    Introspector.flushCaches();
}
 
Example 5
Source File: Test4520754.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a regression test to ensure that 4168475 does not regress.
 */
private static void test4168475(Class type) {
    String[] newPath = {"infos"};
    String[] oldPath = Introspector.getBeanInfoSearchPath();

    Introspector.setBeanInfoSearchPath(newPath);
    BeanInfo info = getBeanInfo(Boolean.TRUE, type);
    Introspector.setBeanInfoSearchPath(oldPath);

    PropertyDescriptor[] pds = info.getPropertyDescriptors();
    if (pds.length != 1) {
        throw new Error("could not find custom BeanInfo for " + type);
    }
    Introspector.flushCaches();
}
 
Example 6
Source File: Test4520754.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a regression test to ensure that 4168475 does not regress.
 */
private static void test4168475(Class type) {
    String[] newPath = {"infos"};
    String[] oldPath = Introspector.getBeanInfoSearchPath();

    Introspector.setBeanInfoSearchPath(newPath);
    BeanInfo info = getBeanInfo(Boolean.TRUE, type);
    Introspector.setBeanInfoSearchPath(oldPath);

    PropertyDescriptor[] pds = info.getPropertyDescriptors();
    if (pds.length != 1) {
        throw new Error("could not find custom BeanInfo for " + type);
    }
    Introspector.flushCaches();
}
 
Example 7
Source File: Test4520754.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a regression test to ensure that 4168475 does not regress.
 */
private static void test4168475(Class type) {
    String[] newPath = {"infos"};
    String[] oldPath = Introspector.getBeanInfoSearchPath();

    Introspector.setBeanInfoSearchPath(newPath);
    BeanInfo info = getBeanInfo(Boolean.TRUE, type);
    Introspector.setBeanInfoSearchPath(oldPath);

    PropertyDescriptor[] pds = info.getPropertyDescriptors();
    if (pds.length != 1) {
        throw new Error("could not find custom BeanInfo for " + type);
    }
    Introspector.flushCaches();
}
 
Example 8
Source File: Test4520754.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a regression test to ensure that 4168475 does not regress.
 */
private static void test4168475(Class type) {
    String[] newPath = {"infos"};
    String[] oldPath = Introspector.getBeanInfoSearchPath();

    Introspector.setBeanInfoSearchPath(newPath);
    BeanInfo info = getBeanInfo(Boolean.TRUE, type);
    Introspector.setBeanInfoSearchPath(oldPath);

    PropertyDescriptor[] pds = info.getPropertyDescriptors();
    if (pds.length != 1) {
        throw new Error("could not find custom BeanInfo for " + type);
    }
    Introspector.flushCaches();
}
 
Example 9
Source File: Test4520754.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a regression test to ensure that 4168475 does not regress.
 */
private static void test4168475(Class type) {
    String[] newPath = {"infos"};
    String[] oldPath = Introspector.getBeanInfoSearchPath();

    Introspector.setBeanInfoSearchPath(newPath);
    BeanInfo info = getBeanInfo(Boolean.TRUE, type);
    Introspector.setBeanInfoSearchPath(oldPath);

    PropertyDescriptor[] pds = info.getPropertyDescriptors();
    if (pds.length != 1) {
        throw new Error("could not find custom BeanInfo for " + type);
    }
    Introspector.flushCaches();
}
 
Example 10
Source File: Test4520754.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a regression test to ensure that 4168475 does not regress.
 */
private static void test4168475(Class type) {
    String[] newPath = {"infos"};
    String[] oldPath = Introspector.getBeanInfoSearchPath();

    Introspector.setBeanInfoSearchPath(newPath);
    BeanInfo info = getBeanInfo(Boolean.TRUE, type);
    Introspector.setBeanInfoSearchPath(oldPath);

    PropertyDescriptor[] pds = info.getPropertyDescriptors();
    if (pds.length != 1) {
        throw new Error("could not find custom BeanInfo for " + type);
    }
    Introspector.flushCaches();
}
 
Example 11
Source File: Test4520754.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a regression test to ensure that 4168475 does not regress.
 */
private static void test4168475(Class type) {
    String[] newPath = {"infos"};
    String[] oldPath = Introspector.getBeanInfoSearchPath();

    Introspector.setBeanInfoSearchPath(newPath);
    BeanInfo info = getBeanInfo(Boolean.TRUE, type);
    Introspector.setBeanInfoSearchPath(oldPath);

    PropertyDescriptor[] pds = info.getPropertyDescriptors();
    if (pds.length != 1) {
        throw new Error("could not find custom BeanInfo for " + type);
    }
    Introspector.flushCaches();
}
 
Example 12
Source File: Test4520754.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a regression test to ensure that 4168475 does not regress.
 */
private static void test4168475(Class type) {
    String[] newPath = {"infos"};
    String[] oldPath = Introspector.getBeanInfoSearchPath();

    Introspector.setBeanInfoSearchPath(newPath);
    BeanInfo info = getBeanInfo(Boolean.TRUE, type);
    Introspector.setBeanInfoSearchPath(oldPath);

    PropertyDescriptor[] pds = info.getPropertyDescriptors();
    if (pds.length != 1) {
        throw new Error("could not find custom BeanInfo for " + type);
    }
    Introspector.flushCaches();
}
 
Example 13
Source File: PEAnnotationProcessorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testBeanInfoRegistration() {
    NodeOp.registerPropertyEditors();
    NodeOp.registerPropertyEditors();
    
    int count = 0;
    String[] path = Introspector.getBeanInfoSearchPath();
    for (int i = 0; i < path.length; i++) {
        if ("org.netbeans.modules.openide.nodes".equals(path[i])) {
            count++;
        }
    }
    assertFalse("Package path is registered multiple times", count > 1);
    assertFalse("Package path is not registered", count == 0);
}
 
Example 14
Source File: Test4520754.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a regression test to ensure that 4168475 does not regress.
 */
private static void test4168475(Class type) {
    String[] newPath = {"infos"};
    String[] oldPath = Introspector.getBeanInfoSearchPath();

    Introspector.setBeanInfoSearchPath(newPath);
    BeanInfo info = getBeanInfo(Boolean.TRUE, type);
    Introspector.setBeanInfoSearchPath(oldPath);

    PropertyDescriptor[] pds = info.getPropertyDescriptors();
    if (pds.length != 1) {
        throw new Error("could not find custom BeanInfo for " + type);
    }
    Introspector.flushCaches();
}
 
Example 15
Source File: Test4520754.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a regression test to ensure that 4168475 does not regress.
 */
private static void test4168475(Class type) {
    String[] newPath = {"infos"};
    String[] oldPath = Introspector.getBeanInfoSearchPath();

    Introspector.setBeanInfoSearchPath(newPath);
    BeanInfo info = getBeanInfo(Boolean.TRUE, type);
    Introspector.setBeanInfoSearchPath(oldPath);

    PropertyDescriptor[] pds = info.getPropertyDescriptors();
    if (pds.length != 1) {
        throw new Error("could not find custom BeanInfo for " + type);
    }
    Introspector.flushCaches();
}
 
Example 16
Source File: Test4520754.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a regression test to ensure that 4168475 does not regress.
 */
private static void test4168475(Class type) {
    String[] newPath = {"infos"};
    String[] oldPath = Introspector.getBeanInfoSearchPath();

    Introspector.setBeanInfoSearchPath(newPath);
    BeanInfo info = getBeanInfo(Boolean.TRUE, type);
    Introspector.setBeanInfoSearchPath(oldPath);

    PropertyDescriptor[] pds = info.getPropertyDescriptors();
    if (pds.length != 1) {
        throw new Error("could not find custom BeanInfo for " + type);
    }
    Introspector.flushCaches();
}
 
Example 17
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Override
protected void setUp() throws Exception {
    super.setUp();
    defaultPackage = Introspector.getBeanInfoSearchPath();
}
 
Example 18
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 4 votes vote down vote up
public void testGetBeanInfoSearchPath() {
    String[] path = Introspector.getBeanInfoSearchPath();
    assertEquals(1, path.length);
    assertTrue(path[0].endsWith("beans.infos"));
}