Package org.omnifaces.el

Examples of org.omnifaces.el.MethodReference


    return "data:" + contentType + ";base64," + base64;
  }

  @Override
  public InputStream getInputStream() throws IOException {
    MethodReference methodReference = ALLOWED_METHODS.get(getResourceName().split("\\.", 2)[0]);

    if (methodReference == null) {
      return null; // Ignore hacker attempts. I'd rather return 400 here, but JSF spec doesn't support it.
    }

    Method method = methodReference.getMethod();
    Object[] convertedParams = convertToObjects(getContext(), params, method.getParameterTypes());
    Object content;

    try {
      content = method.invoke(methodReference.getBase(), convertedParams);
    }
    catch (Exception e) {
      throw new FacesException(e);
    }
View Full Code Here


   * @return The new graphic resource.
   * @throws IllegalArgumentException When the "value" attribute of the given component is absent or does not
   * represent a method expression referring an existing method taking at least one argument.
   */
  public static GraphicResource create(FacesContext context, ValueExpression value, Object lastModified) {
    MethodReference methodReference = ExpressionInspector.getMethodReference(context.getELContext(), value);

    if (methodReference.getMethod() == null) {
      throw new IllegalArgumentException(String.format(ERROR_UNKNOWN_METHOD, value.getExpressionString()));
    }

    String name = getResourceName(methodReference);

    if (!ALLOWED_METHODS.containsKey(name)) { // No need to validate everytime when already known.
      Class<? extends Object> beanClass = methodReference.getBase().getClass();

      if (!isOneAnnotationPresent(beanClass, REQUIRED_ANNOTATION_TYPES)) {
        throw new IllegalArgumentException(String.format(ERROR_INVALID_SCOPE, beanClass));
      }

      ALLOWED_METHODS.put(name, new MethodReference(methodReference.getBase(), methodReference.getMethod()));
    }

    Object[] params = methodReference.getActualParameters();
    String[] convertedParams = convertToStrings(context, params, methodReference.getMethod().getParameterTypes());
    return new GraphicResource(name, convertedParams, lastModified);
  }
View Full Code Here

TOP

Related Classes of org.omnifaces.el.MethodReference

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.