Package net.vidageek.mirror.dsl

Examples of net.vidageek.mirror.dsl.Mirror


  }

  private void tryToDefineInjectConstructor(ProcessAnnotatedType pat,
      AnnotatedTypeBuilder builder) {
    Class componentClass = pat.getAnnotatedType().getJavaClass();
    List<Constructor> constructors = new Mirror().on(componentClass)
        .reflectAll()
        .constructorsMatching(new ArgsAndNoInjectConstructorMatcher());
    boolean hasArgsConstructorAndNoInjection = !constructors.isEmpty();
    if (hasArgsConstructorAndNoInjection) {
      Constructor constructor = constructors.get(0);
View Full Code Here


    return builder.toString();
  }


  public String getControllerAndMethodName() {
    Field resourceMethodField = new Mirror().on(FixedMethodStrategy.class).reflect().field("resourceMethod");
    resourceMethodField.setAccessible(true);
    try {
      ControllerMethod resourceMethod = (ControllerMethod) resourceMethodField.get(route);
      return resourceMethod.getMethod().toString();
    } catch (Exception e) {
View Full Code Here

    collectors.collect(result);
  }

  void includeMethodInvocationReturnInResult(String name, Object obj, String methodName) {
    try {
      Object toBeIncluded = new Mirror().on(obj).invoke().method(methodName).withoutArgs();
      result.include(name, toBeIncluded);
    } catch (Exception e) {
      result.include(name, "not found");
    }
  }
View Full Code Here

  }

    private String toJBossVFSFileName(URL url)
        throws IOException {
        Object content = url.openConnection().getContent();
        File pfile = (File) new Mirror().on(content).invoke().method("getPhysicalFile").withoutArgs();
        logger.info("real file for url {} is {}", url, pfile);

        if (pfile.isDirectory()) {
            return pfile.getAbsolutePath() + "/";
        }
View Full Code Here

      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);

      if (validator.hasErrors()) { // method should have thrown
                      // ValidationException
        if (log.isDebugEnabled()) {
          try {
View Full Code Here

  }

  private Set<Class<?>> getParentTypes(String name, Class<?> type) {
    String[] path = name.split("\\.");
    for (int i = 0; i < path.length - 1; i++) {
      type = getActualType(new Mirror().on(type).reflect().field(path[i]).getGenericType());
    }
    Set<Class<?>> types = Sets.newHashSet();
    while(type != Object.class) {
      types.add(type);
      type = type.getSuperclass();
View Full Code Here

    }
    return set;
  }

  private void excludeNonPrimitiveFields(Class<?> type) {
    for (Field field : new Mirror().on(type).reflectAll().fields()) {
      if (!isPrimitive(field.getType())) {
        excludes.put(field.getDeclaringClass(), field.getName());
      }
    }
  }
View Full Code Here

    for (String field : fields) {
      try {
        Set<Class<?>> parentTypes = getParentTypesFor(field);
        String fieldName = getNameFor(field);
        for (Class<?> parentType : parentTypes) {
          Type genericType = new Mirror().on(parentType).reflect().field(fieldName).getGenericType();
          Class<?> fieldType = getActualType(genericType);

          if (!excludes.containsKey(fieldType)) {
            excludeNonPrimitiveFields(fieldType);
          }
View Full Code Here

  }

  public <I> void hear(TypeLiteral<I> literal, TypeEncounter<I> encounter) {
    final List<Method> constructs = new ArrayList<Method>();
    final List<Method> destroys = new ArrayList<Method>();
    for (Method method : new Mirror().on(literal.getRawType()).reflectAll().methods()) {
      if (method.isAnnotationPresent(PostConstruct.class)) {
        constructs.add(method);
      }

      if (method.isAnnotationPresent(PreDestroy.class)) {
        destroys.add(method);
      }
    }
   
    logger.debug("Registering lifecycle listeners for {}", literal);
   
    if (!constructs.isEmpty() || !destroys.isEmpty()) {
      encounter.register(new InjectionListener() {

        public void afterInjection(final Object instance) {
          for (Method method : constructs) {
            new Mirror().on(instance).invoke().method(method).withoutArgs();
          }
          scope.registerDestroyListener(new LifecycleListener() {
            public void onEvent() {
              for (Method method : destroys) {
                new Mirror().on(instance).invoke().method(method).withoutArgs();
              }
            }
          });
        }
View Full Code Here

  }

    public void replay(Result result) {
        Object current = result;
        for (ExceptionRecorderParameter p : parameters) {
            current = new Mirror().on(current).invoke().method(p.getMethod()).withArgs(p.getArgs());
        }
    }
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.