1 23 24 package org.objectweb.fractal.adl.implementations; 25 26 import java.util.HashMap ; 27 import java.util.Map ; 28 29 import org.objectweb.fractal.api.Component; 30 import org.objectweb.fractal.api.NoSuchInterfaceException; 31 import org.objectweb.fractal.api.type.ComponentType; 32 import org.objectweb.fractal.util.Fractal; 33 34 38 39 public class FractalImplementationBuilder implements ImplementationBuilder { 40 41 45 public Object createComponent ( 46 final Object type, 47 final String name, 48 final String definition, 49 final Object controllerDesc, 50 final Object contentDesc, 51 final Object context) throws Exception 52 { 53 ClassLoader loader = null; 54 if (context instanceof Map ) { 55 loader = (ClassLoader )((Map )context).get("classloader"); 56 } 57 58 Component bootstrap = null; 59 if (context != null) { 60 bootstrap = (Component)((Map )context).get("bootstrap"); 61 } 62 if (bootstrap == null) { 63 if (loader != null) { 64 Map ctxt = new HashMap (); 65 ctxt.put("classloader", loader); 66 bootstrap = Fractal.getBootstrapComponent(ctxt); 67 } else { 68 bootstrap = Fractal.getBootstrapComponent(); 69 } 70 } 71 Component result = Fractal.getGenericFactory(bootstrap).newFcInstance( 72 (ComponentType)type, 73 loader == null ? controllerDesc : new Object [] {loader, controllerDesc}, 74 contentDesc); 75 try { 76 Fractal.getNameController(result).setFcName(name); 77 } catch (NoSuchInterfaceException ignored) { 78 } 79 return result; 80 } 81 } 82 | Popular Tags |