1 23 24 package org.objectweb.fractal.julia.control.binding; 25 26 import org.objectweb.fractal.api.control.BindingController; 27 import org.objectweb.fractal.api.control.IllegalBindingException; 28 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 29 import org.objectweb.fractal.api.NoSuchInterfaceException; 30 31 import org.objectweb.fractal.julia.ComponentInterface; 32 33 import java.util.Map ; 34 import java.util.HashMap ; 35 36 51 52 public abstract class OptimizedContainerBindingMixin 53 implements BindingController 54 { 55 56 60 private OptimizedContainerBindingMixin () { 61 } 62 63 67 72 73 public Map fcBindings; 74 75 82 83 public String [] listFc () { 84 Map fcBindings = getFcBindings(); 85 return (String [])fcBindings.keySet().toArray(new String [fcBindings.size()]); 86 } 87 88 103 104 public Object lookupFc (final String clientItfName) 105 throws NoSuchInterfaceException 106 { 107 Map fcBindings = getFcBindings(); 108 Object result = fcBindings.get(clientItfName); 109 if (result == fcBindings) { 110 result = null; 111 } 112 return result; 113 } 114 115 133 134 public void bindFc (final String clientItfName, final Object serverItf) throws 135 NoSuchInterfaceException, 136 IllegalBindingException, 137 IllegalLifeCycleException 138 { 139 Object o = serverItf; 140 if (o instanceof ComponentInterface) { 141 o = ((ComponentInterface)o).getFcItfImpl(); 142 } 143 if (o != null) { 144 _super_bindFc(clientItfName, o); 145 } 146 Map fcBindings = getFcBindings(); 147 fcBindings.put(clientItfName, serverItf); 148 } 149 150 164 165 public void unbindFc (final String clientItfName) throws 166 NoSuchInterfaceException, 167 IllegalBindingException, 168 IllegalLifeCycleException 169 { 170 _super_unbindFc(clientItfName); 171 if (fcBindings != null) { 172 fcBindings.put(clientItfName, fcBindings); 173 } 174 } 175 176 182 183 private Map getFcBindings () { 184 if (fcBindings == null) { 185 fcBindings = new HashMap (); 186 String [] names = _super_listFc(); 187 for (int i = 0; i < names.length; ++i) { 188 fcBindings.put(names[i], fcBindings); 189 } 190 } 191 return fcBindings; 192 } 193 194 198 205 206 public abstract String [] _super_listFc (); 207 208 220 221 public abstract Object _super_lookupFc (String clientItfName) throws 222 NoSuchInterfaceException; 223 224 236 237 public abstract void _super_bindFc (String clientItfName, Object serverItf) throws 238 NoSuchInterfaceException, 239 IllegalBindingException, 240 IllegalLifeCycleException; 241 242 254 255 public abstract void _super_unbindFc (String clientItfName) throws 256 NoSuchInterfaceException, 257 IllegalBindingException, 258 IllegalLifeCycleException; 259 } 260 | Popular Tags |