Package org.ajax4jsf.templatecompiler.builder

Examples of org.ajax4jsf.templatecompiler.builder.CompilationException


    Node functionNameNode = nnm.getNamedItem(FUNCTION_NAME_ATTRIBUTE_NAME);

    if (functionNameNode != null) {
      this.functionName = functionNameNode.getNodeValue();
    } else {
      throw new CompilationException("function name is not set");
    }

    Node nodeUseOnlyThisParameters = nnm
        .getNamedItem(USE_ONLY_THIS_PARAMETERS);
    if (nodeUseOnlyThisParameters != null) {
      this.useOnlyEnumeratingParaments = Boolean
          .getBoolean(nodeUseOnlyThisParameters.getNodeValue());
    } // if

    // read name of variable if need
    Node variableName = nnm.getNamedItem(VAR_ATTRIBUTE_NAME);
    if (variableName != null) {
      this.variable = variableName.getNodeValue();
    } // if

    // read name of parameters if need
    ParameterProcessor parameterProcessor = new ParameterProcessor(element,
        componentBean);

    this.parameters = parameterProcessor.getParameters();
    log.debug(this.parameters);

    List decodeFunctionName = null;

    decodeFunctionName = Arrays.asList(this.functionName
        .split(FUNCTION_DELIMITER));
    if (null == decodeFunctionName) {
      decodeFunctionName = new ArrayList();
      decodeFunctionName.add(this.functionName);
    }

    ArrayList functionNames = new ArrayList();
    String lastClassName = componentBean.getFullBaseclass();

    for (Iterator iter = decodeFunctionName.iterator(); iter.hasNext();) {
      String elementFunction = (String) iter.next();

      try {
        log.debug("Try to load class : " + lastClassName);

        Class clazz = componentBean.loadClass(lastClassName);

        if (!iter.hasNext()) {
          String method = getMethod(clazz, elementFunction);
          if (method != null) {
            log.debug(method);
            functionNames.add(method);
          } else {
            log.error("Method  " + elementFunction
                + " not found in class : " + lastClassName);
            throw new CompilationException();
          }

        } else {
          //
          // Probing properties !!!!
          //

          PropertyDescriptor propertyDescriptor = getPropertyDescriptor(
              clazz, elementFunction);

          if (propertyDescriptor != null) {
            functionNames.add(propertyDescriptor.getReadMethod()
                .getName()
                + "()");
            log.debug("Property " + elementFunction
                + " mapped to function  : "
                + propertyDescriptor.getReadMethod().getName());
            lastClassName = propertyDescriptor.getPropertyType()
                .getName();
          } else {
            log.error("Property " + elementFunction
                + " not found in class : " + lastClassName);
            throw new CompilationException();
          }
        }

      } catch (Throwable e) {

        log.error("Error load class : " + lastClassName + ", "
            + e.getLocalizedMessage());
        e.printStackTrace();
        throw new CompilationException("Error load class : "
            + lastClassName, e);
      }

    }
View Full Code Here


                Class parameterType;
                try {
                  parameterType = componentBean
                      .loadClass(nodeType.getNodeValue());
                } catch (ClassNotFoundException e) {
                  throw new CompilationException(e.getLocalizedMessage(), e);
                }
                param = new Parameter(nodeValue.getNodeValue(),
                    parameterType);
              } else {
                param = new Parameter(nodeValue.getNodeValue());
View Full Code Here

    try {
        this.type = componentBean.getMethodReturnedClass(componentBean
            .getVariableType("component"), "getClientId", parameters);
    } catch (NoSuchMethodException e) {
        throw new CompilationException(e.getLocalizedMessage(), e);
    }

    componentBean.addVariable(this.strThisVariable, this.type);
  }
View Full Code Here

  public Template getTemplate(String name) throws CompilationException {
    // TODO Auto-generated method stub
    try {
      return _config.getTemplate(name);
    } catch (GeneratorException e) {
      throw new CompilationException(e);
    }
  }
View Full Code Here

    Template template = _templates.get(name);
    if(null == template){
      try {
        template = engine.getTemplate(name);
      } catch (ResourceNotFoundException e) {
        throw new CompilationException(e.getLocalizedMessage());
      } catch (ParseErrorException e) {
        throw new CompilationException(e.getLocalizedMessage());
      } catch (Exception e) {
        throw new CompilationException(e.getLocalizedMessage());
      }
      _templates.put(name, template);
    }
    return template;
  }
View Full Code Here

        objects[1] = componentBean;

        returnValue = (TemplateElement) class1.getConstructor(
            paramClasses).newInstance(objects);
      } catch (InstantiationException e) {
        throw new CompilationException("InstantiationException: "
            + e.getLocalizedMessage(), e);
      } catch (IllegalAccessException e) {
        throw new CompilationException("IllegalAccessException: "
            + e.getLocalizedMessage(), e);
      } catch (IllegalArgumentException e) {
        e.printStackTrace();
      } catch (SecurityException e) {
        e.printStackTrace();
      } catch (InvocationTargetException e) {
        e.printStackTrace();
        throw new CompilationException("InvocationTargetException: "
            + e.getMessage(), e);
      } catch (NoSuchMethodException e) {
        e.printStackTrace();
      } catch (ClassNotFoundException e) {
        throw new CompilationException(" error loading class: "
            + e.getLocalizedMessage());
      }
    }
    }
    return returnValue;
View Full Code Here

  private static ThreadLocal<String> variableNamesStorage = new ThreadLocal<String>();
 
  public String getBeginElement() throws CompilationException {
    if (variableNamesStorage.get() != null) {
      throw new CompilationException("Nested c:scriptObject tags aren't allowed!");
    }
    variableNamesStorage.set(variableName);
   
    VelocityContext context = new VelocityContext();
    context.put("variable", this.variableName);
View Full Code Here

TOP

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

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.