I figured out how to efficiently do the HaD for classes. Not too hard actually. This will allow key framework classes to be hot deployed and will act as a simpler, though how effective remains to be seen, way to solve the problem IoC is presently used to solve through dependency injection. The solution is at http://131.191.32.112:8080/classes.zip . Essentially it is a simple wrapper solution. I suggest that those interested have a look. There is a test class to run it and see what is up.
The PointFactory actually can be generalized for all classes when Sun's Tiger is out with the generic capabilities. The main classes are given below. I find hot deploy at least a very interesting if not a real (and I suspect a real) possibility and hope that the mavens on the list will not mind me expressing my view. This is the only place I know to do it, other than the forest, and that creates all those philosophical problems. I think calling this [OT] and relegating it to the level of Friday beer conversations should appease those who find this sort of discussion noisy. Peace, Jack package com.crackwillow.deploy; import java.io.Serializable; import com.crackwillow.state.StateContainer; public interface Point extends Serializable { public int getId(); public int getX(); public int getY(); public void move(int dx, int dy); //------------- DEPLOY UTILITIES ---------------------- public StateContainer getState(); public void setState(StateContainer state); } package com.crackwillow.deploy; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.Iterator; import java.util.Set; import java.util.WeakHashMap; import com.crackwillow.constant.SiteConstant; import com.crackwillow.deploy.Point; import com.crackwillow.id.Id; public class PointFactory { private transient static WeakHashMap references = new WeakHashMap(); private static ClassLoader pointClassLoader; private static Class pointClass; public static synchronized void setObject(Id id) { // Clear references that are cut loose. System.gc(); references.put(id,createPoint(null)); } public static synchronized Point getObject(Id id) { Point point = (Point)references.get(id); return point; } public static synchronized Point createPoint(Point existingPoint) { if (pointClass == null) { loadImpl(); } Point newPoint = null; try { newPoint = (Point) pointClass.newInstance(); } catch(InstantiationException ie) { ie.printStackTrace(); } catch(IllegalAccessException iae) { iae.printStackTrace(); } if (existingPoint != null) { newPoint.move(existingPoint.getX(), existingPoint.getY()); } return newPoint; } public static synchronized void loadImpl() { try { pointClassLoader = new URLClassLoader(new URL[] { new URL(SiteConstant.DEPLOY) }); } catch (MalformedURLException mue) { mue.printStackTrace(); } try { pointClass = pointClassLoader.loadClass("com.crackwillow.deploy.PointImpl"); } catch (ClassNotFoundException cnfe) { cnfe.printStackTrace(); } System.out.println(references); Set set = references.keySet(); Iterator iter = set.iterator(); while(iter.hasNext()) { Id id = (Id)iter.next(); if(id != null) { Point point = (Point)references.get(id); point = PointFactory.createPoint(point); references.put(id,point); } } } } package com.crackwillow.point; import com.crackwillow.deploy.PointFactory; import com.crackwillow.id.Id; public class Point { public Point() { PointFactory.setObject(id = new Id()); } public int getX() { return getObject(id).getX(); } public int getY() { return getObject(id).getY(); } public void move(int dx, int dy) { getObject(id).move(dx,dy); } //------------- DEPLOY UTILITIES ---------------------- private final Id id; private com.crackwillow.deploy.Point getObject(Id id) { return PointFactory.getObject(id); } } package com.crackwillow.deploy; import java.util.Collections; import java.util.Map; import java.util.Set; import com.crackwillow.state.StateContainer; public class PointImpl implements Point { public static int mainId; public int id; private int x; private int y; public PointImpl() { mainId += 1; id = mainId; } public int getId() { return id; } public int getX() { return x; } public int getY() { return y; } public void move(int dx, int dy) { // Change these to test hot deploy x += dx; y += dy; } public boolean equals(Object object) { if(!(object instanceof PointImpl)) { return false; } else { return (id == ((PointImpl)object).id); } } public int hashCode() { return id; } public int compareTo(Object object) { if(id == ((PointImpl)object).id) { return 0; } else if(id < ((PointImpl)object).id) { return -1; } else { return +1; } } public String toString() { return "Point[id = " + id + " x = " + x + " y = " + y + "]"; } // Hot deploy added code ------------------------------------------- public StateContainer getState() { return new StateContainer().putState("x",new Integer(x)) .putState("y",new Integer(y)); } public void setState(StateContainer state) { x = ((Integer)state.get("x")).intValue(); y = ((Integer)state.get("y")).intValue(); } } package com.crackwillow.id; public class Id implements Comparable { private static int count; public final int id; public Id() { id = ++count; } public boolean equals(Object object) { if(!(object instanceof Id)) { return false; } else { return (id == ((Id)object).id); } } public int hashCode() { return id; } public int compareTo(Object object) { if(id == ((Id)object).id) { return 0; } else if(id < ((Id)object).id) { return -1; } else { return +1; } } public String toString() { return "Id[id = " + id + " count = " + count + "]"; } } -- "You can't wake a person who is pretending to be asleep." ~Native Proverb~ "Each man is good in His sight. It is not necessary for eagles to be crows." ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]