1 23 24 package org.objectweb.fractal.julia.control.content; 25 26 import org.objectweb.fractal.api.Component; 27 import org.objectweb.fractal.api.NoSuchInterfaceException; 28 import org.objectweb.fractal.api.control.ContentController; 29 import org.objectweb.fractal.api.control.IllegalContentException; 30 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 31 import org.objectweb.fractal.api.factory.InstantiationException; 32 33 import org.objectweb.fractal.julia.ChainedNoSuchInterfaceException; 34 import org.objectweb.fractal.julia.Controller; 35 import org.objectweb.fractal.julia.InitializationContext; 36 37 import java.util.ArrayList ; 38 import java.util.List ; 39 import java.util.Map ; 40 41 50 51 public abstract class BasicContentControllerMixin 52 implements Controller, ContentController 53 { 54 55 59 private BasicContentControllerMixin () { 60 } 61 62 66 70 71 public Map fcInternalInterfaces; 72 73 77 78 public List fcSubComponents; 79 80 87 88 public void initFcController (final InitializationContext ic) 89 throws InstantiationException 90 { 91 fcInternalInterfaces = ic.internalInterfaces; 92 _super_initFcController(ic); 93 } 94 95 public Object [] getFcInternalInterfaces () { 96 if (fcInternalInterfaces == null) { 97 return new Object [0]; 98 } 99 int size = 0; 102 String [] names = new String [fcInternalInterfaces.size()]; 103 names = (String [])fcInternalInterfaces.keySet().toArray(names); 104 for (int i = 0; i < names.length; ++i) { 105 if (names[i].charAt(0) != '/') { 106 ++size; 107 } 108 } 109 int index = 0; 110 Object [] itfs = new Object [size]; 111 for (int i = 0; i < names.length; ++i) { 112 if (names[i].charAt(0) != '/') { 113 itfs[index++] = fcInternalInterfaces.get(names[i]); 114 } 115 } 116 return itfs; 117 } 118 119 public Object getFcInternalInterface (final String interfaceName) 120 throws NoSuchInterfaceException 121 { 122 Object itf; 123 if (fcInternalInterfaces == null) { 124 itf = null; 125 } else { 126 itf = fcInternalInterfaces.get(interfaceName); 127 } 128 if (itf == null) { 129 throw new ChainedNoSuchInterfaceException( 130 null, _this_weaveableOptC, interfaceName); 131 } 132 return itf; 133 } 134 135 public Component[] getFcSubComponents () { 136 if (fcSubComponents == null) { 137 return new Component[0]; 138 } 139 return (Component[])fcSubComponents.toArray( 140 new Component[fcSubComponents.size()]); 141 } 142 143 public void addFcSubComponent (final Component subComponent) 144 throws IllegalContentException, IllegalLifeCycleException 145 { 146 if (fcSubComponents == null) { 147 fcSubComponents = new ArrayList (); 148 } 149 fcSubComponents.add(subComponent); 150 } 151 152 public void removeFcSubComponent (final Component subComponent) 153 throws IllegalContentException, IllegalLifeCycleException 154 { 155 if (fcSubComponents != null) { 156 fcSubComponents.remove(subComponent); 157 } 158 } 159 160 164 169 170 public Component _this_weaveableOptC; 171 172 180 181 public abstract void _super_initFcController (InitializationContext ic) 182 throws InstantiationException ; 183 } 184 | Popular Tags |