Package net.vidageek.mirror.dsl

Examples of net.vidageek.mirror.dsl.Mirror


  @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


    @Override
    public String toString() {
      Method method = null;
     
      if(getMethodsAmountWithSameName() > 1 && args.size() > 0) {
        method = new Mirror().on(controller).reflect().method(methodName).withArgs(getClasses(args));
      } else {
        method = findMethodWithName(controller, methodName);
      }
     
      if(method == null)
View Full Code Here

    return returnObject;
  }

  private Object invokeMethod(Object interceptor, Method stepMethod, Object... params) {
    try {
      return new Mirror().on(interceptor).invoke().method(stepMethod).withArgs(params);
    } catch (Exception e) {
      // we dont wanna wrap it if it is a simple controller business logic
      // exception
      propagateIfInstanceOf(e.getCause(), ApplicationLogicException.class);
      throw new InterceptionException(e.getCause());
View Full Code Here

    }
    return true;
  }

  public MirrorList<Method> findAllMethods(Class<?> interceptorClass) {
    return new Mirror().on(interceptorClass).reflectAll().methods();
  }
View Full Code Here

    }
    return values;
  }

  public boolean invoke() {
    return (boolean) new Mirror().on(toInvoke).invoke().method(methodToInvoke).withArgs(argumentValues);
  }
View Full Code Here

    return methodToInvoke;
  }

  private Method getMethodToInvoke(Class<?> toInvoke, String methodName, final Object[] arguments) throws NoSuchMethodException, SecurityException {
   
    ClassController<?> clazz = new Mirror().on(toInvoke);
    if(arguments == null)
      return clazz.reflect().method(methodName).withoutArgs();

    MirrorList<Method> matching = clazz
        .reflectAll()
View Full Code Here

    }

    boolean skip = false;

    if (!serializee.isRecursive())
      skip = !isPrimitive(new Mirror().on(definedIn).reflect().field(fieldName).getType());

    return skip;
  }
View Full Code Here

 
  protected Method getMethod() {
    Method method = null;

    if (countMethodsWithSameName() > 1) {
      method = new Mirror().on(controller).reflect().method(methodName).withArgs(getClasses(args));
      if (method == null && args.isEmpty()) {
        throw new IllegalArgumentException("Ambiguous method '" + methodName + "' on " + controller + ". Try to add some parameters to resolve ambiguity, or use different method names.");
      }
    } else {
      method = findMethodWithName(controller, methodName);
View Full Code Here

  }

  private List<Method> getMethods(Class<?> controller) {
    List<Method> methods = new ArrayList<>();
   
    for (Method method : new Mirror().on(controller).reflectAll().methods()) {
      if (!method.getDeclaringClass().equals(Object.class)) {
        methods.add(method);
      }
    }
   
View Full Code Here

    public String getLink() {
      Method method = null;

      if (getMethodsAmountWithSameName() > 1) {
        method = new Mirror().on(controller).reflect().method(methodName).withArgs(getClasses(args));
        if (method == null && args.isEmpty()) {
          throw new IllegalArgumentException("Ambiguous method '" + methodName + "' on " + controller + ". Try to add some parameters to resolve ambiguity, or use different method names.");
        }
      } else {
        method = findMethodWithName(controller, methodName);
View Full Code Here

TOP

Related Classes of net.vidageek.mirror.dsl.Mirror

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.