Skip to content
This repository has been archived by the owner on May 28, 2018. It is now read-only.

Commit

Permalink
Clearing HK2 locator caches after the locator is initialised.
Browse files Browse the repository at this point in the history
Change-Id: I3379c7914e95bf36191d672fef1820efb03f8829
Signed-off-by: Jakub Podlesak <[email protected]>
  • Loading branch information
japod authored and pavelbucek committed Sep 16, 2015
1 parent c80d563 commit 2ccb947
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.hk2.utilities.binding.ScopedBindingBuilder;

import org.jvnet.hk2.external.runtime.ServiceLocatorRuntimeBean;

import jersey.repackaged.com.google.common.base.Function;
import jersey.repackaged.com.google.common.base.Predicate;
import jersey.repackaged.com.google.common.collect.Collections2;
Expand Down Expand Up @@ -594,9 +596,22 @@ private ServerRuntime initialize(Iterable<ComponentProvider> componentProviders)
.to(routingStage)
.to(resourceFilteringStage)
.build(Routing.matchedEndpointExtractor());

final ServerRuntime serverRuntime = locator.createAndInitialize(ServerRuntime.Builder.class)
.build(rootStage, compositeListener, processingProviders);

// clear HK2 caches
final ServiceLocatorRuntimeBean serviceLocatorRuntimeBean = locator.getService(ServiceLocatorRuntimeBean.class);
if (serviceLocatorRuntimeBean != null) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine(LocalizationMessages.CLEARING_HK_2_CACHE(
serviceLocatorRuntimeBean.getServiceCacheSize(),
serviceLocatorRuntimeBean.getReflectionCacheSize()));
}
serviceLocatorRuntimeBean.clearReflectionCache();
serviceLocatorRuntimeBean.clearServiceCache();
}

// Inject instances.
for (final Object instance : componentBag.getInstances(ComponentBag.EXCLUDE_META_PROVIDERS)) {
locator.inject(instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ form.param.method.error=The "@FormParam" is utilized when the request method is
get.consumes.entity=A HTTP GET method, {0}, should not consume any entity.
get.consumes.form.param=A HTTP GET method, {0}, should not consume any form parameter.
get.returns.void=A HTTP GET method, {0}, returns a void type. It can be intentional and perfectly fine, but it is a little uncommon that GET method returns always "204 No Content".
clearing.hk2.cache=Clearing Jersey HK2 caches. Service cache size: {0}, reflection cache size: {1}.
chunked.output.closed=This chunked output has been closed.
illegal.client.config.class.property.value="{0}" property value ({1}) does not represent a valid client configuration class. Falling back to "{2}".
init.msg=Initiating Jersey application, version {0}...
Expand Down

0 comments on commit 2ccb947

Please sign in to comment.