Search in sources :

Example 1 with ServiceLocatorRuntimeBean

use of org.jvnet.hk2.external.runtime.ServiceLocatorRuntimeBean in project jersey by jersey.

the class HK2InjectionManager method initialize.

@Override
public void initialize(String name, Object parent, Binder... binders) {
    ServiceLocator parentLocator = resolveServiceLocatorParent(parent);
    this.locator = createLocator(name, parentLocator);
    // Register all components needed for proper HK2 locator bootstrap
    Hk2Helper.bind(locator, new Hk2BootstrapBinder(this, CompositeBinder.wrap(binders)));
    this.locator.setDefaultClassAnalyzerName(JerseyClassAnalyzer.NAME);
    // clear HK2 caches
    ServiceLocatorRuntimeBean serviceLocatorRuntimeBean = locator.getService(ServiceLocatorRuntimeBean.class);
    if (serviceLocatorRuntimeBean != null) {
        if (LOGGER.isLoggable(Level.FINE)) {
            LOGGER.fine(LocalizationMessages.HK_2_CLEARING_CACHE(serviceLocatorRuntimeBean.getServiceCacheSize(), serviceLocatorRuntimeBean.getReflectionCacheSize()));
        }
        serviceLocatorRuntimeBean.clearReflectionCache();
        serviceLocatorRuntimeBean.clearServiceCache();
    }
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) ServiceLocatorRuntimeBean(org.jvnet.hk2.external.runtime.ServiceLocatorRuntimeBean)

Aggregations

ServiceLocator (org.glassfish.hk2.api.ServiceLocator)1 ServiceLocatorRuntimeBean (org.jvnet.hk2.external.runtime.ServiceLocatorRuntimeBean)1