You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by we...@apache.org on 2004/07/02 16:45:31 UTC
cvs commit: jakarta-jetspeed/fusion/src/java/org/apache/jetspeed/fusion/tools/pamanager FusionAppServerPAM.java
weaver 2004/07/02 07:45:31
Added: fusion/src/java/org/apache/jetspeed/fusion/tools/pamanager
FusionAppServerPAM.java
Log:
Renamed from FusionCatalinaPAM to FusionAppServerPAM since it now will support any app server based
on the ApplicationServerManager implementation passed into the constructor.
Revision Changes Path
1.1 jakarta-jetspeed/fusion/src/java/org/apache/jetspeed/fusion/tools/pamanager/FusionAppServerPAM.java
Index: FusionAppServerPAM.java
===================================================================
/*
* Copyright 2000-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.fusion.tools.pamanager;
import java.io.IOException;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.vfs.FileSystemManager;
import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
import org.apache.jetspeed.components.portletregistry.PortletRegistryComponent;
import org.apache.jetspeed.container.window.PortletWindowAccessor;
import org.apache.jetspeed.tools.pamanager.Lifecycle;
import org.apache.jetspeed.tools.pamanager.PortletApplicationException;
import org.apache.jetspeed.tools.pamanager.PortletApplicationManagement;
import org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager;
import org.apache.jetspeed.util.ArgUtil;
import org.apache.jetspeed.util.descriptor.PortletApplicationWar;
/**
* FusionCatalinaPAM
*
* @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
* @version $Id: FusionAppServerPAM.java,v 1.1 2004/07/02 14:45:31 weaver Exp $
*/
public class FusionAppServerPAM extends FusionPAM implements PortletApplicationManagement, 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 ApplicationServerManager appServerManager = null;
protected static final Log log = LogFactory.getLog("deployment");
public FusionAppServerPAM( String webAppsDir, PortletRegistryComponent registry, FileSystemManager fsManager,
PortletEntityAccessComponent entityAccess, PortletWindowAccessor windowAccess,
ApplicationServerManager appServerManager )
{
super(webAppsDir, registry, fsManager, entityAccess, windowAccess);
ArgUtil.assertNotNull(ApplicationServerManager.class, appServerManager, this);
}
/**
* 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
*/
public void deploy( PortletApplicationWar paWar ) throws PortletApplicationException
{
super.deploy(paWar);
String paName = paWar.getPortletApplicationName();
try
{
if (isServerAvailable())
{
checkResponse(appServerManager.install(webAppsDir + "/" + paName, paName));
}
}
catch (PortletApplicationException pe)
{
throw pe;
}
catch (Exception e)
{
throw new PortletApplicationException(e);
}
}
/**
* Prepares the specified war file for deployment.
*
* @param paName
* The Portlet Application name
* @throws PortletApplicationException
*/
public void undeploy( PortletApplicationWar paWar ) throws PortletApplicationException
{
try
{
if (isServerAvailable())
{
checkResponse(appServerManager.remove(paWar.getPortletApplicationName()));
Thread.sleep(2000);
}
super.undeploy(paWar);
}
catch (UnsupportedOperationException usoe)
{
// ignore FS PAM not suporting this
}
catch (Exception e)
{
throw new PortletApplicationException(e);
}
} // Implementaion of Lifecycle interface
/**
* Starts the specified Portlet Application on the Application Server
*
* @param paName
* The Portlet Application name
* @throws PortletApplicationException
*/
public void startPortletApplication( String paName ) throws PortletApplicationException
{
try
{
if (isServerAvailable())
{
checkResponse(appServerManager.start(paName));
}
else
{
throw new IllegalStateException("startPortletApplication() failed, could not connect to app server.");
}
}
catch (PortletApplicationException pe)
{
throw pe;
}
catch (HttpException e)
{
throw new PortletApplicationException(e);
}
catch (IOException e)
{
throw new PortletApplicationException(e);
}
}
/**
* Stops a portlet application from running on the Application Server
*
* @param paName
* The Portlet Application name
* @throws PortletApplicationException
*/
public void stopPortletApplication( String paName ) throws PortletApplicationException
{
try
{
if (isServerAvailable())
{
checkResponse(appServerManager.stop(paName));
}
else
{
throw new IllegalStateException("stopPortletApplication() failed, could not connect to app server.");
}
}
catch (PortletApplicationException pe)
{
throw pe;
}
catch (HttpException e)
{
throw new PortletApplicationException(e);
}
catch (IOException e)
{
throw new PortletApplicationException(e);
}
}
/**
* Reloads a portlet application.
*
* @param paName
* The Portlet Application name
* @throws PortletApplicationException
*/
public void reloadPortletApplication( String paName ) throws PortletApplicationException
{
try
{
if (isServerAvailable())
{
checkResponse(appServerManager.reload(paName));
}
else
{
throw new IllegalStateException("startPortletApplication() failed, could not connect to app server.");
}
}
catch (PortletApplicationException pe)
{
throw pe;
}
catch (HttpException e)
{
throw new PortletApplicationException(e);
}
catch (IOException e)
{
throw new PortletApplicationException(e);
}
}
/**
*
* @param response
* @throws PortletApplicationException
*/
private void checkResponse( String response ) throws PortletApplicationException
{
if (response == null
|| (!response.startsWith("OK") && response.indexOf("Application already exists at path") == -1))
{
if (response == null)
{
response = "null response";
}
throw new PortletApplicationException("Catalina container action failed, \"" + response + "\"");
}
else
{
log.info("Catalina deployment response: " + response);
}
}
private boolean isServerAvailable()
{
return appServerManager.isConnected();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org