Package org.ajax4jsf.templatecompiler.builder

Examples of org.ajax4jsf.templatecompiler.builder.CompilationContext


          template = new File(getSrcDir(), renderer.getTemplate());
        } else {
          template = new File(renderer.getTemplate());
        }
        ClassLoader classLoader = getClassLoader();
        CompilationContext rendererBean = new RendererCompilationContext(
            getLog(), classLoader,getConfig());
        if (null != renderer.getClassname()) {
          rendererBean.setBaseclass(renderer.getClassname());

        }
        if (null != renderer.getClassname()) {
          rendererBean.setFullClassName(renderer.getClassname());
        }
        if (null != component) {
          try {
            rendererBean
                .setComponentClass(component.getClassname());
          } catch (CompilationException e) {
            if (null != component.getSuperclass()) {
              rendererBean.setComponentClass(component
                  .getSuperclass());
            }
          }

        }

// unfinished check of non-static fields in renderer classes       
//       
//        String baseclassName = rendererBean.getFullClassName();
//        try {
//            classLoader.loadClass(baseclassName);
//        } catch (ClassNotFoundException e) {
//            getLog().debug("Class not found: " + e.getLocalizedMessage());
//
//            baseclassName = rendererBean.getFullBaseclass();
//            classLoader.loadClass(baseclassName);
//        }
//       
//        if (baseclassName != null) {
//            Class<?> baseclass = classLoader.loadClass(baseclassName);
//            Class<? extends Annotation> annotationClass = (Class<? extends Annotation>) classLoader.loadClass("org.richfaces.AllowedRendererField");
//
//            do {
//          Field[] fields = baseclass.getDeclaredFields();
//          for (Field field : fields) {
//              if ((field.getModifiers() & Modifier.STATIC) == 0 && field.getAnnotation(annotationClass) == null) {
//            throw new RuntimeException("Non-static field: " + field + " in renderer class. ");
//              }
//          }
//         
//          baseclass = baseclass.getSuperclass();
//            } while (baseclass != null);
//        }
       
        TemplateCompiler templateCompiler = new TemplateCompiler();
        InputStream templateStream = new FileInputStream(template);
        templateCompiler.processing(templateStream, rendererBean);
        renderer.setClassname(rendererBean.getFullClassName());
        String resultPath = rendererBean.getComponentFileName();
        if (null == getPackage()) {
          resultPath = resultPath.replace('.', '/');
        } else {
          resultPath = getPackage().replace('.', '/') + "/"
              + resultPath;
View Full Code Here


      configBean.addResource(name, packageName, null, true);
    } else if (templateElement instanceof RootElement) {
      RootElement rootElement = (RootElement) templateElement;

      CompilationContext compilationContext = rootElement
          .getComponentBean();

      addResource(configBean, renderer, builderConfig, compilationContext);
    } else if (templateElement instanceof HeaderResourceElement) {
      HeaderResourceElement resourceElement = (HeaderResourceElement) templateElement;
View Full Code Here

  private void addResources(ResourcesConfigGeneratorBean configBean,
      RendererBean renderer, BuilderConfig builderConfig)
      throws CompilationException, IOException, ClassNotFoundException {
    if (null != renderer) {
      CompilationContext compilationContext = new RendererCompilationContext(
          log, config.getClassLoader(), config);

      if (renderer.isGenerate()) {
        String templateString = renderer.getTemplate();
        if (templateString != null) {
          File template;
          if (null != getTemplates()) {
            template = new File(getTemplates(), templateString);
          } else {
            template = new File(templateString);
          }

          TemplateCompiler templateCompiler = new TemplateCompiler();
          InputStream templateStream = new FileInputStream(template);
          templateCompiler.processing(templateStream,
              compilationContext);

          TemplateElement root = compilationContext.getTree();

          String classname = renderer.getClassname();
          String packageName;
          int idx = classname.lastIndexOf('.');
          if (idx != -1) {
View Full Code Here

    ClassLoader loader = getClassLoader();

    try {

      CompilationContext componentBean = new AntCompilationContext(this,loader);
      TemplateCompiler templateCompiler = new TemplateCompiler();

      // componentBean.setDefaultVariables();

      InputStream inputStream = null;
      File inputFile = new File(sFileTemplate);
      String sF = inputFile.getName().toString();

      componentBean.setFullClassName(generateJavaClassName(sF));

      inputStream = new FileInputStream(inputFile);

      templateCompiler.processing(inputStream, componentBean);

      String resultPath = componentBean.getComponentFileName() + ".java";
      File javaFile = new File(getDestdir(), resultPath);
      File javaDir = javaFile.getParentFile();
      if (!javaDir.exists()) {
        javaDir.mkdirs();
      } // try
View Full Code Here

TOP

Related Classes of org.ajax4jsf.templatecompiler.builder.CompilationContext

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.