1 18 package org.objectweb.perseus.cache; 19 20 import org.objectweb.fractal.adl.Parser; 21 import org.objectweb.fractal.adl.Launcher; 22 import org.objectweb.fractal.util.Fractal; 23 import org.objectweb.fractal.api.Component; 24 25 29 public class FractalHelper { 30 31 private final static String FRACTAL_PROVIDER = "fractal.provider"; 32 private final static String DEFAULT_FRACTAL_PROVIDER 33 = "org.objectweb.fractal.julia.Julia"; 34 35 private final static String JULIA_LOADER = "julia.loader"; 36 private final static String DEFAULT_JULIA_LOADER 37 = "org.objectweb.fractal.julia.loader.DynamicLoader"; 38 39 private final static String JULIA_CONFIG = "julia.config"; 40 private final static String DEFAULT_JULIA_CONFIG = "julia.cfg"; 41 42 private static Parser parser; 43 44 49 private static Parser getParser() throws Exception { 50 if (parser == null) { 51 synchronized(FractalHelper.class) { 52 if (parser == null) { 53 System.setProperty(FRACTAL_PROVIDER, DEFAULT_FRACTAL_PROVIDER); 54 System.setProperty(JULIA_LOADER, DEFAULT_JULIA_LOADER); 55 System.setProperty(JULIA_CONFIG, DEFAULT_JULIA_CONFIG); 56 parser = Launcher.getBootstrapParser(); 57 } 58 } 59 } 60 return parser; 61 } 62 63 64 72 public static Component instanciate(String templateName) throws Exception { 73 return instanciate(getParser().loadTemplate(templateName, true)); 74 } 75 76 79 public static Component instanciate(Component template) throws Exception { 80 return Fractal.getFactory(template).newFcInstance(); 81 } 82 83 } 84 | Popular Tags |