Package ch.ralscha.extdirectspring.util

Examples of ch.ralscha.extdirectspring.util.MethodInfo


  @RequestMapping(value = "/router", method = RequestMethod.POST, params = "extAction")
  public String router(final HttpServletRequest request, final HttpServletResponse response,
      @RequestParam("extAction") final String extAction, @RequestParam("extMethod") final String extMethod)
      throws IOException {

    MethodInfo methodInfo = MethodInfoCache.INSTANCE.get(extAction, extMethod);

    if (methodInfo != null && methodInfo.getForwardPath() != null) {
      return methodInfo.getForwardPath();
    }

    log.error("Error invoking method '" + extAction + "." + extMethod + "'. Method  or Bean not found");
    ExtDirectResponse directResponse = new ExtDirectResponse(request);
    handleMethodNotFoundError(directResponse, extAction, extMethod);
View Full Code Here


    for (ExtDirectRequest directRequest : directRequests) {

      ExtDirectResponse directResponse = new ExtDirectResponse(directRequest);

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

      if (methodInfo != null) {

        try {
          streamResponse = streamResponse || methodInfo.isStreamResponse();

          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())
                && configuration.isAlwaysWrapStoreResponse()) {
              if (result instanceof Collection) {
                result = new ExtDirectStoreResponse((Collection) result);
              } else {
                result = new ExtDirectStoreResponse(result);
              }
            }

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

        } catch (Exception e) {
View Full Code Here

  }

  private void buildRemotingApi(final RemotingApi remotingApi, final String group) {

    for (Map.Entry<MethodInfoCache.Key, MethodInfo> entry : MethodInfoCache.INSTANCE) {
      final MethodInfo methodInfo = entry.getValue();
      if (isSameGroup(group, methodInfo.getGroup())) {
        if (methodInfo.getAction() != null) {
          remotingApi.addAction(entry.getKey().getBeanName(), methodInfo.getAction());
        } else {
          remotingApi.addPollingProvider(methodInfo.getPollingProvider());
        }
      }
    }
  }
View Full Code Here

      final HttpServletResponse response, final Locale locale) throws Exception {

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

    MethodInfo methodInfo = MethodInfoCache.INSTANCE.get(beanName, method);
    boolean streamResponse;

    if (methodInfo != null) {

      streamResponse = configuration.isStreamResponse() || methodInfo.isStreamResponse();

      try {

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

          for (int paramIndex = 0; paramIndex < methodParameters.size(); paramIndex++) {
            ParameterInfo methodParameter = methodParameters.get(paramIndex);

            if (methodParameter.isSupportedParameter()) {
              parameters[paramIndex] = SupportedParameters.resolveParameter(methodParameter.getType(),
                  request, response, locale);
            } else if (methodParameter.isHasRequestHeaderAnnotation()) {
              parameters[paramIndex] = handleRequestHeader(request, methodParameter);
            } else {
              parameters[paramIndex] = handleRequestParam(request, null, methodParameter);
            }

          }
        }

        if (configuration.isSynchronizeOnSession() || methodInfo.isSynchronizeOnSession()) {
          HttpSession session = request.getSession(false);
          if (session != null) {
            Object mutex = WebUtils.getSessionMutex(session);
            synchronized (mutex) {
              directPollResponse.setData(ExtDirectSpringUtil.invoke(context, beanName, methodInfo,
View Full Code Here

  @RequestMapping(value = "/router", method = RequestMethod.POST, params = "extAction")
  public String router(final HttpServletRequest request, final HttpServletResponse response,
      @RequestParam("extAction") final String extAction, @RequestParam("extMethod") final String extMethod)
      throws IOException {

    MethodInfo methodInfo = MethodInfoCache.INSTANCE.get(extAction, extMethod);

    if (methodInfo != null && methodInfo.getForwardPath() != null) {
      return methodInfo.getForwardPath();
    }

    log.error("Error invoking method '" + extAction + "." + extMethod + "'. Method  or Bean not found");
    ExtDirectResponse directResponse = new ExtDirectResponse(request);
    handleMethodNotFoundError(directResponse, extAction, extMethod);
View Full Code Here

    for (ExtDirectRequest directRequest : directRequests) {

      ExtDirectResponse directResponse = new ExtDirectResponse(directRequest);

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

      if (methodInfo != null) {

        try {
          streamResponse = streamResponse || methodInfo.isStreamResponse();

          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())
                && configuration.isAlwaysWrapStoreResponse()) {
              if (result instanceof Collection) {
                result = new ExtDirectStoreResponse((Collection) result);
              } else {
                List responses = new ArrayList();
                responses.add(result);
                result = new ExtDirectStoreResponse(responses);
              }
            }

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

        } catch (Exception e) {
View Full Code Here

  }

  private static void buildRemotingApi(RemotingApi remotingApi, String group) {

    for (Map.Entry<MethodInfoCache.Key, MethodInfo> entry : MethodInfoCache.INSTANCE) {
      MethodInfo methodInfo = entry.getValue();
      if (isSameGroup(group, methodInfo.getGroup())) {
        if (methodInfo.getAction() != null) {
          remotingApi.addAction(entry.getKey().getBeanName(), methodInfo.getAction());
        } else {
          remotingApi.addPollingProvider(methodInfo.getPollingProvider());
        }
      }
    }
  }
View Full Code Here

      throws Exception {

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

    MethodInfo methodInfo = MethodInfoCache.INSTANCE.get(beanName, method);
    boolean streamResponse;

    if (methodInfo != null) {

      streamResponse = configuration.isStreamResponse() || methodInfo.isStreamResponse();

      try {

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

          for (int paramIndex = 0; paramIndex < methodParameters.size(); paramIndex++) {
            ParameterInfo methodParameter = methodParameters.get(paramIndex);

            if (methodParameter.isSupportedParameter()) {
              parameters[paramIndex] = SupportedParameters.resolveParameter(methodParameter.getType(),
                  request, response, locale);
            } else if (methodParameter.isHasRequestHeaderAnnotation()) {
              parameters[paramIndex] = parametersResolver.resolveRequestHeader(request, methodParameter);
            } else {
              parameters[paramIndex] = parametersResolver.resolveRequestParam(request, null,
                  methodParameter);
            }

          }
        }

        if (configuration.isSynchronizeOnSession() || methodInfo.isSynchronizeOnSession()) {
          HttpSession session = request.getSession(false);
          if (session != null) {
            Object mutex = WebUtils.getSessionMutex(session);
            synchronized (mutex) {
              directPollResponse.setData(ExtDirectSpringUtil.invoke(context, beanName, methodInfo,
View Full Code Here

  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.INSTANCE.get(extAction, extMethod);
    boolean streamResponse;

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

      HandlerMethod handlerMethod = methodInfo.getHandlerMethod();
      try {

        ModelAndView modelAndView = null;

        if (configuration.isSynchronizeOnSession() || methodInfo.isSynchronizeOnSession()) {
          HttpSession session = request.getSession(false);
          if (session != null) {
            Object mutex = WebUtils.getSessionMutex(session);
            synchronized (mutex) {
              modelAndView = handlerAdapter.handle(request, response, handlerMethod);
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.INSTANCE.get(directRequest.getAction(), directRequest.getMethod());

    if (methodInfo != null) {

      try {
        directResponse.setStreamResponse(methodInfo.isStreamResponse());

        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))
              && !ExtDirectStoreReadResult.class.isAssignableFrom(result.getClass())
              && configuration.isAlwaysWrapStoreResponse()) {
            if (result instanceof Collection) {
              result = new ExtDirectStoreReadResult((Collection) result);
            } else {
              result = new ExtDirectStoreReadResult(result);
            }
          }

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

      } catch (Exception e) {
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.