1 24 import java.util.HashMap ; 25 import java.util.Iterator ; 26 import java.util.Map ; 27 28 import org.objectweb.fractal.api.NoSuchInterfaceException; 29 import org.objectweb.fractal.api.control.BindingController; 30 import org.objectweb.fractal.api.control.IllegalBindingException; 31 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 32 33 36 public class ServiceDuplicatorImpl implements Service, BindingController 37 { 38 39 Map services = new HashMap (); 40 41 public void print(String msg) 42 { 43 Iterator iter = services.values().iterator(); 44 while (iter.hasNext()) 45 { 46 Service serviceItf = (Service) iter.next(); 47 serviceItf.print(msg); 48 } 49 } 50 51 public String [] listFc() 52 { 53 return (String []) services.keySet().toArray(new String [services.size()]); 54 } 55 56 public Object lookupFc(String clientItfName) throws NoSuchInterfaceException 57 { 58 return services.get(clientItfName); 59 } 60 61 public void bindFc(String clientItfName, Object serverItf) 62 throws NoSuchInterfaceException, IllegalBindingException, 63 IllegalLifeCycleException 64 { 65 if (clientItfName.startsWith("clientService")) 66 { 67 services.put(clientItfName, serverItf); 68 } 69 } 70 71 public void unbindFc(String clientItfName) throws NoSuchInterfaceException, 72 IllegalBindingException, IllegalLifeCycleException 73 { 74 if (clientItfName.startsWith("clientService")) 75 { 76 services.remove(clientItfName); 77 } 78 } 79 }
| Popular Tags
|