1 31 package org.objectweb.proactive.core.component; 32 33 import org.objectweb.fractal.api.NoSuchInterfaceException; 34 import org.objectweb.fractal.api.type.InterfaceType; 35 36 import org.objectweb.proactive.core.ProActiveRuntimeException; 37 import org.objectweb.proactive.core.component.controller.ComponentParametersController; 38 39 import java.io.Serializable ; 40 41 import java.util.Hashtable ; 42 import java.util.Map ; 43 import java.util.Vector ; 44 45 46 59 public class Bindings implements Serializable { 60 private Hashtable clientInterfaceBindings; 61 private Hashtable parallelInternalClientInterfaceBindings; 62 63 public Bindings() { 66 clientInterfaceBindings = new Hashtable (); 67 } 68 69 72 public void add(Binding binding) { 73 try { 74 InterfaceType client_itf_type = (InterfaceType) binding.getClientInterface() 75 .getFcItfType(); 76 if (client_itf_type.isFcCollectionItf()) { 77 addCollectiveBindingOnExternalClientItf(binding); 78 } else if (((ComponentParametersController) binding.getClientInterface() 79 .getFcItfOwner().getFcInterface(Constants.COMPONENT_PARAMETERS_CONTROLLER)).getComponentParameters() 80 .getHierarchicalType().equals(Constants.PARALLEL)) { 81 addCollectiveBindingOnInternalClientItf(binding); 82 } else { 83 clientInterfaceBindings.put(client_itf_type.getFcItfName(), 84 binding); 85 } 86 } catch (NoSuchInterfaceException nsie) { 87 throw new ProActiveRuntimeException("interface not found : " + 88 nsie.getMessage()); 89 } 90 } 91 92 94 97 public Object remove(String clientItfName) { 98 return clientInterfaceBindings.remove(clientItfName); 99 } 100 101 public Object get(String clientItfName) { 102 return clientInterfaceBindings.get(clientItfName); 103 } 104 105 110 public boolean containsBindingOn(String clientItfName) { 111 return clientInterfaceBindings.containsKey(clientItfName); 112 } 113 114 138 143 public String [] getExternalClientBindings() { 144 return (String []) clientInterfaceBindings.keySet().toArray(new String [clientInterfaceBindings.keySet() 145 .size()]); 146 } 147 148 private void addCollectiveBinding(Map bindingsTable, Binding binding) { 149 String clientItfName = binding.getClientInterface().getFcItfName(); 150 if (bindingsTable.containsKey(clientItfName)) { 151 ((Vector ) bindingsTable.get(clientItfName)).add(binding); 153 } else { Vector bindings_collection = new Vector (); 155 bindings_collection.add(binding); 156 bindingsTable.put(clientItfName, bindings_collection); 157 } 158 } 159 160 private void addCollectiveBindingOnExternalClientItf(Binding binding) { 161 addCollectiveBinding(clientInterfaceBindings, binding); 162 } 163 164 private void addCollectiveBindingOnInternalClientItf(Binding binding) { 165 if (parallelInternalClientInterfaceBindings == null) { 166 parallelInternalClientInterfaceBindings = new Hashtable (); 167 } 168 addCollectiveBinding(parallelInternalClientInterfaceBindings, binding); 169 } 170 } 171 | Popular Tags |