/** * Initializes this object with the given arguments. * * @param args the arguments to be used to initialize this object. The format * of these arguments depends on the class of this object. * @throws Exception if a problem occurs during the object initialization. */ public void initialize (final Tree args) throws Exception { Tree t = args.getValue("use-context-class-loader"); if (t != null && t.equals("true")) { useContextClassLoader = true; } }
/** * Return the fully-qualified name of the ADL descriptor associated to the * specified controller descriptor. */ protected String getADLDesc( String ctrlDesc ) throws NoSuchControllerDescriptorException { Tree t = jloader.loadTree(KOCK_PREFIX+ctrlDesc); // may throw ArrayOutOfBoundException String adl = t.getSubTree(0).toString(); return adl; }
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; } }
public void initialize (final Tree args) throws Exception { _super_initialize(args); for (int i = 0; i < args.getSize(); ++i) { Tree arg = args.getSubTree(i); if (arg.getSize() == 2 && arg.getSubTree(0).equals("monolog-conf-file")) { String monologConfFile = arg.getSubTree(1).toString(); if (Monolog.monologFactory == Monolog.getDefaultMonologFactory()) { Monolog.getMonologFactory(monologConfFile); } } } }
/** * Initializes this object with the given arguments. * The first subtree (if any) must represent the value of {@link #_period period}. * * @param args the arguments to be used to initialize this object. * @throws NumberFormatException * if the first subtree is not a valid string representation of a long value. * @throws IllegalStateException if the firts subtree does not represent a positive value. */ public void initialize(final Tree args) { //System.out.println("-- " + args.toString() + ", period=" + period); if (args.getSize() == 0) return; _period = Long.valueOf(args.getSubTree(0).toString()).longValue(); if (_period < 1) throw new IllegalStateException("period=" + _period + " is invalid. The value must be positive."); //System.out.println("-- " + args.toString() + ", period=" + period); }
public Class loadClass(final Tree classDescriptor, final Object loader) throws ClassNotFoundException { if (classDescriptor.getSize() == 0) { return loadClass(classDescriptor.toString(), loader); + Integer.toHexString(classDescriptor.hashCode()) + "_"; while (true) { String name = s + n; Generated gen = (Generated) c.newInstance(); if (gen != null && classDescriptor.equals(gen .getFcGeneratorParameters())) { return c;
public Tree evalTree(final Tree tree, final Map context) throws Exception { if (tree.getSize() == 0) { String var = tree.toString(); if (var.startsWith("'")) { var = var.substring(1); throw new Exception(var); if (!val.toString().equals("QUOTE")) { return evalTree(val, context); } else { boolean ok = true; Tree[] subTrees = tree.getSubTrees(); for (int i = 0; i < subTrees.length; ++i) { Tree oldSubTree = subTrees[i]; return (ok ? tree : new Tree(subTrees));
/** * 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"); } }
/** * 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"); } }
Tree controllerTree = getFcControllerDescriptor(controller); Tree contentTree = getFcContentDescriptor(contentDesc); Tree componentTree = new Tree( new Tree[] { new Tree( "org.objectweb.fractal.julia.asm.ContextClassGenerator"), typeTree, controllerTree, contentTree }); initializationContextClass = _this_weaveableL.loadClass( componentTree, loader); } catch (Exception e) {
/** * Initializes the fields of this mixin and then calls the overriden method. * * @param ic information about the component to which this controller object * belongs. * @throws InstantiationException if the initialization fails. */ public void initFcController (final InitializationContext ic) throws InstantiationException { weaveableL = (Loader)ic.getInterface("loader"); _super_initFcController(ic); }
public void initialize (final Tree args) throws Exception { _super_initialize(args); for (int i = 0; i < args.getSize(); ++i) { Tree arg = args.getSubTree(i); if (arg.getSize() == 2 && arg.getSubTree(0).equals("monolog-conf-file")) { String monologConfFile = arg.getSubTree(1).toString(); if (Monolog.monologFactory == Monolog.getDefaultMonologFactory()) { Monolog.getMonologFactory(monologConfFile); } } } }
/** * Initializes this object with the given arguments. * The first subtree (if any) must represent the value of {@link #_period period}. * The second subtree (if any) must represent the value of the {@link #_alpha smoothing constant}. * * @param args the arguments to be used to initialize this object. * @throws NumberFormatException * if the first subtree is not a valid string representation of a long value, * or if the second subtree is not a valid string representation of a double value. * @throws IllegalStateException * if the firts subtree does not represent a positive value * or if the second subtree does not represent a value in the interval [0-1]. */ public void initialize(final Tree args) { //System.out.println("-- " + args.toString() + ", period=" + period + ", alpha=" + alpha); if (args.getSize() == 0) return; else if (args.getSize() == 1){ super.initialize(args); return; } super.initialize(args); _alpha = Double.valueOf(args.getSubTree(1).toString()).doubleValue(); if ((_alpha < 0) || (_alpha > 1)) throw new IllegalStateException("alpha=" + _alpha + " is invalid. The value must in the interval [0-1]."); //System.out.println("-- " + args.toString() + ", period=" + period + ", alpha=" + alpha); }
/** * implementation of the Initializable interface. * @param args the defaulot argument */ public void initialize(final Tree args) { String s = null; int period = StatControllerImpl.DEFAULT_PERIOD; if (args.getSubTree(0) != null) { s = args.getSubTree(0).toString(); } try { period = Integer.parseInt(s); } catch (final NumberFormatException e) { } final Timer timer = new Timer(); timer.schedule(new WriteStatsTask(this), 0, period); }
/** * Initializes this object with the given arguments. * * @param args the arguments to be used to initialize this object. The format * of these arguments depends on the class of this object. * @throws Exception if a problem occurs during the object initialization. */ public void initialize (final Tree args) throws Exception { Tree t = args.getValue("use-context-class-loader"); if (t != null && t.equals("true")) { useContextClassLoader = true; } }
/** * Initializes the fields of this mixin and then calls the overriden method. * * @param ic information about the component to which this controller object * belongs. * @throws InstantiationException if the initialization fails. */ public void initFcController (final InitializationContext ic) throws InstantiationException { weaveableL = (Loader)ic.getInterface("loader"); _super_initFcController(ic); }
/** * Initializes this object with the given arguments. * * @param args * the arguments to be used to initialize this object. The format * of these arguments depends on the class of this object. * @throws Exception * if a problem occurs during the object initialization. */ public void initialize(final Tree args) throws Exception { Tree t = args.getValue("use-context-class-loader"); if (t != null && t.equals("true")) { useContextClassLoader = true; } }
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; }