Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Refactor initialization logic for cache container.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmunoz committed Nov 28, 2014
1 parent b2c6d3b commit 0501b44
Showing 1 changed file with 13 additions and 15 deletions.
Expand Up @@ -52,24 +52,22 @@ public class CacheContainerProducer {

@Create
public void initialize() {
getCacheContainer();
try {
container =
ServiceLocator.instance().getJndiComponent(
CACHE_CONTAINER_NAME,
CacheContainer.class);
} catch (NamingException e) {
String msg = "A cache container with name " +
"'" + CACHE_CONTAINER_NAME + "' " +
"has not been configured.";
log.warn(msg);
throw new RuntimeException(msg, e);
}
}

@Unwrap
public synchronized CacheContainer getCacheContainer() {
if(container == null) {
try {
return ServiceLocator.instance().getJndiComponent(CACHE_CONTAINER_NAME,
CacheContainer.class);
}
catch (NamingException e) {
String msg = "A cache container with name " +
"'" + CACHE_CONTAINER_NAME + "' " +
"has not been configured.";
log.warn(msg);
throw new RuntimeException(msg, e);
}
}
public CacheContainer getCacheContainer() {
return container;
}
}

0 comments on commit 0501b44

Please sign in to comment.