Package br.com.caelum.vraptor.resource

Examples of br.com.caelum.vraptor.resource.ResourceClass


      }
    });
    }

    public String pathFor(ResourceMethod method) {
        ResourceClass resource = method.getResource();
        if (Info.isOldComponent(resource)) {
            String component = Info.getComponentName(resource.getType());
            String logicName = Info.getLogicName(method.getMethod());
          logger.debug("path for {} - {}", component, logicName);

            return pattern.replaceAll("\\$component", component).replaceAll("\\$logic", logicName).replaceAll("\\$result", info.getResult().toString());
        }
View Full Code Here


  private void vraptor2Forward(ResourceMethod method) throws ServletException,
      IOException {
      logger.debug("Forwading using VRaptor2 URLs");

    String result = info.getResult().toString();
    ResourceClass resource = method.getResource();

    String key = Info.getComponentName(resource.getType()) + "." + Info.getLogicName(method.getMethod()) + "."
        + result;

    String path = config.getForwardFor(key);

    if (path == null) {
View Full Code Here

      }
    });
    }

    public String pathFor(ResourceMethod method) {
        ResourceClass resource = method.getResource();
        if (Info.isOldComponent(resource)) {
            String component = Info.getComponentName(resource.getType());
            String logicName = Info.getLogicName(method.getMethod());
          logger.debug("path for {} - {}", component, logicName);

            return pattern.replaceAll("\\$component", component).replaceAll("\\$logic", logicName).replaceAll("\\$result", info.getResult().toString());
        }
View Full Code Here

  private void vraptor2ForwardTo(ResourceMethod method) throws ServletException,
      IOException {
      logger.debug("Forwading using VRaptor2 URLs");

    String result = info.getResult().toString();
    ResourceClass resource = method.getResource();

    String key = Info.getComponentName(resource.getType()) + "." + Info.getLogicName(method.getMethod()) + "."
        + result;

    String path = config.getForwardFor(key);

    if (path == null) {
View Full Code Here

  }

  private void registerRulesFor(Class<?> type) {
    RoutesParser parser = new PathAnnotationRoutesParser(router);
   
    ResourceClass resourceClass = new DefaultResourceClass(type);
    List<Route> rules = parser.rulesFor(resourceClass);
    for (Route route : rules) {
      router.add(route);
    }
  }
View Full Code Here

    extractor = new DefaultTypeNameExtractor();
   
  deserializer = new JsonDeserializer(provider, extractor, XStreamBuilderImpl.cleanInstance());
 
    ResourceClass resourceClass = new DefaultResourceClass(CatController.class);

    meow = new DefaultResourceMethod(resourceClass, CatController.class.getDeclaredMethod("meow"));
    roll = new DefaultResourceMethod(resourceClass, CatController.class.getDeclaredMethod("roll", Cat.class));
    jump = new DefaultResourceMethod(resourceClass, CatController.class.getDeclaredMethod("jump", Cat.class, Integer.class));
    sleep = new DefaultResourceMethod(resourceClass, CatController.class.getDeclaredMethod("sleep", Integer.class, Cat.class));
View Full Code Here

  @Test
  public void shouldDeserializeFromGenericTypeOneParam() {
    InputStream stream = new ByteArrayInputStream(
        "{'entity':{'name':'Brutus','age':7,'birthday':'06/01/1987'}}".getBytes());
    ResourceClass resourceClass = new DefaultResourceClass(ExtGenericController.class);
    Method method = new Mirror().on(GenericController.class).reflect().method("method").withAnyArgs();
    ResourceMethod resource = new DefaultResourceMethod(resourceClass, method);
    when(provider.parameterNamesFor(resource.getMethod())).thenReturn(new String[] { "entity" });

    Object[] deserialized = deserializer.deserialize(stream, resource);
View Full Code Here

  @Test
  public void shouldDeserializeFromGenericTypeTwoParams() {
    InputStream stream = new ByteArrayInputStream(
        "{'entity':{'name':'Brutus','age':7,'birthday':'06/01/1987'}, 'param': 'test'}".getBytes());
    ResourceClass resourceClass = new DefaultResourceClass(ExtGenericController.class);
    Method method = new Mirror().on(GenericController.class).reflect().method("anotherMethod").withAnyArgs();
    ResourceMethod resource = new DefaultResourceMethod(resourceClass, method);
    when(provider.parameterNamesFor(resource.getMethod())).thenReturn(new String[] { "entity", "param" });

    Object[] deserialized = deserializer.deserialize(stream, resource);
View Full Code Here

  @Test
  public void shouldDeserializeWithoutGenericType() {
    InputStream stream = new ByteArrayInputStream(
        "{'param': 'test'}".getBytes());
    ResourceClass resourceClass = new DefaultResourceClass(ExtGenericController.class);
    Method method = new Mirror().on(GenericController.class).reflect().method("methodWithoutGenericType").withArgs(String.class);
    ResourceMethod resource = new DefaultResourceMethod(resourceClass, method);
    when(provider.parameterNamesFor(resource.getMethod())).thenReturn(new String[] { "param" });

    Object[] deserialized = deserializer.deserialize(stream, resource);
View Full Code Here

    public boolean matches(Object item) {
    if (!(item instanceof ResourceClass)) {
      return false;
    }
    ResourceClass other = (ResourceClass) item;
    return other.getType().equals(type);
    }

    public void describeTo(Description description) {
    description.appendText(" resource for " + type.getName());
    }
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.resource.ResourceClass

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.