[jboss-cvs] jboss-portal/common/src/main/org/jboss/portal/common/ant ...

Julien Viet julien at jboss.com
Sun Jul 16 09:09:58 EDT 2006


  User: julien  
  Date: 06/07/16 09:09:58

  Added:       common/src/main/org/jboss/portal/common/ant   
                        AbstractDeploymentTask.java Deploy.java
                        Undeploy.java
  Log:
  - added blocking Deploy/Undeploy ant task based on Cargo framework
  - added cargo 0.8 jar in tools/lib
  - working on sunday
  
  Revision  Changes    Path
  1.1      date: 2006/07/16 13:09:58;  author: julien;  state: Exp;jboss-portal/common/src/main/org/jboss/portal/common/ant/AbstractDeploymentTask.java
  
  Index: AbstractDeploymentTask.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portal.common.ant;
  
  import org.apache.tools.ant.Task;
  import org.apache.tools.ant.BuildException;
  import org.codehaus.cargo.generic.configuration.ConfigurationFactory;
  import org.codehaus.cargo.generic.configuration.DefaultConfigurationFactory;
  import org.codehaus.cargo.generic.ContainerFactory;
  import org.codehaus.cargo.generic.DefaultContainerFactory;
  import org.codehaus.cargo.container.configuration.Configuration;
  import org.codehaus.cargo.container.configuration.ConfigurationType;
  import org.codehaus.cargo.container.property.GeneralPropertySet;
  import org.codehaus.cargo.container.property.ServletPropertySet;
  import org.codehaus.cargo.container.RemoteContainer;
  import org.codehaus.cargo.container.ContainerType;
  import org.codehaus.cargo.container.jboss.JBossJMXDeployer;
  import org.codehaus.cargo.container.deployable.Deployable;
  import org.codehaus.cargo.container.deployable.EAR;
  
  import java.io.File;
  
  /**
   * A deployment task.
   *
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public abstract class AbstractDeploymentTask extends Task
  {
  
     /** The file. */
     private File file;
  
     /** The JBoss config. */
     private String config;
  
     public AbstractDeploymentTask()
     {
        file = null;
        config = "default";
     }
  
     public File getFile()
     {
        return file;
     }
  
     public void setFile(File file)
     {
        this.file = file;
     }
  
     public String getConfig()
     {
        return config;
     }
  
     public void setConfig(String config)
     {
        this.config = config;
     }
  
     public void execute() throws BuildException
     {
        //
        ConfigurationFactory cfgFactory = new DefaultConfigurationFactory();
        Configuration cfg = cfgFactory.createConfiguration("jboss4x", ConfigurationType.RUNTIME);
  
        // Configure the container
        if ("default".equals(config))
        {
           cfg.setProperty(GeneralPropertySet.PROTOCOL, "http");
           cfg.setProperty(GeneralPropertySet.HOSTNAME, "localhost");
           cfg.setProperty(ServletPropertySet.PORT, "8080");
        }
        else
        {
           throw new BuildException("Unknown configuration " + config);
        }
  
        //
        if (file == null)
        {
           throw new BuildException("No specified file to deploy");
        }
  
        //
        ContainerFactory containerFactory = new DefaultContainerFactory();
        RemoteContainer container = (RemoteContainer)containerFactory.createContainer("jboss4x", ContainerType.REMOTE, cfg);
  
        //
        JBossJMXDeployer deployer = new JBossJMXDeployer(container);
        execute(deployer);
     }
  
     protected abstract void execute(JBossJMXDeployer deployer);
  }
  
  
  
  1.1      date: 2006/07/16 13:09:58;  author: julien;  state: Exp;jboss-portal/common/src/main/org/jboss/portal/common/ant/Deploy.java
  
  Index: Deploy.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portal.common.ant;
  
  import org.codehaus.cargo.container.deployable.Deployable;
  import org.codehaus.cargo.container.deployable.EAR;
  import org.codehaus.cargo.container.jboss.JBossJMXDeployer;
  
  /**
   * A blocking deploy task.
   *
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public class Deploy extends AbstractDeploymentTask
  {
  
     public Deploy()
     {
     }
  
     protected void execute(JBossJMXDeployer deployer)
     {
        //
        Deployable deployable = new EAR(getFile().getAbsolutePath());
  
        //
        deployer.deploy(deployable);
     }
  }
  
  
  
  1.1      date: 2006/07/16 13:09:58;  author: julien;  state: Exp;jboss-portal/common/src/main/org/jboss/portal/common/ant/Undeploy.java
  
  Index: Undeploy.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portal.common.ant;
  
  import org.codehaus.cargo.container.jboss.JBossJMXDeployer;
  import org.codehaus.cargo.container.deployable.Deployable;
  import org.codehaus.cargo.container.deployable.EAR;
  
  /**
   * A blocking undeploy task.
   *
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public class Undeploy extends AbstractDeploymentTask
  {
  
     protected void execute(JBossJMXDeployer deployer)
     {
        //
        Deployable deployable = new EAR(getFile().getAbsolutePath());
  
        //
        deployer.deploy(deployable);
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list