1 5 package ve.luz.ica.jackass.client; 6 7 import java.util.HashMap ; 8 import java.util.Map ; 9 10 import org.apache.commons.logging.Log; 11 import org.apache.commons.logging.LogFactory; 12 13 import org.omg.CORBA.ORB ; 14 import org.omg.CORBA.Object ; 15 16 23 final class SingleHostProxyManager implements ProxyManager 24 { 25 private static final Log LOG = LogFactory.getLog(SingleHostProxyManager.class); 26 27 private Map proxyMap; 28 private SolverManager solverMgr; 29 30 34 public SingleHostProxyManager(ORB orb) 35 { 36 proxyMap = new HashMap (); 37 solverMgr = new SingleHostSolverManager(orb); 38 if (LOG.isDebugEnabled()) LOG.debug("Initialized SolverMgr: " + solverMgr); 39 } 40 41 public Object getProxy(String componentID) 42 { 43 if (LOG.isDebugEnabled()) LOG.debug("Searching proxy cache"); 44 Object [] proxies = (Object []) proxyMap.get(componentID); 45 if (proxies == null) 46 { 47 if (LOG.isDebugEnabled()) LOG.debug("component is not in cache, forwarding to SolverManager"); 48 proxies = solverMgr.solve(componentID); 49 proxyMap.put(componentID, proxies); 50 if (LOG.isDebugEnabled()) LOG.debug("Proxies successfully obtained. Added to cache proxies " + proxies); 51 } 52 53 return proxies[0]; 54 } 55 56 62 public boolean isComponentFaulted(String componentID) 63 { 64 if (LOG.isWarnEnabled()) LOG.warn("Component is faulted"); 65 return true; 66 } 67 } 68 | Popular Tags |