Package org.apache.tools.ant

Examples of org.apache.tools.ant.AntClassLoader


                    }
                    if (loader == null) {
                        log(
                                "Loading " + driver + " using AntClassLoader with classpath " + classpath,
                                Project.MSG_VERBOSE);
                        loader = new AntClassLoader(project, classpath);
                        if (caching) {
                            loaderMap.put(driver, loader);
                        }
                    } else {
                        log(
View Full Code Here


        if (classpath != null) {
            lookupPath.append(classpath);
        }

        return new AntClassLoader(getTask().getProject(), lookupPath);
    }
View Full Code Here

                    log("Weblogic Jar rebuild needed due to changed "
                         + "interface or XML", Project.MSG_VERBOSE);
                }

                if (genericLoader instanceof AntClassLoader) {
                    AntClassLoader loader = (AntClassLoader)genericLoader;
                    loader.cleanup();
                }
            } else {
                rebuild = true;
            }
        } catch (ClassNotFoundException cnfe) {
View Full Code Here

        if (classpath != null) {
            lookupPath.append(classpath);
        }

        return new AntClassLoader(getTask().getProject(), lookupPath);
    }
View Full Code Here

        classpathDependencies = null;
        Path checkPath = getCheckClassPath();
        if (checkPath != null) {
            // now determine which jars each class depends upon
            classpathDependencies = new Hashtable();
            AntClassLoader loader
                = new AntClassLoader(getProject(), checkPath);

            Hashtable classpathFileCache = new Hashtable();
            Object nullFileMarker = new Object();
            for (Enumeration e = dependencyMap.keys(); e.hasMoreElements();) {
                String className = (String) e.nextElement();
                Vector dependencyList = (Vector) dependencyMap.get(className);
                Hashtable dependencies = new Hashtable();
                classpathDependencies.put(className, dependencies);
                Enumeration e2 = dependencyList.elements();
                while (e2.hasMoreElements()) {
                    String dependency = (String) e2.nextElement();
                    Object classpathFileObject
                        = classpathFileCache.get(dependency);
                    if (classpathFileObject == null) {
                        classpathFileObject = nullFileMarker;

                        if (!dependency.startsWith("java.")
                            && !dependency.startsWith("javax.")) {
                            URL classURL = loader.getResource(dependency.replace('.', '/') + ".class");
                            if (classURL != null) {
                                if (classURL.getProtocol().equals("jar")) {
                                    String jarFilePath = classURL.getFile();
                                    if (jarFilePath.startsWith("file:")) {
                                        int classMarker = jarFilePath.indexOf('!');
View Full Code Here

    public boolean execute() throws BuildException {
        getRmic().log("Using WebLogic rmic", Project.MSG_VERBOSE);
        Commandline cmd = setupRmicCommand(new String[] {"-noexit"});

        AntClassLoader loader = null;
        try {
            // Create an instance of the rmic
            Class c = null;
            if (getRmic().getClasspath() == null) {
                c = Class.forName("weblogic.rmic");
            } else {
                loader = new AntClassLoader(getRmic().getProject(),
                                            getRmic().getClasspath());
                c = loader.loadClass("weblogic.rmic");
                AntClassLoader.initializeClass(c);
            }
            Method doRmic = c.getMethod("main",
                                        new Class [] { String[].class });
            doRmic.invoke(null, new Object[] {cmd.getArguments()  });
            return true;
        } catch (ClassNotFoundException ex) {
            throw new BuildException("Cannot use WebLogic rmic, as it is not "
                                     + "available.  A common solution is to "
                                     + "set the environment variable "
                                     + "CLASSPATH.", getRmic().getLocation());
        } catch (Exception ex) {
            if (ex instanceof BuildException) {
                throw (BuildException) ex;
            } else {
                throw new BuildException("Error starting WebLogic rmic: ", ex,
                                         getRmic().getLocation());
            }
        } finally {
            if (loader != null) {
                loader.cleanup();
            }
        }
    }
View Full Code Here

             *
             * todo look into this further!!!!!
             */


            AntClassLoader cl = new AntClassLoader(
                    null,
                    getProject(),
                    classpath,
                    false);

            Thread.currentThread().setContextClassLoader(cl);
            cl.addPathElement(output);

            Map commandLineOptions = this.fillOptionMap();
            CommandLineOptionParser parser =
                    new CommandLineOptionParser(commandLineOptions);
            new CodeGenerationEngine(parser).generate();
View Full Code Here

    if (!srcdir.exists()) {
      throw new BuildException("Source directory does not exists."
          + srcdir.getAbsolutePath());
    }

    AntClassLoader loader = null;
    try {
      // create a specialized classloader
      loader = getClassLoader();

      // create a package builder configured to use the given classloader
      PackageBuilder builder = getPackageBuilder(loader);

      // get the list of files to be added to the rulebase
      String[] fileNames = getFileList();

      for (int i = 0; i < fileNames.length; i++) {
        // compile rule file and add to the builder
        compileAndAddFile(builder, fileNames[i]);
      }
     
      if ( builder.hasErrors() ) {
          System.err.println( builder.getErrors().toString() );
      }

      // gets the package
      org.drools.rule.Package pkg = builder.getPackage();
     
            // creates the rulebase
            RuleBase ruleBase = RuleBaseFactory.newRuleBase();

            // adds the package
            ruleBase.addPackage(pkg);
     
     
      if (PACKAGEBINFORMAT.equals( binformat )  ) {
          serializeObject( pkg );
      } else {
              // serialize the rule base to the destination file
              serializeObject(ruleBase);
      }
    } catch (Exception e) {
      throw new BuildException("RuleBaseTask failed: " + e.getMessage(),
          e);
    } finally {
      if (loader != null) {
        loader.resetThreadContextLoader();
      }
    }
  }
View Full Code Here

   * @return
   */
  private AntClassLoader getClassLoader() {
    // defining a new specialized classloader and setting it as the thread
    // context classloader
    AntClassLoader loader = null;
    if (classpath != null) {
      loader = new AntClassLoader(PackageBuilder.class.getClassLoader(),
          getProject(), classpath, false);
    } else {
      loader = new AntClassLoader(PackageBuilder.class.getClassLoader(),
          false);
    }
    loader.setThreadContextLoader();
    return loader;
  }
View Full Code Here

      this.genwsdl = genwsdl;
   }
  
   private ClassLoader getClasspathLoader(ClassLoader parent)
   {
    AntClassLoader antLoader = new AntClassLoader(parent, getProject(), classpath, false);

    // It's necessary to wrap it into an URLLoader in order to extract that information
    // within the actual provider impl.
    // See SunRIProviderImpl for instance
    List<URL> urls = new ArrayList<URL>();
    StringTokenizer tok = new StringTokenizer(antLoader.getClasspath(), File.separator);
    while(tok.hasMoreTokens())
    {
      try
      {
            String path = tok.nextToken();
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.AntClassLoader

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.