/** * Returns the tree corresponding to the given content descriptor. This tree * has the format specified in {@link * org.objectweb.fractal.julia.asm.ContextClassGenerator} * * @param contentDesc * a content descriptor. * @return the tree corresponding to the given content descriptor. */ public Tree getFcContentDescriptor(final Object contentDesc) { if (contentDesc instanceof String) { return new Tree((String) contentDesc); } else if (contentDesc != null && !(contentDesc instanceof Object[])) { return new Tree(contentDesc.getClass().getName()); } else { return new Tree("EMPTY"); } }
/** * Returns the tree corresponding to the given controller descriptor. This * tree is found by using the {@link #_this_weaveableL} loader. It must have * the format specified in {@link * org.objectweb.fractal.julia.asm.ContextClassGenerator} * * @param controllerDesc * a string referencing a true controller descriptor. * @return the tree corresponding to the given controller descriptor. * @throws InstantiationException * if the tree cannot be loaded. */ public Tree getFcControllerDescriptor(final Object controllerDesc) throws InstantiationException { Map definitions = new HashMap(); definitions.put("attributeControllerInterface", new Tree("QUOTE")); definitions.put("interfaceName", new Tree("QUOTE")); try { return _this_weaveableL.evalTree(_this_weaveableL .loadTree((String) controllerDesc), definitions); } catch (Exception e) { throw new ChainedInstantiationException(e, null, "Cannot load the '" + controllerDesc + "' controller descriptor"); } }
private ComponentDesc<?> getComponentDescFromADL( ComponentType ct, String ctrlDesc, String classname ) throws IOException { Map<Object,Object> cclcontext = new HashMap<Object,Object>(); try { InterfaceType attrit = ct.getFcInterfaceType("attribute-controller"); String attrsig = attrit.getFcItfSignature(); cclcontext.put("attributeControllerInterface",new Tree(attrsig)); } catch( NoSuchInterfaceException e ) {} /* * Generate the factory for the membrane. */ String adl = getADLDesc(ctrlDesc); ADLParserSupportItf fadl = jc.getADLDesc(adl); ComponentDesc<?> cdesc = fadl.parse(adl,cclcontext); fadl.generate(cdesc,classname); return cdesc; }
public Object newObject(final Tree objectDescriptor, final Object loader) throws Exception { if (objectDescriptor.getSize() == 0) { return loadClass(objectDescriptor.toString(), loader).newInstance(); } else { Object o; o = loadClass(objectDescriptor.getSubTree(0), loader).newInstance(); if (objectDescriptor.getSize() > 1) { Tree[] trees = objectDescriptor.getSubTrees(); Tree[] args = new Tree[trees.length - 1]; System.arraycopy(trees, 1, args, 0, args.length); ((Initializable) o).initialize(new Tree(args)); } return o; } }
return (ok ? tree : new Tree(subTrees));