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 at...@apache.org on 2006/11/04 00:06:39 UTC
svn commit: r471040 - in /portals/jetspeed-2/trunk:
components/portal/src/java/org/apache/jetspeed/deployment/impl/
components/portal/src/java/org/apache/jetspeed/tools/pamanager/
src/webapp/WEB-INF/assembly/
Author: ate
Date: Fri Nov 3 15:06:38 2006
New Revision: 471040
URL: http://svn.apache.org/viewvc?view=rev&rev=471040
Log:
JS2-606: Allow deployment of local portlet applications without a jetspeed- name prefix
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/DeployPortletAppEventListener.java
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/StandardDeploymentManager.java
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/deployment.xml
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/DeployPortletAppEventListener.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/DeployPortletAppEventListener.java?view=diff&rev=471040&r1=471039&r2=471040
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/DeployPortletAppEventListener.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/DeployPortletAppEventListener.java Fri Nov 3 15:06:38 2006
@@ -47,7 +47,9 @@
protected static final Log log = LogFactory.getLog("deployment");
private String webAppDir;
+ private int localPAPrefixLength;
private String localAppDir;
+ private String localAppStagingDir;
private boolean stripLoggers;
private PortletApplicationManagement pam;
private PortletRegistry registry;
@@ -56,15 +58,31 @@
* @param pam
* @param webAppDir
* @param localAppDir
+ * @param stripLoggers
* @throws FileNotFoundException the <code>webAppDir</code> or <code>localAppDir</code> directory does not
* exist.
*/
public DeployPortletAppEventListener(PortletApplicationManagement pam, PortletRegistry registry, String webAppDir,
String localAppDir, boolean stripLoggers) throws FileNotFoundException
{
+ this(pam,registry,webAppDir,localAppDir,null,stripLoggers);
+ }
+ /**
+ * @param pam
+ * @param webAppDir
+ * @param localAppDir
+ * @param localAppStagingDir
+ * @param stripLoggers
+ * @throws FileNotFoundException the <code>webAppDir</code> or <code>localAppDir</code> directory does not
+ * exist.
+ */
+ public DeployPortletAppEventListener(PortletApplicationManagement pam, PortletRegistry registry, String webAppDir,
+ String localAppDir, String localAppStagingDir, boolean stripLoggers) throws FileNotFoundException
+ {
this.pam = pam;
this.registry = registry;
this.stripLoggers = stripLoggers;
+ localPAPrefixLength = PortletApplicationManagement.LOCAL_PA_PREFIX.length();
File webAppDirFile = new File(webAppDir);
@@ -97,6 +115,24 @@
this.localAppDir = localAppDirFile.getCanonicalPath();
}
catch (IOException e) {}
+ if ( localAppStagingDir != null )
+ {
+ File localAppStagingDirFile = new File(localAppStagingDir);
+ if ( !localAppStagingDirFile.exists() )
+ {
+ localAppStagingDirFile.mkdirs();
+ }
+ else if (!localAppStagingDirFile.isDirectory())
+ {
+ throw new FileNotFoundException("Invalid staging directory for local portlet applications: \""
+ + localAppStagingDirFile.getAbsolutePath());
+ }
+ try
+ {
+ this.localAppStagingDir = localAppStagingDirFile.getCanonicalPath();
+ }
+ catch (IOException e) {}
+ }
}
public void initialize()
@@ -133,6 +169,18 @@
}
}
}
+
+ private String getEventParentPath(DeploymentEvent event)
+ {
+ try
+ {
+ return event.getDeploymentObject().getFile().getParentFile().getCanonicalPath();
+ }
+ catch (IOException io)
+ {
+ return null;
+ }
+ }
/**
* <p>
@@ -147,9 +195,9 @@
String fileName = event.getName();
if (fileName.endsWith(".war"))
{
- int prefixLength = PortletApplicationManagement.LOCAL_PA_PREFIX.length();
- if (fileName.length() > prefixLength
- && fileName.substring(0, prefixLength).equalsIgnoreCase(PortletApplicationManagement.LOCAL_PA_PREFIX))
+ if ((localAppStagingDir != null && getEventParentPath(event).equals(localAppStagingDir))
+ || (fileName.length() > localPAPrefixLength && fileName.substring(0, localPAPrefixLength)
+ .equalsIgnoreCase(PortletApplicationManagement.LOCAL_PA_PREFIX)))
{
deployLocalPortletApplication(event);
}
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/StandardDeploymentManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/StandardDeploymentManager.java?view=diff&rev=471040&r1=471039&r2=471040
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/StandardDeploymentManager.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/StandardDeploymentManager.java Fri Nov 3 15:06:38 2006
@@ -190,7 +190,7 @@
{
// check for new deployment
File aFile = stagedFiles[i];
- if (!ignoreFile(aFile))
+ if (aFile.isFile() && !ignoreFile(aFile))
{
boolean failed = false;
boolean unknown = false;
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java?view=diff&rev=471040&r1=471039&r2=471040
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java Fri Nov 3 15:06:38 2006
@@ -158,7 +158,6 @@
throws RegistryException
{
checkStarted();
- checkValidContextName(contextName, true);
startPA(contextName, warStruct, paClassLoader, true);
}
@@ -171,7 +170,6 @@
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
try
{
- checkValidContextName(contextName, false);
startPA(contextName, warStruct, paClassLoader, false);
}
finally
@@ -183,8 +181,7 @@
public void stopLocalPortletApplication(String contextName)
throws RegistryException
{
- checkValidContextName(contextName, true);
- stopPA(contextName);
+ stopPA(contextName, true);
}
public void stopPortletApplication(String contextName)
@@ -194,8 +191,7 @@
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
try
{
- checkValidContextName(contextName, false);
- stopPA(contextName);
+ stopPA(contextName, false);
}
finally
{
@@ -236,6 +232,11 @@
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
+
+ protected int getApplicationType(boolean local)
+ {
+ return local ? MutablePortletApplication.LOCAL : MutablePortletApplication.WEBAPP;
+ }
protected void checkValidContextName(String contextName, boolean local)
throws RegistryException
@@ -432,6 +433,17 @@
if (pa != null)
{
+ if ( pa.getApplicationType() != getApplicationType(local) )
+ {
+ if ( local )
+ {
+ throw new RegistryException("Cannot start local portlet application "+contextName+": it is not a local application");
+ }
+ else
+ {
+ throw new RegistryException("Cannot start portlet application "+contextName+": it is a local application");
+ }
+ }
DescriptorChangeMonitor changeMonitor = this.monitor;
if (!monitored && changeMonitor != null)
{
@@ -478,7 +490,7 @@
}
}
- protected void stopPA(String contextName)
+ protected void stopPA(String contextName, boolean local)
throws RegistryException
{
MutablePortletApplication pa = null;
@@ -490,6 +502,17 @@
catch (Exception e)
{
// ignore errors during portal shutdown
+ }
+ if (pa != null && pa.getApplicationType() != getApplicationType(local) )
+ {
+ if ( local )
+ {
+ throw new RegistryException("Cannot stop local portlet application "+contextName+": it is not a local application");
+ }
+ else
+ {
+ throw new RegistryException("Cannot stop portlet application "+contextName+": it is a local application");
+ }
}
DescriptorChangeMonitor monitor = this.monitor;
if ( monitor != null )
Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/deployment.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/deployment.xml?view=diff&rev=471040&r1=471039&r2=471040
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/deployment.xml (original)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/deployment.xml Fri Nov 3 15:06:38 2006
@@ -68,8 +68,9 @@
<constructor-arg index="1"><ref bean="org.apache.jetspeed.components.portletregistry.PortletRegistry"/></constructor-arg>
<constructor-arg index="2"><value>${autodeployment.target.dir}</value></constructor-arg>
<constructor-arg index="3"><value>${applicationRoot}/WEB-INF/apps</value></constructor-arg>
+ <constructor-arg index="4"><value>${autodeployment.staging.dir}/local</value></constructor-arg>
<!-- strip commons-logging and/or log4j jars from war files: for JBoss set this to true -->
- <constructor-arg index="4"><value>false</value></constructor-arg>
+ <constructor-arg index="5"><value>false</value></constructor-arg>
</bean>
<bean id="decoratorDeploymentRegistry"
class="org.apache.jetspeed.deployment.simpleregistry.impl.InMemoryRegistryImpl"
@@ -89,7 +90,7 @@
class="org.apache.jetspeed.deployment.impl.StandardDeploymentManager"
init-method="start" destroy-method="stop"
>
- <constructor-arg ><value>${autodeployment.staging.dir}</value></constructor-arg>
+ <constructor-arg ><value>${autodeployment.staging.dir},${autodeployment.staging.dir}/local</value></constructor-arg>
<constructor-arg type="long" ><value>${autodeployment.delay}</value></constructor-arg>
<constructor-arg >
<list>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org