portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/servletcontainer TomcatManager.java
Date Thu, 15 Jan 2004 23:42:47 GMT
weaver      2004/01/15 15:42:47

  Modified:    portal/src/java/org/apache/jetspeed/deployment/impl
                        DeployPortletAppEventListener.java
               portal/src/java/org/apache/jetspeed/tools/pamanager
                        CatalinaPAM.java FileSystemPAM.java
               portal/src/java/org/apache/jetspeed/tools/pamanager/servletcontainer
                        TomcatManager.java
  Added:       portal/src/java/org/apache/jetspeed/deployment/impl
                        CatalinaAutoDeploymentServiceImpl.java
  Log:
  auto-deployment system
  
  Revision  Changes    Path
  1.2       +20 -4     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/impl/DeployPortletAppEventListener.java
  
  Index: DeployPortletAppEventListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/impl/DeployPortletAppEventListener.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeployPortletAppEventListener.java	15 Jan 2004 16:14:33 -0000	1.1
  +++ DeployPortletAppEventListener.java	15 Jan 2004 23:42:47 -0000	1.2
  @@ -16,6 +16,7 @@
   import org.apache.jetspeed.deployment.DeploymentException;
   import org.apache.jetspeed.deployment.DeploymentHandler;
   import org.apache.jetspeed.deployment.fs.FSObjectHandler;
  +import org.apache.jetspeed.tools.pamanager.Deployment;
   import org.apache.jetspeed.tools.pamanager.FileSystemPAM;
   import org.apache.jetspeed.tools.pamanager.PortletApplicationException;
   import org.jdom.Document;
  @@ -39,13 +40,21 @@
       protected static final Log log = LogFactory.getLog("deployment");
       private String webAppDir;
       private String dbAalias;
  +    private Deployment pam;
       
       
   
  -	public DeployPortletAppEventListener(String webAppDir, String dbAlias)
  +	public DeployPortletAppEventListener(String webAppDir, String dbAlias, Deployment pam)
   	{
   		this.webAppDir = webAppDir;
   		this.dbAalias = dbAlias;
  +		this.pam = pam;
  +	}
  +	
  +	public DeployPortletAppEventListener(String webAppDir,  Deployment pam)
  +	{
  +		this.webAppDir = webAppDir;		
  +		this.pam = pam;
   	}
   
       /**
  @@ -76,8 +85,15 @@
   						throw new PortletApplicationException("<portlet-app> requires a unique \"id\"
attribute.");
                       }             
                       log.info("Preparing to deploy portlet app \""+id+"\"");
  -                    FileSystemPAM pam = new FileSystemPAM();
  -                    pam.deploy(webAppDir, handler.getPath(), id, dbAalias, 0);
  +                    if(dbAalias != null)
  +                    {
  +						pam.deploy(webAppDir, handler.getPath(), id, dbAalias, 0);
  +                    }
  +                    else
  +                    {
  +						pam.deploy(webAppDir, handler.getPath(), id);
  +                    }
  +                    
   					log.info("Portlet app \""+id+"\" "+"successfuly deployed.");
                   }
               }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/impl/CatalinaAutoDeploymentServiceImpl.java
  
  Index: CatalinaAutoDeploymentServiceImpl.java
  ===================================================================
  /**
   * Created on Jan 15, 2004
   *
   * 
   * @author
   */
  package org.apache.jetspeed.deployment.impl;
  
  import java.io.File;
  import java.io.IOException;
  import java.net.Socket;
  import java.net.UnknownHostException;
  import java.util.HashMap;
  
  import org.apache.commons.configuration.Configuration;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.fulcrum.InitializationException;
  import org.apache.jetspeed.cps.BaseCommonService;
  
  import org.apache.jetspeed.deployment.AutoDeploymentService;
  import org.apache.jetspeed.deployment.DeploymentEventDispatcher;
  import org.apache.jetspeed.deployment.fs.FileSystemScanner;
  import org.apache.jetspeed.deployment.fs.JARObjectHandlerImpl;
  import org.apache.jetspeed.tools.pamanager.CatalinaPAM;
  
  /**
   * <p>
   * CatalinaAutoDeploymentServiceImpl
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: CatalinaAutoDeploymentServiceImpl.java,v 1.1 2004/01/15 23:42:47 weaver
Exp $
   *
   */
  public class CatalinaAutoDeploymentServiceImpl extends BaseCommonService implements AutoDeploymentService
  {
      protected Log log = LogFactory.getLog("deployment");
  
      protected FileSystemScanner scanner;
  
      /**
       * @see org.apache.fulcrum.Service#init()
       */
      public void init() throws InitializationException
      {
          Configuration conf = getConfiguration();
          log.info("Starting auto deployment service: " + getClass().getName());
          long delay = conf.getLong("delay", 10000);
          log.info("Deployment scanning delay: " + delay);
  
          String server = conf.getString("server", "localhost");
          log.info("Deployment server: " + server);
          int port = conf.getInt("port", 8080);
          log.info("Deployment server port: " + port);
          String userName = conf.getString("user");
          log.info("Deployment server user name: " + userName);
          String password = conf.getString("password");
          String stagingDir = conf.getString("staging.dir", "WEB-INF/deploy");
          log.info("Deployment staging directory: " + stagingDir);
          String targetDir = conf.getString("target.dir", "../");
          log.info("Deployment target directory: " + targetDir);
  
          File stagingDirFile = new File(getRealPath(stagingDir));
          File targetDirFile = new File(getRealPath(targetDir));
          if (!targetDirFile.exists())
          {
              log.error(targetDirFile.getAbsolutePath() + " does not exist, auto deployment
disabled.");
              setInit(false);
              shutdown();
              return;
          }
  
          if (!stagingDirFile.exists())
          {
              log.error(targetDirFile.getAbsolutePath() + " does not exist, auto deployment
disabled.");
              setInit(false);
              shutdown();
              return;
          }
  
  		Socket checkSocket = null;
          try
          {
              checkSocket = new Socket(server, port);
          }
          catch (UnknownHostException e1)
          {
          	log.warn("Unknown server, auto deployment will be disabled: " + e1.toString());
              setInit(false);
              shutdown();
              return;
          }
          catch (IOException e1)
          {
              log.warn("IOException, auto deployment will be disabled: " + e1.toString());
              setInit(false);
              shutdown();
              return;
          }
          finally
          {
  			try
              {
              	// close the server check
              	if(checkSocket != null)
              	{
  					checkSocket.close();
              	}                
              }
              catch (IOException e2)
              {
                  // do nothing
              }
          }
  
          try
          {
              CatalinaPAM catPAM = new CatalinaPAM(server, port, userName, password);
              DeployPortletAppEventListener dpal = new DeployPortletAppEventListener(targetDir,
catPAM);
              DeploymentEventDispatcher dispatcher = new DeploymentEventDispatcher(targetDir);
              HashMap handlers = new HashMap();
              handlers.put("war", JARObjectHandlerImpl.class);
              scanner = new FileSystemScanner(stagingDirFile.getCanonicalPath(), handlers,
dispatcher, delay);
              scanner.start();
              log.info("Deployment scanner successfuly started!");
          }
          catch (Exception e)
          {
              log.error("Unable to intialize Catalina Portlet Application Manager: " + e.toString(),
e);
              setInit(false);
              shutdown();
              return;
          }
  
      }
  
      /**
       * @see org.apache.fulcrum.Service#shutdown()
       */
      public void shutdown()
      {
          if (scanner != null)
          {
              scanner.safeStop();
          }
          super.shutdown();
      }
  
  }
  
  
  
  1.5       +0 -0      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/CatalinaPAM.java
  
  Index: CatalinaPAM.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/CatalinaPAM.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  
  
  
  1.14      +2 -2      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/FileSystemPAM.java
  
  Index: FileSystemPAM.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/FileSystemPAM.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- FileSystemPAM.java	15 Jan 2004 22:26:22 -0000	1.13
  +++ FileSystemPAM.java	15 Jan 2004 23:42:47 -0000	1.14
  @@ -146,7 +146,7 @@
        * 0 deploy war - 1 Update Web XML - 2 Update Regsitry
        * @throws PortletApplicationException
        */
  -    public void deploy(String webAppsDir, String warFile, String paName, String deploymentDbAlias,
int startState)
  +    public void deploy(String webAppsDir, String warFile, String paName, String deploymentDbAlias,
int startState) 
           throws PortletApplicationException
       {
           this.deploymentDbAlias = deploymentDbAlias;
  
  
  
  1.2       +9 -9      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/servletcontainer/TomcatManager.java
  
  Index: TomcatManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/servletcontainer/TomcatManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TomcatManager.java	15 Jan 2004 19:53:28 -0000	1.1
  +++ TomcatManager.java	15 Jan 2004 23:42:47 -0000	1.2
  @@ -94,14 +94,14 @@
   
           // perform a test, we can use this to close a
           GetMethod test = new GetMethod(serverInfoPath);
  -        try
  -        {
  -            client.executeMethod(test);
  -        }
  -        finally
  -        {
  -            test.releaseConnection();
  -        }
  +//        try
  +//        {
  +//            client.executeMethod(test);
  +//        }
  +//        finally
  +//        {
  +//            test.releaseConnection();
  +//        }
           start = new GetMethod(startPath);
           stop = new GetMethod(stopPath);
           remove = new GetMethod(removePath);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message