Beispiel #1
0
 public static void setEnv(Map<String, String> newenv) {
   try {
     Class<?> processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment");
     Field theEnvironmentField = processEnvironmentClass.getDeclaredField("theEnvironment");
     theEnvironmentField.setAccessible(true);
     Map<String, String> env = (Map<String, String>) theEnvironmentField.get(null);
     env.putAll(newenv);
     Field theCaseInsensitiveEnvironmentField =
         processEnvironmentClass.getDeclaredField("theCaseInsensitiveEnvironment");
     theCaseInsensitiveEnvironmentField.setAccessible(true);
     Map<String, String> cienv =
         (Map<String, String>) theCaseInsensitiveEnvironmentField.get(null);
     cienv.putAll(newenv);
   } catch (NoSuchFieldException e) {
     try {
       Class[] classes = Collections.class.getDeclaredClasses();
       Map<String, String> env = System.getenv();
       for (Class cl : classes) {
         if ("java.util.Collections$UnmodifiableMap".equals(cl.getName())) {
           Field field = cl.getDeclaredField("m");
           field.setAccessible(true);
           Object obj = field.get(env);
           Map<String, String> map = (Map<String, String>) obj;
           map.clear();
           map.putAll(newenv);
         }
       }
     } catch (Exception e2) {
       e2.printStackTrace();
     }
   } catch (Exception e1) {
     e1.printStackTrace();
   }
 }
  /**
   * Generates views based on annotations found in a repository class. If the repository class
   * extends org.ektorp.support.CouchDbRepositorySupport its handled type will also examined for
   * annotations eligible for view generation.
   *
   * @param repository
   * @return a Map with generated views.
   */
  public Map<String, DesignDocument.View> generateViews(final Object repository) {
    final Map<String, DesignDocument.View> views = new HashMap<String, DesignDocument.View>();
    final Class<?> repositoryClass = repository.getClass();

    final Class<?> handledType =
        repository instanceof CouchDbRepositorySupport<?>
            ? ((CouchDbRepositorySupport<?>) repository).getHandledType()
            : null;

    createDeclaredViews(views, repositoryClass);

    eachMethod(
        repositoryClass,
        new Predicate<Method>() {
          public boolean apply(Method input) {
            if (hasAnnotation(input, GenerateView.class)) {
              generateView(views, input, handledType);
            }
            return false;
          }
        });

    if (handledType != null) {
      views.putAll(generateViewsFromPersistentType(handledType));
    }
    return views;
  }
    /** Create a new round. */
    private Round(
        Round prev, Set<JavaFileObject> newSourceFiles, Map<String, JavaFileObject> newClassFiles) {
      this(prev.nextContext(), prev.number + 1, prev.nMessagerErrors, prev.compiler.log.nwarnings);
      this.genClassFiles = prev.genClassFiles;

      List<JCCompilationUnit> parsedFiles = compiler.parseFiles(newSourceFiles);
      roots = cleanTrees(prev.roots).appendList(parsedFiles);

      // Check for errors after parsing
      if (unrecoverableError()) return;

      enterClassFiles(genClassFiles);
      List<ClassSymbol> newClasses = enterClassFiles(newClassFiles);
      genClassFiles.putAll(newClassFiles);
      enterTrees(roots);

      if (unrecoverableError()) return;

      topLevelClasses =
          join(getTopLevelClasses(parsedFiles), getTopLevelClassesFromClasses(newClasses));

      packageInfoFiles =
          join(getPackageInfoFiles(parsedFiles), getPackageInfoFilesFromClasses(newClasses));

      findAnnotationsPresent();
    }
Beispiel #4
0
 /**
  * Copy constructor, used to get a deep copy of the passed instance
  *
  * @param source the instance to copy
  */
 public Dom(Dom source, Dom parent) {
   this(source.getHabitat(), source.document, parent, source.model);
   List<Child> newChildren = new ArrayList<Child>();
   for (Child child : source.children) {
     newChildren.add(child.deepCopy(this));
   }
   setChildren(newChildren);
   attributes.putAll(source.attributes);
 }