Package com.almende.util.AnnotationUtil

Examples of com.almende.util.AnnotationUtil.AnnotatedMethod


      RequestParams requestParams) {
    JSONResponse resp = new JSONResponse();
    resp.setId(request.getId());

    try {
      AnnotatedMethod annotatedMethod = getMethod(object.getClass(),
          request.getMethod(), requestParams);
      if (annotatedMethod == null) {
        throw new JSONRPCException(
            JSONRPCException.CODE.METHOD_NOT_FOUND,
            "Method '" + request.getMethod() + "' not found");
      }
     
      Method method = annotatedMethod.getActualMethod();
     
      Object[] params = castParams(request.getParams(),
          annotatedMethod.getParams(), requestParams);
      Object result = method.invoke(object, params);
      if (result == null) {
        result = JOM.createNullNode();
      }
      resp.setResult(result);
View Full Code Here


   * @param method
   * @param args
   * @return
   */
  public static JSONRequest createRequest(Method method, Object[] args) {
    AnnotatedMethod annotatedMethod = new AnnotationUtil.AnnotatedMethod(method);
    List<AnnotatedParam> annotatedParams = annotatedMethod.getParams();
   
    ObjectNode params = JOM.createObjectNode();
   
    for(int i = 0; i < annotatedParams.size(); i++) {
      AnnotatedParam annotatedParam = annotatedParams.get(i);
View Full Code Here

    try {
      final CallTuple tuple = NamespaceUtil.get(destination,
          request.getMethod());
     
      final Object realDest = tuple.getDestination();
      final AnnotatedMethod annotatedMethod = tuple.getMethod();
      if (!isAvailable(annotatedMethod, realDest, requestParams, auth)) {
        throw new JSONRPCException(
            JSONRPCException.CODE.METHOD_NOT_FOUND,
            "Method '"
                + request.getMethod()
                + "' not found. The method does not exist or you are not authorized.");
      }
     
      final MethodHandle methodHandle = annotatedMethod.getMethodHandle();
      final Method method = annotatedMethod.getActualMethod();
     
      Object result;
      if (useMethodHandles) {
        final Object[] params = castParams(realDest,
            request.getParams(), annotatedMethod.getParams(),
            requestParams);
        result = methodHandle.invokeExact(params);
      } else {
        final Object[] params = castParams(request.getParams(),
            annotatedMethod.getParams(), requestParams);
        result = method.invoke(realDest, params);
      }
      if (result == null) {
        result = JOM.createNullNode();
      }
View Full Code Here

   *            the args
   * @return the jSON request
   */
  public static JSONRequest createRequest(final Method method,
      final Object[] args) {
    AnnotatedMethod annotatedMethod = null;
    try {
      annotatedMethod = new AnnotationUtil.AnnotatedMethod(method);
    } catch (final Exception e) {
      LOG.log(Level.WARNING, "Method can't be used as annotated method",
          e);
      throw new IllegalArgumentException("Method '" + method.getName()
          + "' can't be used as annotated method.", e);
    }
    final List<AnnotatedParam> annotatedParams = annotatedMethod
        .getParams();
   
    final ObjectNode params = JOM.createObjectNode();
   
    for (int i = 0; i < annotatedParams.size(); i++) {
View Full Code Here

      final CallTuple tuple = NamespaceUtil.get(destination,
          request.getMethod());
      final Object realDest = tuple.getDestination();
      final String realMethod = tuple.getMethodName();
     
      final AnnotatedMethod annotatedMethod = getMethod(realDest,
          realMethod, requestParams, auth);
      if (annotatedMethod == null) {
        throw new JSONRPCException(
            JSONRPCException.CODE.METHOD_NOT_FOUND,
            "Method '"
                + request.getMethod()
                + "' not found. The method does not exist or you are not authorized.");
      }
     
      final Method method = annotatedMethod.getActualMethod();
      final Object[] params = castParams(request.getParams(),
          annotatedMethod.getParams(), requestParams);
      Object result = method.invoke(realDest, params);
      if (result == null) {
        result = JOM.createNullNode();
      }
      resp.setResult(result);
View Full Code Here

   *            the args
   * @return the jSON request
   */
  public static JSONRequest createRequest(final Method method,
      final Object[] args) {
    AnnotatedMethod annotatedMethod = null;
    try {
      annotatedMethod = new AnnotationUtil.AnnotatedMethod(method);
    } catch (final Exception e) {
      LOG.log(Level.WARNING, "Method can't be used as annotated method",
          e);
      throw new IllegalArgumentException("Method '" + method.getName()
          + "' can't be used as annotated method.", e);
    }
    final List<AnnotatedParam> annotatedParams = annotatedMethod
        .getParams();
   
    final ObjectNode params = JOM.createObjectNode();
   
    for (int i = 0; i < annotatedParams.size(); i++) {
View Full Code Here

      RequestParams requestParams) {
    JSONResponse resp = new JSONResponse();
    resp.setId(request.getId());

    try {
      AnnotatedMethod annotatedMethod = getMethod(destination,
          request.getMethod(), requestParams);
      if (annotatedMethod == null) {
        throw new JSONRPCException(
            JSONRPCException.CODE.METHOD_NOT_FOUND, "Method '"
                + request.getMethod() + "' not found. The method does not exist or you are not authorized.");
      }

      Method method = annotatedMethod.getActualMethod();

      Object[] params = castParams(request.getParams(),
          annotatedMethod.getParams(), requestParams);
      Object result = method.invoke(destination, params);
      if (result == null) {
        result = JOM.createNullNode();
      }
      resp.setResult(result);
View Full Code Here

   * @param method
   * @param args
   * @return
   */
  public static JSONRequest createRequest(Method method, Object[] args) {
    AnnotatedMethod annotatedMethod = null;
    try {
      annotatedMethod = new AnnotationUtil.AnnotatedMethod(method);
    } catch (Exception e) {
      e.printStackTrace();
      throw new IllegalArgumentException("Method '" + method.getName()
          + "' can't be used as annotated method.");
    }
    List<AnnotatedParam> annotatedParams = annotatedMethod.getParams();

    ObjectNode params = JOM.createObjectNode();

    for (int i = 0; i < annotatedParams.size(); i++) {
      AnnotatedParam annotatedParam = annotatedParams.get(i);
View Full Code Here

      CallTuple tuple = NamespaceUtil.get(destination,
          request.getMethod());
      Object realDest = tuple.getDestination();
      String realMethod = tuple.getMethodName();
     
      AnnotatedMethod annotatedMethod = getMethod(realDest, realMethod,
          requestParams, auth);
      if (annotatedMethod == null) {
        throw new JSONRPCException(
            JSONRPCException.CODE.METHOD_NOT_FOUND,
            "Method '"
                + request.getMethod()
                + "' not found. The method does not exist or you are not authorized.");
      }
     
      Method method = annotatedMethod.getActualMethod();
      Object[] params = castParams(request.getParams(),
          annotatedMethod.getParams(), requestParams);
      Object result = method.invoke(realDest, params);
      if (result == null) {
        result = JOM.createNullNode();
      }
      resp.setResult(result);
View Full Code Here

   * @param method
   * @param args
   * @return
   */
  public static JSONRequest createRequest(Method method, Object[] args) {
    AnnotatedMethod annotatedMethod = null;
    try {
      annotatedMethod = new AnnotationUtil.AnnotatedMethod(method);
    } catch (Exception e) {
      logger.log(Level.WARNING,
          "Method can't be used as annotated method", e);
      throw new IllegalArgumentException("Method '" + method.getName()
          + "' can't be used as annotated method.", e);
    }
    List<AnnotatedParam> annotatedParams = annotatedMethod.getParams();
   
    ObjectNode params = JOM.createObjectNode();
   
    for (int i = 0; i < annotatedParams.size(); i++) {
      AnnotatedParam annotatedParam = annotatedParams.get(i);
View Full Code Here

TOP

Related Classes of com.almende.util.AnnotationUtil.AnnotatedMethod

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.