Package org.apache.tools.ant.taskdefs

Examples of org.apache.tools.ant.taskdefs.Java


        
         ProcessLauncher launcher = new ProcessLauncher(log, "Geronimo Server", background,session.getConsole()) {
             @Override
             protected void process() throws Exception {
                 try {
                     Java javaTask = (Java) ant.createTask("java");
                     javaTask.setClassname("org.apache.geronimo.cli.daemon.DaemonCLI");
                     Path path = javaTask.createClasspath();
                     File libDir = new File(geronimoHome, "lib");
                     FileSet fileSet = new FileSet();
                     fileSet.setDir(libDir);
                     path.addFileset(fileSet);
                     javaTask.setDir(new File(geronimoHome));
                     javaTask.setFailonerror(true);
                     javaTask.setFork(true);
                    
                     if (timeout > 0) {
                         log.info("Timeout after: " + timeout + " seconds");
                         javaTask.setTimeout((long) timeout);
                     }

                     if (logFile != null) {
                         log.info("Redirecting output to: " + logFile);
                         File output = new File(logFile);
                         output.mkdirs();
                         javaTask.setOutput(output);
                     }

                     if (javaVirtualMachine != null) {
                         if (!(new File(javaVirtualMachine).exists())) {
                             throw new Exception("Java virtual machine is not valid: " + javaVirtualMachine);
                         }

                         log.info("Using Java virtual machine: " + javaVirtualMachine);
                         javaTask.setJvm(javaVirtualMachine);
                     }

                     if (javaFlags != null) {
                         for (String javaFlag : javaFlags) {
                             javaTask.createJvmarg().setValue(javaFlag);
                         }
                     }
                    
                     for (String i : properties.keySet()) {
                         Variable sysp = new Variable();
                         sysp.setKey(i);
                         sysp.setValue(properties.get(i));
                         javaTask.addSysproperty(sysp);
                     }

                     if (quiet) {
                         javaTask.createArg().setValue("--quiet");
                     } else {
                         javaTask.createArg().setValue("--long");
                     }
                    
                     if (verbose) {
                         javaTask.createArg().setValue("--verbose");
                     }
                    
                     if (startModules != null) {
                         javaTask.createArg().setValue("--override");
                         for (String module : startModules) {
                             javaTask.createArg().setValue(module);
                         }
                     }
                    
                     javaTask.execute();
                 } catch (ExitStatusException e) {
                     String tmp = "";
                     log.info(tmp);

                     if (e.getStatus() != 0) {
View Full Code Here


     *
     * @param theArg Either 'start' or 'stop'
     */
    private void invoke(String theArg)
    {
        Java java = null;
        if ("start".equals(theArg))
        {
            java = createJavaForStartUp();
        }
        else
        {
            java = createJavaForShutDown();
        }
        java.addSysproperty(createSysProperty("tomcat.install", getDir()));
        java.addSysproperty(createSysProperty("tomcat.home", this.tmpDir));
        Path classpath = java.createClasspath();
        classpath.createPathElement().setLocation(
            new File(getDir(), "lib/tomcat.jar"));

        // It seems that since Tomcat 3.3.2, the commons-logging jar is
        // required in the Tomcat bootstrap classpath...
        File commonsLoggingJarFile =
            new File(getDir(), "lib/common/commons-logging-api.jar");
        if (commonsLoggingJarFile.exists())
        {
            classpath.createPathElement().setLocation(commonsLoggingJarFile);
        }
       
        java.setClassname("org.apache.tomcat.startup.Main");
        java.createArg().setValue(theArg);
        java.execute();
    }
View Full Code Here

     *
     * @param theArg Either 'start' or 'stop'
     */
    protected final void invokeBootstrap(String theArg)
    {
        Java java = null;
        if ("start".equals(theArg))
        {
            java = createJavaForStartUp();
        }
        else
        {
            java = createJavaForShutDown();
        }
        java.addSysproperty(createSysProperty("catalina.home", getDir()));
        java.addSysproperty(createSysProperty("catalina.base", getTmpDir()));
        Path classpath = java.createClasspath();
        classpath.createPathElement().setLocation(
            new File(getDir(), "bin/bootstrap.jar"));
        addToolsJarToClasspath(classpath);
        java.setClassname("org.apache.catalina.startup.Bootstrap");
        java.createArg().setValue(theArg);
        java.execute();
    }
View Full Code Here

     * @see org.apache.cactus.integration.ant.container.Container#shutDown
     */
    public final void shutDown()
    {
        // invoke the main class
        Java java = createJavaForShutDown();
        Path classpath = java.createClasspath();
        FileSet fileSet = new FileSet();
        fileSet.setDir(this.dir);
        fileSet.createInclude().setName("*.jar");
        classpath.addFileset(fileSet);
        java.setClassname("com.evermind.client.orion.OrionConsoleAdmin");
        java.createArg().setValue("ormi://" + this.getServer() + ":23791/");
        java.createArg().setValue("admin");
        java.createArg().setValue("password");
        java.createArg().setValue("-shutdown");
        java.execute();
    }
View Full Code Here

     * Invokes the command to start the Orion application server.
     */
    protected final void invokeServer()
    {
        // invoke the main class
        Java java = createJavaForStartUp();
        Path classpath = java.createClasspath();
        FileSet fileSet = new FileSet();
        fileSet.setDir(this.dir);
        fileSet.createInclude().setName("*.jar");
        classpath.addFileset(fileSet);
        addToolsJarToClasspath(classpath);
        java.setClassname("com.evermind.server.ApplicationServer");
        java.createArg().setValue("-config");
        java.createArg().setFile(new File(tmpDir, "conf/server.xml"));
        java.execute();
    }
View Full Code Here

     *
     * @return The created task instance
     */
    protected final Java createJavaForShutDown()
    {
        Java java = (Java) createAntTask("java");
        java.setFork(true);

        // Add extra container classpath entries specified by the user.
        addExtraClasspath(java);
       
        return java;
View Full Code Here

     *
     * @return The created task instance
     */
    protected final Java createJavaForStartUp()
    {
        Java java = (Java) createAntTask("java");
        java.setFork(true);
        java.setOutput(this.output);
        java.setAppend(this.append);

        // pass arguments to the JVM
        if (this.jvmArgs != null)
        {
            getLog().trace(
                "Passing arguments to the container JVM: " + this.jvmArgs);
            java.createJvmarg().setLine(this.jvmArgs);
        }

        // Add extra container classpath entries specified by the user.
        addExtraClasspath(java);
      
        // Add Cactus properties for the server side
        if (getSystemProperties() != null)
        {
            for (int i = 0; i < getSystemProperties().length; i++)
            {
                java.addSysproperty(
                    createSysProperty(getSystemProperties()[i].getKey(),
                        getSystemProperties()[i].getValue()));
            }
        }
       
View Full Code Here

           
            prepare("cactus/jboss3x", customServerDir);
           
            File binDir = new File(this.dir, "bin");
           
            Java java = createJavaForStartUp();
            java.setDir(binDir);
           
            java.addSysproperty(
                createSysProperty("program.name",
                    new File(binDir, "run.bat")));
            java.addSysproperty(
                createSysProperty("jboss.server.home.dir", customServerDir));
            java.addSysproperty(
                createSysProperty("jboss.server.home.url",
                    customServerDir.toURL().toString()));

            Path classpath = java.createClasspath();
            classpath.createPathElement().setLocation(
                new File(binDir, "run.jar"));
            addToolsJarToClasspath(classpath);
            java.setClassname("org.jboss.Main");
            java.createArg().setValue("-c");
            java.createArg().setValue(this.config);
            java.execute();
        }
        catch (IOException ioe)
        {
            getLog().error("Failed to startup the container", ioe);
            throw new BuildException(ioe);
View Full Code Here

     *      of Exception
     */
    public void validateAttributes() throws BuildException {
        // super.validateAttributes(); // don't want to call this method

        Java java = getJava();

        String action = getTask().getAction();
        if (action == null) {
            throw new BuildException("The \"action\" attribute must be set");
        }

        if (!isActionValid()) {
            throw new BuildException("Invalid action \"" + action + "\" passed");
        }

        if (getClassName() == null) {
            setClassName(JONAS_DEPLOY_CLASS_NAME);
        }

        if (jonasroot == null || jonasroot.isDirectory()) {
            java.createJvmarg().setValue("-Dinstall.root=" + jonasroot);
            java.createJvmarg().setValue("-Djava.security.policy=" + jonasroot
                + "/config/java.policy");

            if ("DAVID".equals(orb)) {
                java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBClass"
                    + "=org.objectweb.david.libs.binding.orbs.iiop.IIOPORB");
                java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBSingletonClass="
                    + "org.objectweb.david.libs.binding.orbs.ORBSingletonClass");
                java.createJvmarg().setValue("-Djavax.rmi.CORBA.StubClass="
                    + "org.objectweb.david.libs.stub_factories.rmi.StubDelegate");
                java.createJvmarg().setValue("-Djavax.rmi.CORBA.PortableRemoteObjectClass="
                    + "org.objectweb.david.libs.binding.rmi.ORBPortableRemoteObjectDelegate");
                java.createJvmarg().setValue("-Djavax.rmi.CORBA.UtilClass="
                    + "org.objectweb.david.libs.helpers.RMIUtilDelegate");
                java.createJvmarg().setValue("-Ddavid.CosNaming.default_method=0");
                java.createJvmarg().setValue("-Ddavid.rmi.ValueHandlerClass="
                    + "com.sun.corba.se.internal.io.ValueHandlerImpl");
                if (davidHost != null) {
                    java.createJvmarg().setValue("-Ddavid.CosNaming.default_host="
                        + davidHost);
                }
                if (davidPort != 0) {
                    java.createJvmarg().setValue("-Ddavid.CosNaming.default_port="
                        + davidPort);
                }
            }
        }

        if (getServer() != null) {
            java.createArg().setLine("-n " + getServer());
        }

        if (action.equals(ACTION_DEPLOY)
            || action.equals(ACTION_UPDATE)
            || action.equals("redeploy")) {
            java.createArg().setLine("-a " + getTask().getSource());
        } else if (action.equals(ACTION_DELETE) || action.equals(ACTION_UNDEPLOY)) {
            java.createArg().setLine("-r " + getTask().getSource());
        } else if (action.equals(ACTION_LIST)) {
            java.createArg().setValue("-l");
        }
    }
View Full Code Here

     @param task An ServerDeploy object representing the parent task.
     *  @ant.attribute ignored="true"
     */
    public void setTask(ServerDeploy task) {
        super.setTask(task);
        java = new Java(task);
    }
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.taskdefs.Java

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.