1 23 24 package org.objectweb.fractal.julia; 25 26 import org.objectweb.fractal.api.Component; 27 import org.objectweb.fractal.api.Type; 28 import org.objectweb.fractal.api.factory.InstantiationException; 29 30 import org.objectweb.fractal.julia.factory.ChainedInstantiationException; 31 32 import java.util.ArrayList ; 33 import java.util.HashMap ; 34 import java.util.List ; 35 import java.util.Map ; 36 37 41 42 public class InitializationContext { 43 44 47 48 public Type type; 49 50 54 55 public List controllers; 56 57 61 62 public Map interfaces; 63 64 68 69 public Map internalInterfaces; 70 71 74 75 public Object content; 76 77 80 81 public Object hints; 82 83 86 87 public InitializationContext () { 88 } 89 90 98 99 public void create () throws InstantiationException { 100 controllers = new ArrayList (); 101 interfaces = new HashMap (); 102 internalInterfaces = new HashMap (); 103 } 104 105 113 114 public Object getInterface (final String name) throws InstantiationException { 115 Object o = getOptionalInterface(name); 116 if (o == null) { 117 throw new ChainedInstantiationException( 118 null, 119 (Component)getOptionalInterface("component"), 120 "Cannot find the required interface '" + name + '\''); 121 } 122 return o; 123 } 124 125 133 134 public Object getOptionalInterface (final String name) { 135 Object o = interfaces.get(name); 136 if (o instanceof ComponentInterface) { 137 o = ((ComponentInterface)o).getFcItfImpl(); 138 } 139 return o; 140 } 141 } 142 | Popular Tags |