1 24 25 package org.objectweb.dream.adl.nodes; 26 27 import java.util.Map ; 28 29 import org.objectweb.fractal.adl.ADLException; 30 import org.objectweb.fractal.adl.AbstractLoader; 31 import org.objectweb.fractal.adl.Definition; 32 import org.objectweb.fractal.adl.Node; 33 import org.objectweb.fractal.adl.components.Component; 34 import org.objectweb.fractal.adl.components.ComponentContainer; 35 import org.objectweb.fractal.adl.nodes.VirtualNode; 36 import org.objectweb.fractal.adl.nodes.VirtualNodeContainer; 37 import org.objectweb.fractal.rmi.registry.NamingService; 38 39 42 public class RemoteBootstrapLoader extends AbstractLoader 43 { 44 45 48 public Definition load(final String name, final Map context) 49 throws ADLException 50 { 51 NamingService ns = (NamingService) context.get("naming-service"); 52 Definition d = clientLoader.load(name, context); 53 checkNode((Node) d, ns, context); 54 return d; 55 } 56 57 private void checkNode(final Node node, final NamingService ns, 58 final Map context) throws ADLException 59 { 60 if (node instanceof VirtualNodeContainer) 61 { 62 VirtualNode vn = ((VirtualNodeContainer) node).getVirtualNode(); 63 if (vn != null) 64 { 65 String name = vn.getName(); 66 if (context.get(name) == null) 67 { 68 if (ns == null) 69 { 70 throw new ADLException( 71 "Unable to find the naming service in the context", null); 72 } 73 System.out.println("looking for " + name); 74 Object bootstrap = ns.lookup(name); 75 if (bootstrap == null) 76 { 77 throw new ADLException( 78 "Unable to find the bootstrap component for virtual node " 79 + name, null); 80 } 81 context.put(name, bootstrap); 82 } 83 } 84 } 85 if (node instanceof ComponentContainer) 86 { 87 ComponentContainer container = (ComponentContainer) node; 88 Component[] tab = container.getComponents(); 89 for (int i = 0; i < tab.length; i++) 90 { 91 Component subComponent = tab[i]; 92 checkNode((Node) subComponent, ns, context); 93 } 94 } 95 } 96 97 } | Popular Tags |