Package br.com.caelum.vraptor.controller

Examples of br.com.caelum.vraptor.controller.ControllerMethod


    String controllerName = request.getRequestedUri();

    logger.debug("trying to access {}", controllerName);

    HttpMethod method = getHttpMethod(request, controllerName);
    ControllerMethod controller = router.parse(controllerName, method, request);

    logger.debug("found controller {}", controller);
    return controller;
  }
View Full Code Here


  }

  public void deserializes(@Observes InterceptorsReady event, HttpServletRequest request,
      MethodInfo methodInfo, Status status) throws IOException {

    ControllerMethod method = event.getControllerMethod();

    if (!method.containsAnnotation(Consumes.class)) return;

    List<String> supported =  asList(method.getMethod().getAnnotation(Consumes.class).value());

    String contentType = mime(request.getContentType());
    if (!supported.isEmpty() && !supported.contains(contentType)) {
      unsupported("Request with media type [%s]. Expecting one of %s.", status, contentType, supported);
      return;
View Full Code Here

    this.interceptorStack = interceptorStack;
  }

  public void handle(@Observes VRaptorRequestStarted event) {
    try {
      ControllerMethod method = translator.translate(event.getRequest());
      controllerFoundEvent.fire(new ControllerFound(method));
      interceptorStack.start();
      endRequestEvent.fire(new RequestSucceded(event.getRequest(), event.getResponse()));
    } catch (ControllerNotFoundException e) {
      controllerNotFoundHandler.couldntFind(event.getChain(), event.getRequest(), event.getResponse());
View Full Code Here

  }

  @Override
  public void start() {
    ControllerMethod method = controllerMethod.get();
    interceptorsReadyEvent.fire(new InterceptorsReady(method));
    LinkedList<InterceptorHandler> handlers = cache.getInterceptorHandlers();
    internalStack.addFirst(handlers.iterator());
    this.next(method, controllerInstance.get().getController());
    internalStack.poll();
View Full Code Here

    this.methodReady = methodReady;
  }

  public void execute(@Observes InterceptorsExecuted event) {
    try {
      ControllerMethod method = event.getControllerMethod();
      methodReady.fire(new MethodReady(method));
      Method reflectionMethod = method .getMethod();
      Object[] parameters = methodInfo.getParametersValues();

      log.debug("Invoking {}", reflectionMethod);
      Object instance = event.getControllerInstance();
      Object result = new Mirror().on(instance).invoke().method(reflectionMethod).withArgs(parameters);
View Full Code Here

    return any(asList(method.getMethod().getParameterAnnotations()), hasAnnotation(Load.class));
  }

  public void load(@Observes ControllerMethodDiscovered event){
   
    ControllerMethod method = event.getControllerMethod();
   
    if (!containsLoadAnnotation(method)) return;
   
    Annotation[][] annotations = method.getMethod().getParameterAnnotations();

    Parameter[] parameters = provider.parametersFor(method.getMethod());
    Class<?>[] types = method.getMethod().getParameterTypes();

    Object[] args = flash.consumeParameters(method);

    for (int i = 0; i < parameters.length; i++) {
      if (hasLoadAnnotation(annotations[i])) {
View Full Code Here

    }
    return routesMatchingURI;
  }

  public void cacheRoute(Route r) {
    ControllerMethod controllerMethod = r.getControllerMethod();
    BeanClass controller = controllerMethod.getController();
    Invocation invocation = new Invocation(controller.getType(), controllerMethod.getMethod());
    cache.putIfAbsent(invocation, r);
  }
View Full Code Here

    return proxifier.proxify(type, handler);
  }

  public void is(Class<?> type, Method method) {
    addParametersInfo(method);
    ControllerMethod controllerMethod = DefaultControllerMethod.instanceFor(type, method);
    String[] parameterNames = nameProvider.parameterNamesFor(method);
    this.strategy = new FixedMethodStrategy(originalUri, controllerMethod, this.supportedMethods, builder.build(), priority, parameterNames);

    logger.info(String.format("%-50s%s -> %10s", originalUri,
        this.supportedMethods.isEmpty() ? "[ALL]" : this.supportedMethods,
View Full Code Here

    try {
      method = HttpMethod.of(request);
    } catch (IllegalArgumentException e) {
      throw new MethodNotAllowedException(router.allowedMethodsFor(controllerName), request.getMethod());
    }
    ControllerMethod controller = router.parse(controllerName, method, request);

    logger.debug("found controller {}", controller);
    return controller;
  }
View Full Code Here

  public <T> T forwardTo(final Class<T> type) {
    return proxifier.proxify(type, new MethodInvocation<T>() {
      public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) {
        try {
          logger.debug("Executing {}", Stringnifier.simpleNameFor(method));
          ControllerMethod old = methodInfo.getControllerMethod();
          methodInfo.setControllerMethod(DefaultControllerMethod.instanceFor(type, method));
          Object result = method.invoke(container.instanceFor(type), args);
          methodInfo.setControllerMethod(old);

          Type returnType = method.getGenericReturnType();
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.controller.ControllerMethod

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.