Thursday, May 22, 2014

Multiton Pattern (Registry of Singletons) in Java


Simple Note

From reference:
The multiton pattern expands on the singleton concept to manage a map of named instances as key-value pairs.
Rather than having a single instance per application (e.g. the java.lang.Runtime object in the Java programming language) the multiton pattern instead ensures a single instance per key.

Program

https://github.com/benbai123/JSP_Servlet_Practice/tree/master/Practice/JAVA/DesignPattern/src/multiton

Run TestMain.java to test.

Put Vitamin into VitaminBox, there is only one VitaminBox for a kind of Vitamin.

Reference:

Multiton pattern

No comments:

Post a Comment