public TemplatesDescriptor( ApplicationDescriptor application, ClassLoader loader, JSON config) throws Exception { ArrayList<BeanDescriptor> beans = new ArrayList<BeanDescriptor>(); List<TemplateDescriptor> templates = new ArrayList<TemplateDescriptor>(); // String packageName = config.getString("package"); Name pkg = Name.parse(packageName); // Load templates for (String fqn : config.getList("templates", String.class)) { Class<?> clazz = loader.loadClass(fqn); Field f = clazz.getField("DESCRIPTOR"); TemplateDescriptor descriptor = (TemplateDescriptor)f.get(null); templates.add(descriptor); juzu.impl.common.Path.Absolute path = (juzu.impl.common.Path.Absolute)juzu.impl.common.Path.parse(descriptor.getPath()); Path qualifier; if (pkg.isPrefix(path.getName())) { juzu.impl.common.Path.Relative relativePath = juzu.impl.common.Path.relative(path.getName().subName(pkg.size()), path.getExt()); qualifier = new PathLiteral(relativePath.getCanonical()); } else { qualifier = new PathLiteral(path.getCanonical()); } beans.add(BeanDescriptor.createFromImpl(Template.class, null, Arrays.<Annotation>asList(qualifier), descriptor.getType())); } // this.templates = templates; this.pkg = pkg; this.beans = beans; }
public TemplatesDescriptor( ApplicationDescriptor application, ClassLoader loader, JSON config) throws Exception { ArrayList<BeanDescriptor> beans = new ArrayList<BeanDescriptor>(); List<TemplateDescriptor> templates = new ArrayList<TemplateDescriptor>(); // String packageName = config.getString("package"); Name pkg = Name.parse(packageName); // Load templates for (String fqn : config.getList("templates", String.class)) { Class<?> clazz = loader.loadClass(fqn); Field f = clazz.getField("DESCRIPTOR"); TemplateDescriptor descriptor = (TemplateDescriptor)f.get(null); templates.add(descriptor); juzu.impl.common.Path.Absolute path = (juzu.impl.common.Path.Absolute)juzu.impl.common.Path.parse(descriptor.getPath()); Path qualifier; if (pkg.isPrefix(path.getName())) { juzu.impl.common.Path.Relative relativePath = juzu.impl.common.Path.relative(path.getName().subName(pkg.size()), path.getExt()); qualifier = new PathLiteral(relativePath.getCanonical()); } else { qualifier = new PathLiteral(path.getCanonical()); } beans.add(BeanDescriptor.createFromImpl(Template.class, null, Arrays.<Annotation>asList(qualifier), descriptor.getType())); } // this.templates = templates; this.pkg = pkg; this.beans = beans; }
throw TemplateMetaModel.TEMPLATE_NOT_RESOLVED.failure(path); } else { TemplateProvider<M> provider = (TemplateProvider<M>)owner.resolveTemplateProvider(path.getExt()); M templateAST; try {
throw TemplateMetaModel.TEMPLATE_NOT_RESOLVED.failure(path); } else { TemplateProvider<M> provider = (TemplateProvider<M>)owner.resolveTemplateProvider(path.getExt()); M templateAST; try {
public static FileKey newName(Path.Absolute path) { return new FileKey(path.getDirs().toString(), path.getRawName(), path.getExt()); }
public static FileKey newName(Path.Absolute path) { return new FileKey(path.getDirs().toString(), path.getRawName(), path.getExt()); }
@Test public void testResolveUp() throws Exception { Name name = Name.parse("foo.bar"); Path.Absolute file = name.resolve("../juu/daa.txt"); assertEquals("foo.juu", file.getDirs().toString()); assertEquals("daa.txt", file.getSimpleName()); assertEquals("txt", file.getExt()); assertEquals("daa", file.getRawName()); assertEquals("foo.juu.daa", file.getName().toString()); }
@Test public void testResolveUp() throws Exception { Name name = Name.parse("foo.bar"); Path.Absolute file = name.resolve("../juu/daa.txt"); assertEquals("foo.juu", file.getDirs().toString()); assertEquals("daa.txt", file.getSimpleName()); assertEquals("txt", file.getExt()); assertEquals("daa", file.getRawName()); assertEquals("foo.juu.daa", file.getName().toString()); }
void emit(TemplateMetaModel template, Element[] elements) { TemplateProvider<?> provider = owner.resolveTemplateProvider(template.getPath().getExt()); resolvedQualified(provider, template, elements); emitScript(template, provider, elements); }
void emit(TemplateMetaModel template, Element[] elements) { TemplateProvider<?> provider = owner.resolveTemplateProvider(template.getPath().getExt()); resolvedQualified(provider, template, elements); emitScript(template, provider, elements); }