Skip to content

Instantly share code, notes, and snippets.

Created May 17, 2012 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2715028 to your computer and use it in GitHub Desktop.
Save anonymous/2715028 to your computer and use it in GitHub Desktop.
Container and module using third party library
public class ContainerUsingLibrary extends Container
{
private final Resource resource = ResourceLibrary.getResource(ContainerUsingLibrary.class);
}
public class ModuleUsingLibrary extends Module
{
private final Resource resource = ResourceLibrary.getResource(ModuleUsingLibrary.class);
}
public class ResourceLibrary
{
// simulate a 3rd party library that holds references to its clients
private static final Map<Class<?>, Resource> lookup = new HashMap<Class<?>, Resource>();
public static synchronized Resource getResource(Class<?> clazz)
{
if (!lookup.containsKey(clazz))
{
lookup.put(clazz, new Resource());
}
return lookup.get(clazz);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment