1 28 29 package org.objectweb.util.explorer.core.common.lib; 30 31 import java.util.HashMap ; 32 import java.util.Map ; 33 34 import org.objectweb.fractal.api.NoSuchInterfaceException; 35 import org.objectweb.fractal.api.control.BindingController; 36 import org.objectweb.fractal.api.control.IllegalBindingException; 37 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 38 39 40 45 public abstract class BindingFeature 46 extends BasicLoggable 47 implements BindingController 48 { 49 50 private Map fcBindings ; 51 52 55 private Map getFcBindings() { 56 return fcBindings; 57 } 58 59 62 private void setFcBindings(Map fcBindings) { 63 this.fcBindings = fcBindings; 64 } 65 66 public BindingFeature() { 67 setFcBindings(new HashMap ()); 68 } 69 70 76 private String checkBinding(String name) 77 throws NoSuchInterfaceException 78 { 79 String [] list = clientFc(); 80 for (int i=0 ; i < list.length ; i++) 81 if (name.startsWith(list[i])) 82 return name ; 83 throw new NoSuchInterfaceException(name); 84 } 85 86 protected Object lookupFc(int index) { 87 try { 88 return lookupFc(listFc()[index]); 89 } catch (NoSuchInterfaceException e) { 90 return null; 91 } catch (ArrayIndexOutOfBoundsException e2) { 92 return null; 93 } 94 } 95 96 public abstract String [] clientFc(); 97 98 101 public String [] listFc() { 102 return (String []) getFcBindings().keySet().toArray(new String [0]); 103 } 104 105 108 public Object lookupFc(String arg0) 109 throws NoSuchInterfaceException 110 { 111 return getFcBindings().get(checkBinding(arg0)); 112 } 113 114 117 public void bindFc(String arg0, Object arg1) 118 throws NoSuchInterfaceException, 119 IllegalBindingException, 120 IllegalLifeCycleException 121 { 122 getFcBindings().put(checkBinding(arg0),arg1); 123 } 124 125 128 public void unbindFc(String arg0) 129 throws NoSuchInterfaceException, 130 IllegalBindingException, 131 IllegalLifeCycleException 132 { 133 getFcBindings().remove(checkBinding(arg0)); 134 } 135 } | Popular Tags |