portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal maven.xml
Date Fri, 21 May 2004 18:31:37 GMT
taylor      2004/05/21 11:31:37

  Modified:    portal/src/java/org/apache/jetspeed/deployment/impl
                        CatalinaAutoDeploymentServiceImpl.java
               portal/src/java/org/apache/jetspeed/tools/pamanager
                        PortletApplicationManager.java Deployment.java
                        CatalinaPAM.java Lifecycle.java FileSystemPAM.java
               portal/src/java/org/apache/jetspeed/container
                        JetspeedPortletContainerWrapper.java
               portal   maven.xml
  Added:       portal/src/java/org/apache/jetspeed/tools/pamanager
                        Registration.java
  Log:
  Completed work on PAM refactoring
  
  http://nagoya.apache.org/jira/browse/JS2-36
  
  PR:
  Obtained from:
  Submitted by:	
  Reviewed by:	
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.6       +10 -2     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/impl/CatalinaAutoDeploymentServiceImpl.java
  
  Index: CatalinaAutoDeploymentServiceImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/impl/CatalinaAutoDeploymentServiceImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CatalinaAutoDeploymentServiceImpl.java	19 Jan 2004 21:53:47 -0000	1.5
  +++ CatalinaAutoDeploymentServiceImpl.java	21 May 2004 18:31:36 -0000	1.6
  @@ -11,6 +11,7 @@
   import java.net.Socket;
   import java.net.UnknownHostException;
   import java.util.HashMap;
  +import java.util.Map;
   
   import org.apache.commons.configuration.Configuration;
   import org.apache.commons.logging.Log;
  @@ -116,7 +117,14 @@
   
           try
           {
  -            CatalinaPAM catPAM = new CatalinaPAM(server, port, userName, password);
  +            CatalinaPAM catPAM = new CatalinaPAM();
  +            Map map = new HashMap();
  +            map.put(CatalinaPAM.PAM_PROPERTY_SERVER, server);
  +            map.put(CatalinaPAM.PAM_PROPERTY_PORT, new Integer(port));
  +            map.put(CatalinaPAM.PAM_PROPERTY_USER, userName);
  +            map.put(CatalinaPAM.PAM_PROPERTY_PASSWORD, password);            
  +            
  +            catPAM.connect(map);
               
               DeployPortletAppEventListener dpal = new DeployPortletAppEventListener(targetDirFile.getCanonicalPath(), catPAM);
               DeploymentEventDispatcher dispatcher = new DeploymentEventDispatcher(targetDirFile.getCanonicalPath());
  
  
  
  1.10      +357 -259  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
  
  Index: PortletApplicationManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PortletApplicationManager.java	29 Mar 2004 04:51:48 -0000	1.9
  +++ PortletApplicationManager.java	21 May 2004 18:31:36 -0000	1.10
  @@ -17,6 +17,9 @@
   
   import org.apache.commons.configuration.Configuration;
   import org.apache.commons.configuration.PropertiesConfiguration;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +
   import org.apache.jetspeed.Jetspeed;
   import org.apache.jetspeed.engine.Engine;
   import org.apache.jetspeed.engine.JetspeedEngineConstants;
  @@ -25,11 +28,19 @@
   import java.io.File;
   import java.io.IOException;
   import java.io.FileInputStream;
  +import java.util.HashMap;
  +import java.util.Map;
   import java.util.Properties;
   import java.util.Iterator;
   import java.util.Map.Entry;
   
   /**
  + * PortletApplicationManager
  + *
  + * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  + * @version $Id$
  + */
  +/**
    * This is the interface that defines the Lifecycle-related methods to control
    * Portlet Applications.
    *
  @@ -39,6 +50,8 @@
   
   public class PortletApplicationManager implements JetspeedEngineConstants
   {
  +    private static final Log log = LogFactory.getLog("deployment");
  +    
       /**
        * Command line utility to deploy a portlet application to an application server.
        * The command line has the following options:
  @@ -59,6 +72,7 @@
        *   (optional: required for if deploying to Catalina)
        * -DPassword={Password to access the servers management system}
        *   (optional: required for if deploying to Catalina)
  +     * -DImpl=(full class name i.e. org.apache.jetspeed.tools.pamanager.FileSystemPAM)
        *
        *Notes: The deploy action requires the WarFileName. If no ApplicationServer
        *       is defined it requires in additionthe WebappDir.
  @@ -78,12 +92,16 @@
           String strAction = "";
           String strWarFileName = "";
           String strPortletAppName = "";
  -        String strAppServer = "";
           String strPortalName = "jetspeed";
           String applicationType = "webapp";
   		String strUserName = "";
   		String strPassword = "";
   		String strServer = "localhost";
  +        String className = "org.apache.jetspeed.tools.pamanager.FileSystemPAM"; // default
  +        Deployment deployer = null;
  +        Registration registrator = null;
  +        Lifecycle lifecycle = null;
  +        
   		int intServerPort = 8080;
           String jetspeedPropertiesFile = System.getProperty("pam.jetspeed.properties", "/WEB-INF/conf/jetspeed.properties");
           String appsDirectory = System.getProperty("pam.apps.directory", "/WEB-INF/apps/");
  @@ -98,6 +116,11 @@
                   if (i < args.length)
                       strPortletAppName = args[i++];
               }
  +            else if (arg.equalsIgnoreCase("-Impl"))
  +            {
  +                if (i < args.length)
  +                    className = args[i++];
  +            }            
               else if (arg.equalsIgnoreCase("-Action"))
               {
                   if (i < args.length)
  @@ -113,11 +136,6 @@
                   if (i < args.length)
                       strWarFileName = args[i++];
               }
  -            else if (arg.equalsIgnoreCase("-ApplicationServer"))
  -            {
  -                if (i < args.length)
  -                    strAppServer = args[i++];
  -            }
               else if (arg.equalsIgnoreCase("-PortalName"))
               {
                   if (i < args.length)
  @@ -161,7 +179,7 @@
                   return;
               }
           }
  -
  +        
           // Portlet Application Name and action are required by all functions.
           // Make sure that the values were defined from the command line.
           if (strPortletAppName.length() == 0 || strAction.length() == 0)
  @@ -170,6 +188,11 @@
                   "\nPortlet Application Name and/or action are not defined."
                       + "Please use '-PortletAppName appName' and/or '-Action deploy' from the command line\n");
               helpScreen();
  +            log.error("PAM Error: Invalid parameter(s) passed, cannot process PAM request.");
  +            if (!log.isInfoEnabled())
  +            {
  +                logRequest(args, true);
  +            }            
               return;
           }
   
  @@ -186,32 +209,63 @@
               // Override the properties with PAM specifice settings
               overrideProperties(strAppRoot, properties);
   
  -            engine = Jetspeed.createEngine(properties, strAppRoot, null);
  -
  +            engine = Jetspeed.createEngine(properties, strAppRoot, null);            
           }
           catch (Exception e)
           {
  -            System.out.println("Failed connecting to registry service. Error: " + e.getMessage());
  +            String msg = "PAM Error: Failed to create the Jetspeed Engine. Error: ";
  +            System.out.println(msg + e.getMessage());
  +            log.error(msg, e);
  +            shutdownAndExit(engine);
           }
   
  -        // Invoke the functions
  -        if (strAction.compareToIgnoreCase("deploy") == 0)
  +        logRequest(args, false);
  +        
  +        try
           {
  -            // Make sure that the WarFileName and the ApplicationServer are defined
  -            if (strWarFileName.length() == 0)
  -            {
  -                System.out.println(
  -                    "\nDeploy action requires the war file name. Use '-WarFileName file.war' to specify the file name");
  -                return;
  +            System.out.println("Ready to run PAM implementation: " + className);
  +            System.out.print("Supporting interfaces: Deployment");
  +            Class clas = Class.forName(className);
  +            deployer = (Deployment)clas.newInstance(); 
  +            if (deployer instanceof Registration)
  +            {                
  +                System.out.print(", Registration");
  +                registrator = (Registration)deployer;
               }
  -            else
  +            if (deployer instanceof Lifecycle)
               {
  -                if (strAppServer.length() == 0)
  +                System.out.print(", Lifecycle");
  +                lifecycle = (Lifecycle)deployer;
  +            }            
  +            System.out.println();
  +        }
  +        catch (Exception e)
  +        {
  +            String msg = "PAM Error: Failed to create PAM implementation class object: " + className + " Error: ";
  +            System.out.println(msg  + e.getMessage());
  +            log.error(msg, e);
  +            shutdownAndExit(engine);                        
  +        }
  +        
  +        try
  +        {
  +            // Invoke the functions
  +            if (strAction.compareToIgnoreCase("deploy") == 0)
  +            {
  +                // Make sure that the WarFileName and the ApplicationServer are defined
  +                if (strWarFileName.length() == 0)
  +                {
  +                    System.out.println(
  +                        "\nDeploy action requires the war file name. Use '-WarFileName file.war' to specify the file name");
  +                    log.error("PAM Error: Web application (WAR) file name not specified.");
  +                    shutdownAndExit(engine);                
  +                }
  +                else
                   {
                       if (applicationType.equals("local"))
                       {
                           String portletAppRoot = strAppRoot + appsDirectory;
  -                        deploy(portletAppRoot, strWarFileName, strPortletAppName);
  +                        deploy(deployer, portletAppRoot, strWarFileName, strPortletAppName); // [RUN]
                       }
                       else
                       {
  @@ -220,62 +274,123 @@
                           {
                               System.out.println(
                                   "\nDeploy action requires the definition of the ApplicationServer or the Web application directory.");
  -                            return;
  +                            log.error("PAM Deploy Error: Web application (WAR) directory name not specified.");
  +                            shutdownAndExit(engine);                        
                           }
  -
  +    
                           // File deploy uses Directory and warfile
  -                        deploy(strWebAppDir, strWarFileName, strPortletAppName);
  +                        deploy(deployer, strWebAppDir, strWarFileName, strPortletAppName); // [RUN]
                       }
                   }
  -                else
  +            }
  +            else if (strAction.compareToIgnoreCase("register") == 0)
  +            {
  +                // Requires WebAppDir
  +                if (strWebAppDir.length() == 0)
  +                {
  +                    System.out.println("\nRegister action requires the definition of the Web application directory.");
  +                    log.error("PAM Register Error: Web application (WAR) directory name not specified.");                        
  +                    shutdownAndExit(engine);
  +                }
  +                if (null == registrator)
  +                {
  +                    String msg = "PAM Register Error: Registration interface not supported by implementation: " + className;            
  +                    System.out.println("\n" + msg);
  +                    log.error(msg);
  +                    shutdownAndExit(engine);                                
  +                }
  +    
  +                register(registrator, strWebAppDir, strPortletAppName); // [RUN]
  +            }
  +            else if (strAction.compareToIgnoreCase("unregister") == 0)
  +            {          
  +                if (null == registrator)
                   {
  -                    // Uses war file and applicationServerName
  -                    // DST: deployServer(strWarFileName, strAppServer, strPortletAppName, strServer, intServerPort, strUserName, strPassword);
  +                    String msg = "PAM Register Error: Registration interface not supported by implementation: " + className;            
  +                    System.out.println("\n" + msg);
  +                    log.error(msg);  
  +                    shutdownAndExit(engine);                
                   }
  +                
  +                // Application server can be null -- using Catalina as default
  +                unregister(registrator, strWebAppDir, strPortletAppName); // [RUN]
               }
  -        }
  -        else if (strAction.compareToIgnoreCase("register") == 0)
  -        {
  -            // Requires WebAppDir
  -            if (strWebAppDir.length() == 0)
  +            else if (strAction.compareToIgnoreCase("undeploy") == 0)
               {
  -                System.out.println("\nRegister action requires the definition of the Web application directory.");
  -                return;
  +                if (null == lifecycle)
  +                {
  +                    String msg = "PAM Lifecycle Error: Lifecycle interface not supported by implementation: " + className;            
  +                    System.out.println("\n" + msg);
  +                    log.error(msg);
  +                    shutdownAndExit(engine);                                
  +                }
  +                
  +                undeploy(deployer, strWebAppDir, strPortletAppName, strServer, intServerPort, strUserName, strPassword); // [RUN]
  +            }
  +            else if (strAction.compareToIgnoreCase("start") == 0)
  +            {
  +                if (null == lifecycle)
  +                {
  +                    String msg = "PAM Lifecycle Error: Lifecycle interface not supported by implementation: " + className;            
  +                    System.out.println("\n" + msg);
  +                    log.error(msg);
  +                    shutdownAndExit(engine);                                
  +                }
  +    
  +                start(lifecycle, strPortletAppName, strServer, intServerPort, strUserName, strPassword); // [RUN]
  +            }
  +            else if (strAction.compareToIgnoreCase("stop") == 0)
  +            {
  +                stop(lifecycle, strPortletAppName, strServer, intServerPort, strUserName, strPassword); // [RUN]
  +            }
  +            else if (strAction.compareToIgnoreCase("reload") == 0)
  +            {
  +                if (null == lifecycle)
  +                {
  +                    String msg = "PAM Lifecycle Error: Lifecycle interface not supported by implementation: " + className;            
  +                    System.out.println("\n" + msg);
  +                    log.error(msg);
  +                    shutdownAndExit(engine);                                
  +                }
  +                // Application server can be null -- using Catalina as default
  +                reload(lifecycle, strPortletAppName, strServer, intServerPort, strUserName, strPassword); // [RUN]
  +            }
  +            else
  +            {
  +                System.out.println("\nAction: " + strAction + " not recognized by the PortletApplicationManager.");
  +                helpScreen();
               }
  -
  -            register(strWebAppDir, strWarFileName, strPortletAppName);
  -        }
  -        else if (strAction.compareToIgnoreCase("unregister") == 0)
  -        {
  -            // Application server can be null -- using Catalina as default
  -            unregister(strWebAppDir, strPortletAppName, strAppServer);
  -        }
  -        else if (strAction.compareToIgnoreCase("undeploy") == 0)
  -        {
  -            // Application server can be null -- using Catalina as default
  -            undeploy(strWebAppDir, strPortletAppName, strAppServer, strServer, intServerPort, strUserName, strPassword);
  -        }
  -        else if (strAction.compareToIgnoreCase("start") == 0)
  -        {
  -            // Application server can be null -- using Catalina as default
  -            start(strAppServer, strPortletAppName, strServer, intServerPort, strUserName, strPassword);
           }
  -        else if (strAction.compareToIgnoreCase("stop") == 0)
  +        catch (Exception e)
           {
  -            // Application server can be null -- using Catalina as default
  -            stop(strAppServer, strPortletAppName, strServer, intServerPort, strUserName, strPassword);
  +            String msg = "PAM Error: Failed during execution of " + strAction + ", error = " + e.getMessage();
  +            System.out.println(msg);
  +            log.error(msg);                        
  +            shutdownAndExit(engine);                    
           }
  -        else if (strAction.compareToIgnoreCase("reload") == 0)
  +        
  +        try
           {
  -            // Application server can be null -- using Catalina as default
  -            reload(strAppServer, strPortletAppName, strServer, intServerPort, strUserName, strPassword);
  +            if (engine != null)
  +            {
  +                engine.shutdown();
  +            }
           }
  -        else
  +        catch (JetspeedException e1)
           {
  -            System.out.println("\nAction: " + strAction + " not recognized by the PortletApplicationManager.");
  -            helpScreen();
  +            System.out.println("Failed shutting down the engine. Error: " + e1.getMessage());
  +            log.error("PAM Error: Failed shutting down the engine.", e1);                        
  +            System.exit(0);            
           }
  +        
  +        String msg = "PAM: completed operation " + strAction;
  +        System.out.println(msg);
  +        log.info(msg);
  +        System.exit(0);
  +    }
   
  +    public static void shutdownAndExit(Engine engine)
  +    {
           try
           {
               if (engine != null)
  @@ -286,12 +401,12 @@
           catch (JetspeedException e1)
           {
               System.out.println("Failed shutting down the engine. Error: " + e1.getMessage());
  +            log.error("PAM Error: Failed shutting down the engine.", e1);                        
           }
  -        System.out.println("Done");
  -        // return;
  -        System.exit(0);
  +        
  +        System.exit(0);                    
       }
  -
  +    
       public static void helpScreen()
       {
           System.out.println("\nPortletApplicationManager [options]\n");
  @@ -299,7 +414,7 @@
           System.out.println("\t-PortletAppName\t\t{AppName}\n");
           System.out.println("\t-WebAppDir\t\t{Path to target WebApp directory}\n");
           System.out.println("\t-WarFileName\t\t{Path to war file to deploy}\n");
  -        System.out.println("\t-ApplicationServer\t{Application server}\n");
  +        System.out.println("\t-Impl\t\t{class name of implementation}\n");
           System.out.println("\t-ApplicationType\t{webapp|local}\n");
   
           System.out.println("\nNotes:");
  @@ -317,247 +432,196 @@
       /**
        * Registers the already deployed WAR into the Portal registry
        *
  -     * @param webAppsDir The webapps directory inside the Application Server
  -     * @param warFile The warFile containing the Portlet Application
  -     * @param paName The Portlet Application name
  +     * @param registrator PAM implementation supporting Registration interface
  +     * @param webApplicationName The webapps directory or name inside the Application Server
  +     * @param portletApplicationName The Portlet Application name
        * @throws PortletApplicationException
        */
   
  -    public static void register(String webAppsDir, String warFile, String strPortletAppName)
  -    {
  -        // Invoke FileSystemPAM
  -        FileSystemPAM fs = new FileSystemPAM();
  -        try
  -        {
  -            System.out.println("Calling FileSystemPAM...");
  -
  -            fs.deploy(webAppsDir, warFile, strPortletAppName, 2);
  -        }
  -        catch (PortletApplicationException e)
  -        {
  -            //e.printStackTrace(System.out);
  -            System.out.println(e.getMessage());
  -        }
  +    public static void register(Registration registrator,
  +                                String webApplicationName, 
  +                                String portletApplicationName)
  +    throws PortletApplicationException
  +    {
  +        System.out.println("Registering Web Application [" + webApplicationName + "] to Portlet Application [" + portletApplicationName + "]...");
  +        registrator.register(webApplicationName, portletApplicationName);
  +        System.out.println("...PAM Register done");        
       }
   
       /**
        * Unregisterd a deployed portlet application
        *
  -     * @param paName The Portlet Application name
  -     * @throws PortletApplicationException
  +     * @param registrator PAM implementation supporting Registration interface
  +     * @param webApplicationName The webapps directory or name inside the Application Server
  +     * @param portletApplicationName The Portlet Application name
        */
   
  -    public static void unregister(String strWebAppDir, String paName, String appServer)
  -    {
  -        if (strWebAppDir.length() != 0)
  -        {
  -            // FileSystem undeploy
  -            FileSystemPAM dc = new FileSystemPAM();
  -            try
  -            {
  -                dc.unregister(strWebAppDir, paName);
  -            }
  -            catch (PortletApplicationException e)
  -            {
  -                e.printStackTrace(System.out);
  -            }
  -        }
  -
  +    public static void unregister(Registration registrator, 
  +                                  String webApplicationName, 
  +                                  String portletApplicationName)
  +    throws PortletApplicationException    
  +    {
  +        System.out.println("Unregistering Portlet Application [" + portletApplicationName + "...");
  +        registrator.unregister(webApplicationName, portletApplicationName);
  +        System.out.println("...PAM Unregister done");        
       }
   
       /**
        * Deploys the specified war file to the webapps dirctory specified.
        *
  -     * @param webAppsDir The webapps directory inside the Application Server
  +     * @param webApplicationName The webapps directory or name inside the Application Server
        * @param warFile The warFile containing the Portlet Application
  -     * @param paName The Portlet Application name
  +     * @param portletApplicationName The Portlet Application name
        * @throws PortletApplicationException
        */
   
  -    public static void deploy(String webAppsDir, String warFile, String strPortletAppName)
  -    {
  -        // Invoke FileSystemPAM
  -        FileSystemPAM fs = new FileSystemPAM();
  -        try
  -        {
  -            System.out.println("Calling FileSystemPAM...");
  -
  -            fs.deploy(webAppsDir, warFile, strPortletAppName);
  -        }
  -        catch (PortletApplicationException e)
  -        {
  -            //e.printStackTrace(System.out);
  -            System.out.println(e.getMessage());
  -        }
  +    public static void deploy(Deployment deployer,
  +                              String webApplicationName, 
  +                              String warFile,
  +                              String portletApplicationName)
  +    throws PortletApplicationException        
  +    {
  +        System.out.println("Deploying Web Application [" + webApplicationName + "] to Portlet Application [" + portletApplicationName + "]...");
  +        deployer.deploy(webApplicationName, warFile, portletApplicationName);
  +        System.out.println("...PAM Deploy done");        
       }
   
       /**
  -     * Deploys the specified war file to the webapps directory on the Application Server.
  -     * The appServer parameter specifies a specific Application Server.
  -     *
  -     * @param warFile The warFile containing the Portlet Application
  -     * @param appServer The Application Server name receiving the Portlet Application.
  -     * @param paName The Portlet Application name
  -     * @throws PortletApplicationException
  -     */
  -/*
  -    public static void deployServer(String warFile, String appServer, String strPortletAppName, String strServer, int intServerPort, String strUser, String strPassword)
  -    {
  -        Object dc;
  -        if (appServer == null || (appServer.compareToIgnoreCase("catalina") == 0))
  -        {
  -            
  -            try
  -            {
  -                dc = new CatalinaPAM(strServer, intServerPort, strUser, strPassword);
  -                ((Deployment) dc).deploy(warFile, strPortletAppName);
  -            }
  -            catch (PortletApplicationException e)
  -            {
  -                e.printStackTrace(System.out);
  -            }
  -
  -        }
  -        else
  -        {
  -            System.out.println("Application Server: " + appServer + " not supported");
  -        }
  -    }
  -*/
  -    /**
        * Prepares the specified war file for deployment.
        *
        * @param paName The Portlet Application name
        * @throws PortletApplicationException
  -     */
  -
  -    public static void undeploy(String strWebAppDir, String paName, String appServer, String strServer, int intServerPort, String strUser, String strPassword)
  -    {
  -        Object dc;
  -        if (strWebAppDir.length() == 0)
  -        {
  -            if (appServer == null || (appServer.compareToIgnoreCase("catalina") == 0))
  -            {                
  -                try
  -                {
  -					dc = new CatalinaPAM(strServer, intServerPort, strUser, strPassword);
  -                    ((Deployment) dc).undeploy(paName);
  -                }
  -                catch (PortletApplicationException e)
  -                {
  -                    e.printStackTrace(System.out);
  -                }
  -
  -            }
  -            else
  -            {
  -                System.out.println("Application Server: " + appServer + " not supported");
  -            }
  -        }
  -        else
  -        {
  -            // FileSystem undeploy
  -            dc = new FileSystemPAM();
  -            try
  -            {
  -                ((Deployment) dc).undeploy(strWebAppDir, paName);
  -            }
  -            catch (PortletApplicationException e)
  -            {
  -                e.printStackTrace(System.out);
  -            }
  -        }
  -
  +     */    
  +    public static void undeploy(Deployment deployer,
  +                                String webApplicationName, 
  +                                String portletApplicationName, 
  +                                String host, 
  +                                int port, 
  +                                String user, 
  +                                String password)
  +    throws PortletApplicationException    
  +    {
  +        Map map = new HashMap();        
  +        if (deployer instanceof CatalinaPAM)
  +        {
  +            map.put(CatalinaPAM.PAM_PROPERTY_SERVER, host);
  +            map.put(CatalinaPAM.PAM_PROPERTY_PORT, new Integer(port));
  +            map.put(CatalinaPAM.PAM_PROPERTY_USER, user);
  +            map.put(CatalinaPAM.PAM_PROPERTY_PASSWORD, password);            
  +        }
  +        System.out.println("Un-deploying Web Application [" + webApplicationName + "], Portlet Application [" + portletApplicationName + "]...");
  +        deployer.connect(map);
  +        deployer.undeploy(webApplicationName, portletApplicationName);
  +        System.out.println("...PAM Undeploy done");                                
       }
   
       /**
  -    * Starts the specified Portlet Application on the Application Server
  -    *
  -    * @param paName The Portlet Application name
  -    * @throws PortletApplicationException
  -    */
  -
  -    public static void start(String paName, String appServer, String strServer, int intServerPort, String strUser, String strPassword)
  -    {
  -        Object dc;
  -        if (appServer == null || (appServer.compareToIgnoreCase("catalina") == 0))
  -        {
  -            
  -            try
  -            {
  -				dc = new CatalinaPAM(strServer, intServerPort, strUser, strPassword);
  -                ((Lifecycle) dc).start(paName);
  -            }
  -            catch (PortletApplicationException e)
  -            {
  -                e.printStackTrace(System.out);
  -            }
  -
  +     * Starts the specified Portlet Application on the Application Server
  +     * 
  +     * @param lifecycle
  +     * @param portletApplicationName
  +     * @param host
  +     * @param port
  +     * @param user
  +     * @param password
  +     * @throws PortletApplicationException
  +     */
  +    public static void start(Lifecycle lifecycle,
  +                             String portletApplicationName, 
  +                             String host, 
  +                             int port, 
  +                             String user,
  +                             String password)
  +    throws PortletApplicationException
  +    {
  +        Map map = new HashMap();        
  +        if (lifecycle instanceof CatalinaPAM)
  +        {
  +            map.put(CatalinaPAM.PAM_PROPERTY_SERVER, host);
  +            map.put(CatalinaPAM.PAM_PROPERTY_PORT, new Integer(port));
  +            map.put(CatalinaPAM.PAM_PROPERTY_USER, user);
  +            map.put(CatalinaPAM.PAM_PROPERTY_PASSWORD, password);            
           }
  -        else
  +        System.out.println("Starting Portlet Application [" + portletApplicationName + "...");
  +        if (lifecycle instanceof Deployment)
           {
  -            System.out.println("Application Server: " + appServer + " not supported");
  +            ((Deployment)lifecycle).connect(map);
           }
  -
  +        lifecycle.start(portletApplicationName);
  +        System.out.println("...PAM Start done");                        
       }
   
       /**
        * Stops a portlet application from running on the Application Server
        *
  -     * @param paName The Portlet Application name
  -     * @throws PortletApplicationException
  -     */
  -
  -    public static void stop(String paName, String appServer, String strServer, int intServerPort, String strUser, String strPassword)
  -    {
  -        Object dc;
  -        if (appServer == null || (appServer.compareToIgnoreCase("catalina") == 0))
  -        {            
  -            try
  -            {
  -				dc = new CatalinaPAM(strServer, intServerPort, strUser, strPassword);
  -                ((Lifecycle) dc).stop(paName);
  -            }
  -            catch (PortletApplicationException e)
  -            {
  -                e.printStackTrace(System.out);
  -            }
  -
  +     * @param lifecycle
  +     * @param portletApplicationName
  +     * @param appServer
  +     * @param host
  +     * @param port
  +     * @param user
  +     * @param password
  +     */    
  +    public static void stop(Lifecycle lifecycle, 
  +                            String portletApplicationName, 
  +                            String host, 
  +                            int port, 
  +                            String user, 
  +                            String password)
  +    throws PortletApplicationException        
  +    {
  +        Map map = new HashMap();        
  +        if (lifecycle instanceof CatalinaPAM)
  +        {
  +            map.put(CatalinaPAM.PAM_PROPERTY_SERVER, host);
  +            map.put(CatalinaPAM.PAM_PROPERTY_PORT, new Integer(port));
  +            map.put(CatalinaPAM.PAM_PROPERTY_USER, user);
  +            map.put(CatalinaPAM.PAM_PROPERTY_PASSWORD, password);            
           }
  -        else
  +        System.out.println("Stopping Portlet Application [" + portletApplicationName + "...");
  +        if (lifecycle instanceof Deployment)
           {
  -            System.out.println("Application Server: " + appServer + " not supported");
  +            ((Deployment)lifecycle).connect(map);
           }
  -
  +        lifecycle.stop(portletApplicationName);
  +        System.out.println("...PAM Stop done");                
       }
   
       /**
        * Reloads a portlet application.
  -     *
  -     * @param paName The Portlet Application name
  +     * 
  +     * @param lifecycle
  +     * @param portletApplicationName
  +     * @param appServer
  +     * @param host
  +     * @param port
  +     * @param user
  +     * @param password
        * @throws PortletApplicationException
  -     */
  -
  -    public static void reload(String paName, String appServer, String strServer, int intServerPort, String strUser, String strPassword)
  -    {
  -        Object dc;
  -        if (appServer == null || (appServer.compareToIgnoreCase("catalina") == 0))
  -        {            
  -            try
  -            {
  -				dc = new CatalinaPAM(strServer, intServerPort, strUser, strPassword);
  -                ((Lifecycle) dc).reload(paName);
  -            }
  -            catch (PortletApplicationException e)
  -            {
  -                e.printStackTrace(System.out);
  -            }
  -
  +     */    
  +    public static void reload(Lifecycle lifecycle, 
  +                              String portletApplicationName, 
  +                              String host, 
  +                              int port, 
  +                              String user, 
  +                              String password)
  +    throws PortletApplicationException    
  +    {        
  +        Map map = new HashMap();        
  +        if (lifecycle instanceof CatalinaPAM)
  +        {
  +            map.put(CatalinaPAM.PAM_PROPERTY_SERVER, host);
  +            map.put(CatalinaPAM.PAM_PROPERTY_PORT, new Integer(port));
  +            map.put(CatalinaPAM.PAM_PROPERTY_USER, user);
  +            map.put(CatalinaPAM.PAM_PROPERTY_PASSWORD, password);            
           }
  -        else
  +        System.out.println("Reloading Portlet Application [" + portletApplicationName + "...");
  +        if (lifecycle instanceof Deployment)
           {
  -            System.out.println("Application Server: " + appServer + " not supported");
  +            ((Deployment)lifecycle).connect(map);
           }
  +        lifecycle.reload(portletApplicationName);
  +        System.out.println("...PSM Reload done");        
       }
   
       /*
  @@ -582,6 +646,40 @@
                   Entry entry = (Entry) it.next();
                   //if (entry.getValue() != null && ((String)entry.getValue()).length() > 0)
                   properties.setProperty((String) entry.getKey(), (String) entry.getValue());
  +            }
  +        }
  +    }
  +    
  +    public static void logRequest(String[] args, boolean logAsError)
  +    {
  +        String startMsg = "Starting a PAM request. Parameters: ";
  +        if (logAsError)
  +        {
  +            log.error(startMsg);
  +        }
  +        else
  +        {
  +            log.info(startMsg);            
  +        }
  +        
  +        int ix;
  +        
  +        for (ix = 0; ix < args.length; ix++)
  +        {
  +            String paramName = args[ix];            
  +            String paramValue = "--PARAMS OUT OF BALANCE--";
  +            if (ix < args.length)
  +            {
  +                paramValue = args[++ix];
  +            }
  +
  +            if (logAsError)
  +            {            
  +                log.error(paramName + " : " + paramValue);
  +            }
  +            else
  +            {
  +                log.info(paramName + " : " + paramValue);
               }
           }
       }
  
  
  
  1.5       +24 -20    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/Deployment.java
  
  Index: Deployment.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/Deployment.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Deployment.java	8 Mar 2004 00:34:16 -0000	1.4
  +++ Deployment.java	21 May 2004 18:31:36 -0000	1.5
  @@ -15,6 +15,8 @@
    */
   package org.apache.jetspeed.tools.pamanager;
   
  +import java.util.Map;
  +
   /**
    * This is the interface that defines the Deployment-related methods to deploy
    * Portlet Applications.
  @@ -24,7 +26,15 @@
    * @version $Id$
    */
   public interface Deployment
  -{
  +{    
  +    /**
  +     * Some application servers require connections created before deploying.
  +     * 
  +     * @param params map of server specific properties
  +     */
  +    public void connect(Map params)
  +    throws PortletApplicationException;
  +    
       /**
        * Deploys the specified war file to the webapps dirctory specified.
        * 
  @@ -34,41 +44,35 @@
        * @throws PortletApplicationException
        */
       public void deploy(String webAppsDir, 
  -                       String warFile ,
  +                       String warFile,
                          String paName
  -                       ) throws PortletApplicationException;
  +                       ) 
  +    throws PortletApplicationException;
       
       /**
        * Deploys the specified war file to the webapps directory on the Application Server.
        * The appServer parameter specifies a specific Application Server.
        * 
  -     * 
        * @param warFile The warFile containing the Portlet Application
        * @param paName The Portlet Application name
  -     * @throws PortletApplicationException
  +     * @throws PortletApplicationException 
        */
       public void deploy(String warFile,
  -                       String paName) throws PortletApplicationException;
  +                       String portletApplicationName) 
  +        throws PortletApplicationException;
                          
   	
  -
       /**
        * Undeploys application.
        * 
  -     * @param paName The Portlet Application name 
  -     * @throws PortletApplicationException
  -     */
  -    public void undeploy(String paName) throws PortletApplicationException;
  -
  -    /**
  -     * Undeploys application.
  -     * 
  -     * @param webAppsDir The webapps directory inside the Application Server
  -     * @param paName The Portlet Application name 
  +     * @param webApplicationName The web application directory name inside the Application Server. 
  +     *                           Parameter can be ignored for some servers
  +     * @param portletApplicationName The Portlet Application name
        * @throws PortletApplicationException
        */
  -    public void undeploy(String webAppsDir,
  -                         String paName) throws PortletApplicationException;
  +    public void undeploy(String webApplicationName,
  +                         String portletApplicationName) 
  +    throws PortletApplicationException;
   
   
   }
  
  
  
  1.12      +31 -14    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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- CatalinaPAM.java	15 Apr 2004 21:23:49 -0000	1.11
  +++ CatalinaPAM.java	21 May 2004 18:31:36 -0000	1.12
  @@ -17,6 +17,8 @@
   
   
   
  +import java.util.Map;
  +
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.jetspeed.tools.pamanager.servletcontainer.TomcatManager;
  @@ -33,27 +35,42 @@
   public class CatalinaPAM extends FileSystemPAM implements Deployment, Lifecycle
   {
       // Implementaion of deplyment interface
  +    public final static String PAM_PROPERTY_SERVER = "server";
  +    public final static String PAM_PROPERTY_PORT = "port";
  +    public final static String PAM_PROPERTY_USER = "user";
  +    public final static String PAM_PROPERTY_PASSWORD = "password";
   
  -    private TomcatManager tomcatManager;
  +    private TomcatManager tomcatManager = null;
       protected static final Log log = LogFactory.getLog("deployment");
   
  -    public CatalinaPAM(String server, int port, String user, String password) throws PortletApplicationException
  -    {		
  +
  +    public void connect(Map params)
  +    throws PortletApplicationException
  +    {      
           try
           {
  -            tomcatManager = new TomcatManager(server, port, user, password);
  +            int port = 8080;
  +            String server = (String)params.get(PAM_PROPERTY_SERVER);
  +            Integer portNumber = (Integer)params.get(PAM_PROPERTY_PORT);
  +            if (null != portNumber)
  +            {
  +                port = portNumber.intValue();
  +            }
  +            String username = (String)params.get(PAM_PROPERTY_USER);
  +            String password = (String)params.get(PAM_PROPERTY_PASSWORD);
  +            
  +            tomcatManager = new TomcatManager(server, port, username, password);
           }
           catch (Exception e)
           {
               throw new PortletApplicationException(e);
  -        }
  -
  +        }        
       }
  -
  +    
       // Interface not supported by this implementation 
  -    public void deploy(String webAppsDir, String warFile, String paName) throws PortletApplicationException
  +    public void deploy(String webAppsDir, String warFile, String paName) 
  +    throws PortletApplicationException
       {
  -        
           try
           {            
               super.deploy(webAppsDir, warFile, paName);
  @@ -149,7 +166,7 @@
       /**
       * Starts the specified Portlet Application on the Application Server
       * 
  -    * @param paName The Portlet Application name 
  +    * @param paName The Portlet Application name
       * @throws PortletApplicationException
       */
   
  @@ -173,7 +190,7 @@
       /**
        * Stops a portlet application from running on the Application Server
        * 
  -     * @param paName The Portlet Application name 
  +     * @param paName The Portlet Application name
        * @throws PortletApplicationException
        */
   
  @@ -196,14 +213,14 @@
       /**
        * Reloads a portlet application.
        * 
  -     * @param paName The Portlet Application name 
  +     * @param paName The Portlet Application name
        * @throws PortletApplicationException
        */
  -
       public void reload(String paName) throws PortletApplicationException
       {
           try
           {
  +            
               checkResponse(tomcatManager.reload(paName));
           }
           catch (PortletApplicationException pe)
  
  
  
  1.3       +3 -1      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/Lifecycle.java
  
  Index: Lifecycle.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/Lifecycle.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Lifecycle.java	8 Mar 2004 00:34:16 -0000	1.2
  +++ Lifecycle.java	21 May 2004 18:31:36 -0000	1.3
  @@ -15,6 +15,8 @@
    */
   package org.apache.jetspeed.tools.pamanager;
   
  +import java.util.Map;
  +
   
   /**
    * This is the interface that defines the Lifecycle-related methods to control
  
  
  
  1.27      +23 -8     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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- FileSystemPAM.java	10 May 2004 17:43:07 -0000	1.26
  +++ FileSystemPAM.java	21 May 2004 18:31:36 -0000	1.27
  @@ -16,6 +16,7 @@
   package org.apache.jetspeed.tools.pamanager;
   
   import java.io.File;
  +import java.util.Map;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -37,9 +38,12 @@
    * @version $Id$
    */
   
  -public class FileSystemPAM implements Deployment
  +public class FileSystemPAM implements Deployment, Registration
   {
       // Implementation of deplyment interface
  +    public final int DEPLOY_WAR = 0;
  +    public final int UPDATE_WEB_XML = 1;
  +    public final int UPDATE_REGISTRY = 2;
   
       protected String deploymentDbAlias;
       private static final Log log = LogFactory.getLog("deployment");
  @@ -67,7 +71,7 @@
        */
       public void deploy(String webAppsDir, String warFile, String paName) throws PortletApplicationException
       {
  -        sysDeploy(webAppsDir, warFile, paName, 0);
  +        sysDeploy(webAppsDir, warFile, paName, DEPLOY_WAR);
   
       }
   
  @@ -81,7 +85,7 @@
        * @param warFile
        * @param paName
        * @param startState The deployment state where deployment should start:
  -     * 0 deploy war - 1 Update Web XML - 2 Update Regsitry
  +     * 0 deploy war - 1 Update Web XML - 2 Update Registry
        * @throws PortletApplicationException
        */
       public void deploy(String webAppsDir, String warFile, String paName, int startState) throws PortletApplicationException
  @@ -100,6 +104,12 @@
           throw new UnsupportedOperationException("FileSystemPAM.deploy(String warFile, String paName) is not supported.");
       }
   
  +    public void register(String webApplicationName, String portletApplicationName) 
  +    throws PortletApplicationException
  +    {
  +        sysDeploy(webApplicationName, "", portletApplicationName, UPDATE_REGISTRY);        
  +    }
  +    
       /**
        * Unregisters application.
        *
  @@ -291,7 +301,7 @@
           // 2 WEB XML updated
           // 3 Registry updated
           //
  -        int nState = 0; //Initialize
  +        int nState = DEPLOY_WAR; //Initialize
           MutablePortletApplication app = null;
   
           try
  @@ -301,21 +311,21 @@
                   util.deployArchive(webAppsDir, warFile, paName);
               }
   
  -            nState = 1;
  +            nState = UPDATE_WEB_XML;
   
               if (startState <= nState)
               {
                   util.processWebXML(util.getWebXMLPath(webAppsDir, warFile, paName), paName);
               }
   
  -            nState = 2;
  +            nState = UPDATE_REGISTRY;
   
               if (startState <= nState)
               {
                   registerApplication(webAppsDir, paName);
               }
   
  -            nState = 3;
  +            nState = UPDATE_REGISTRY;
   
               // DONE
               log.info("FileSystem deployment done.");
  @@ -487,4 +497,9 @@
           }
       }
   
  +    public void connect(Map params)
  +    throws PortletApplicationException
  +    {        
  +    }
  +    
   }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/Registration.java
  
  Index: Registration.java
  ===================================================================
  /*
   * Copyright 2000-2001,2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.jetspeed.tools.pamanager;
  
  /**
   * Registration interface for registering and deregistering portlet applications in the registry.
   * Registration does not include deployment operations. See the <link>Deployment</link> interface.
   *
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
   * @version $Id: Registration.java,v 1.1 2004/05/21 18:31:36 taylor Exp $
   */
  public interface Registration
  {
      /**
       * Register a portlet application into the registry.
       * A PA should not be allowed to be registered if another PA with the same name or web application name exists. 
       * 
       * @param webApplicationName The name or directory name of the web application to be registered.
       * @param portletApplicationName The name of the portlet application to be registered. Can be same as web application.
       * @throws PortletApplicationException
       */
      void register(String webApplicationName, String portletApplicationName) 
          throws PortletApplicationException;
          
      /**
       * Unregister a portlet application from the registry.
       * A PA should not be allowed to be unregistered if any portlets are referenced 
       * in a portal page.
       * 
       * @param webApplicationName The name or directory name of the web application to be unregistered.
       * @param portletApplicationName The name of the portlet application to be unregistered. Can be same as web application.
       * @throws PortletApplicationException
       */
      void unregister(String webApplicationName, String portletApplicationName) 
          throws PortletApplicationException;
      
  }
  
  
  
  1.9       +13 -14    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/JetspeedPortletContainerWrapper.java
  
  Index: JetspeedPortletContainerWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/JetspeedPortletContainerWrapper.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JetspeedPortletContainerWrapper.java	17 Mar 2004 01:50:12 -0000	1.8
  +++ JetspeedPortletContainerWrapper.java	21 May 2004 18:31:37 -0000	1.9
  @@ -47,7 +47,6 @@
       public JetspeedPortletContainerWrapper(PortletContainer pluto)
       {
           this.pluto = pluto;
  -        System.out.println("PLUTO = " + pluto);
       }
   
       public void start()
  @@ -83,18 +82,18 @@
       public void renderPortlet(PortletWindow portletWindow, HttpServletRequest servletRequest, HttpServletResponse servletResponse)
           throws PortletException, IOException, PortletContainerException
       {
  -    	    	
  -		if(portletWindow.getPortletEntity() == null)
  -		{
  -			log.warn("Could not render PortletWindow "+ portletWindow.getId() + " as it has no PortletEntity defined.");
  -			return;
  -		}		
  -    	
  -    	if(portletWindow.getPortletEntity().getPortletDefinition() == null)
  -    	{
  -    		log.warn("Could not render PortletWindow"+ portletWindow.getId() + " as it has no PortletDefintion defined.");
  -    		return;
  -    	}
  +                
  +        if(portletWindow.getPortletEntity() == null)
  +        {
  +            log.warn("Could not render PortletWindow "+ portletWindow.getId() + " as it has no PortletEntity defined.");
  +            return;
  +        }        
  +        
  +        if(portletWindow.getPortletEntity().getPortletDefinition() == null)
  +        {
  +            log.warn("Could not render PortletWindow"+ portletWindow.getId() + " as it has no PortletDefintion defined.");
  +            return;
  +        }
           pluto.renderPortlet(portletWindow, servletRequest, servletResponse);
           // TODO: figure out how to access pluto-services before container kicks in
           //                              ServletObjectAccess.getServletRequest(servletRequest),
  
  
  
  1.75      +2 -1      jakarta-jetspeed-2/portal/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/maven.xml,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- maven.xml	18 May 2004 19:51:39 -0000	1.74
  +++ maven.xml	21 May 2004 18:31:37 -0000	1.75
  @@ -20,7 +20,7 @@
            xmlns:maven="jelly:maven">
   
     <!-- Target of maven test:single test -->
  -<property name='testcase' value='org.apache.jetspeed.pipeline.TestPipeline'/>
  +<property name='testcase' value='org.apache.jetspeed.deployment.TestSimpleDeployment'/>
   
   <preGoal name="java:prepare-filesystem">
    	<echo message="====================================" />
  @@ -561,4 +561,5 @@
       <delete dir="${deploy.war.dir}/security"/>
       <delete dir="${deploy.war.dir}/struts-demo"/>      
     </goal>
  +    
   </project>
  
  
  

---------------------------------------------------------------------
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