1 25 26 package org.objectweb.easybeans.server; 27 28 import java.lang.ref.WeakReference ; 29 import java.util.Map ; 30 import java.util.WeakHashMap ; 31 32 import org.objectweb.easybeans.api.EZBServer; 33 34 40 public final class EmbeddedManager { 41 42 45 private EmbeddedManager() { 46 47 } 48 49 52 private static Map <Integer , WeakReference <EZBServer>> servers = new WeakHashMap <Integer , WeakReference <EZBServer>>(); 53 54 55 60 public static EZBServer getEmbedded(final Integer id) { 61 WeakReference <EZBServer> weakRef = servers.get(id); 62 if (weakRef != null) { 63 return weakRef.get(); 64 } 65 return null; 67 } 68 69 73 protected static void addEmbedded(final EZBServer embedded) { 74 Integer id = embedded.getID(); 76 77 WeakReference <EZBServer> weakRef = new WeakReference <EZBServer>(embedded); 79 80 servers.put(id, weakRef); 82 } 83 84 } 85 | Popular Tags |