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

The following examples show how to use java.beans.Introspector#flushFromCaches() . 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: DefaultWidgetIntrospector.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
	Introspector.flushFromCaches(beanClass);
	BeanInfo bi = Introspector.getBeanInfo(beanClass);
	BeanDescriptor bd = bi.getBeanDescriptor();
	MethodDescriptor mds[] = bi.getMethodDescriptors();
	EventSetDescriptor esds[] = bi.getEventSetDescriptors();
	PropertyDescriptor pds[] = bi.getPropertyDescriptors();

	List<PropertyDescriptor> filteredPDList = new ArrayList<PropertyDescriptor>();
	
	List<String> nonPropList = Arrays.asList(getNonProperties());
	for(PropertyDescriptor pd : pds){
		if(!nonPropList.contains(pd.getName()) && pd.getWriteMethod() != null && pd.getReadMethod() != null)
			filteredPDList.add(pd);
	}
	
	int defaultEvent = bi.getDefaultEventIndex();
	int defaultProperty = bi.getDefaultPropertyIndex();

     return new GenericBeanInfo(bd, esds, defaultEvent, 
    		 filteredPDList.toArray(new PropertyDescriptor[filteredPDList.size()]),
			defaultProperty, mds, null);
	
}
 
Example 2
Source File: Cloneable.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void checkListeners() {
	BeanInfo beanInfo = null;
	try {
		beanInfo = Introspector.getBeanInfo( getClass(), Object.class );
		internalCheckListeners( beanInfo );
	}
	catch (IntrospectionException t) {
		throw new HibernateException( "Unable to validate listener config", t );
	}
	finally {
		if ( beanInfo != null ) {
			// release the jdk internal caches everytime to ensure this
			// plays nicely with destroyable class-loaders
			Introspector.flushFromCaches( getClass() );
		}
	}
}
 
Example 3
Source File: Cloneable.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void checkListeners() {
	BeanInfo beanInfo = null;
	try {
		beanInfo = Introspector.getBeanInfo( getClass(), Object.class );
		internalCheckListeners( beanInfo );
	}
	catch( IntrospectionException t ) {
		throw new HibernateException( "Unable to validate listener config", t );
	}
	finally {
		if ( beanInfo != null ) {
			// release the jdk internal caches everytime to ensure this
			// plays nicely with destroyable class-loaders
			Introspector.flushFromCaches( getClass() );
		}
	}
}
 
Example 4
Source File: GateClassLoader.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void forgetClassLoader(String id, Plugin dInfo) {

    if(dInfo == null) {
      forgetClassLoader(id);
      return;
    }

    GateClassLoader classloader = null;

    synchronized(childClassLoaders) {
      classloader = childClassLoaders.remove(id);
    }

    if(classloader != null && !classloader.isIsolated()) {
      // now only remove those classes from the caches that the
      // classloader was responsible for
      for(ResourceInfo rInfo : dInfo.getResourceInfoList()) {
        try {
          @SuppressWarnings("unchecked")
          Class<? extends Resource> c =
                  (Class<? extends Resource>)classloader.loadClass(
                          rInfo.getResourceClassName());
          
          if(c != null) {
            // in theory this shouldn't be needed as the Introspector
            // uses soft references if we move to requiring Java 8 it
            // should be safe to drop this call
            Introspector.flushFromCaches(c);

            AbstractResource.forgetBeanInfo(c);
          }
        } catch(ClassNotFoundException e) {
          // hmm not sure what to do now
           e.printStackTrace();
        }
      }
    }
  }
 
Example 5
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void testFlushFromCaches() throws IntrospectionException {
    BeanInfo info = Introspector.getBeanInfo(MockFooSubSub.class);
    BeanInfo info2 = Introspector.getBeanInfo(MockFooSubSub.class);
    assertSame(info, info2);
    Introspector.flushFromCaches(MockFooSubSub.class);
    BeanInfo info3 = Introspector.getBeanInfo(MockFooSubSub.class);
    assertNotSame(info, info3);
}
 
Example 6
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void testFlushFromCaches_Null() throws IntrospectionException {
    BeanInfo info = Introspector.getBeanInfo(MockJavaBean.class);
    BeanDescriptor beanDesc = new BeanDescriptor(MockJavaBean.class);
    assertEquals(beanDesc.getName(), info.getBeanDescriptor().getName());
    assertEquals(beanDesc.isExpert(), info.getBeanDescriptor().isExpert());
    try {
        Introspector.flushFromCaches(null);
        fail("Should throw NullPointerException.");
    } catch (NullPointerException e) {
    }
}
 
Example 7
Source File: InvokerHelper.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
public static void removeClass(Class clazz) {
    metaRegistry.removeMetaClass(clazz);
    Introspector.flushFromCaches(clazz);
}
 
Example 8
Source File: InvokerHelper.java    From groovy with Apache License 2.0 4 votes vote down vote up
public static void removeClass(Class clazz) {
    metaRegistry.removeMetaClass(clazz);
    ClassInfo.remove(clazz);
    Introspector.flushFromCaches(clazz);
}