1 26 package org.objectweb.util.explorer.interpreter.lib; 27 28 import org.objectweb.fractal.api.NoSuchInterfaceException; 29 import org.objectweb.util.explorer.api.RootContext; 30 import org.objectweb.util.explorer.core.code.api.CodeDescription; 31 import org.objectweb.util.explorer.core.common.api.Description; 32 import org.objectweb.util.explorer.core.common.lib.BindingFeature; 33 import org.objectweb.util.explorer.core.root.api.RootDescriptions; 34 import org.objectweb.util.explorer.core.root.lib.DefaultRootContext; 35 import org.objectweb.util.explorer.interpreter.api.DescriptionInterpreter; 36 37 45 public class RootInterpreter 46 extends BindingFeature 47 implements DescriptionInterpreter 48 { 49 50 56 protected static final String CODE_INTERPRETER = "code-interpreter"; 57 58 64 70 protected DescriptionInterpreter getCodeInterpreter(){ 71 try { 72 return (DescriptionInterpreter)lookupFc(CODE_INTERPRETER); 73 } catch (NoSuchInterfaceException e) { 74 getTrace().warn(CODE_INTERPRETER + ": interface not found!"); 75 return null; 76 } 77 } 78 79 85 88 public String [] clientFc() { 89 return new String []{CODE_INTERPRETER}; 90 } 91 92 98 101 public Object interprete(Description description, Object params) { 102 RootDescriptions rootDesc = (RootDescriptions)description; 103 DefaultRootContext rootContext = new DefaultRootContext(); 104 CodeDescription[] codeDesc = rootDesc.getRootDescriptions(); 105 for (int i = 0; i < codeDesc.length; i++) { 106 rootContext.addRootContext((RootContext)getCodeInterpreter().interprete(codeDesc[i], params)); 107 } 108 return rootContext; 109 } 110 111 } 112 | Popular Tags |