1 24 25 package org.objectweb.dream.adl; 26 27 import java.util.Map ; 28 29 import org.objectweb.dream.adl.legacy.ComponentNotFoundException; 30 import org.objectweb.fractal.api.Component; 31 import org.objectweb.fractal.api.NoSuchInterfaceException; 32 import org.objectweb.fractal.api.control.ContentController; 33 import org.objectweb.fractal.api.control.NameController; 34 import org.objectweb.fractal.util.Fractal; 35 36 39 public class FractalResolver implements Resolver 40 { 41 42 50 public Object resolve(Object namingContext, String name, Map context) 51 throws ComponentNotFoundException 52 { 53 Component composite = (Component) namingContext; 54 ContentController cc; 55 try 56 { 57 cc = Fractal.getContentController(composite); 58 } 59 catch (NoSuchInterfaceException e) 60 { 61 throw new ComponentNotFoundException( 62 "The given component doesn't have a Content Controller", context, 63 name); 64 } 65 Component subComponents[] = cc.getFcSubComponents(); 66 for (int i = 0; i < subComponents.length; i++) 67 { 68 Component subComponent = subComponents[i]; 69 NameController nc; 70 try 71 { 72 nc = Fractal.getNameController(subComponent); 73 } 74 catch (NoSuchInterfaceException e1) 75 { 76 break; 77 } 78 if (nc.getFcName().equals(name)) 79 { 80 return subComponent; 81 } 82 } 83 throw new ComponentNotFoundException( 84 "Unable to find sub component with the given name", context, name); 85 } 86 87 } | Popular Tags |