1 23 24 package org.objectweb.fractal.adl; 25 26 import java.util.HashMap ; 27 import java.util.Map ; 28 29 import org.objectweb.deployment.scheduling.core.lib.BasicScheduler; 30 import org.objectweb.fractal.adl.arguments.ArgumentComponentLoader; 31 import org.objectweb.fractal.adl.arguments.ArgumentLoader; 32 import org.objectweb.fractal.adl.attributes.AttributeCompiler; 33 import org.objectweb.fractal.adl.attributes.AttributeLoader; 34 import org.objectweb.fractal.adl.attributes.JavaAttributeBuilder; 35 import org.objectweb.fractal.adl.bindings.BindingCompiler; 36 import org.objectweb.fractal.adl.bindings.JavaBindingBuilder; 37 import org.objectweb.fractal.adl.bindings.TypeBindingLoader; 38 import org.objectweb.fractal.adl.components.ComponentCompiler; 39 import org.objectweb.fractal.adl.components.JavaComponentBuilder; 40 import org.objectweb.fractal.adl.components.PrimitiveComponentCompiler; 41 import org.objectweb.fractal.adl.implementations.ImplementationCompiler; 42 import org.objectweb.fractal.adl.implementations.ImplementationLoader; 43 import org.objectweb.fractal.adl.implementations.JavaImplementationBuilder; 44 import org.objectweb.fractal.adl.interfaces.InterfaceLoader; 45 import org.objectweb.fractal.adl.types.JavaTypeBuilder; 46 import org.objectweb.fractal.adl.types.TypeCompiler; 47 import org.objectweb.fractal.adl.types.TypeLoader; 48 import org.objectweb.fractal.adl.xml.XMLLoader; 49 50 53 54 public class FactoryFactory { 55 56 public final static String FRACTAL_BACKEND = 57 "org.objectweb.fractal.adl.FractalBackend"; 58 59 public final static String STATIC_FRACTAL_BACKEND = 60 "org.objectweb.fractal.adl.StaticFractalBackend"; 61 62 public final static String JAVA_BACKEND = 63 "org.objectweb.fractal.adl.JavaBackend"; 64 65 public final static String STATIC_JAVA_BACKEND = 66 "org.objectweb.fractal.adl.StaticJavaBackend"; 67 68 private static Factory FACTORY; 69 70 75 76 public static Factory getFactory () { 77 if (FACTORY != null) { 78 return FACTORY; 79 } 80 81 BasicFactory r = new BasicFactory(); 82 83 XMLLoader xmll = new XMLLoader(); 84 ArgumentLoader argl = new ArgumentLoader(); 85 InterfaceLoader itfl = new InterfaceLoader(); 86 TypeLoader typl = new TypeLoader(); 87 ImplementationLoader impll = new ImplementationLoader(); 88 AttributeLoader attrl1 = new AttributeLoader(); 89 ArgumentComponentLoader compl = new ArgumentComponentLoader(); 90 TypeBindingLoader bindl = new TypeBindingLoader(); 91 AttributeLoader attrl2 = new AttributeLoader(); 93 94 TypeCompiler typc = new TypeCompiler(); 95 ImplementationCompiler implc = new ImplementationCompiler(); 96 PrimitiveComponentCompiler compc = new PrimitiveComponentCompiler(); 97 BindingCompiler bindc = new BindingCompiler(); 98 AttributeCompiler attrc = new AttributeCompiler(); 99 ComponentCompiler allc = new ComponentCompiler(); 100 101 JavaTypeBuilder typb = new JavaTypeBuilder(); 102 JavaImplementationBuilder implb = new JavaImplementationBuilder(); 103 JavaComponentBuilder compb = new JavaComponentBuilder(); 104 JavaBindingBuilder bindb = new JavaBindingBuilder(); 105 JavaAttributeBuilder attrb = new JavaAttributeBuilder(); 106 107 BasicScheduler s = new BasicScheduler(); 108 109 typc.bindFc(TypeCompiler.BUILDER_BINDING, typb); 110 implc.bindFc(ImplementationCompiler.BUILDER_BINDING, implb); 111 compc.bindFc(PrimitiveComponentCompiler.BUILDER_BINDING, compb); 112 bindc.bindFc(BindingCompiler.BUILDER_BINDING, bindb); 113 attrc.bindFc(AttributeCompiler.BUILDER_BINDING, attrb); 114 115 argl.clientLoader = xmll; 116 itfl.clientLoader = argl; 117 typl.clientLoader = itfl; 118 impll.clientLoader = typl; 119 attrl1.clientLoader = impll; 120 compl.clientLoader = attrl1; 121 bindl.clientLoader = compl; 122 attrl2.clientLoader = bindl; 123 124 allc.bindFc(ComponentCompiler.PRIMITIVE_COMPILERS_BINDING+"0", typc); 125 allc.bindFc(ComponentCompiler.PRIMITIVE_COMPILERS_BINDING+"1", implc); 126 allc.bindFc(ComponentCompiler.PRIMITIVE_COMPILERS_BINDING+"2", compc); 127 allc.bindFc(ComponentCompiler.PRIMITIVE_COMPILERS_BINDING+"3", bindc); 128 allc.bindFc(ComponentCompiler.PRIMITIVE_COMPILERS_BINDING+"4", attrc); 129 130 r.bindFc(BasicFactory.LOADER_BINDING, attrl2); 131 r.bindFc(BasicFactory.COMPILER_BINDING, allc); 132 r.bindFc(BasicFactory.SCHEDULER_BINDING, s); 133 134 FACTORY = r; 135 return r; 136 } 137 138 145 146 public static Factory getFactory (final String backend) throws ADLException { 147 return getFactory(backend, new HashMap ()); 148 } 149 150 158 159 public static Factory getFactory (final String backend, final Map context) 160 throws ADLException 161 { 162 return getFactory("org.objectweb.fractal.adl.BasicFactory", backend, context); 163 } 164 165 174 175 public static Factory getFactory ( 176 final String factory, 177 final String backend, 178 final Map context) throws ADLException 179 { 180 context.put("backend", backend); 181 Factory f = getFactory(); 182 Map c = (Map )f.newComponent(factory, context); 183 return (Factory)c.get("factory"); 184 } 185 } 186 | Popular Tags |