Java Ping Servers - Flyweight Reduce Memory Footprint
package ServerProbe; /* * Simple demonstration how to use the flyweight design pattern to improve performance and reduce * memory footprint. * Create a ServerFactory based on a pre-defined number of server types e.g. Windows, Unix etc * Within Server object, for example have a shareable method such as pingIT, also the server_type is * shareable * Pass IP address and ping duration in as parameters * */ public class Server { String server_type; Server(String type){ server_type = type; } String getType() { return server_type; } public void pingIT(String ip, int duration) { System.out.println("Pinging ->" + server_type + " IP -> " + ip); } public String toString() { return server_type; } } import java.util.HashMap; public class ServerFactory { private static final HashMap serverByType = new HashMap(); public static Server getServer(Strin