Package juzu.impl.template.spi

Examples of juzu.impl.template.spi.TemplateStub


  public TemplateStub resolveTemplateStub(String path) {
    return resolveTemplateStub(juzu.impl.common.Path.parse(path));
  }

  public TemplateStub resolveTemplateStub(juzu.impl.common.Path path) {
    TemplateStub stub = stubs.get(path);
    if (stub == null) {

      //
      Path.Absolute resolved = descriptor.getPackage().resolve(path);

      //
      TemplateDescriptor desc;
      try {
        Class<?> clazz = context.getClassLoader().loadClass(resolved.getName().toString());
        Field f = clazz.getField("DESCRIPTOR");
        desc = (TemplateDescriptor)f.get(null);
      }
      catch (Exception e) {
        throw new UnsupportedOperationException("Handle me gracefully", e);
      }

      //
      stub = desc.getStub();

      //
      TemplateStub phantom = stubs.putIfAbsent(path, stub);
      if (phantom != null) {
        stub = phantom;
      } else {
        stub.init();
      }
View Full Code Here


  // Runtime
  public SimpleTag(String name, Class<? extends TemplateStub> stubType) {
    super(name);

    // Init stub
    TemplateStub stub;
    try {
      Constructor ctor = stubType.getConstructor(ClassLoader.class, String.class);
      stub = (TemplateStub)ctor.newInstance(getClass().getClassLoader(), getClass().getName());
    }
    catch (Exception e) {
View Full Code Here

  @Override
  public void render(TemplateRenderContext context, Renderable body, Map<String, String> args) throws IOException {
    InsertTag.current.get().addLast(body);
    try {
      String path = args.get("path");
      TemplateStub template = context.resolveTemplate(path);
      template.render(context);
    }
    finally {
      InsertTag.current.get().removeLast();
    }
  }
View Full Code Here

  }

  @Override
  public void render(TemplateRenderContext context, Renderable body, Map<String, String> args) throws IOException {
    String path = args.get("path");
    TemplateStub template = context.resolveTemplate(path);
    template.render(context);
  }
View Full Code Here

        // Get the specified locale or the current user's one
        final Locale locale = computeLocale();

        //
        TemplateStub stub = plugin.resolveTemplateStub(path);
        if (stub == null) {
          throw new UnsupportedOperationException("Handle me gracefully: couldn't get stub for template " + path);
        }

        //
View Full Code Here

      long md5,
      Class<? extends Template> type,
      Class<? extends TemplateStub> stubType) {

    //
    TemplateStub stub;
    try {
      Constructor ctor = stubType.getConstructor(ClassLoader.class, String.class);
      stub = (TemplateStub)ctor.newInstance(type.getClassLoader(), type.getName());

    }
View Full Code Here

TOP

Related Classes of juzu.impl.template.spi.TemplateStub

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.