Examples of AntPatternMatcher


Examples of org.codehaus.enunciate.util.AntPatternMatcher

          imported |= !classes2sources.containsKey(foundEntry.getKey());
          classes2sources.put(foundEntry.getKey(), sourceFile);
        }
      }
      else if (this.enunciate.getConfig() != null && this.enunciate.getConfig().getAPIImports() != null && !this.enunciate.getConfig().getAPIImports().isEmpty()) {
        AntPatternMatcher matcher = new AntPatternMatcher();
        matcher.setPathSeparator(".");
        for (APIImport apiImport : this.enunciate.getConfig().getAPIImports()) {
          String pattern = apiImport.getPattern();
          if (pattern != null) {
            if (!classes2sources.containsKey(foundEntry.getKey())) {
              if (pattern.equals(foundEntry.getKey())) {
                this.enunciate.debug("Class %s will be imported because it was explicitly listed.", foundEntry.getKey());
                imported |= !classes2sources.containsKey(foundEntry.getKey());
                classes2sources.put(foundEntry.getKey(), apiImport.isSeekSource() ? foundEntry.getValue() : null);
              }
              else if (matcher.isPattern(pattern) && matcher.match(pattern, foundEntry.getKey())) {
                this.enunciate.debug("Class %s will be imported because it matches pattern %s.", foundEntry.getKey(), pattern);
                imported |= !classes2sources.containsKey(foundEntry.getKey());
                classes2sources.put(foundEntry.getKey(), apiImport.isSeekSource() ? foundEntry.getValue() : null);
              }
            }
View Full Code Here

Examples of org.codehaus.enunciate.util.AntPatternMatcher

    final File compileDir = getCompileDir();
    if (!enunciate.isUpToDateWithSources(compileDir)) {
      enunciate.compileSources(compileDir);

      if (getWebAppConfig() != null && !getWebAppConfig().getCopyResources().isEmpty()) {
        AntPatternMatcher matcher = new AntPatternMatcher();
        for (CopyResources copyResource : getWebAppConfig().getCopyResources()) {
          String pattern = copyResource.getPattern();
          if (pattern == null) {
            throw new EnunciateException("A pattern must be specified for copying resources.");
          }

          if (!matcher.isPattern(pattern)) {
            warn("'%s' is not a valid pattern.  Resources NOT copied!", pattern);
            continue;
          }

          File basedir;
View Full Code Here

Examples of org.codehaus.enunciate.util.AntPatternMatcher

    File webinf = new File(buildDir, "WEB-INF");
    File webinfClasses = new File(webinf, "classes");
    File webinfLib = new File(webinf, "lib");

    //initialize the include filters.
    AntPatternMatcher pathMatcher = new AntPatternMatcher();
    pathMatcher.setPathSeparator(File.separator);
    List<File> explicitIncludes = new ArrayList<File>();
    List<String> includePatterns = new ArrayList<String>();
    WebAppConfig webAppConfig = getWebAppConfig();
    if (webAppConfig != null) {
      for (IncludeExcludeLibs el : webAppConfig.getIncludeLibs()) {
        if (el.getFile() != null) {
          //add explicit files to the include files list.
          explicitIncludes.add(el.getFile());
        }

        String pattern = el.getPattern();
        if (pattern != null) {
          //normalize the pattern to the platform.
          pattern = pattern.replace('/', File.separatorChar);
          if (pathMatcher.isPattern(pattern)) {
            //make sure that the includes pattern list only has patterns.
            includePatterns.add(pattern);
          }
          else {
            warn("Pattern '%s' is not a valid pattern, so it will not be applied.", pattern);
          }
        }
      }
    }

    if (includePatterns.isEmpty()) {
      //if no include patterns are specified, the implicit pattern is "**/*".
      String starPattern = "**" + File.separatorChar + "*";
      debug("No include patterns have been specified.  Using the implicit '%s' pattern.", starPattern);
      includePatterns.add(starPattern);
    }

    List<String> warLibs = new ArrayList<String>();
    if (webAppConfig == null || webAppConfig.isIncludeClasspathLibs()) {
      debug("Using the Enunciate classpath as the initial list of libraries to be passed through the include/exclude filter.");
      //prime the list of libs to include in the war with what's on the enunciate classpath.
      warLibs.addAll(Arrays.asList(enunciate.getEnunciateRuntimeClasspath().split(File.pathSeparator)));
    }

    // Apply the "in filter" (i.e. the filter that specifies the files to be included).
    List<File> includedLibs = new ArrayList<File>();
    for (String warLib : warLibs) {
      File libFile = new File(warLib);
      if (libFile.exists()) {
        for (String includePattern : includePatterns) {
          String absolutePath = libFile.getAbsolutePath();
          if (absolutePath.startsWith(File.separator)) {
            //lob off the beginning "/" for Linux boxes.
            absolutePath = absolutePath.substring(1);
          }
          if (pathMatcher.match(includePattern, absolutePath)) {
            debug("Library '%s' passed the include filter. It matches pattern '%s'.", libFile.getAbsolutePath(), includePattern);
            includedLibs.add(libFile);
            break;
          }
          else if (enunciate.isDebug()) {
            debug("Library '%s' did NOT match include pattern '%s'.", includePattern);
          }
        }
      }
    }

    //Now, with what's left, apply the "exclude filter".
    boolean excludeDefaults = webAppConfig == null || webAppConfig.isExcludeDefaultLibs();
    List<String> manifestClasspath = new ArrayList<String>();
    Iterator<File> toBeIncludedIt = includedLibs.iterator();
    while (toBeIncludedIt.hasNext()) {
      File toBeIncluded = toBeIncludedIt.next();
      if (excludeDefaults && knownExclude(toBeIncluded)) {
        toBeIncludedIt.remove();
      }
      else if (webAppConfig != null) {
        for (IncludeExcludeLibs excludeLibs : webAppConfig.getExcludeLibs()) {
          boolean exclude = false;
          if ((excludeLibs.getFile() != null) && (excludeLibs.getFile().equals(toBeIncluded))) {
            exclude = true;
            debug("%s was explicitly excluded.", toBeIncluded);
          }
          else {
            String pattern = excludeLibs.getPattern();
            if (pattern != null) {
              pattern = pattern.replace('/', File.separatorChar);
              if (pathMatcher.isPattern(pattern)) {
                String absolutePath = toBeIncluded.getAbsolutePath();
                if (absolutePath.startsWith(File.separator)) {
                  //lob off the beginning "/" for Linux boxes.
                  absolutePath = absolutePath.substring(1);
                }

                if (pathMatcher.match(pattern, absolutePath)) {
                  exclude = true;
                  debug("%s was excluded because it matches pattern '%s'", toBeIncluded, pattern);
                }
              }
            }
View Full Code Here

Examples of org.codehaus.enunciate.util.AntPatternMatcher

    // initialize the list classes that were imported.
    final Map<String, File> classes2sources = importedClassesHandler.getClassesToSources();

    //now add any explicit api imports that are not patterns (i.e. they're assumed to be class names).
    if (this.config != null && this.config.getAPIImports() != null && !this.config.getAPIImports().isEmpty()) {
      AntPatternMatcher matcher = new AntPatternMatcher();
      matcher.setPathSeparator(".");
      for (APIImport apiImport : this.config.getAPIImports()) {
        if (!matcher.isPattern(apiImport.getPattern()) && !classes2sources.containsKey(apiImport.getPattern())) {
          warn("Class %s was explicitly imported, but it was not found on the classpath. We'll try to import it anyway.", apiImport.getPattern());
          classes2sources.put(apiImport.getPattern(), null);
        }
      }
    }
View Full Code Here

Examples of org.codehaus.enunciate.util.AntPatternMatcher

   *
   * @param typeDeclarations the declarations.
   */
  protected void removeExcludedClasses(Collection<TypeDeclaration> typeDeclarations) {
    EnunciateConfiguration config = this.enunciate.getConfig();
    AntPatternMatcher matcher = new AntPatternMatcher();
    matcher.setPathSeparator(".");
    if (!config.getApiExcludePatterns().isEmpty()) {
      Iterator<TypeDeclaration> typeDeclarationIt = typeDeclarations.iterator();
      while (typeDeclarationIt.hasNext()) {
        TypeDeclaration typeDeclaration = typeDeclarationIt.next();
        boolean exclude = false;
        if (config.getApiExcludePatterns().contains(typeDeclaration.getQualifiedName())) {
          exclude = true;
          debug("%s was explicitly excluded.", typeDeclaration.getQualifiedName());
        }
        else {
          for (String excludePattern : config.getApiExcludePatterns()) {
            if (matcher.match(excludePattern, typeDeclaration.getQualifiedName())) {
              exclude = true;
              debug("%s matches exclude pattern %s.", typeDeclaration.getQualifiedName(), excludePattern);
              break;
            }
          }
View Full Code Here

Examples of org.codehaus.enunciate.util.AntPatternMatcher

   *
   * @param typeDeclarations The declarations.
   */
  protected void trimNotIncludedClasses(Collection<TypeDeclaration> typeDeclarations) {
    EnunciateConfiguration config = this.enunciate.getConfig();
    AntPatternMatcher matcher = new AntPatternMatcher();
    matcher.setPathSeparator(".");
    if (!config.getApiIncludePatterns().isEmpty()) {
      Iterator<TypeDeclaration> typeDeclarationIt = typeDeclarations.iterator();
      while (typeDeclarationIt.hasNext()) {
        TypeDeclaration typeDeclaration = typeDeclarationIt.next();
        boolean include = false;
        if (config.getApiIncludePatterns().contains(typeDeclaration.getQualifiedName())) {
          include = true;
          debug("%s was explicitly included.", typeDeclaration.getQualifiedName());
        }
        else {
          for (String includePattern : config.getApiIncludePatterns()) {
            if (matcher.match(includePattern, typeDeclaration.getQualifiedName())) {
              include = true;
              debug("%s matches include pattern %s.", typeDeclaration.getQualifiedName(), includePattern);
              break;
            }
          }
View Full Code Here

Examples of org.codehaus.enunciate.util.AntPatternMatcher

            processTemplate(soapImplTemplate, model);
          }
        }
      }

      AntPatternMatcher matcher = new AntPatternMatcher();
      matcher.setPathSeparator(".");
      for (WebFault webFault : allFaults.values()) {
        if (useServerSide(webFault, matcher)) {
          SourcePosition position = webFault.getPosition();
          if (position == null || position.file() == null) {
            throw new IllegalStateException("Unable to find source file for " + webFault.getQualifiedName());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.