FileDocCategorySizeDatePackage
LocalhostTarget.javaAPI DocJBoss 4.2.15022Fri Jul 13 20:52:34 BST 2007org.jboss.deployment.spi

LocalhostTarget

public class LocalhostTarget extends Object implements JBossTarget
A Target interface represents a single logical core server of one instance of a J2EE platform product. It is a designator for a server and the implied location to copy a configured application for the server to access.
author
thomas.diesler@jboss.org
version
$Revision: 57190 $

Fields Summary
private static final Logger
log
Constructors Summary
Methods Summary
public voiddeploy(javax.enterprise.deploy.spi.TargetModuleID targetModuleID)
Deploy a given module

      // get the server deploydir
      String deployDir = getDeploydir();

      FileOutputStream outs = null;
      FileInputStream ins = null;
      try
      {
         File deployableFile = new File(targetModuleID.getModuleID());
         File targetFile = new File(deployDir + "/" + deployableFile.getName());
         log.info("Writing deployableFile: " + deployableFile.getAbsolutePath() + " to: " + targetFile.getAbsolutePath());
         outs = new FileOutputStream(targetFile);
         ins = new FileInputStream(deployableFile);
         JarUtils.copyStream(outs, ins);
         log.info("Waiting 10 seconds for deploy to finish...");
         Thread.sleep(10000);
      }
      finally
      {
         try
         {
            if (outs != null)
            {
               outs.close();
            }
            if (ins != null)
            {
               ins.close();
            }
         }
         catch (IOException e)
         {
            // ignore this one            
         }
      }
   
public javax.enterprise.deploy.spi.TargetModuleID[]getAvailableModules(javax.enterprise.deploy.shared.ModuleType moduleType)
Retrieve the list of all J2EE application modules running or not running on the identified targets.

      return null;
   
private java.lang.StringgetDeploydir()
Get the server deploydir

      //[todo] replace this System property lookup
      String deployDir = System.getProperty("jboss.deploy.dir");
      if (deployDir == null)
      {
         String j2eeHome = System.getProperty("J2EE_HOME");
         if (j2eeHome == null)
            throw new RuntimeException("Cannot obtain system property: jboss.deploy.dir or J2EE_HOME");
         deployDir = j2eeHome + "/server/cts/deploy";
      }
      log.info("Using deploy dir: " + deployDir);
      return deployDir;
   
public java.lang.StringgetDescription()
Get the target's description

return
the description


               
     
   
      return "JBoss localhost deployment target";
   
public java.lang.StringgetHostName()
Get the target's host name

      try
      {
         return InetAddress.getLocalHost().getHostName();
      }
      catch (UnknownHostException e)
      {
         log.error("Cannot obtain localhost", e);
         return null;
      }
   
public java.lang.StringgetName()
Get the target's name

return
the name

      return "localhost";
   
public voidstart(javax.enterprise.deploy.spi.TargetModuleID targetModuleID)
Start a given module

   
public voidstop(javax.enterprise.deploy.spi.TargetModuleID targetModuleID)
Stop a given module

   
public voidundeploy(javax.enterprise.deploy.spi.TargetModuleID targetModuleID)
Undeploy a given module

      // get the server deploydir
      String deployDir = getDeploydir();
      File file = new File(deployDir + "/" + targetModuleID.getModuleID());
      file.delete();