Examples of AntClassLoader


Examples of org.apache.tools.ant.AntClassLoader

     */
    private InputSource classpathLookup(ResourceLocation matchingEntry) {

        InputSource source = null;

        AntClassLoader loader = null;
        Path cp = classpath;
        if (cp != null) {
            cp = classpath.concatSystemClasspath("ignore");
        } else {
            cp = (new Path(getProject())).concatSystemClasspath("last");
        }
        loader = getProject().createClassLoader(cp);

        //
        // for classpath lookup we ignore the base directory
        //
        InputStream is
            = loader.getResourceAsStream(matchingEntry.getLocation());

        if (is != null) {
            source = new InputSource(is);
            URL entryURL = loader.getResource(matchingEntry.getLocation());
            String sysid = entryURL.toExternalForm();
            source.setSystemId(sysid);
            log("catalog entry matched a resource in the classpath: '"
                + sysid + "'", Project.MSG_DEBUG);
        }
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

     */
    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(WLRMIC_CLASSNAME);
            } else {
                loader
                    = getRmic().getProject().createClassLoader(getRmic().getClasspath());
                c = Class.forName(WLRMIC_CLASSNAME, true, loader);
            }
            Method doRmic = c.getMethod("main",
                                        new Class [] {String[].class});
            doRmic.invoke(null, new Object[] {cmd.getArguments()});
            return true;
        } catch (ClassNotFoundException ex) {
            throw new BuildException(ERROR_NO_WLRMIC_ON_CLASSPATH, getRmic().getLocation());
        } catch (Exception ex) {
            if (ex instanceof BuildException) {
                throw (BuildException) ex;
            } else {
                throw new BuildException(ERROR_WLRMIC_FAILED, ex,
                                         getRmic().getLocation());
            }
        } finally {
            if (loader != null) {
                loader.cleanup();
            }
        }
    }
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

        }

        try
        {
            ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
            AntClassLoader loader = new AntClassLoader(ctxLoader, project, cmdl.getClasspath(), true);
            loader.setIsolated(false);
            loader.setThreadContextLoader();
            // nothing
            // m_embeddor.execute();
            // Launch the startup thread.
            Thread startThread = new StartupThread();
            startThread.start();
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

            public boolean accept( File dir, String name ) {
                return name.endsWith( ".jar" );
            }
        } );

        AntClassLoader antClassLoader = new AntClassLoader( Thread.currentThread().getContextClassLoader(), false );

        for ( File jarFile : jarFiles ) {
            antClassLoader.addPathComponent( jarFile );
        }
       
        if (world == null) {
            world = new ClassWorld();
        }
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

     */
    String getGenicClassName(Path classpath) {

  log("Looking for GenIC class in classpath: " + classpath.toString(), Project.MSG_VERBOSE);

  AntClassLoader cl = new AntClassLoader(classpath.getProject(), classpath);

  try {
      cl.loadClass(JonasDeploymentTool.GENIC_CLASS);
      log("Found GenIC class '" + JonasDeploymentTool.GENIC_CLASS + "' in classpath.", Project.MSG_VERBOSE);
      return JonasDeploymentTool.GENIC_CLASS;

  } catch (ClassNotFoundException cnf1) {
       log("GenIC class '" + JonasDeploymentTool.GENIC_CLASS + "' not found in classpath.",
    Project.MSG_VERBOSE);
  }

  try {
      cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_1);
      log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 +
    "' in classpath.", Project.MSG_VERBOSE);
      return JonasDeploymentTool.OLD_GENIC_CLASS_1;

  } catch (ClassNotFoundException cnf2) {
       log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 +
    "' not found in classpath.",
    Project.MSG_VERBOSE);
  }

  try {
      cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_2);
      log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2 +
    "' in classpath.", Project.MSG_VERBOSE);
      return JonasDeploymentTool.OLD_GENIC_CLASS_2;

  } catch (ClassNotFoundException cnf3) {
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

        InputStream is = null;
        try {
            ClassLoader cL = null;

            if (classpath != null) {
                cL = new AntClassLoader(project, classpath);
            } else {
                cL = this.getClass().getClassLoader();
            }

            if (cL == null) {
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

    }

    public void execute(Project project) throws BuildException{
        final String classname = javaCommand.getExecutable();

        AntClassLoader loader = null;
        try {
            if (sysProperties != null) {
                sysProperties.setSystem();
            }

            final Class[] param = { Class.forName("[Ljava.lang.String;") };
            Class target = null;
            if (classpath == null) {
                target = Class.forName(classname);
            } else {
                loader = new AntClassLoader(project.getCoreLoader(), project,
                                            classpath, false);
                loader.setIsolated(true);
                loader.setThreadContextLoader();
                target = loader.forceLoadClass(classname);
                AntClassLoader.initializeClass(target);
            }
            main = target.getMethod("main", param);
            if (main == null) {
                throw new BuildException("Could not find main() method in "
                                         + classname);
            }

            if (timeout == null) {
                run();
            } else {
                thread = new Thread(this, "ExecuteJava");
                Task currentThreadTask
                    = project.getThreadTask(Thread.currentThread());
                project.registerThreadTask(thread, currentThreadTask);
                // if we run into a timout, the run-away thread shall not
                // make the VM run forever - if no timeout occurs, Ant's
                // main thread will still be there to let the new thread
                // finish
                thread.setDaemon(true);
                Watchdog w = new Watchdog(timeout.longValue());
                w.addTimeoutObserver(this);
                synchronized (this) {
                    thread.start();
                    w.start();
                    try {
                        wait();
                    } catch (InterruptedException e) {}
                    if (timedOut) {
                        project.log("Timeout: sub-process interrupted",
                                    Project.MSG_WARN);
                    } else {
                        thread = null;
                        w.stop();
                    }
                }
            }

            if (caught != null) {
                throw caught;
            }

        } catch (ClassNotFoundException e) {
            throw new BuildException("Could not find " + classname + "."
                                     + " Make sure you have it in your"
                                     + " classpath");
        } catch (SecurityException e) {
            throw e;
        } catch (Throwable e) {
            throw new BuildException(e);
        } finally {
            if (loader != null) {
                loader.resetThreadContextLoader();
                loader.cleanup();
            }
            if (sysProperties != null) {
                sysProperties.restoreSystem();
            }
        }
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

        loaderId = r.getRefId();
    }

   
    public void execute() throws BuildException {
        AntClassLoader al = createLoader();

        if (file == null && resource == null) {

            // simple case - one definition
            if (name == null || value == null) {
                String msg = "name or classname attributes of "
                    + getTaskName() + " element "
                    + "are undefined";
                throw new BuildException(msg);
            }
            addDefinition(al, name, value);

        } else {

            InputStream is = null;
            try {
                if (name != null || value != null) {
                    String msg = "You must not specify name or value "
                        + "together with file or resource.";
                    throw new BuildException(msg, location);
                }
           
                if (file != null && resource != null) {
                    String msg = "You must not specify both, file and "
                        + "resource.";
                    throw new BuildException(msg, location);
                }
           

                Properties props = new Properties();
                if (file != null) {
                    log("Loading definitions from file " + file,
                        Project.MSG_VERBOSE);
                    is = new FileInputStream(file);
                    if (is == null) {
                        log("Could not load definitions from file " + file
                            + ". It doesn\'t exist.", Project.MSG_WARN);
                    }
                }   
                if (resource != null) {
                    log("Loading definitions from resource " + resource,
                        Project.MSG_VERBOSE);
                    is = al.getResourceAsStream(resource);
                    if (is == null) {
                        log("Could not load definitions from resource "
                            + resource + ". It could not be found.",
                            Project.MSG_WARN);
                    }
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

                //      return ((Loader)reusedLoader).getLoader(project);
                // }
            }
        }
      
        AntClassLoader al = null;
        if (classpath != null) {
            al = new AntClassLoader(project, classpath, !reverseLoader);
        } else {
            al = new AntClassLoader(project, Path.systemClasspath,
                                    !reverseLoader);
        }
        // need to load Task via system classloader or the new
        // task we want to define will never be a Task but always
        // be wrapped into a TaskAdapter.
        al.addSystemPackageRoot("org.apache.tools.ant");


        // If the loader is new, record it for future uses by other
        // task/typedefs
        if (loaderId != null) {
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

            if (classPath == null) {
              throw new BuildException("The reference " + cRef + " is not set.", getLocation());
            }
        }
      }
      AntClassLoader acl;
      if (classPath == null) {
        acl = null;
      } else {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        if (cl == null) {
          cl = getClass().getClassLoader();
            if (cl == null) {
              cl = ClassLoader.getSystemClassLoader();
            }
        }
        acl = new AntClassLoader(cl, getProject(), classPath, true);
        acl.setThreadContextLoader();
      }
      try {
          finish();
          doExecute();
      } catch (BuildException e) {
          throw e;
      } catch (Exception e) {
          throw new BuildException(e, getLocation());
      } finally {
          if (acl != null) {
              acl.resetThreadContextLoader();
          }
      }
    }
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.