Package ch.ralscha.extdirectspring.util

Examples of ch.ralscha.extdirectspring.util.MethodInfo


  public String router(HttpServletRequest request, HttpServletResponse response,
      @RequestParam("extAction") String extAction,
      @RequestParam("extMethod") String extMethod) throws IOException {

    ExtDirectResponse directResponse = new ExtDirectResponse(request);
    MethodInfo methodInfo = methodInfoCache.get(extAction, extMethod);

    boolean streamResponse;

    if (methodInfo != null && methodInfo.getForwardPath() != null) {
      return methodInfo.getForwardPath();
    }
    else if (methodInfo != null && methodInfo.getHandlerMethod() != null) {
      streamResponse = configurationService.getConfiguration().isStreamResponse()
          || methodInfo.isStreamResponse();

      HandlerMethod handlerMethod = methodInfo.getHandlerMethod();
      try {

        ModelAndView modelAndView;

        if (configurationService.getConfiguration().isSynchronizeOnSession()
            || methodInfo.isSynchronizeOnSession()) {
          HttpSession session = request.getSession(false);
          if (session != null) {
            Object mutex = WebUtils.getSessionMutex(session);
            synchronized (mutex) {
              modelAndView = handlerAdapter.handle(request, response,
                  handlerMethod);
            }
          }
          else {
            modelAndView = handlerAdapter.handle(request, response,
                handlerMethod);
          }
        }
        else {
          modelAndView = handlerAdapter
              .handle(request, response, handlerMethod);
        }

        ExtDirectFormPostResult formPostResult = (ExtDirectFormPostResult) modelAndView
            .getModel().get("extDirectFormPostResult");
        directResponse.setResult(formPostResult.getResult());
        directResponse.setJsonView(getJsonView(formPostResult,
            methodInfo.getJsonView()));
      }
      catch (Exception e) {
        log.error("Error calling method: " + extMethod,
            e.getCause() != null ? e.getCause() : e);
        directResponse.setResult(handleException(methodInfo, directResponse, e,
View Full Code Here


  @SuppressWarnings({ "rawtypes", "unchecked" })
  ExtDirectResponse handleMethodCall(ExtDirectRequest directRequest,
      HttpServletRequest request, HttpServletResponse response, Locale locale) {
    ExtDirectResponse directResponse = new ExtDirectResponse(directRequest);

    MethodInfo methodInfo = methodInfoCache.get(directRequest.getAction(),
        directRequest.getMethod());

    if (methodInfo != null) {

      try {
        directResponse.setStreamResponse(methodInfo.isStreamResponse());
        Object result = processRemotingRequest(request, response, locale,
            directRequest, methodInfo);

        if (result != null) {

          ModelAndJsonView modelAndJsonView = null;
          if (result instanceof ModelAndJsonView) {
            modelAndJsonView = (ModelAndJsonView) result;
            result = modelAndJsonView.getModel();
          }

          if (methodInfo.isType(ExtDirectMethodType.FORM_LOAD)
              && !ExtDirectFormLoadResult.class.isAssignableFrom(result
                  .getClass())) {
            ExtDirectFormLoadResult formLoadResult = new ExtDirectFormLoadResult(
                result);
            if (result instanceof JsonViewHint) {
              formLoadResult.setJsonView(((JsonViewHint) result)
                  .getJsonView());
            }
            result = formLoadResult;
          }
          else if ((methodInfo.isType(ExtDirectMethodType.STORE_MODIFY) || methodInfo
              .isType(ExtDirectMethodType.STORE_READ))
              && !ExtDirectStoreResult.class.isAssignableFrom(result
                  .getClass())
              && configurationService.getConfiguration()
                  .isAlwaysWrapStoreResponse()) {
            if (result instanceof Collection) {
              result = new ExtDirectStoreResult((Collection) result);
            }
            else {
              result = new ExtDirectStoreResult(result);
            }
          }
          else if (methodInfo.isType(ExtDirectMethodType.FORM_POST_JSON)) {
            if (result instanceof ExtDirectFormPostResult) {
              ExtDirectFormPostResult formPostResult = (ExtDirectFormPostResult) result;
              result = formPostResult.getResult();
            }
          }

          directResponse.setResult(result);
          if (modelAndJsonView != null) {
            directResponse.setJsonView(getJsonView(modelAndJsonView,
                methodInfo.getJsonView()));
          }
          else {
            directResponse.setJsonView(getJsonView(result,
                methodInfo.getJsonView()));
          }

        }
        else {
          if (methodInfo.isType(ExtDirectMethodType.STORE_MODIFY)
              || methodInfo.isType(ExtDirectMethodType.STORE_READ)) {
            directResponse.setResult(Collections.emptyList());
          }
        }

      }
View Full Code Here

    }
    return paramLength;
  }
 
  private List<String> parameterNames(final Class<?> beanClass, final Method method) {
    MethodInfo methodInfo = new MethodInfo(beanClass, method);
   
    List<String> result = new ArrayList<String>();
    List<ParameterInfo> parameters = methodInfo.getParameters();
    for (ParameterInfo parameter : parameters) {
      if (!parameter.isSupportedParameter()) {
        result.add(parameter.getName());
      }
    }
View Full Code Here

    ExtDirectPollResponse directPollResponse = new ExtDirectPollResponse();
    directPollResponse.setName(event);

    try {
      MethodInfo methodInfo = ExtDirectSpringUtil.findMethodInfo(context, beanName, method);

      List<ParameterInfo> methodParameters = methodInfo.getParameters();
      Object[] parameters = null;
      if (!methodParameters.isEmpty()) {
        parameters = new Object[methodParameters.size()];

        for (int paramIndex = 0; paramIndex < methodParameters.size(); paramIndex++) {
View Full Code Here

  }

  @RequestMapping(value = "/router", method = RequestMethod.POST, params = "extAction")
  public String router(@RequestParam("extAction") String extAction, @RequestParam("extMethod") String extMethod) {

    MethodInfo methodInfo = ExtDirectSpringUtil.findMethodInfo(context, extAction, extMethod);
    if (methodInfo.getForwardPath() != null) {
      return methodInfo.getForwardPath();
    }
    throw new IllegalArgumentException("Invalid remoting form method: " + extAction + "." + extMethod);

  }
View Full Code Here

    for (ExtDirectRequest directRequest : directRequests) {

      ExtDirectResponse directResponse = new ExtDirectResponse(directRequest);

      try {
        MethodInfo methodInfo = ExtDirectSpringUtil.findMethodInfo(context, directRequest.getAction(),
            directRequest.getMethod());

        Object result = processRemotingRequest(request, response, locale, directRequest, methodInfo);

        if (result != null) {

          if (methodInfo.isType(ExtDirectMethodType.FORM_LOAD)
              && !ExtDirectFormLoadResult.class.isAssignableFrom(result.getClass())) {
            result = new ExtDirectFormLoadResult(result);
          } else if ((methodInfo.isType(ExtDirectMethodType.STORE_MODIFY) || methodInfo
              .isType(ExtDirectMethodType.STORE_READ))
              && !ExtDirectStoreResponse.class.isAssignableFrom(result.getClass())) {
            result = new ExtDirectStoreResponse((Collection) result);
          }
View Full Code Here

    ExtDirectPollResponse directPollResponse = new ExtDirectPollResponse();
    directPollResponse.setName(event);

    try {
      MethodInfo methodInfo = ExtDirectSpringUtil.findMethodInfo(context, beanName, method);

      List<ParameterInfo> methodParameters = methodInfo.getParameters();
      Object[] parameters = null;
      if (!methodParameters.isEmpty()) {
        parameters = new Object[methodParameters.size()];

        for (int paramIndex = 0; paramIndex < methodParameters.size(); paramIndex++) {
View Full Code Here

  }

  @RequestMapping(value = "/router", method = RequestMethod.POST, params = "extAction")
  public String router(@RequestParam("extAction") String extAction, @RequestParam("extMethod") String extMethod) {

    MethodInfo methodInfo = ExtDirectSpringUtil.findMethodInfo(context, extAction, extMethod);
    if (methodInfo.getForwardPath() != null) {
      return methodInfo.getForwardPath();
    }
    throw new IllegalArgumentException("Invalid remoting form method: " + extAction + "." + extMethod);

  }
View Full Code Here

    for (ExtDirectRequest directRequest : directRequests) {

      ExtDirectResponse directResponse = new ExtDirectResponse(directRequest);

      try {
        MethodInfo methodInfo = ExtDirectSpringUtil.findMethodInfo(context, directRequest.getAction(),
            directRequest.getMethod());

        Object result = processRemotingRequest(request, response, locale, directRequest, methodInfo);

        if (result != null) {

          if (methodInfo.isType(ExtDirectMethodType.FORM_LOAD)
              && !ExtDirectFormLoadResult.class.isAssignableFrom(result.getClass())) {
            result = new ExtDirectFormLoadResult(result);
          } else if ((methodInfo.isType(ExtDirectMethodType.STORE_MODIFY) || methodInfo
              .isType(ExtDirectMethodType.STORE_READ))
              && !ExtDirectStoreResponse.class.isAssignableFrom(result.getClass())) {
            result = new ExtDirectStoreResponse((Collection) result);
          }
         
View Full Code Here

    ExtDirectPollResponse directPollResponse = new ExtDirectPollResponse();
    directPollResponse.setName(event);

    try {
      MethodInfo methodInfo = ExtDirectSpringUtil.findMethodInfo(context, beanName, method);

      List<ParameterInfo> methodParameters = methodInfo.getParameters();
      Object[] parameters = null;
      if (!methodParameters.isEmpty()) {
        parameters = new Object[methodParameters.size()];

        for (int paramIndex = 0; paramIndex < methodParameters.size(); paramIndex++) {
View Full Code Here

TOP

Related Classes of ch.ralscha.extdirectspring.util.MethodInfo

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.