Example usage for org.springframework.beans CachedIntrospectionResults clearClassLoader

List of usage examples for org.springframework.beans CachedIntrospectionResults clearClassLoader

Introduction

In this page you can find the example usage for org.springframework.beans CachedIntrospectionResults clearClassLoader.

Prototype

public static void clearClassLoader(@Nullable ClassLoader classLoader) 

Source Link

Document

Clear the introspection cache for the given ClassLoader, removing the introspection results for all classes underneath that ClassLoader, and removing the ClassLoader (and its children) from the acceptance list.

Usage

From source file:com.liferay.portal.spring.extender.internal.context.ModuleApplicationContextRegistrator.java

private void _cleanInstropectionCaches(Bundle bundle) {
    BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);

    CachedIntrospectionResults.clearClassLoader(bundleWiring.getClassLoader());

    Introspector.flushCaches();//w  ww .  ja v  a  2  s  . com
}

From source file:com.techtrip.dynbl.web.controllers.DynamicBeanController.java

@RequestMapping(method = RequestMethod.GET, value = "/registerBean")
@ResponseBody//from   w  w  w  . j  av a2s.c o  m
private String registerBean(@RequestParam(value = "beanName", required = true) String beanName,
        @RequestParam(value = "beanType", required = true) String beanType) {
    try {

        /* String demoMessage = getDemoMessage(); */

        Class<?> c;

        c = Class.forName(beanType);

        CachedIntrospectionResults.clearClassLoader(c.getClassLoader());

        beanFactory.registerBean(c, beanName, "prototype", false, true);

        Object myBean = beanFactory.getBean(beanName);

        String ret = PAGE_HEADER + SPRING_VERSION + BEAN_INFO_MSG + CLASSLOADER_DELAY + BEAN_INFO_HEADER
                + String.format(BEAN_INFO_FORMAT, beanName, myBean.getClass().getName(), myBean.toString()) /*
                                                                                                            * +
                                                                                                            * DEMO_MESSAGE_HEADER
                                                                                                            * +
                                                                                                            * tagHTML(
                                                                                                            * "p",
                                                                                                            * demoMessage
                                                                                                            * )
                                                                                                            */;

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(beanType);
        }

        /* CachedIntrospectionResults cir; */
        /*
         * 
         * if (ClassUtils.isCacheSafe(beanClass,
         * CachedIntrospectionResults.class.getClassLoader()) ||
         * isClassLoaderAccepted(beanClass.getClassLoader())) {
         */
        // CachedIntrospectionResults.clearClassLoader(c.getClassLoader());

        /* tripsDemo.getMessage(); */

        return ret;
    } catch (Exception e) {
        return String.format("Unable to create bean of type %s with the following error:</br>%s!", beanType,
                e.getMessage());
    }
}

From source file:br.com.uol.runas.classloader.ClassLoaderGC.java

private void releaseFromBeans(WeakReference<ClassLoader> classLoader) {
    CachedIntrospectionResults.clearClassLoader(classLoader.get());
    Introspector.flushCaches();
}

From source file:net.firejack.platform.model.config.listener.ConfigContextLoaderListener.java

@Override
public void contextDestroyed(ServletContextEvent event) {
    try {/*from   ww  w. j a v  a  2 s  .c  o m*/
        Map<String, BasicDataSource> dataSources = getCurrentWebApplicationContext()
                .getBeansOfType(BasicDataSource.class);
        for (BasicDataSource dataSource : dataSources.values()) {
            try {
                dataSource.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        Enumeration<Driver> drivers = DriverManager.getDrivers();
        while (drivers.hasMoreElements()) {
            try {
                DriverManager.deregisterDriver(drivers.nextElement());
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        JAXBContextCache.clearCaches();
        ClassFactory.cleanCache();
        CachedIntrospectionResults.clearClassLoader(getClass().getClassLoader());
    } finally {
        super.contextDestroyed(event);
    }
}

From source file:org.impalaframework.module.runtime.BaseModuleRuntime.java

public final void closeModule(Application application, RuntimeModule runtimeModule) {

    final ClassLoaderRegistry classLoaderRegistry = application.getClassLoaderRegistry();

    final ModuleDefinition moduleDefinition = runtimeModule.getModuleDefinition();
    final ClassLoader classLoader = classLoaderRegistry.removeClassLoader(moduleDefinition.getName());

    if (classLoader != null) {
        CachedIntrospectionResults.clearClassLoader(classLoader);
    }//  w w w . ja  v a  2s.com
    doCloseModule(application.getId(), runtimeModule);
}

From source file:org.springframework.context.support.AbstractApplicationContext.java

/**
 * Reset Spring's common core caches, in particular the {@link ReflectionUtils},
 * {@link ResolvableType} and {@link CachedIntrospectionResults} caches.
 * @since 4.2/* ww w .  jav a2  s.c o m*/
 * @see ReflectionUtils#clearCache()
 * @see ResolvableType#clearCache()
 * @see CachedIntrospectionResults#clearClassLoader(ClassLoader)
 */
protected void resetCommonCaches() {
    ReflectionUtils.clearCache();
    ResolvableType.clearCache();
    CachedIntrospectionResults.clearClassLoader(getClassLoader());
}