Пример #1
0
  @SuppressWarnings("unchecked")
  public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) {
    parameters.add(new ExceptionRecorderParameter(args, method));

    if (void.class.equals(method.getReturnType())) {
      return null;
    }

    return proxifier.proxify(findReturnType(method, args), (MethodInvocation) this);
  }
 public <T> T relation(final Class<T> type) {
   return proxifier.proxify(
       type,
       new MethodInvocation<T>() {
         public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) {
           T instance = relation(method.getName()).uses(type);
           new Mirror().on(instance).invoke().method(method).withArgs(args);
           return null;
         }
       });
 }
Пример #3
0
 public <T> T uriFor(final Class<T> type) {
   return proxifier.proxify(
       type,
       new MethodInvocation<T>() {
         public Object intercept(
             T proxy,
             java.lang.reflect.Method method,
             Object[] args,
             br.com.caelum.vraptor.proxy.SuperMethod superMethod) {
           uri = router.urlFor(type, method, args);
           return null;
         };
       });
 }
Пример #4
0
 /**
  * This implementation don't actually use request dispatcher for the forwarding. It runs
  * forwarding logic, and renders its <b>default</b> view.
  */
 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 {
             method.invoke(container.instanceFor(type), args);
             request
                 .getRequestDispatcher(
                     resolver.pathFor(DefaultResourceMethod.instanceFor(type, method)))
                 .forward(request, response);
             return null;
           } catch (Exception e) {
             throw new ProxyInvocationException(e);
           }
         }
       });
 }
Пример #5
0
 public <T> T redirectTo(final Class<T> type) {
   return proxifier.proxify(
       type,
       new MethodInvocation<T>() {
         public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) {
           if (!acceptsHttpGet(method)) {
             throw new IllegalArgumentException(
                 "Your logic method must accept HTTP GET method if you want to redirect to it");
           }
           try {
             String path = context.getContextPath();
             String url = router.urlFor(type, method, args);
             includeParametersInFlash(type, method, args);
             response.sendRedirect(path + url);
             return null;
           } catch (IOException e) {
             throw new ProxyInvocationException(e);
           }
         }
       });
 }
Пример #6
0
 @Override
 public <T> T linkTo(Class<T> controllerType) {
   this.controllerType = controllerType;
   MethodInvocation<T> invocation = new CacheInvocation();
   return proxifier.proxify(controllerType, invocation);
 }