Created
May 17, 2012 00:02
-
-
Save anonymous/2715028 to your computer and use it in GitHub Desktop.
Container and module using third party library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ContainerUsingLibrary extends Container | |
{ | |
private final Resource resource = ResourceLibrary.getResource(ContainerUsingLibrary.class); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ModuleUsingLibrary extends Module | |
{ | |
private final Resource resource = ResourceLibrary.getResource(ModuleUsingLibrary.class); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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