Skip to content

Instantly share code, notes, and snippets.

@ramapalani
Created March 27, 2014 00:53
Show Gist options
  • Save ramapalani/9797475 to your computer and use it in GitHub Desktop.
Save ramapalani/9797475 to your computer and use it in GitHub Desktop.
private static final ConcurrentMap<AppDescriptor, TestContainer> cache = new ConcurrentHashMap<AppDescriptor, TestContainer>();
private final TestContainerFactory tcf;
public OnePerAppDescriptorTestContainerFactory(TestContainerFactory tcf) {
this.tcf = tcf;
}
@Override
public Class<? extends AppDescriptor> supports() {
return tcf.supports();
}
@Override
public TestContainer create(URI baseUri, AppDescriptor ad) {
if (cache.get(ad) == null) {
cache.putIfAbsent(ad, tcf.create(baseUri, ad));
}
return cache.get(ad);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment