本文整理汇总了Java中java.beans.Introspector.flushFromCaches方法的典型用法代码示例。如果您正苦于以下问题:Java Introspector.flushFromCaches方法的具体用法?Java Introspector.flushFromCaches怎么用?Java Introspector.flushFromCaches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.beans.Introspector
的用法示例。
在下文中一共展示了Introspector.flushFromCaches方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkListeners
import java.beans.Introspector; //导入方法依赖的package包/类
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() );
}
}
}
示例2: getBeanInfo
import java.beans.Introspector; //导入方法依赖的package包/类
/**
* @desc 根据对象获取对象所有属性、属性值
*
* @author liuliang
*
* @param entity 对象
* @return Map<String,Object> [key:属性名 value:属性名对应的值]
*/
public static Map<String,Object> getBeanInfo(Object entity){
Map<String,Object> map = new HashMap<String, Object>(16);
try {
Class<?> clazz = entity.getClass();
BeanInfo beanInfo = null;
if(null == methodCache.get(clazz)){
Class<?> superClazz =clazz.getSuperclass();
beanInfo = Introspector.getBeanInfo(clazz, superClazz);
methodCache.put(clazz, beanInfo);
Introspector.flushFromCaches(clazz);
if(null != superClazz){
Introspector.flushFromCaches(superClazz);
}
}else{
beanInfo = methodCache.get(clazz);
}
PropertyDescriptor[] pdArr = beanInfo.getPropertyDescriptors();
for(PropertyDescriptor pd:pdArr){
String fieldName = pd.getName();
Object fieldValue = getFieldValue(pd.getReadMethod(),entity);
map.put(fieldName, fieldValue);
}
} catch (IntrospectionException e) {
logger.error("获取对象信息异常,entity:{}",entity.getClass(),e);
}
return map;
}
示例3: forgetClassLoader
import java.beans.Introspector; //导入方法依赖的package包/类
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();
}
}
}
}