JBoss Portal SVN: r10073 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-21 19:12:06 -0500 (Thu, 21 Feb 2008)
New Revision: 10073
Removed:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletAPIFactoryImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletAPIFactory.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java
modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml
modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml
Log:
- remote PortletAPIFactory
Deleted: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletAPIFactoryImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletAPIFactoryImpl.java 2008-02-21 23:41:05 UTC (rev 10072)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletAPIFactoryImpl.java 2008-02-22 00:12:06 UTC (rev 10073)
@@ -1,84 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.impl.jsr168;
-
-import org.jboss.portal.portlet.invocation.ActionInvocation;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.invocation.EventInvocation;
-import org.jboss.portal.portlet.invocation.ResourceInvocation;
-import org.jboss.portal.portlet.impl.jsr168.api.ActionResponseImpl;
-import org.jboss.portal.portlet.impl.jsr168.api.ActionRequestImpl;
-import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
-import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
-import org.jboss.portal.portlet.impl.jsr168.api.EventRequestImpl;
-import org.jboss.portal.portlet.impl.jsr168.api.EventResponseImpl;
-import org.jboss.portal.portlet.impl.jsr168.api.ResourceRequestImpl;
-import org.jboss.portal.portlet.impl.jsr168.api.ResourceResponseImpl;
-import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 7226 $
- */
-public class PortletAPIFactoryImpl implements PortletAPIFactory
-{
- public ActionRequestImpl createActionRequest(ActionInvocation invocation)
- {
- return new ActionRequestImpl(null, invocation);
- }
-
- public ActionResponseImpl createActionResponse(ActionInvocation invocation, ActionRequestImpl actionRequest)
- {
- return new ActionResponseImpl(invocation, actionRequest);
- }
-
- public EventRequestImpl createEventRequest(EventInvocation invocation)
- {
- return new EventRequestImpl(null, invocation);
- }
-
- public EventResponseImpl createEventResponse(EventInvocation invocation, EventRequestImpl eventRequest)
- {
- return new EventResponseImpl(invocation, eventRequest);
- }
-
- public RenderRequestImpl createRenderRequest(RenderInvocation invocation)
- {
- return new RenderRequestImpl(null, invocation);
- }
-
- public RenderResponseImpl createRenderResponse(RenderInvocation invocation, RenderRequestImpl renderRequest)
- {
- return new RenderResponseImpl(invocation, renderRequest);
- }
-
- public ResourceRequestImpl createResourceRequest(ResourceInvocation invocation)
- {
- return new ResourceRequestImpl(null, invocation);
- }
-
- public ResourceResponseImpl createResourceResponse(ResourceInvocation invocation, ResourceRequestImpl renderRequest)
- {
- return new ResourceResponseImpl(invocation, renderRequest);
- }
-}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-02-21 23:41:05 UTC (rev 10072)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-02-22 00:12:06 UTC (rev 10073)
@@ -25,7 +25,6 @@
import org.jboss.portal.portlet.impl.jsr168.api.PortletContextImpl;
import org.jboss.portal.portlet.impl.jsr168.api.PortletURLGenerationListenerChain;
import org.jboss.portal.portlet.impl.jsr168.api.FilterConfigImpl;
-import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
import org.jboss.portal.portlet.impl.info.ContainerPortletApplicationInfo;
import org.jboss.portal.portlet.impl.info.ContainerListenerInfo;
@@ -65,9 +64,6 @@
protected final JBossApplicationMetaData jbossMetaData;
/** . */
- protected final PortletAPIFactory portletAPIFactory;
-
- /** . */
protected PortletApplicationContext context;
/** Logger. */
@@ -91,13 +87,11 @@
public PortletApplicationImpl(
ContainerPortletApplicationInfo info,
PortletApplication10MetaData metaData,
- JBossApplicationMetaData jbossMetaData,
- PortletAPIFactory portletAPIFactory)
+ JBossApplicationMetaData jbossMetaData)
{
this.info = info;
this.metaData = metaData;
this.jbossMetaData = jbossMetaData;
- this.portletAPIFactory = portletAPIFactory;
this.portlets = new LinkedHashMap<String, PortletContainer>();
this.log = Logger.getLogger(PortletApplication.class);
}
@@ -127,11 +121,6 @@
return info;
}
- public PortletAPIFactory getPortletAPIFactory()
- {
- return portletAPIFactory;
- }
-
public PortletApplication10MetaData getMetaData()
{
return metaData;
Deleted: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletAPIFactory.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletAPIFactory.java 2008-02-21 23:41:05 UTC (rev 10072)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletAPIFactory.java 2008-02-22 00:12:06 UTC (rev 10073)
@@ -1,77 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.impl.jsr168.spi;
-
-import org.jboss.portal.portlet.invocation.ActionInvocation;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.invocation.EventInvocation;
-import org.jboss.portal.portlet.invocation.ResourceInvocation;
-import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
-import org.jboss.portal.portlet.impl.jsr168.api.ActionRequestImpl;
-import org.jboss.portal.portlet.impl.jsr168.api.ActionResponseImpl;
-import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
-import org.jboss.portal.portlet.impl.jsr168.api.EventRequestImpl;
-import org.jboss.portal.portlet.impl.jsr168.api.EventResponseImpl;
-import org.jboss.portal.portlet.impl.jsr168.api.ResourceRequestImpl;
-import org.jboss.portal.portlet.impl.jsr168.api.ResourceResponseImpl;
-
-/**
- * Factory for portlet API implementation.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 7226 $
- */
-public interface PortletAPIFactory
-{
- /**
- */
- ActionRequestImpl createActionRequest(ActionInvocation invocation);
-
- /**
- */
- ActionResponseImpl createActionResponse(ActionInvocation invocation, ActionRequestImpl actionRequest);
-
- /**
- */
- EventRequestImpl createEventRequest(EventInvocation invocation);
-
- /**
- */
- EventResponseImpl createEventResponse(EventInvocation invocation, EventRequestImpl eventRequest);
-
- /**
- */
- RenderRequestImpl createRenderRequest(RenderInvocation invocation);
-
- /**
- */
- RenderResponseImpl createRenderResponse(RenderInvocation invocation, RenderRequestImpl renderRequest);
-
- /**
- */
- ResourceRequestImpl createResourceRequest(ResourceInvocation invocation);
-
- /**
- */
- ResourceResponseImpl createResourceResponse(ResourceInvocation invocation, ResourceRequestImpl renderRequest);
-}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java 2008-02-21 23:41:05 UTC (rev 10072)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java 2008-02-22 00:12:06 UTC (rev 10073)
@@ -31,7 +31,6 @@
import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletFilterImpl;
-import org.jboss.portal.portlet.impl.jsr168.PortletAPIFactoryImpl;
import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
import org.jboss.portal.portlet.impl.container.PortletApplicationLifeCycle;
import org.jboss.portal.portlet.impl.container.PortletFilterLifeCycle;
@@ -96,7 +95,9 @@
//
PortletApplicationObject portletApplicationObject = new PortletApplicationImpl(
- builder.getApplication(), metaData, new JBossApplicationMetaData(), new PortletAPIFactoryImpl());
+ builder.getApplication(),
+ metaData,
+ new JBossApplicationMetaData());
PortletApplicationContext portletApplicationContext = new PortletApplicationContextImpl(webApp);
Modified: modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml 2008-02-21 23:41:05 UTC (rev 10072)
+++ modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml 2008-02-22 00:12:06 UTC (rev 10073)
@@ -40,8 +40,6 @@
<property name="portletContainerInvoker"><inject bean="PortletContainerInvoker"/></property>
</bean>
- <bean name="PortletAPIFactory" class="org.jboss.portal.portlet.impl.jsr168.PortletAPIFactoryImpl"/>
-
<!-- The ServletContainerFactory -->
<bean name="ServletContainerFactory" class="org.jboss.portal.web.impl.DefaultServletContainerFactory">
<constructor factoryClass="org.jboss.portal.web.impl.DefaultServletContainerFactory" factoryMethod="getInstance"/>
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml 2008-02-21 23:41:05 UTC (rev 10072)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml 2008-02-22 00:12:06 UTC (rev 10073)
@@ -28,8 +28,6 @@
<property name="portletContainerInvoker"><inject bean="PortletContainerInvoker"/></property>
</bean>
- <bean name="PortletAPIFactory" class="org.jboss.portal.portlet.impl.jsr168.PortletAPIFactoryImpl"/>
-
<!-- The ServletContainerFactory -->
<bean name="ServletContainerFactory" class="org.jboss.portal.web.impl.DefaultServletContainerFactory">
<constructor factoryClass="org.jboss.portal.web.impl.DefaultServletContainerFactory" factoryMethod="getInstance"/>
16 years, 7 months
JBoss Portal SVN: r10072 - in modules/portlet/trunk/portlet/src: test/java/org/jboss/portal/portlet/container and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-21 18:41:05 -0500 (Thu, 21 Feb 2008)
New Revision: 10072
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/LifeCycleReentranceDetectionTest.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/LifeCycle.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/LifeCycle1Test.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/ObjectSupport.java
modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml
Log:
implement reentrancy detection + test case
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/LifeCycle.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/LifeCycle.java 2008-02-21 22:45:43 UTC (rev 10071)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/LifeCycle.java 2008-02-21 23:41:05 UTC (rev 10072)
@@ -44,6 +44,9 @@
/** . */
private LifeCycleStatus status = LifeCycleStatus.STOPPED;
+ /** Cheap reentrancy detection. */
+ private boolean active = false;
+
public final LifeCycleStatus getStatus()
{
return status;
@@ -51,8 +54,17 @@
private static final ThreadLocal<Set<Object>> faileds = new ThreadLocal<Set<Object>>();
- public final void managedStart() throws IllegalStateException
+ public synchronized final void managedStart() throws IllegalStateException
{
+ if (active)
+ {
+ throw new IllegalStateException("Reentrancy detected");
+ }
+
+ //
+ active = true;
+
+ //
boolean clearFaileds = false;
//
@@ -122,36 +134,55 @@
{
faileds.set(null);
}
+
+ //
+ active = false;
}
}
- public final void managedStop()
+ public synchronized final void managedStop()
{
- stopDependents();
+ if (active)
+ {
+ throw new IllegalStateException("Reentrancy detected");
+ }
//
- if (status == LifeCycleStatus.STARTED)
+ active = true;
+
+ //
+ try
{
- try
+ stopDependents();
+
+ //
+ if (status == LifeCycleStatus.STARTED)
{
- invokeStop();
+ try
+ {
+ invokeStop();
+ }
+ catch (Exception e)
+ {
+ log.error("Error during object stop", e);
+ }
+ catch (Error e)
+ {
+ log.error("Error during object stop", e);
+ }
+ finally
+ {
+ status = LifeCycleStatus.STOPPED;
+ }
+
+ //
+ getListener().onEvent(new ManagedObjectLifeCycleEvent(this, LifeCycleStatus.STOPPED));
}
- catch (Exception e)
- {
- log.error("Error during object stop", e);
- }
- catch (Error e)
- {
- log.error("Error during object stop", e);
- }
- finally
- {
- status = LifeCycleStatus.STOPPED;
- }
-
- //
- getListener().onEvent(new ManagedObjectLifeCycleEvent(this, LifeCycleStatus.STOPPED));
}
+ finally
+ {
+ active = false;
+ }
}
protected void startDependents()
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/LifeCycle1Test.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/LifeCycle1Test.java 2008-02-21 22:45:43 UTC (rev 10071)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/LifeCycle1Test.java 2008-02-21 23:41:05 UTC (rev 10072)
@@ -214,7 +214,7 @@
events.clear();
//
- container.failOnStart = true;
+ container.startCallback = ObjectSupport.FAILURE_CALLBACK;
//
applicationLC.managedStart();
@@ -281,7 +281,7 @@
events.clear();
//
- application.failOnStart = true;
+ application.startCallback = ObjectSupport.FAILURE_CALLBACK;
//
applicationLC.managedStart();
@@ -312,7 +312,7 @@
events.clear();
//
- filter.failOnStart = true;
+ filter.startCallback = ObjectSupport.FAILURE_CALLBACK;
//
applicationLC.managedStart();
@@ -371,7 +371,7 @@
@Test
public void testContainerFailsOnStop()
{
- container.failOnStop = true;
+ container.stopCallback = ObjectSupport.FAILURE_CALLBACK;
//
testApplicationLifeCycle();
@@ -380,7 +380,7 @@
@Test
public void testApplicationFailsOnStop()
{
- application.failOnStop = true;
+ application.stopCallback = ObjectSupport.FAILURE_CALLBACK;
//
testApplicationLifeCycle();
@@ -389,7 +389,7 @@
@Test
public void testFilterFailsOnStop()
{
- filter.failOnStop = true;
+ filter.stopCallback = ObjectSupport.FAILURE_CALLBACK;
//
testApplicationLifeCycle();
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/LifeCycleReentranceDetectionTest.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/LifeCycleReentranceDetectionTest.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/LifeCycleReentranceDetectionTest.java 2008-02-21 23:41:05 UTC (rev 10072)
@@ -0,0 +1,219 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.portal.portlet.impl.container.PortletApplicationLifeCycle;
+import org.jboss.portal.portlet.impl.container.PortletContainerLifeCycle;
+import org.jboss.portal.portlet.impl.container.LifeCycle;
+import org.jboss.portal.portlet.container.managed.LifeCycleStatus;
+
+import static org.jboss.unit.api.Assert.*;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@Test
+public class LifeCycleReentranceDetectionTest
+{
+
+ PortletApplicationLifeCycle applicationLF;
+ PortletApplicationObjectSupport application;
+ PortletContainerLifeCycle containerLF;
+ PortletContainerObjectSupport container;
+
+ IllegalStateException ise;
+
+ @Create
+ public void create()
+ {
+ this.ise = null;
+ }
+
+ private class InvokeLifeCycleCallback implements ObjectSupport.Callback
+ {
+
+ /** . */
+ private LifeCycle lifeCycle;
+
+ /** . */
+ private boolean invokeStart;
+
+ /** . */
+ private boolean rethrowISE;
+
+ private InvokeLifeCycleCallback(LifeCycle lifeCycle, boolean invokeStart, boolean rethrowISE)
+ {
+ this.lifeCycle = lifeCycle;
+ this.invokeStart = invokeStart;
+ this.rethrowISE = rethrowISE;
+ }
+
+ public void execute()
+ {
+ try
+ {
+ if (invokeStart)
+ {
+ lifeCycle.managedStart();
+ }
+ else
+ {
+ lifeCycle.managedStop();
+ }
+ }
+ catch (IllegalStateException e)
+ {
+ ise = e;
+
+ //
+ if (rethrowISE)
+ {
+ throw e;
+ }
+ }
+ }
+ }
+
+ @Test
+ public void applicationReentersApplication1()
+ {
+ application = new PortletApplicationObjectSupport("application");
+ applicationLF = new PortletApplicationLifeCycle(new PortletApplicationContextSupport(), application);
+ application.startCallback = new InvokeLifeCycleCallback(applicationLF, true, false);
+
+ //
+ applicationLF.create();
+
+ //
+ applicationLF.managedStart();
+
+ //
+ assertNotNull(ise);
+ assertEquals(LifeCycleStatus.STARTED, applicationLF.getStatus());
+ }
+
+ @Test
+ public void applicationReentersApplication2()
+ {
+ application = new PortletApplicationObjectSupport("application");
+ applicationLF = new PortletApplicationLifeCycle(new PortletApplicationContextSupport(), application);
+ application.startCallback = new InvokeLifeCycleCallback(applicationLF, true, true);
+
+ //
+ applicationLF.create();
+
+ //
+ applicationLF.managedStart();
+
+ //
+ assertNotNull(ise);
+ assertEquals(LifeCycleStatus.FAILED, applicationLF.getStatus());
+ }
+
+ @Test
+ public void containerReentersContainer1()
+ {
+ application = new PortletApplicationObjectSupport("application");
+ applicationLF = new PortletApplicationLifeCycle(new PortletApplicationContextSupport(), application);
+ container = new PortletContainerObjectSupport("container");
+ containerLF = applicationLF.addPortletContainer(new PortletContainerContextSupport(), container);
+ container.startCallback = new InvokeLifeCycleCallback(containerLF, true, false);
+
+ //
+ applicationLF.create();
+
+ //
+ applicationLF.managedStart();
+
+ //
+ assertNotNull(ise);
+ assertEquals(LifeCycleStatus.STARTED, applicationLF.getStatus());
+ assertEquals(LifeCycleStatus.STARTED, containerLF.getStatus());
+ }
+
+ @Test
+ public void containerReentersContainer2()
+ {
+ application = new PortletApplicationObjectSupport("application");
+ applicationLF = new PortletApplicationLifeCycle(new PortletApplicationContextSupport(), application);
+ container = new PortletContainerObjectSupport("container");
+ containerLF = applicationLF.addPortletContainer(new PortletContainerContextSupport(), container);
+ container.startCallback = new InvokeLifeCycleCallback(containerLF, true, true);
+
+ //
+ applicationLF.create();
+
+ //
+ applicationLF.managedStart();
+
+ //
+ assertNotNull(ise);
+ assertEquals(LifeCycleStatus.STARTED, applicationLF.getStatus());
+ assertEquals(LifeCycleStatus.FAILED, containerLF.getStatus());
+ }
+
+ @Test
+ public void containerReentersApplication1()
+ {
+ application = new PortletApplicationObjectSupport("application");
+ applicationLF = new PortletApplicationLifeCycle(new PortletApplicationContextSupport(), application);
+ container = new PortletContainerObjectSupport("container");
+ containerLF = applicationLF.addPortletContainer(new PortletContainerContextSupport(), container);
+ container.startCallback = new InvokeLifeCycleCallback(applicationLF, true, false);
+
+ //
+ applicationLF.create();
+
+ //
+ applicationLF.managedStart();
+
+ //
+ assertNotNull(ise);
+ assertEquals(LifeCycleStatus.STARTED, applicationLF.getStatus());
+ assertEquals(LifeCycleStatus.STARTED, containerLF.getStatus());
+ }
+
+ @Test
+ public void containerReentersApplication2()
+ {
+ application = new PortletApplicationObjectSupport("application");
+ applicationLF = new PortletApplicationLifeCycle(new PortletApplicationContextSupport(), application);
+ container = new PortletContainerObjectSupport("container");
+ containerLF = applicationLF.addPortletContainer(new PortletContainerContextSupport(), container);
+ container.startCallback = new InvokeLifeCycleCallback(applicationLF, true, true);
+
+ //
+ applicationLF.create();
+
+ //
+ applicationLF.managedStart();
+
+ //
+ assertNotNull(ise);
+ assertEquals(LifeCycleStatus.STARTED, applicationLF.getStatus());
+ assertEquals(LifeCycleStatus.FAILED, containerLF.getStatus());
+ }
+}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/ObjectSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/ObjectSupport.java 2008-02-21 22:45:43 UTC (rev 10071)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/ObjectSupport.java 2008-02-21 23:41:05 UTC (rev 10072)
@@ -39,16 +39,16 @@
private int stopped;
/** . */
- boolean failOnStart;
+ Callback startCallback;
/** . */
- boolean failOnStop;
+ Callback stopCallback;
public ObjectSupport(String id)
{
this.id = id;
- this.failOnStart = false;
- this.failOnStop = false;
+ this.startCallback = null;
+ this.stopCallback = null;
}
public String getId()
@@ -71,9 +71,9 @@
started++;
//
- if (failOnStart)
+ if (startCallback != null)
{
- throw new RuntimeException();
+ startCallback.execute();
}
}
@@ -82,9 +82,22 @@
stopped++;
//
- if (failOnStop)
+ if (stopCallback != null)
{
+ stopCallback.execute();
+ }
+ }
+
+ public interface Callback
+ {
+ void execute();
+ }
+
+ public static Callback FAILURE_CALLBACK = new Callback()
+ {
+ public void execute()
+ {
throw new RuntimeException();
}
- }
+ };
}
Modified: modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml 2008-02-21 22:45:43 UTC (rev 10071)
+++ modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml 2008-02-21 23:41:05 UTC (rev 10072)
@@ -4,7 +4,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
<pojo>
-<!--
<test>
<class name="org.jboss.portal.test.portlet.state.LocalStoreProducerStatefulPortletInvokerTestCase"/>
</test>
@@ -38,9 +37,11 @@
<test>
<class name="org.jboss.portal.test.portlet.StateStringTestCase"/>
</test>
--->
<test>
<class name="org.jboss.portal.portlet.container.LifeCycle1Test"/>
</test>
+ <test>
+ <class name="org.jboss.portal.portlet.container.LifeCycleReentranceDetectionTest"/>
+ </test>
</pojo>
</jboss-unit>
16 years, 7 months
JBoss Portal SVN: r10071 - modules/portlet/trunk/test/src/test.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-21 17:45:43 -0500 (Thu, 21 Feb 2008)
New Revision: 10071
Modified:
modules/portlet/trunk/test/src/test/build.xml
Log:
set jpda=false again
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-02-21 22:27:47 UTC (rev 10070)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-02-21 22:45:43 UTC (rev 10071)
@@ -661,7 +661,7 @@
<taskdef name="jboss-unit" classname="org.jboss.unit.tooling.ant.JBossUnitTask" classpath="${plugin_classpath}"/>
- <jboss-unit jpda="true" jpdaPort="9000" jpdaSuspend="true" failOnError="false">
+ <jboss-unit jpda="false" jpdaPort="9000" jpdaSuspend="true" failOnError="false">
<tests config="${target}/test-classes/test/remote-jboss-unit.xml">
<property name="archivePath" value="${test.temp.lib}"/>
16 years, 7 months
JBoss Portal SVN: r10070 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet and 6 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-21 17:27:47 -0500 (Thu, 21 Feb 2008)
New Revision: 10070
Modified:
modules/portlet/trunk/bridge/src/main/java/org/jboss/portal/portlet/bridge/JBossServletContextProvider.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ContextDispatcherInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletApplication.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainer.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainerInvoker.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletFilter.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletApplicationObject.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletContainerObject.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletFilterObject.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletApplicationLifeCycle.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletFilterImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletApplicationObjectSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletContainerObjectSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletFilterObjectSupport.java
Log:
correct minor consistency in the model
Modified: modules/portlet/trunk/bridge/src/main/java/org/jboss/portal/portlet/bridge/JBossServletContextProvider.java
===================================================================
--- modules/portlet/trunk/bridge/src/main/java/org/jboss/portal/portlet/bridge/JBossServletContextProvider.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/bridge/src/main/java/org/jboss/portal/portlet/bridge/JBossServletContextProvider.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -126,7 +126,7 @@
//
this.invocation = invocation;
- this.ctx = container.getApplication().getContext().getServletContext();
+ this.ctx = container.getPortletApplication().getContext().getServletContext();
this.breq = null;
this.bresp = null;
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ContextDispatcherInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ContextDispatcherInterceptor.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ContextDispatcherInterceptor.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -67,7 +67,7 @@
protected Object invoke(PortletInvocation invocation) throws Exception, InvocationException
{
PortletContainer container = (PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE, PortletContainerInvoker.PORTLET_CONTAINER);
- PortletApplication portletApplication = container.getApplication();
+ PortletApplication portletApplication = container.getPortletApplication();
ServerContext reqCtx = invocation.getServerContext();
ServletContext targetCtx = portletApplication.getContext().getServletContext();
ServletContainer servletContainer = servletContainerFactory.getServletContainer();
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletApplication.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletApplication.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletApplication.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -55,6 +55,11 @@
*/
PortletContainer getPortletContainer(String containerId);
+ /**
+ * Returns the context of the portlet application.
+ *
+ * @return the context
+ */
PortletApplicationContext getContext();
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainer.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainer.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainer.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -64,7 +64,12 @@
*
* @return the application
*/
- PortletApplication getApplication();
+ PortletApplication getPortletApplication();
+ /**
+ * Returns the context of the portlet container.
+ *
+ * @return the context
+ */
PortletContainerContext getContext();
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainerInvoker.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainerInvoker.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainerInvoker.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -254,7 +254,7 @@
public PortletImpl(PortletContainer container)
{
this.container = container;
- this.context = PortletContext.createPortletContext(container.getApplication().getId() + "." + container.getId());
+ this.context = PortletContext.createPortletContext(container.getPortletApplication().getId() + "." + container.getId());
}
public PortletContext getContext()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletFilter.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletFilter.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletFilter.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -36,4 +36,17 @@
*/
String getId();
+ /**
+ * Returns the wired application.
+ *
+ * @return the application
+ */
+ PortletApplication getPortletApplication();
+
+ /**
+ * Returns the context of the portlet filter
+ *
+ * @return the context
+ */
+ PortletFilterContext getContext();
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletApplicationObject.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletApplicationObject.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletApplicationObject.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -55,28 +55,28 @@
*
* @param container the container
*/
- void addContainer(PortletContainer container);
+ void addPortletContainer(PortletContainer container);
/**
* Remove a container.
*
* @param container the container
*/
- void removeContainer(PortletContainer container);
+ void removePortletContainer(PortletContainer container);
/**
* Add a filter.
*
* @param filter the filter
*/
- void addFilter(PortletFilter filter);
+ void addPortletFilter(PortletFilter filter);
/**
* Remove a filter.
*
* @param filter the filter
*/
- void removeFilter(PortletFilter filter);
+ void removePortletFilter(PortletFilter filter);
/**
* Starts the application only. It does not take care of starting its components.
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletContainerObject.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletContainerObject.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletContainerObject.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -41,7 +41,7 @@
*
* @param application the related application
*/
- void setApplication(PortletApplication application);
+ void setPortletApplication(PortletApplication application);
/**
* Set/unset the portlet container context.
@@ -55,14 +55,14 @@
*
* @param filter the portlet filter
*/
- void addFilter(PortletFilter filter);
+ void addPortletFilter(PortletFilter filter);
/**
* Remove a filter.
*
* @param filter the portlet filter
*/
- void removeFilter(PortletFilter filter);
+ void removePortletFilter(PortletFilter filter);
/**
* Starts the portlet container.
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletFilterObject.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletFilterObject.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletFilterObject.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -38,7 +38,7 @@
*
* @param application the application
*/
- void setApplication(PortletApplication application);
+ void setPortletApplication(PortletApplication application);
/**
* Set the context required by that filter.
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletApplicationLifeCycle.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletApplicationLifeCycle.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletApplicationLifeCycle.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -103,8 +103,8 @@
for (PortletFilterLifeCycle portletFilterLifeCycle : portletFilterLifeCycles.values())
{
portletFilterLifeCycle.portletFilter.setContext(portletFilterLifeCycle.portletFilterContext);
- portletFilterLifeCycle.portletFilter.setApplication(portletApplication);
- portletApplication.addFilter(portletFilterLifeCycle.portletFilter);
+ portletFilterLifeCycle.portletFilter.setPortletApplication(portletApplication);
+ portletApplication.addPortletFilter(portletFilterLifeCycle.portletFilter);
//
listener.onEvent(new ManagedObjectAddedEvent(portletFilterLifeCycle));
@@ -114,8 +114,8 @@
for (PortletContainerLifeCycle portletContainerLifeCycle : portletContainerLifeCycles.values())
{
portletContainerLifeCycle.portletContainer.setContext(portletContainerLifeCycle.portletContainerContext);
- portletContainerLifeCycle.portletContainer.setApplication(portletApplication);
- portletApplication.addContainer(portletContainerLifeCycle.portletContainer);
+ portletContainerLifeCycle.portletContainer.setPortletApplication(portletApplication);
+ portletApplication.addPortletContainer(portletContainerLifeCycle.portletContainer);
//
listener.onEvent(new ManagedObjectAddedEvent(portletContainerLifeCycle));
@@ -126,7 +126,7 @@
{
for (PortletContainerLifeCycle portletContainerLifeCycle : entry.getValue())
{
- portletContainerLifeCycle.portletContainer.addFilter(entry.getKey().portletFilter);
+ portletContainerLifeCycle.portletContainer.addPortletFilter(entry.getKey().portletFilter);
}
}
@@ -148,7 +148,7 @@
{
for (PortletContainerLifeCycle portletContainerLifeCycle : entry.getValue())
{
- portletContainerLifeCycle.portletContainer.removeFilter(entry.getKey().portletFilter);
+ portletContainerLifeCycle.portletContainer.removePortletFilter(entry.getKey().portletFilter);
}
}
@@ -157,8 +157,8 @@
listener.onEvent(new ManagedObjectRemovedEvent(portletContainerLifeCycle));
//
- portletApplication.removeContainer(portletContainerLifeCycle.portletContainer);
- portletContainerLifeCycle.portletContainer.setApplication(null);
+ portletApplication.removePortletContainer(portletContainerLifeCycle.portletContainer);
+ portletContainerLifeCycle.portletContainer.setPortletApplication(null);
portletContainerLifeCycle.portletContainer.setContext(null);
}
@@ -168,8 +168,8 @@
listener.onEvent(new ManagedObjectRemovedEvent(portletFilterLifeCycle));
//
- portletApplication.removeFilter(portletFilterLifeCycle.portletFilter);
- portletFilterLifeCycle.portletFilter.setApplication(null);
+ portletApplication.removePortletFilter(portletFilterLifeCycle.portletFilter);
+ portletFilterLifeCycle.portletFilter.setPortletApplication(null);
portletFilterLifeCycle.portletFilter.setContext(null);
}
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -112,12 +112,12 @@
return metaData.getId();
}
- public void addFilter(org.jboss.portal.portlet.container.PortletFilter filter)
+ public void addPortletFilter(org.jboss.portal.portlet.container.PortletFilter filter)
{
}
- public void removeFilter(org.jboss.portal.portlet.container.PortletFilter filter)
+ public void removePortletFilter(org.jboss.portal.portlet.container.PortletFilter filter)
{
}
@@ -142,12 +142,12 @@
return jbossMetaData;
}
- public void addContainer(PortletContainer container)
+ public void addPortletContainer(PortletContainer container)
{
portlets.put(container.getId(), container);
}
- public void removeContainer(PortletContainer container)
+ public void removePortletContainer(PortletContainer container)
{
portlets.remove(container.getId());
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -190,12 +190,12 @@
return info.getName();
}
- public void addFilter(org.jboss.portal.portlet.container.PortletFilter filter)
+ public void addPortletFilter(org.jboss.portal.portlet.container.PortletFilter filter)
{
filters.add((PortletFilterImpl)filter);
}
- public void removeFilter(org.jboss.portal.portlet.container.PortletFilter filter)
+ public void removePortletFilter(org.jboss.portal.portlet.container.PortletFilter filter)
{
filters.remove((PortletFilterImpl)filter);
}
@@ -380,12 +380,12 @@
}
// Cannot use covariant here as it will break the javabean property getter convention used by MC.
- public PortletApplication getApplication()
+ public PortletApplication getPortletApplication()
{
return application;
}
- public void setApplication(PortletApplication application)
+ public void setPortletApplication(PortletApplication application)
{
this.application = (PortletApplicationImpl)application;
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletFilterImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletFilterImpl.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletFilterImpl.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -104,16 +104,26 @@
return null;
}
- public void setApplication(PortletApplication application)
+ public void setPortletApplication(PortletApplication application)
{
this.application = (PortletApplicationImpl)application;
}
+ public PortletApplication getPortletApplication()
+ {
+ return application;
+ }
+
public void setContext(PortletFilterContext context)
{
this.context = context;
}
+ public PortletFilterContext getContext()
+ {
+ return context;
+ }
+
public void start() throws Exception
{
PortletContext portletContext = application.portletContext;
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -105,7 +105,7 @@
if (infos != null)
{
// Get portlet application metadata
- PortletApplicationImpl portletApp = (PortletApplicationImpl)container.getApplication();
+ PortletApplicationImpl portletApp = (PortletApplicationImpl)container.getPortletApplication();
PortletApplication10MetaData pamd = portletApp.getMetaData();
Map<String, UserAttributeMetaData> uaMD = pamd.getUserAttributes();
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -25,7 +25,6 @@
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
-import org.jboss.portal.common.NotYetImplemented;
import org.jboss.portal.common.io.WriterCharWriter;
import org.jboss.portal.common.text.EntityEncoder;
@@ -142,7 +141,7 @@
public String toString()
{
- PortletURLGenerationListener listener = ((PortletApplicationImpl)preq.container.getApplication()).getListener(PortletURLGenerationListener.class);
+ PortletURLGenerationListener listener = ((PortletApplicationImpl)preq.container.getPortletApplication()).getListener(PortletURLGenerationListener.class);
//
InternalContainerURL url;
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -101,7 +101,7 @@
//
try
{
- PortletApplication application = req.container.getApplication();
+ PortletApplication application = req.container.getPortletApplication();
PortletApplicationContext applicationContext = application.getContext();
ServletContext servletContext = applicationContext.getServletContext();
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -28,7 +28,6 @@
import org.jboss.portal.common.util.MultiValuedPropertyMap;
import org.jboss.portal.common.util.SimpleMultiValuedPropertyMap;
import org.jboss.portal.common.util.ContentInfo;
-import org.jboss.portal.portlet.container.PortletContainerInvoker;
import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
@@ -428,7 +427,7 @@
{
// For sure we need a session we will obtain a valid one
HttpSession hsession = realReq.getSession();
- PortletApplicationImpl portletApp = (PortletApplicationImpl)container.getApplication();
+ PortletApplicationImpl portletApp = (PortletApplicationImpl)container.getPortletApplication();
psession = new PortletSessionImpl(hsession, windowContext.getId(), portletApp.getPortletContext());
}
else
@@ -439,7 +438,7 @@
//
if (hsession != null)
{
- PortletApplicationImpl portletApp = (PortletApplicationImpl)container.getApplication();
+ PortletApplicationImpl portletApp = (PortletApplicationImpl)container.getPortletApplication();
psession = new PortletSessionImpl(hsession, windowContext.getId(), portletApp.getPortletContext());
}
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -320,7 +320,7 @@
}
//
- ContainerPortletApplicationInfo info = ((PortletApplicationImpl)preq.container.getApplication()).getInfo();
+ ContainerPortletApplicationInfo info = ((PortletApplicationImpl)preq.container.getPortletApplication()).getInfo();
QName name = new QName(info.getDefaultNamespace(), localName);
setEvent(name, value);
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletApplicationObjectSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletApplicationObjectSupport.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletApplicationObjectSupport.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -59,7 +59,7 @@
throw new UnsupportedOperationException();
}
- public void addContainer(PortletContainer container)
+ public void addPortletContainer(PortletContainer container)
{
if (container == null)
{
@@ -72,7 +72,7 @@
containers.put(container.getId(), container);
}
- public void removeContainer(PortletContainer container)
+ public void removePortletContainer(PortletContainer container)
{
if (container == null)
{
@@ -85,7 +85,7 @@
containers.remove(container.getId());
}
- public void addFilter(PortletFilter filter)
+ public void addPortletFilter(PortletFilter filter)
{
if (filter == null)
{
@@ -98,7 +98,7 @@
filters.put(filter.getId(), filter);
}
- public void removeFilter(PortletFilter filter)
+ public void removePortletFilter(PortletFilter filter)
{
if (filter == null)
{
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletContainerObjectSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletContainerObjectSupport.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletContainerObjectSupport.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -53,7 +53,7 @@
super(id);
}
- public void setApplication(PortletApplication application)
+ public void setPortletApplication(PortletApplication application)
{
this.application = application;
}
@@ -63,7 +63,7 @@
this.context = context;
}
- public void addFilter(PortletFilter filter)
+ public void addPortletFilter(PortletFilter filter)
{
if (filter == null)
{
@@ -76,7 +76,7 @@
filters.put(filter.getId(), filter);
}
- public void removeFilter(PortletFilter filter)
+ public void removePortletFilter(PortletFilter filter)
{
if (filter == null)
{
@@ -99,7 +99,7 @@
throw new UnsupportedOperationException();
}
- public PortletApplication getApplication()
+ public PortletApplication getPortletApplication()
{
throw new UnsupportedOperationException();
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletFilterObjectSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletFilterObjectSupport.java 2008-02-21 22:21:37 UTC (rev 10069)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletFilterObjectSupport.java 2008-02-21 22:27:47 UTC (rev 10070)
@@ -42,13 +42,24 @@
super(id);
}
- public void setApplication(PortletApplication application)
+ public void setPortletApplication(PortletApplication application)
{
this.application = application;
}
+ public PortletApplication getPortletApplication()
+ {
+ return application;
+ }
+
public void setContext(PortletFilterContext context)
{
this.context = context;
}
+
+ public PortletFilterContext getContext()
+ {
+ return context;
+ }
+
}
16 years, 7 months
JBoss Portal SVN: r10069 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/container and 13 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-21 17:21:37 -0500 (Thu, 21 Feb 2008)
New Revision: 10069
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletFilter.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletFilterContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/LifeCycleStatus.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectAddedEvent.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectEvent.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectLifeCycleEvent.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRegistryEvent.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRegistryEventBroadcaster.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRegistryEventListener.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRemovedEvent.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletFilter.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletFilterObject.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/DependencyNotResolvedException.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/LifeCycle.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/NullManagedObjectRegistryEventListener.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletApplicationLifeCycle.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletContainerLifeCycle.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletFilterLifeCycle.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletFilterImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/LifeCycle1Test.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/ManagedObjectRegistryEventList.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/ObjectSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletApplicationContextSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletApplicationObjectSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletContainerContextSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletContainerObjectSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletFilterContextSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletFilterObjectSupport.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/portal/samples/basic/FailDuringInitPortlet.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletContainerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletFilterContextImpl.java
Removed:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectStatus.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelObject.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletApplication.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletContainer.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ValveInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletApplicationContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainerContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObject.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletApplication.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/PortletApplicationRegistry.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletApplicationObject.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletContainerObject.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ClassInstanceLifeCycle.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml
modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml
Log:
refactor of the kernel integration layer to take in account filter dependencies
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ValveInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ValveInterceptor.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ValveInterceptor.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -60,7 +60,7 @@
PortletContainerContext context = container.getContext();
// Invoke stop
- context.invokeStop();
+// context.invokeStop();
}
//
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletApplicationContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletApplicationContext.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletApplicationContext.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -54,16 +54,4 @@
* @return the classloader
*/
ClassLoader getClassLoader();
-
- /**
- * Start the portlet application and its components.
- *
- * @throws Exception any exception
- */
- void invokeStart() throws Exception;
-
- /**
- * Stop the portlet application and its components.
- */
- void invokeStop();
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainerContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainerContext.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainerContext.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -28,17 +28,4 @@
*/
public interface PortletContainerContext
{
-
- /**
- * Start the portlet container.
- *
- * @throws Exception any exception
- */
- void invokeStart() throws Exception;
-
- /**
- * Stop the portlet container.
- */
- void invokeStop();
-
}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletFilter.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletFilter.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletFilter.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface PortletFilter
+{
+
+ /**
+ * Returns the id.
+ *
+ * @return the id
+ */
+ String getId();
+
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletFilterContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletFilterContext.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletFilterContext.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface PortletFilterContext
+{
+}
Copied: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/LifeCycleStatus.java (from rev 10034, modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectStatus.java)
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/LifeCycleStatus.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/LifeCycleStatus.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container.managed;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public enum LifeCycleStatus
+{
+
+ STOPPED, STARTED, FAILED
+
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObject.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObject.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObject.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -29,9 +29,9 @@
public interface ManagedObject
{
- ManagedObjectStatus getStatus();
+ LifeCycleStatus getStatus();
- void managedStart() throws Exception;
+ void managedStart() throws IllegalStateException;
void managedStop();
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectAddedEvent.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectAddedEvent.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectAddedEvent.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container.managed;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ManagedObjectAddedEvent extends ManagedObjectEvent
+{
+ public ManagedObjectAddedEvent(ManagedObject managedObject)
+ {
+ super(managedObject);
+ }
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectEvent.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectEvent.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectEvent.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container.managed;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ManagedObjectEvent extends ManagedObjectRegistryEvent
+{
+
+ /** . */
+ private final ManagedObject managedObject;
+
+ public ManagedObjectEvent(ManagedObject managedObject)
+ {
+ if (managedObject == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.managedObject = managedObject;
+ }
+
+ public ManagedObject getManagedObject()
+ {
+ return managedObject;
+ }
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectLifeCycleEvent.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectLifeCycleEvent.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectLifeCycleEvent.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container.managed;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ManagedObjectLifeCycleEvent extends ManagedObjectEvent
+{
+
+ /** . */
+ private final LifeCycleStatus status;
+
+ public ManagedObjectLifeCycleEvent(ManagedObject managedObject, LifeCycleStatus status)
+ {
+ super(managedObject);
+
+ //
+ this.status = status;
+ }
+
+ public LifeCycleStatus getStatus()
+ {
+ return status;
+ }
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRegistryEvent.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRegistryEvent.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRegistryEvent.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container.managed;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ManagedObjectRegistryEvent
+{
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRegistryEventBroadcaster.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRegistryEventBroadcaster.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRegistryEventBroadcaster.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container.managed;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ManagedObjectRegistryEventBroadcaster implements ManagedObjectRegistryEventListener
+{
+
+ /** . */
+ private final List<ManagedObjectRegistryEventListener> listeners;
+
+ public ManagedObjectRegistryEventBroadcaster()
+ {
+ listeners = new CopyOnWriteArrayList<ManagedObjectRegistryEventListener>();
+ }
+
+ public void addListener(ManagedObjectRegistryEventListener listener)
+ {
+ if (listener == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (!listeners.contains(listener))
+ {
+ listeners.add(listener);
+ }
+ }
+
+ public void removeListener(ManagedObjectRegistryEventListener listener)
+ {
+ if (listener == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (listeners.contains(listener))
+ {
+ listeners.remove(listener);
+ }
+ }
+
+ public void onEvent(ManagedObjectRegistryEvent event)
+ {
+ for (ManagedObjectRegistryEventListener listener : listeners)
+ {
+ try
+ {
+ listener.onEvent(event);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRegistryEventListener.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRegistryEventListener.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRegistryEventListener.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,32 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container.managed;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface ManagedObjectRegistryEventListener
+{
+ void onEvent(ManagedObjectRegistryEvent event);
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRemovedEvent.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRemovedEvent.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectRemovedEvent.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container.managed;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ManagedObjectRemovedEvent extends ManagedObjectEvent
+{
+ public ManagedObjectRemovedEvent(ManagedObject managedObject)
+ {
+ super(managedObject);
+ }
+}
Deleted: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectStatus.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectStatus.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectStatus.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -1,34 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.container.managed;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public enum ManagedObjectStatus
-{
-
- STOPPED, STARTED, FAILED
-
-}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletApplication.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletApplication.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletApplication.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -37,5 +37,8 @@
ManagedPortletContainer getManagedPortletContainer(String portletContainerId);
+ Collection<? extends ManagedPortletFilter> getManagedPortletFilters();
+ ManagedPortletFilter getManagedPortletFilter(String portletFilterId);
+
}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletFilter.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletFilter.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletFilter.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container.managed;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface ManagedPortletFilter extends ManagedObject
+{
+
+ String getId();
+
+ ManagedPortletApplication getManagedPortletApplication();
+
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/PortletApplicationRegistry.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/PortletApplicationRegistry.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/PortletApplicationRegistry.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -47,4 +47,8 @@
*/
ManagedPortletApplication getManagedPortletApplication(String id);
+ void addListener(ManagedObjectRegistryEventListener listener);
+
+ void removeListener(ManagedObjectRegistryEventListener listener);
+
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletApplicationObject.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletApplicationObject.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletApplicationObject.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -25,6 +25,7 @@
import org.jboss.portal.portlet.container.PortletApplicationContext;
import org.jboss.portal.portlet.container.PortletContainer;
import org.jboss.portal.portlet.container.PortletApplication;
+import org.jboss.portal.portlet.container.PortletFilter;
/**
* Contains life cycle and wiring details for the kernel environment.
@@ -50,20 +51,34 @@
PortletApplicationContext getContext();
/**
- * Wire a container.
+ * Add a container.
*
* @param container the container
*/
void addContainer(PortletContainer container);
/**
- * Unwire a container.
+ * Remove a container.
*
* @param container the container
*/
void removeContainer(PortletContainer container);
/**
+ * Add a filter.
+ *
+ * @param filter the filter
+ */
+ void addFilter(PortletFilter filter);
+
+ /**
+ * Remove a filter.
+ *
+ * @param filter the filter
+ */
+ void removeFilter(PortletFilter filter);
+
+ /**
* Starts the application only. It does not take care of starting its components.
*
* @throws Exception any exception preventing the start
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletContainerObject.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletContainerObject.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletContainerObject.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -25,6 +25,7 @@
import org.jboss.portal.portlet.container.PortletApplication;
import org.jboss.portal.portlet.container.PortletContainerContext;
import org.jboss.portal.portlet.container.PortletContainer;
+import org.jboss.portal.portlet.container.PortletFilter;
/**
* Contains life cycle and wiring details for the kernel environment.
@@ -36,20 +37,34 @@
{
/**
- * Wire the application.
+ * Set/unset the application.
*
* @param application the related application
*/
void setApplication(PortletApplication application);
/**
- * Wire the portlet container context.
+ * Set/unset the portlet container context.
*
* @param context the context
*/
void setContext(PortletContainerContext context);
/**
+ * Add a filter.
+ *
+ * @param filter the portlet filter
+ */
+ void addFilter(PortletFilter filter);
+
+ /**
+ * Remove a filter.
+ *
+ * @param filter the portlet filter
+ */
+ void removeFilter(PortletFilter filter);
+
+ /**
* Starts the portlet container.
*
* @throws Exception any exception preventing the start
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletFilterObject.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletFilterObject.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletFilterObject.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container.object;
+
+import org.jboss.portal.portlet.container.PortletApplication;
+import org.jboss.portal.portlet.container.PortletFilter;
+import org.jboss.portal.portlet.container.PortletFilterContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface PortletFilterObject extends PortletFilter
+{
+
+ /**
+ * Set the application on the portlet filter.
+ *
+ * @param application the application
+ */
+ void setApplication(PortletApplication application);
+
+ /**
+ * Set the context required by that filter.
+ *
+ * @param context the context
+ */
+ void setContext(PortletFilterContext context);
+
+ /**
+ * Starts the portlet container.
+ *
+ * @throws Exception any exception preventing the start
+ */
+ void start() throws Exception;
+
+ /**
+ * Stops the portlet container.
+ */
+ void stop();
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/DependencyNotResolvedException.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/DependencyNotResolvedException.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/DependencyNotResolvedException.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.container;
+
+/**
+ * Internally used only.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+class DependencyNotResolvedException extends Exception
+{
+ public DependencyNotResolvedException(String message)
+ {
+ super(message);
+ }
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/LifeCycle.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/LifeCycle.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/LifeCycle.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,171 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.container;
+
+import org.jboss.portal.portlet.container.managed.ManagedObject;
+import org.jboss.portal.portlet.container.managed.LifeCycleStatus;
+import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEventListener;
+import org.jboss.portal.portlet.container.managed.ManagedObjectLifeCycleEvent;
+import org.apache.log4j.Logger;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class LifeCycle implements ManagedObject
+{
+
+ /** . */
+ private Logger log = Logger.getLogger(LifeCycle.class);
+
+ /** . */
+ private LifeCycleStatus status = LifeCycleStatus.STOPPED;
+
+ public final LifeCycleStatus getStatus()
+ {
+ return status;
+ }
+
+ private static final ThreadLocal<Set<Object>> faileds = new ThreadLocal<Set<Object>>();
+
+ public final void managedStart() throws IllegalStateException
+ {
+ boolean clearFaileds = false;
+
+ //
+ try
+ {
+ if (faileds.get() == null)
+ {
+ clearFaileds = true;
+ faileds.set(new HashSet<Object>());
+ }
+ else if (faileds.get().contains(this))
+ {
+ return;
+ }
+
+ //
+ LifeCycleStatus previousStatus = status;
+
+ //
+ if (status != LifeCycleStatus.STARTED)
+ {
+ LifeCycleStatus status = LifeCycleStatus.FAILED;
+ try
+ {
+ invokeStart();
+ status = LifeCycleStatus.STARTED;
+ }
+ catch (DependencyNotResolvedException ignore)
+ {
+ status = LifeCycleStatus.STOPPED;
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot start object", e);
+ }
+ catch (Error e)
+ {
+ log.error("Cannot start object", e);
+ }
+ finally
+ {
+ this.status = status;
+
+ //
+ if (status == LifeCycleStatus.FAILED)
+ {
+ faileds.get().add(this);
+ }
+ }
+ }
+
+ //
+ if (status != previousStatus)
+ {
+ getListener().onEvent(new ManagedObjectLifeCycleEvent(this, status));
+ }
+
+ //
+ if (status == LifeCycleStatus.STARTED)
+ {
+ startDependents();
+ }
+ }
+ finally
+ {
+ if (clearFaileds)
+ {
+ faileds.set(null);
+ }
+ }
+ }
+
+ public final void managedStop()
+ {
+ stopDependents();
+
+ //
+ if (status == LifeCycleStatus.STARTED)
+ {
+ try
+ {
+ invokeStop();
+ }
+ catch (Exception e)
+ {
+ log.error("Error during object stop", e);
+ }
+ catch (Error e)
+ {
+ log.error("Error during object stop", e);
+ }
+ finally
+ {
+ status = LifeCycleStatus.STOPPED;
+ }
+
+ //
+ getListener().onEvent(new ManagedObjectLifeCycleEvent(this, LifeCycleStatus.STOPPED));
+ }
+ }
+
+ protected void startDependents()
+ {
+ }
+
+ protected void stopDependents()
+ {
+ }
+
+ protected abstract void invokeStart() throws Exception;
+
+ protected abstract void invokeStop();
+
+ protected abstract ManagedObjectRegistryEventListener getListener();
+
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/NullManagedObjectRegistryEventListener.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/NullManagedObjectRegistryEventListener.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/NullManagedObjectRegistryEventListener.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.container;
+
+import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEventListener;
+import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEvent;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+class NullManagedObjectRegistryEventListener implements ManagedObjectRegistryEventListener
+{
+
+ /** . */
+ private final static ManagedObjectRegistryEventListener INSTANCE = new NullManagedObjectRegistryEventListener();
+
+ public static ManagedObjectRegistryEventListener getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private NullManagedObjectRegistryEventListener()
+ {
+ }
+
+ public void onEvent(ManagedObjectRegistryEvent event)
+ {
+ }
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletApplicationLifeCycle.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletApplicationLifeCycle.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletApplicationLifeCycle.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,417 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.container;
+
+import org.jboss.portal.portlet.container.object.PortletApplicationObject;
+import org.jboss.portal.portlet.container.object.PortletContainerObject;
+import org.jboss.portal.portlet.container.object.PortletFilterObject;
+import org.jboss.portal.portlet.container.managed.LifeCycleStatus;
+import org.jboss.portal.portlet.container.managed.ManagedPortletApplication;
+import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEventListener;
+import org.jboss.portal.portlet.container.managed.ManagedObjectAddedEvent;
+import org.jboss.portal.portlet.container.managed.ManagedObjectRemovedEvent;
+import org.jboss.portal.portlet.container.PortletApplicationContext;
+import org.jboss.portal.portlet.container.PortletContainerContext;
+import org.jboss.portal.portlet.container.PortletFilterContext;
+import org.jboss.portal.portlet.container.PortletApplication;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletApplicationLifeCycle extends LifeCycle implements ManagedPortletApplication
+{
+
+ /** . */
+ private final PortletApplicationContext portletApplicationContext;
+
+ /** . */
+ private final PortletApplicationObject portletApplication;
+
+ /** . */
+ private final Map<String, PortletContainerLifeCycle> portletContainerLifeCycles;
+
+ /** . */
+ private final Map<String, PortletFilterLifeCycle> portletFilterLifeCycles;
+
+ /** . */
+ private final Map<PortletFilterLifeCycle, Set<PortletContainerLifeCycle>> filterToContainerDependencies;
+
+ /** Internal status to know about wiring. */
+ private boolean created;
+
+ /** . */
+ private ManagedObjectRegistryEventListener listener;
+
+ public PortletApplicationLifeCycle(
+ ManagedObjectRegistryEventListener listener,
+ PortletApplicationContext portletApplicationContext,
+ PortletApplicationObject portletApplication)
+ {
+ this.listener = listener;
+ this.portletApplicationContext = portletApplicationContext;
+ this.portletApplication = portletApplication;
+ this.portletContainerLifeCycles = new HashMap<String, PortletContainerLifeCycle>();
+ this.portletFilterLifeCycles = new HashMap<String, PortletFilterLifeCycle>();
+ this.filterToContainerDependencies = new HashMap<PortletFilterLifeCycle, Set<PortletContainerLifeCycle>>();
+ }
+
+ public PortletApplicationLifeCycle(
+ PortletApplicationContext portletApplicationContext,
+ PortletApplicationObject portletApplication)
+ {
+ this(NullManagedObjectRegistryEventListener.getInstance(), portletApplicationContext, portletApplication);
+ }
+
+ public void create()
+ {
+ if (created)
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ portletApplication.setContext(portletApplicationContext);
+
+ //
+ for (PortletFilterLifeCycle portletFilterLifeCycle : portletFilterLifeCycles.values())
+ {
+ portletFilterLifeCycle.portletFilter.setContext(portletFilterLifeCycle.portletFilterContext);
+ portletFilterLifeCycle.portletFilter.setApplication(portletApplication);
+ portletApplication.addFilter(portletFilterLifeCycle.portletFilter);
+
+ //
+ listener.onEvent(new ManagedObjectAddedEvent(portletFilterLifeCycle));
+ }
+
+ //
+ for (PortletContainerLifeCycle portletContainerLifeCycle : portletContainerLifeCycles.values())
+ {
+ portletContainerLifeCycle.portletContainer.setContext(portletContainerLifeCycle.portletContainerContext);
+ portletContainerLifeCycle.portletContainer.setApplication(portletApplication);
+ portletApplication.addContainer(portletContainerLifeCycle.portletContainer);
+
+ //
+ listener.onEvent(new ManagedObjectAddedEvent(portletContainerLifeCycle));
+ }
+
+ //
+ for (Map.Entry<PortletFilterLifeCycle, Set<PortletContainerLifeCycle>> entry : filterToContainerDependencies.entrySet())
+ {
+ for (PortletContainerLifeCycle portletContainerLifeCycle : entry.getValue())
+ {
+ portletContainerLifeCycle.portletContainer.addFilter(entry.getKey().portletFilter);
+ }
+ }
+
+ //
+ created = true;
+ }
+
+ public void destroy()
+ {
+ if (getStatus() == LifeCycleStatus.STARTED)
+ {
+ managedStop();
+ }
+
+ //
+ if (created)
+ {
+ for (Map.Entry<PortletFilterLifeCycle, Set<PortletContainerLifeCycle>> entry : filterToContainerDependencies.entrySet())
+ {
+ for (PortletContainerLifeCycle portletContainerLifeCycle : entry.getValue())
+ {
+ portletContainerLifeCycle.portletContainer.removeFilter(entry.getKey().portletFilter);
+ }
+ }
+
+ for (PortletContainerLifeCycle portletContainerLifeCycle : portletContainerLifeCycles.values())
+ {
+ listener.onEvent(new ManagedObjectRemovedEvent(portletContainerLifeCycle));
+
+ //
+ portletApplication.removeContainer(portletContainerLifeCycle.portletContainer);
+ portletContainerLifeCycle.portletContainer.setApplication(null);
+ portletContainerLifeCycle.portletContainer.setContext(null);
+ }
+
+ //
+ for (PortletFilterLifeCycle portletFilterLifeCycle : portletFilterLifeCycles.values())
+ {
+ listener.onEvent(new ManagedObjectRemovedEvent(portletFilterLifeCycle));
+
+ //
+ portletApplication.removeFilter(portletFilterLifeCycle.portletFilter);
+ portletFilterLifeCycle.portletFilter.setApplication(null);
+ portletFilterLifeCycle.portletFilter.setContext(null);
+ }
+ }
+
+ //
+ this.created = false;
+ }
+
+ public PortletContainerLifeCycle addPortletContainer(PortletContainerContext portletContainerContext, PortletContainerObject portletContainer)
+ {
+ if (getStatus() != LifeCycleStatus.STOPPED)
+ {
+ throw new IllegalStateException("Cannot add portlet container because not stopped");
+ }
+ if (portletContainer == null)
+ {
+ throw new IllegalArgumentException("No null portlet container can be added");
+ }
+
+ //
+ if (portletContainerLifeCycles.containsKey(portletContainer.getId()))
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ PortletContainerLifeCycle portletContainerLifeCycle = new PortletContainerLifeCycle(this, portletContainerContext, portletContainer);
+
+ // Manage
+ portletContainerLifeCycles.put(portletContainer.getId(), portletContainerLifeCycle);
+
+ //
+ return portletContainerLifeCycle;
+ }
+
+ public PortletFilterLifeCycle addPortletFilter(PortletFilterContext portletFilterContext, PortletFilterObject portletFilter)
+ {
+ if (getStatus() != LifeCycleStatus.STOPPED)
+ {
+ throw new IllegalStateException("Cannot add portlet container because not stopped");
+ }
+ if (portletFilter == null)
+ {
+ throw new IllegalArgumentException("No null portlet filter can be added");
+ }
+
+ //
+ if (portletFilterLifeCycles.containsKey(portletFilter.getId()))
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ PortletFilterLifeCycle portletFilterLifeCycle = new PortletFilterLifeCycle(this, portletFilterContext, portletFilter);
+
+ //
+ portletFilterLifeCycles.put(portletFilter.getId(), portletFilterLifeCycle);
+
+ //
+ return portletFilterLifeCycle;
+ }
+
+ public void addDependency(PortletFilterLifeCycle portletFilterLifeCycle, PortletContainerLifeCycle portletContainerLifeCycle)
+ {
+ if (portletFilterLifeCycle == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (portletContainerLifeCycle == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (!portletFilterLifeCycles.containsValue(portletFilterLifeCycle))
+ {
+ throw new IllegalStateException();
+ }
+ if (!portletContainerLifeCycles.containsValue(portletContainerLifeCycle))
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ Set<PortletContainerLifeCycle> containerDependencies = filterToContainerDependencies.get(portletFilterLifeCycle);
+
+ //
+ if (containerDependencies == null)
+ {
+ containerDependencies = new HashSet<PortletContainerLifeCycle>();
+ filterToContainerDependencies.put(portletFilterLifeCycle, containerDependencies);
+ }
+
+ //
+ if (containerDependencies.contains(portletContainerLifeCycle))
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ containerDependencies.add(portletContainerLifeCycle);
+ }
+
+ public Set<PortletFilterLifeCycle> getDependencies(PortletContainerLifeCycle portletContainerLifeCycle)
+ {
+ if (portletContainerLifeCycle == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Set<PortletFilterLifeCycle> dependencies = new HashSet<PortletFilterLifeCycle>();
+
+ //
+ for (Map.Entry<PortletFilterLifeCycle, Set<PortletContainerLifeCycle>> entry : filterToContainerDependencies.entrySet())
+ {
+ if (entry.getValue().contains(portletContainerLifeCycle))
+ {
+ dependencies.add(entry.getKey());
+ }
+ }
+
+ //
+ return dependencies;
+ }
+
+ public Set<PortletContainerLifeCycle> getDependencies(PortletFilterLifeCycle portletFilterLifeCycle)
+ {
+ if (portletFilterLifeCycle == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Set<PortletContainerLifeCycle> dependencies = filterToContainerDependencies.get(portletFilterLifeCycle);
+
+ if (dependencies == null)
+ {
+ dependencies = new HashSet<PortletContainerLifeCycle>();
+ }
+ else
+ {
+ dependencies = new HashSet<PortletContainerLifeCycle>(dependencies);
+ }
+
+ //
+ return dependencies;
+ }
+
+ protected void invokeStart() throws Exception
+ {
+ if (!created)
+ {
+ throw new DependencyNotResolvedException("Application is not wired");
+ }
+
+ //
+ portletApplication.start();
+ }
+
+ protected void startDependents()
+ {
+ for (PortletFilterLifeCycle portletFilterLifeCycle : portletFilterLifeCycles.values())
+ {
+ try
+ {
+ portletFilterLifeCycle.managedStart();
+ }
+ catch (IllegalStateException ignore)
+ {
+ }
+ }
+
+ //
+ for (PortletContainerLifeCycle portletContainerLifeCycle : portletContainerLifeCycles.values())
+ {
+ try
+ {
+ portletContainerLifeCycle.managedStart();
+ }
+ catch (IllegalStateException ignore)
+ {
+ }
+ }
+ }
+
+ protected void stopDependents()
+ {
+ for (PortletContainerLifeCycle portletContainerLifeCycle : portletContainerLifeCycles.values())
+ {
+ portletContainerLifeCycle.managedStop();
+ }
+
+ //
+ for (PortletFilterLifeCycle portletFilterLifeCycle : portletFilterLifeCycles.values())
+ {
+ portletFilterLifeCycle.managedStop();
+ }
+ }
+
+ protected void invokeStop()
+ {
+ portletApplication.stop();
+ }
+
+ public String getId()
+ {
+ return portletApplication.getId();
+ }
+
+ public Collection<? extends PortletContainerLifeCycle> getManagedPortletContainers()
+ {
+ return portletContainerLifeCycles.values();
+ }
+
+ public PortletContainerLifeCycle getManagedPortletContainer(String portletContainerId)
+ {
+ return portletContainerLifeCycles.get(portletContainerId);
+ }
+
+ public Collection<? extends PortletFilterLifeCycle> getManagedPortletFilters()
+ {
+ return portletFilterLifeCycles.values();
+ }
+
+ public PortletFilterLifeCycle getManagedPortletFilter(String portletFilterId)
+ {
+ return portletFilterLifeCycles.get(portletFilterId);
+ }
+
+ public String toString()
+ {
+ return "PortletApplicationLifeCycle[" + portletApplication.getId() + "]";
+ }
+
+ public PortletApplication getPortletApplication()
+ {
+ return portletApplication;
+ }
+
+ protected ManagedObjectRegistryEventListener getListener()
+ {
+ return listener;
+ }
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletContainerLifeCycle.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletContainerLifeCycle.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletContainerLifeCycle.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.container;
+
+import org.jboss.portal.portlet.container.object.PortletContainerObject;
+import org.jboss.portal.portlet.container.managed.LifeCycleStatus;
+import org.jboss.portal.portlet.container.managed.ManagedPortletContainer;
+import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEventListener;
+import org.jboss.portal.portlet.container.PortletContainerContext;
+import org.jboss.portal.portlet.container.PortletContainer;
+import org.jboss.portal.portlet.info.PortletInfo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletContainerLifeCycle extends LifeCycle implements ManagedPortletContainer
+{
+
+ /** . */
+ private PortletApplicationLifeCycle portletApplicationLifeCycle;
+
+ /** . */
+ final PortletContainerContext portletContainerContext;
+
+ /** . */
+ final PortletContainerObject portletContainer;
+
+ PortletContainerLifeCycle(
+ PortletApplicationLifeCycle portletApplicationLifeCycle,
+ PortletContainerContext portletContainerContext,
+ PortletContainerObject portletContainer)
+ {
+ this.portletApplicationLifeCycle = portletApplicationLifeCycle;
+ this.portletContainerContext = portletContainerContext;
+ this.portletContainer = portletContainer;
+ }
+
+ protected void invokeStart() throws Exception
+ {
+ if (portletApplicationLifeCycle.getStatus() != LifeCycleStatus.STARTED)
+ {
+ throw new DependencyNotResolvedException("The parent application is not started");
+ }
+
+ //
+ for (PortletFilterLifeCycle portletFilterLifeCycle : portletApplicationLifeCycle.getDependencies(this))
+ {
+ if (portletFilterLifeCycle.getStatus() != LifeCycleStatus.STARTED)
+ {
+ throw new DependencyNotResolvedException("The filter " + portletFilterLifeCycle + " is not started");
+ }
+ }
+
+ //
+ portletContainer.start();
+ }
+
+ protected void invokeStop()
+ {
+ portletContainer.stop();
+ }
+
+ public String getId()
+ {
+ return portletContainer.getId();
+ }
+
+ public PortletInfo getInfo()
+ {
+ return portletContainer.getInfo();
+ }
+
+ public PortletApplicationLifeCycle getManagedPortletApplication()
+ {
+ return portletApplicationLifeCycle;
+ }
+
+ public String toString()
+ {
+ return "PortletContainerLifeCycle[" + portletContainer.getId() + "]";
+ }
+
+ public PortletContainer getPortletContainer()
+ {
+ return portletContainer;
+ }
+
+ protected ManagedObjectRegistryEventListener getListener()
+ {
+ return portletApplicationLifeCycle.getListener();
+ }
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletFilterLifeCycle.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletFilterLifeCycle.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletFilterLifeCycle.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.container;
+
+import org.jboss.portal.portlet.container.object.PortletFilterObject;
+import org.jboss.portal.portlet.container.managed.LifeCycleStatus;
+import org.jboss.portal.portlet.container.managed.ManagedPortletFilter;
+import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEventListener;
+import org.jboss.portal.portlet.container.PortletFilterContext;
+import org.jboss.portal.portlet.container.PortletFilter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletFilterLifeCycle extends LifeCycle implements ManagedPortletFilter
+{
+
+ /** . */
+ private PortletApplicationLifeCycle portletApplicationLifeCycle;
+
+ /** . */
+ final PortletFilterContext portletFilterContext;
+
+ /** . */
+ final PortletFilterObject portletFilter;
+
+ PortletFilterLifeCycle(
+ PortletApplicationLifeCycle portletApplicationLifeCycle,
+ PortletFilterContext portletFilterContext,
+ PortletFilterObject portletFilter)
+ {
+ this.portletApplicationLifeCycle = portletApplicationLifeCycle;
+ this.portletFilterContext = portletFilterContext;
+ this.portletFilter = portletFilter;
+ }
+
+ protected void invokeStart() throws Exception
+ {
+ if (portletApplicationLifeCycle.getStatus() != LifeCycleStatus.STARTED)
+ {
+ throw new DependencyNotResolvedException("The parent application is not started");
+ }
+
+ //
+ portletFilter.start();
+ }
+
+ protected void startDependents()
+ {
+ // Dependent containers may or not start (for instance if a container depends on several filters)
+ for (PortletContainerLifeCycle portletContainerLifeCycle : portletApplicationLifeCycle.getDependencies(this))
+ {
+ portletContainerLifeCycle.managedStart();
+ }
+ }
+
+ protected void stopDependents()
+ {
+ for (PortletContainerLifeCycle portletContainerLifeCycle : portletApplicationLifeCycle.getDependencies(this))
+ {
+ portletContainerLifeCycle.managedStop();
+ }
+ }
+
+ protected void invokeStop()
+ {
+ portletFilter.stop();
+ }
+
+ public String getId()
+ {
+ return portletFilter.getId();
+ }
+
+ public PortletApplicationLifeCycle getManagedPortletApplication()
+ {
+ return portletApplicationLifeCycle;
+ }
+
+ public String toString()
+ {
+ return "PortletFilterLifeCycle[" + portletFilter.getId() + "]";
+ }
+
+ public PortletFilter getPortletFilter()
+ {
+ return portletFilter;
+ }
+
+ protected ManagedObjectRegistryEventListener getListener()
+ {
+ return portletApplicationLifeCycle.getListener();
+ }
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -42,7 +42,7 @@
private final String className;
/** . */
- private final Set<LifeCyclePhase> lifeCycles;
+ private final Set<LifeCyclePhase> phases;
/** . */
private final LocalizedString displayName;
@@ -56,14 +56,14 @@
public ContainerFilterInfo(
String name,
String className,
- Set<LifeCyclePhase> lifeCycles,
+ Set<LifeCyclePhase> phases,
LocalizedString displayName,
LocalizedString description,
Map<String, String> parameters)
{
this.name = name;
this.className = className;
- this.lifeCycles = lifeCycles;
+ this.phases = phases;
this.displayName = displayName;
this.description = description;
this.parameters = parameters;
@@ -79,9 +79,9 @@
return className;
}
- public Set<LifeCyclePhase> getLifeCycles()
+ public Set<LifeCyclePhase> getPhases()
{
- return lifeCycles;
+ return phases;
}
public LocalizedString getDisplayName()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ClassInstanceLifeCycle.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ClassInstanceLifeCycle.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ClassInstanceLifeCycle.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -175,5 +175,4 @@
{
}
-
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -36,25 +36,17 @@
import org.jboss.portal.portlet.container.PortletContainer;
import org.jboss.portal.portlet.container.PortletInitializationException;
import org.jboss.portal.portlet.container.object.PortletApplicationObject;
-import org.jboss.portal.portlet.LifeCyclePhase;
import org.apache.log4j.Logger;
import javax.portlet.PortletContext;
import javax.portlet.PortletURLGenerationListener;
import javax.portlet.filter.PortletFilter;
-import javax.portlet.filter.ActionFilter;
-import javax.portlet.filter.EventFilter;
-import javax.portlet.filter.RenderFilter;
-import javax.portlet.filter.ResourceFilter;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
import java.util.List;
import java.util.LinkedList;
import java.util.Collections;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.EnumMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -63,17 +55,6 @@
public class PortletApplicationImpl implements PortletApplicationObject
{
- private static final EnumMap<LifeCyclePhase, Class<? extends PortletFilter>> phaseToType =
- new EnumMap<LifeCyclePhase, Class<? extends PortletFilter>>(LifeCyclePhase.class);
-
- static
- {
- phaseToType.put(LifeCyclePhase.ACTION, ActionFilter.class);
- phaseToType.put(LifeCyclePhase.EVENT, EventFilter.class);
- phaseToType.put(LifeCyclePhase.RENDER, RenderFilter.class);
- phaseToType.put(LifeCyclePhase.RESOURCE, ResourceFilter.class);
- }
-
/** . */
protected final ContainerPortletApplicationInfo info;
@@ -104,9 +85,6 @@
/** . */
protected PortletURLGenerationListener urlListener;
- /** . */
- protected Map<FilterKey, FilterLifecycle> filters;
-
/**
* Todo remove meta data reference and use info instead.
*/
@@ -134,6 +112,16 @@
return metaData.getId();
}
+ public void addFilter(org.jboss.portal.portlet.container.PortletFilter filter)
+ {
+
+ }
+
+ public void removeFilter(org.jboss.portal.portlet.container.PortletFilter filter)
+ {
+
+ }
+
public ContainerPortletApplicationInfo getInfo()
{
return info;
@@ -207,66 +195,16 @@
}
//
- HashMap<FilterKey, FilterLifecycle> filters = new HashMap<FilterKey, FilterLifecycle>();
- for (ContainerFilterInfo filterInfo : info.getFilters().values())
- {
- try
- {
- String className = filterInfo.getClassName();
- FilterLifecycle lifeCycle = new FilterLifecycle(
- PortletFilter.class,
- context.getClassLoader(),
- className,
- "filter",
- filterInfo);
-
- //
- lifeCycle.create();
-
- //
- for (LifeCyclePhase phase : filterInfo.getLifeCycles())
- {
- Class<? extends PortletFilter> type = phaseToType.get(phase);
-
- //
- if (type.isInstance(lifeCycle.getInstance()))
- {
- FilterKey key = new FilterKey(filterInfo.getName(), type);
- filters.put(key, lifeCycle);
- }
- else
- {
- log.error("Cannot realize filter mapping on phase " + phase + " for filter " + filterInfo.getName() +
- " with class " + className + " that does not implement the interface " + type.getName());
- }
- }
- }
- catch (PortletInitializationException e)
- {
- log.error(e.getMessage(), e);
- }
- }
-
- //
this.version = metaData.getVersion();
this.portletContext = portletContext;
this.urlListener = listeners.size() == 0 ? null : new PortletURLGenerationListenerChain(Collections.unmodifiableList(listeners));
- this.filters = filters;
}
public void stop()
{
- // Stop filters
- for (FilterLifecycle filter : filters.values())
- {
- filter.destroy();
- }
-
- //
this.version = null;
this.portletContext = null;
this.urlListener = null;
- this.filters = null;
}
public String getVersion()
@@ -290,6 +228,7 @@
return null;
}
+/*
public <T extends PortletFilter> T getFilter(String filterName, Class<T> phase)
{
FilterLifecycle lifeCycle = filters.get(new FilterKey(filterName, phase));
@@ -303,6 +242,7 @@
// Should be ok
return phase.cast(lifeCycle.getInstance());
}
+*/
// WebApp implementation ********************************************************************************************
@@ -363,23 +303,28 @@
}
}
- private class FilterLifecycle extends ClassInstanceLifeCycle<PortletFilter>
+ static class FilterLifecycle extends ClassInstanceLifeCycle<PortletFilter>
{
/** . */
private final ContainerFilterInfo info;
- private FilterLifecycle(
- Class<PortletFilter> expectedClass,
+ /** . */
+ private final PortletContext portletContext;
+
+ FilterLifecycle(
+ Logger log,
ClassLoader classLoader,
String className,
String type,
- ContainerFilterInfo info)
+ ContainerFilterInfo info,
+ PortletContext portletContext)
{
- super(log, expectedClass, classLoader, className, type);
+ super(log, PortletFilter.class, classLoader, className, type);
//
this.info = info;
+ this.portletContext = portletContext;
}
public void start(PortletFilter instance) throws Exception
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -86,6 +86,7 @@
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -139,6 +140,9 @@
/** . */
private PortletContainerContext context;
+ /** . */
+ private Set<org.jboss.portal.portlet.impl.jsr168.PortletFilterImpl> filters;
+
/**
* The preference validator, this is not exposed as runtime meta data as it is only used by the JSR 168 portlet
* container implementation.
@@ -157,6 +161,7 @@
this.valve = new Valve();
this.log = Logger.getLogger("org.jboss.portal.portlet.container." + info.getClassName().replace('.', '_'));
this.started = false;
+ this.filters = new HashSet<PortletFilterImpl>();
}
public void setContext(PortletContainerContext context)
@@ -185,6 +190,16 @@
return info.getName();
}
+ public void addFilter(org.jboss.portal.portlet.container.PortletFilter filter)
+ {
+ filters.add((PortletFilterImpl)filter);
+ }
+
+ public void removeFilter(org.jboss.portal.portlet.container.PortletFilter filter)
+ {
+ filters.remove((PortletFilterImpl)filter);
+ }
+
public boolean isStarted()
{
return valve.getState() == Valve.OPEN;
@@ -308,8 +323,17 @@
ArrayList<T> list = new ArrayList<T>();
for (String filterRef : info.getFilterRefs())
{
- T filter = application.getFilter(filterRef, type);
- list.add(filter);
+ for (org.jboss.portal.portlet.impl.jsr168.PortletFilterImpl filter : filters)
+ {
+ if (filter.getId().equals(filterRef))
+ {
+ T filterInstance = filter.instance(type);
+ if (filterInstance == null)
+ {
+ list.add(filterInstance);
+ }
+ }
+ }
}
return list;
}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletFilterImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletFilterImpl.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletFilterImpl.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,149 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168;
+
+import org.jboss.portal.portlet.container.PortletApplication;
+import org.jboss.portal.portlet.container.PortletFilterContext;
+import org.jboss.portal.portlet.container.object.PortletFilterObject;
+import org.jboss.portal.portlet.impl.info.ContainerFilterInfo;
+import org.jboss.portal.portlet.LifeCyclePhase;
+import org.apache.log4j.Logger;
+
+import javax.portlet.PortletContext;
+import javax.portlet.filter.ActionFilter;
+import javax.portlet.filter.EventFilter;
+import javax.portlet.filter.RenderFilter;
+import javax.portlet.filter.ResourceFilter;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletFilterImpl implements PortletFilterObject
+{
+
+ /** . */
+ private static final Map<Class<? extends javax.portlet.filter.PortletFilter>, LifeCyclePhase> typeToPhase =
+ new HashMap<Class<? extends javax.portlet.filter.PortletFilter>, LifeCyclePhase>();
+
+ static
+ {
+ typeToPhase.put(ActionFilter.class, LifeCyclePhase.ACTION);
+ typeToPhase.put(EventFilter.class, LifeCyclePhase.EVENT);
+ typeToPhase.put(RenderFilter.class, LifeCyclePhase.RENDER);
+ typeToPhase.put(ResourceFilter.class, LifeCyclePhase.RESOURCE);
+ }
+
+ /** . */
+ private final Logger log;
+
+ /** . */
+ private final ContainerFilterInfo info;
+
+ /** . */
+ private PortletFilterContext context;
+
+ /** . */
+ private PortletApplicationImpl application;
+
+ /** . */
+ private PortletApplicationImpl.FilterLifecycle lifeCycle;
+
+ public PortletFilterImpl(ContainerFilterInfo info)
+ {
+ this.info = info;
+ this.log = Logger.getLogger(PortletFilterImpl.class);
+ }
+
+ public <T> T instance(Class<T> type)
+ {
+ LifeCyclePhase phase = typeToPhase.get(type);
+
+ // It means we can cast unless the developers did not implement the correct interface
+ if (info.getPhases().contains(phase))
+ {
+ if (type.isInstance(lifeCycle.getInstance()))
+ {
+ return type.cast(lifeCycle.getInstance());
+ }
+ }
+
+ //
+ return null;
+ }
+
+ public ContainerFilterInfo getInfo()
+ {
+ return info;
+ }
+
+ public String getId()
+ {
+ return null;
+ }
+
+ public void setApplication(PortletApplication application)
+ {
+ this.application = (PortletApplicationImpl)application;
+ }
+
+ public void setContext(PortletFilterContext context)
+ {
+ this.context = context;
+ }
+
+ public void start() throws Exception
+ {
+ PortletContext portletContext = application.portletContext;
+ String className = info.getClassName();
+ ClassLoader classLoader = application.getContext().getClassLoader();
+
+ //
+ PortletApplicationImpl.FilterLifecycle lifeCycle = new PortletApplicationImpl.FilterLifecycle(
+ log,
+ classLoader,
+ className,
+ "filter",
+ info,
+ portletContext);
+
+ //
+ lifeCycle.create();
+
+ //
+ this.lifeCycle = lifeCycle;
+ }
+
+ public void stop()
+ {
+ if (lifeCycle != null)
+ {
+ lifeCycle.destroy();
+
+ //
+ lifeCycle = null;
+ }
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/LifeCycle1Test.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/LifeCycle1Test.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/LifeCycle1Test.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,397 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.portal.portlet.impl.container.PortletApplicationLifeCycle;
+import org.jboss.portal.portlet.impl.container.PortletFilterLifeCycle;
+import org.jboss.portal.portlet.impl.container.PortletContainerLifeCycle;
+import org.jboss.portal.portlet.container.managed.LifeCycleStatus;
+
+import static org.jboss.unit.api.Assert.*;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@Test
+public class LifeCycle1Test
+{
+
+ ManagedObjectRegistryEventList events;
+
+ PortletApplicationObjectSupport application;
+ PortletApplicationLifeCycle applicationLC;
+
+ PortletFilterObjectSupport filter;
+ PortletContainerObjectSupport container;
+ PortletFilterLifeCycle filterLC;
+ PortletContainerLifeCycle containerLC;
+
+ @Create
+ public void create()
+ {
+ events = new ManagedObjectRegistryEventList();
+
+ application = new PortletApplicationObjectSupport("application");
+ applicationLC = new PortletApplicationLifeCycle(events, new PortletApplicationContextSupport(), application);
+
+ filter = new PortletFilterObjectSupport("filter2");
+ container = new PortletContainerObjectSupport("container2");
+ filterLC = applicationLC.addPortletFilter(new PortletFilterContextSupport(), filter);
+ containerLC = applicationLC.addPortletContainer(new PortletContainerContextSupport(), container);
+ applicationLC.addDependency(filterLC, containerLC);
+
+ applicationLC.create();
+ }
+
+ private void testState(
+ int applicationStarted,
+ int applicationStopped,
+ LifeCycleStatus applicationStatus,
+ int containerStarted,
+ int containerStopped,
+ LifeCycleStatus containerStatus,
+ int filterStarted,
+ int filterStopped,
+ LifeCycleStatus filterStatus
+ )
+ {
+ assertEquals(applicationStarted, application.getStarted());
+ assertEquals(applicationStopped, application.getStopped());
+ assertEquals(applicationStatus, applicationLC.getStatus());
+ assertEquals(containerStarted, container.getStarted());
+ assertEquals(containerStopped, container.getStopped());
+ assertEquals(containerStatus, containerLC.getStatus());
+ assertEquals(filterStarted, filter.getStarted());
+ assertEquals(filterStopped, filter.getStopped());
+ assertEquals(filterStatus, filterLC.getStatus());
+ }
+
+ @Test
+ public void testWiring()
+ {
+ events.assertAddedEvent(filterLC);
+ events.assertAddedEvent(containerLC);
+ events.assertEmpty();
+
+ assertEquals(1, application.containers.size());
+ assertSame(container, application.containers.get(container.getId()));
+ assertEquals(1, application.filters.size());
+ assertSame(filter, application.filters.get(filter.getId()));
+
+ //
+ assertSame(application, filter.application);
+
+ //
+ assertSame(application, container.application);
+ assertEquals(1, container.filters.size());
+ assertSame(filter, container.filters.get(filter.getId()));
+ }
+
+ @Test
+ public void testApplicationLifeCycle()
+ {
+ events.clear();
+
+ //
+ applicationLC.managedStart();
+
+ //
+ testState(1, 0, LifeCycleStatus.STARTED, 1, 0, LifeCycleStatus.STARTED, 1, 0, LifeCycleStatus.STARTED);
+ events.assertStartedEvent(applicationLC);
+ events.assertStartedEvent(filterLC);
+ events.assertStartedEvent(containerLC);
+ events.assertEmpty();
+
+ //
+ applicationLC.managedStart();
+
+ //
+ testState(1, 0, LifeCycleStatus.STARTED, 1, 0, LifeCycleStatus.STARTED, 1, 0, LifeCycleStatus.STARTED);
+ events.assertEmpty();
+
+ //
+ applicationLC.managedStop();
+
+ //
+ testState(1, 1, LifeCycleStatus.STOPPED, 1, 1, LifeCycleStatus.STOPPED, 1, 1, LifeCycleStatus.STOPPED);
+ events.assertStoppedEvent(containerLC);
+ events.assertStoppedEvent(filterLC);
+ events.assertStoppedEvent(applicationLC);
+ events.assertEmpty();
+ }
+
+ @Test
+ public void testFilterLifeCycle()
+ {
+ events.clear();
+
+ //
+ applicationLC.managedStart();
+
+ //
+ events.clear();
+
+ // Filter stop triggers
+ filterLC.managedStop();
+
+ //
+ testState(1, 0, LifeCycleStatus.STARTED, 1, 1, LifeCycleStatus.STOPPED, 1, 1, LifeCycleStatus.STOPPED);
+ events.assertStoppedEvent(containerLC);
+ events.assertStoppedEvent(filterLC);
+ events.assertEmpty();
+
+ // Container does not start if its filter is stopped
+ containerLC.managedStart();
+
+ //
+ testState(1, 0, LifeCycleStatus.STARTED, 1, 1, LifeCycleStatus.STOPPED, 1, 1, LifeCycleStatus.STOPPED);
+ events.assertEmpty();
+
+ // Filter start triggers container start
+ filterLC.managedStart();
+
+ //
+ testState(1, 0, LifeCycleStatus.STARTED, 2, 1, LifeCycleStatus.STARTED, 2, 1, LifeCycleStatus.STARTED);
+ events.assertStartedEvent(filterLC);
+ events.assertStartedEvent(containerLC);
+ events.assertEmpty();
+ }
+
+ @Test
+ public void testContainerLifeCycle()
+ {
+ events.clear();
+
+ //
+ applicationLC.managedStart();
+
+ //
+ events.clear();
+
+ //
+ containerLC.managedStop();
+
+ //
+ testState(1, 0, LifeCycleStatus.STARTED, 1, 1, LifeCycleStatus.STOPPED, 1, 0, LifeCycleStatus.STARTED);
+ events.assertStoppedEvent(containerLC);
+ events.assertEmpty();
+
+ //
+ containerLC.managedStart();
+
+ //
+ testState(1, 0, LifeCycleStatus.STARTED, 2, 1, LifeCycleStatus.STARTED, 1, 0, LifeCycleStatus.STARTED);
+ events.assertStartedEvent(containerLC);
+ events.assertEmpty();
+ }
+
+ @Test
+ public void testContainerFailsOnStart()
+ {
+ events.clear();
+
+ //
+ container.failOnStart = true;
+
+ //
+ applicationLC.managedStart();
+
+ //
+ testState(1, 0, LifeCycleStatus.STARTED, 1, 0, LifeCycleStatus.FAILED, 1, 0, LifeCycleStatus.STARTED);
+ events.assertStartedEvent(applicationLC);
+ events.assertStartedEvent(filterLC);
+ events.assertFailedEvent(containerLC);
+ events.assertEmpty();
+
+ //
+ applicationLC.managedStop();
+
+ //
+ testState(1, 1, LifeCycleStatus.STOPPED, 1, 0, LifeCycleStatus.FAILED, 1, 1, LifeCycleStatus.STOPPED);
+ events.assertStoppedEvent(filterLC);
+ events.assertStoppedEvent(applicationLC);
+ events.assertEmpty();
+
+ //
+ applicationLC.managedStart();
+
+ //
+ testState(2, 1, LifeCycleStatus.STARTED, 2, 0, LifeCycleStatus.FAILED, 2, 1, LifeCycleStatus.STARTED);
+ events.assertStartedEvent(applicationLC);
+ events.assertStartedEvent(filterLC);
+ events.assertEmpty();
+
+ //
+ containerLC.managedStart();
+
+ //
+ testState(2, 1, LifeCycleStatus.STARTED, 3, 0, LifeCycleStatus.FAILED, 2, 1, LifeCycleStatus.STARTED);
+ events.assertEmpty();
+
+ //
+ containerLC.managedStop();
+
+ //
+ testState(2, 1, LifeCycleStatus.STARTED, 3, 0, LifeCycleStatus.FAILED, 2, 1, LifeCycleStatus.STARTED);
+ events.assertEmpty();
+
+ //
+ filterLC.managedStop();
+
+ //
+ testState(2, 1, LifeCycleStatus.STARTED, 3, 0, LifeCycleStatus.FAILED, 2, 2, LifeCycleStatus.STOPPED);
+ events.assertStoppedEvent(filterLC);
+ events.assertEmpty();
+
+ //
+ filterLC.managedStart();
+
+ //
+ testState(2, 1, LifeCycleStatus.STARTED, 4, 0, LifeCycleStatus.FAILED, 3, 2, LifeCycleStatus.STARTED);
+ events.assertStartedEvent(filterLC);
+ events.assertEmpty();
+ }
+
+ @Test
+ public void testApplicationFailsOnStart()
+ {
+ events.clear();
+
+ //
+ application.failOnStart = true;
+
+ //
+ applicationLC.managedStart();
+
+ //
+ testState(1, 0, LifeCycleStatus.FAILED, 0, 0, LifeCycleStatus.STOPPED, 0, 0, LifeCycleStatus.STOPPED);
+ events.assertFailedEvent(applicationLC);
+ events.assertEmpty();
+
+ //
+ applicationLC.managedStart();
+
+ //
+ testState(2, 0, LifeCycleStatus.FAILED, 0, 0, LifeCycleStatus.STOPPED, 0, 0, LifeCycleStatus.STOPPED);
+ events.assertEmpty();
+
+ //
+ applicationLC.managedStop();
+
+ //
+ testState(2, 0, LifeCycleStatus.FAILED, 0, 0, LifeCycleStatus.STOPPED, 0, 0, LifeCycleStatus.STOPPED);
+ events.assertEmpty();
+ }
+
+ @Test
+ public void testFilterFailsOnStart()
+ {
+ events.clear();
+
+ //
+ filter.failOnStart = true;
+
+ //
+ applicationLC.managedStart();
+
+ //
+ testState(1, 0, LifeCycleStatus.STARTED, 0, 0, LifeCycleStatus.STOPPED, 1, 0, LifeCycleStatus.FAILED);
+ events.assertStartedEvent(applicationLC);
+ events.assertFailedEvent(filterLC);
+ events.assertEmpty();
+
+ //
+ applicationLC.managedStop();
+
+ //
+ testState(1, 1, LifeCycleStatus.STOPPED, 0, 0, LifeCycleStatus.STOPPED, 1, 0, LifeCycleStatus.FAILED);
+ events.assertStoppedEvent(applicationLC);
+ events.assertEmpty();
+
+ //
+ applicationLC.managedStart();
+
+ //
+ testState(2, 1, LifeCycleStatus.STARTED, 0, 0, LifeCycleStatus.STOPPED, 2, 0, LifeCycleStatus.FAILED);
+ events.assertStartedEvent(applicationLC);
+ events.assertEmpty();
+
+ //
+ filterLC.managedStart();
+
+ //
+ testState(2, 1, LifeCycleStatus.STARTED, 0, 0, LifeCycleStatus.STOPPED, 3, 0, LifeCycleStatus.FAILED);
+ events.assertEmpty();
+
+ //
+ filterLC.managedStop();
+
+ //
+ testState(2, 1, LifeCycleStatus.STARTED, 0, 0, LifeCycleStatus.STOPPED, 3, 0, LifeCycleStatus.FAILED);
+ events.assertEmpty();
+
+ //
+ filterLC.managedStart();
+
+ //
+ testState(2, 1, LifeCycleStatus.STARTED, 0, 0, LifeCycleStatus.STOPPED, 4, 0, LifeCycleStatus.FAILED);
+ events.assertEmpty();
+
+ //
+ containerLC.managedStart();
+
+ //
+ testState(2, 1, LifeCycleStatus.STARTED, 0, 0, LifeCycleStatus.STOPPED, 4, 0, LifeCycleStatus.FAILED);
+ events.assertEmpty();
+ }
+
+ @Test
+ public void testContainerFailsOnStop()
+ {
+ container.failOnStop = true;
+
+ //
+ testApplicationLifeCycle();
+ }
+
+ @Test
+ public void testApplicationFailsOnStop()
+ {
+ application.failOnStop = true;
+
+ //
+ testApplicationLifeCycle();
+ }
+
+ @Test
+ public void testFilterFailsOnStop()
+ {
+ filter.failOnStop = true;
+
+ //
+ testApplicationLifeCycle();
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/ManagedObjectRegistryEventList.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/ManagedObjectRegistryEventList.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/ManagedObjectRegistryEventList.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,94 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container;
+
+import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEventListener;
+import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEvent;
+import org.jboss.portal.portlet.container.managed.ManagedObject;
+import org.jboss.portal.portlet.container.managed.ManagedObjectAddedEvent;
+import org.jboss.portal.portlet.container.managed.LifeCycleStatus;
+import org.jboss.portal.portlet.container.managed.ManagedObjectLifeCycleEvent;
+
+import java.util.LinkedList;
+
+import static org.jboss.unit.api.Assert.*;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ManagedObjectRegistryEventList implements ManagedObjectRegistryEventListener
+{
+
+ /** . */
+ final LinkedList<ManagedObjectRegistryEvent> list = new LinkedList<ManagedObjectRegistryEvent>();
+
+ public void onEvent(ManagedObjectRegistryEvent event)
+ {
+ list.add(event);
+ }
+
+ public void assertAddedEvent(ManagedObject managedObject)
+ {
+ ManagedObjectAddedEvent event = nextEvent(ManagedObjectAddedEvent.class);
+ assertSame(managedObject, event.getManagedObject());
+ }
+
+ public void assertStartedEvent(ManagedObject managedObject)
+ {
+ assertLifeCycleEvent(managedObject, LifeCycleStatus.STARTED);
+ }
+
+ public void assertStoppedEvent(ManagedObject managedObject)
+ {
+ assertLifeCycleEvent(managedObject, LifeCycleStatus.STOPPED);
+ }
+
+ public void assertFailedEvent(ManagedObject managedObject)
+ {
+ assertLifeCycleEvent(managedObject, LifeCycleStatus.FAILED);
+ }
+
+ public void assertLifeCycleEvent(ManagedObject managedObject, LifeCycleStatus status)
+ {
+ ManagedObjectLifeCycleEvent event = nextEvent(ManagedObjectLifeCycleEvent.class);
+ assertSame(managedObject, event.getManagedObject());
+ assertEquals(status, event.getStatus());
+ }
+
+ public void assertEmpty()
+ {
+ assertTrue(list.isEmpty());
+ }
+
+ public void clear()
+ {
+ list.clear();
+ }
+
+ private <T extends ManagedObjectRegistryEvent> T nextEvent(Class<T> type)
+ {
+ assertFalse(list.isEmpty());
+ return assertInstanceOf(list.removeFirst(), type);
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/ObjectSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/ObjectSupport.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/ObjectSupport.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ObjectSupport
+{
+
+ /** . */
+ private final String id;
+
+ /** . */
+ private int started;
+
+ /** . */
+ private int stopped;
+
+ /** . */
+ boolean failOnStart;
+
+ /** . */
+ boolean failOnStop;
+
+ public ObjectSupport(String id)
+ {
+ this.id = id;
+ this.failOnStart = false;
+ this.failOnStop = false;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public int getStarted()
+ {
+ return started;
+ }
+
+ public int getStopped()
+ {
+ return stopped;
+ }
+
+ public void start() throws Exception
+ {
+ started++;
+
+ //
+ if (failOnStart)
+ {
+ throw new RuntimeException();
+ }
+ }
+
+ public void stop()
+ {
+ stopped++;
+
+ //
+ if (failOnStop)
+ {
+ throw new RuntimeException();
+ }
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletApplicationContextSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletApplicationContextSupport.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletApplicationContextSupport.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container;
+
+import javax.servlet.ServletContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletApplicationContextSupport implements PortletApplicationContext
+{
+ public ServletContext getServletContext()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getContextPath()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public ClassLoader getClassLoader()
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletApplicationObjectSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletApplicationObjectSupport.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletApplicationObjectSupport.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,123 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container;
+
+import org.jboss.portal.portlet.container.object.PortletApplicationObject;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletApplicationObjectSupport extends ObjectSupport implements PortletApplicationObject
+{
+
+ /** . */
+ final Map<String, PortletContainer> containers = new HashMap<String, PortletContainer>();
+
+ /** . */
+ final Map<String, PortletFilter> filters = new HashMap<String, PortletFilter>();
+
+ /** . */
+ PortletApplicationContext context;
+
+ public PortletApplicationObjectSupport(String id)
+ {
+ super(id);
+ }
+
+ public void setContext(PortletApplicationContext context)
+ {
+ this.context = context;
+ }
+
+ public PortletApplicationContext getContext()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addContainer(PortletContainer container)
+ {
+ if (container == null)
+ {
+ throw new AssertionError();
+ }
+ if (containers.containsKey(container.getId()))
+ {
+ throw new AssertionError();
+ }
+ containers.put(container.getId(), container);
+ }
+
+ public void removeContainer(PortletContainer container)
+ {
+ if (container == null)
+ {
+ throw new AssertionError();
+ }
+ if (!containers.containsKey(container.getId()))
+ {
+ throw new AssertionError();
+ }
+ containers.remove(container.getId());
+ }
+
+ public void addFilter(PortletFilter filter)
+ {
+ if (filter == null)
+ {
+ throw new AssertionError();
+ }
+ if (filters.containsKey(filter.getId()))
+ {
+ throw new AssertionError();
+ }
+ filters.put(filter.getId(), filter);
+ }
+
+ public void removeFilter(PortletFilter filter)
+ {
+ if (filter == null)
+ {
+ throw new AssertionError();
+ }
+ if (!filters.containsKey(filter.getId()))
+ {
+ throw new AssertionError();
+ }
+ filters.remove(filter.getId());
+ }
+
+ public Collection<? extends PortletContainer> getPortletContainers()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public PortletContainer getPortletContainer(String containerId)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletContainerContextSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletContainerContextSupport.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletContainerContextSupport.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletContainerContextSupport implements PortletContainerContext
+{
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletContainerObjectSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletContainerObjectSupport.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletContainerObjectSupport.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container;
+
+import org.jboss.portal.portlet.container.object.PortletContainerObject;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.common.invocation.InvocationException;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletContainerObjectSupport extends ObjectSupport implements PortletContainerObject
+{
+
+ /** . */
+ final Map<String, PortletFilter> filters = new HashMap<String, PortletFilter>();
+
+ /** . */
+ PortletApplication application;
+
+ /** . */
+ PortletContainerContext context;
+
+ public PortletContainerObjectSupport(String id)
+ {
+ super(id);
+ }
+
+ public void setApplication(PortletApplication application)
+ {
+ this.application = application;
+ }
+
+ public void setContext(PortletContainerContext context)
+ {
+ this.context = context;
+ }
+
+ public void addFilter(PortletFilter filter)
+ {
+ if (filter == null)
+ {
+ throw new AssertionError();
+ }
+ if (filters.containsKey(filter.getId()))
+ {
+ throw new AssertionError();
+ }
+ filters.put(filter.getId(), filter);
+ }
+
+ public void removeFilter(PortletFilter filter)
+ {
+ if (filter == null)
+ {
+ throw new AssertionError();
+ }
+ if (!filters.containsKey(filter.getId()))
+ {
+ throw new AssertionError();
+ }
+ filters.remove(filter.getId());
+ }
+
+ public PortletInfo getInfo()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public PortletInvocationResponse dispatch(PortletInvocation invocation) throws PortletInvokerException, InvocationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public PortletApplication getApplication()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public PortletContainerContext getContext()
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletFilterContextSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletFilterContextSupport.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletFilterContextSupport.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletFilterContextSupport implements PortletFilterContext
+{
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletFilterObjectSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletFilterObjectSupport.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/container/PortletFilterObjectSupport.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container;
+
+import org.jboss.portal.portlet.container.object.PortletFilterObject;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletFilterObjectSupport extends ObjectSupport implements PortletFilterObject
+{
+
+ /** . */
+ PortletApplication application;
+
+ /** . */
+ PortletFilterContext context;
+
+ public PortletFilterObjectSupport(String id)
+ {
+ super(id);
+ }
+
+ public void setApplication(PortletApplication application)
+ {
+ this.application = application;
+ }
+
+ public void setContext(PortletFilterContext context)
+ {
+ this.context = context;
+ }
+}
Modified: modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml 2008-02-21 22:21:37 UTC (rev 10069)
@@ -4,6 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
<pojo>
+<!--
<test>
<class name="org.jboss.portal.test.portlet.state.LocalStoreProducerStatefulPortletInvokerTestCase"/>
</test>
@@ -37,5 +38,9 @@
<test>
<class name="org.jboss.portal.test.portlet.StateStringTestCase"/>
</test>
+-->
+ <test>
+ <class name="org.jboss.portal.portlet.container.LifeCycle1Test"/>
+ </test>
</pojo>
</jboss-unit>
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/portal/samples/basic/FailDuringInitPortlet.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/portal/samples/basic/FailDuringInitPortlet.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/portal/samples/basic/FailDuringInitPortlet.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.portal.samples.basic;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+
+/**
+ * A portlet that will fail only one time during startup (so it is possible to restart it).
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class FailDuringInitPortlet extends GenericPortlet
+{
+
+ private static int initCount = 0;
+
+ public void init() throws PortletException
+ {
+ if (initCount == 0)
+ {
+ initCount = 1;
+
+ //
+ throw new PortletException();
+ }
+ else
+ {
+ // Nothing
+ }
+ }
+}
Deleted: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelObject.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelObject.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelObject.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -1,125 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.test;
-
-import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.portal.portlet.container.managed.ManagedObject;
-import org.jboss.portal.portlet.container.managed.ManagedObjectStatus;
-
-import java.lang.reflect.UndeclaredThrowableException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class KernelObject implements ManagedObject, KernelControllerContextAware
-{
-
- /** . */
- private KernelControllerContext controllerContext;
-
- public final void setKernelControllerContext(KernelControllerContext controllerContext) throws Exception
- {
- this.controllerContext = controllerContext;
- }
-
- public final void unsetKernelControllerContext(KernelControllerContext controllerContext) throws Exception
- {
- this.controllerContext = null;
- }
-
- public final ManagedObjectStatus getStatus()
- {
- ControllerState state = controllerContext.getState();
-
- //
- if (state == ControllerState.INSTALLED)
- {
- return ManagedObjectStatus.STARTED;
- }
- else if (state == ControllerState.ERROR)
- {
- return ManagedObjectStatus.FAILED;
- }
- else
- {
- return ManagedObjectStatus.STOPPED;
- }
- }
-
- public final void managedStart() throws Exception
- {
- controllerStart();
- }
-
- public final void managedStop()
- {
- controllerStop();
- }
-
- protected final void controllerStart() throws Exception
- {
- if (controllerContext == null)
- {
- throw new IllegalStateException("No under the controller of the kernel");
- }
-
- //
- try
- {
- controllerContext.getController().change(controllerContext, ControllerState.INSTALLED);
- }
- catch (Throwable throwable)
- {
- if (throwable instanceof Exception)
- {
- throw ((Exception)throwable);
- }
- if (throwable instanceof Error)
- {
- throw ((Error)throwable);
- }
- throw new UndeclaredThrowableException(throwable);
- }
- }
-
- protected final void controllerStop()
- {
- if (controllerContext == null)
- {
- throw new IllegalStateException("No under the controller of the kernel");
- }
-
- //
- try
- {
- controllerContext.getController().change(controllerContext, ControllerState.CREATE);
- }
- catch (Throwable throwable)
- {
- throwable.printStackTrace();
- }
- }
-}
Deleted: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletApplication.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletApplication.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletApplication.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -1,165 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.test;
-
-import org.jboss.portal.portlet.container.PortletApplicationContext;
-import org.jboss.portal.portlet.container.PortletApplication;
-import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.portlet.container.object.PortletApplicationObject;
-import org.jboss.portal.portlet.container.managed.ManagedPortletApplication;
-import org.jboss.portal.portlet.container.managed.ManagedPortletContainer;
-import org.jboss.portal.portlet.impl.info.ContainerPortletApplicationInfo;
-import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
-import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
-import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
-import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
-import org.jboss.portal.web.WebApp;
-
-import javax.servlet.ServletContext;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collection;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class KernelPortletApplication extends KernelObject implements PortletApplicationContext, ManagedPortletApplication, PortletApplication
-{
-
- /** . */
- private final WebApp webApp;
-
- /** . */
- final PortletApplicationObject portletApplication;
-
- /** . */
- private final Map<String, KernelPortletContainer> kernelPortletContainers;
-
- public KernelPortletApplication(
- ContainerPortletApplicationInfo info,
- PortletApplication10MetaData metaData,
- JBossApplicationMetaData jbossMetaData,
- PortletAPIFactory portletAPIFactory,
- WebApp webApp)
- {
- this.webApp = webApp;
- this.portletApplication = new PortletApplicationImpl(info, metaData, jbossMetaData, portletAPIFactory);
- this.kernelPortletContainers = new HashMap<String, KernelPortletContainer>();
-
- //
- portletApplication.setContext(this);
- }
-
- public void addKernelPortletContainer(KernelPortletContainer kernelPortletContainer)
- {
- kernelPortletContainers.put(kernelPortletContainer.getPortletContainer().getId(), kernelPortletContainer);
-
- //
- portletApplication.addContainer(kernelPortletContainer.portletContainer);
- }
-
- public void removeKernelPortletContainer(KernelPortletContainer kernelPortletContainer)
- {
- portletApplication.removeContainer(kernelPortletContainer.portletContainer);
-
- //
- kernelPortletContainers.remove(kernelPortletContainer.getPortletContainer().getId());
- }
-
- public PortletApplication getPortletApplication()
- {
- return portletApplication;
- }
-
- public void start() throws Exception
- {
- portletApplication.start();
- }
-
- public void stop()
- {
- portletApplication.stop();
- }
-
- // PortletApplicationContext ****************************************************************************************
-
- public ServletContext getServletContext()
- {
- return webApp.getServletContext();
- }
-
- public String getContextPath()
- {
- return webApp.getContextPath();
- }
-
- public ClassLoader getClassLoader()
- {
- return webApp.getClassLoader();
- }
-
- public void invokeStart() throws Exception
- {
- controllerStart();
- }
-
- public void invokeStop()
- {
- controllerStop();
- }
-
- //
-
- public String getId()
- {
- return portletApplication.getId();
- }
-
- public Collection<? extends ManagedPortletContainer> getManagedPortletContainers()
- {
- return kernelPortletContainers.values();
- }
-
- public ManagedPortletContainer getManagedPortletContainer(String portletContainerId)
- {
- return kernelPortletContainers.get(portletContainerId);
- }
-
- // PortletApplication ***********************************************************************************************
-
- public Collection<? extends PortletContainer> getPortletContainers()
- {
- return kernelPortletContainers.values();
- }
-
- public PortletContainer getPortletContainer(String containerId)
- {
- return kernelPortletContainers.get(containerId);
- }
-
- public PortletApplicationContext getContext()
- {
- return this;
- }
-}
Deleted: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletContainer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletContainer.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletContainer.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -1,142 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.test;
-
-import org.jboss.portal.portlet.container.PortletContainerContext;
-import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.portlet.container.PortletApplication;
-import org.jboss.portal.portlet.container.object.PortletContainerObject;
-import org.jboss.portal.portlet.container.managed.ManagedPortletContainer;
-import org.jboss.portal.portlet.container.managed.ManagedPortletApplication;
-import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
-import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
-import org.jboss.portal.common.invocation.InvocationException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class KernelPortletContainer extends KernelObject implements PortletContainerContext, ManagedPortletContainer, PortletContainer
-{
-
- /** . */
- final PortletContainerObject portletContainer;
-
- /** . */
- private KernelPortletApplication kernelPortletApplication;
-
- public KernelPortletContainer(ContainerPortletInfo info)
- {
- portletContainer = new PortletContainerImpl(info);
-
- //
- portletContainer.setContext(this);
- }
-
- public KernelPortletApplication getKernelPortletApplication()
- {
- return kernelPortletApplication;
- }
-
- public void setKernelPortletApplication(KernelPortletApplication kernelPortletApplication)
- {
- this.kernelPortletApplication = kernelPortletApplication;
-
- //
- if (kernelPortletApplication != null)
- {
- portletContainer.setApplication(kernelPortletApplication.portletApplication);
- }
- else
- {
- portletContainer.setApplication(null);
- }
- }
-
- public PortletContainer getPortletContainer()
- {
- return portletContainer;
- }
-
- public void start() throws Exception
- {
- portletContainer.start();
- }
-
- public void stop()
- {
- portletContainer.stop();
- }
-
- //
-
- public void invokeStart() throws Exception
- {
- controllerStart();
- }
-
- public void invokeStop()
- {
- controllerStop();
- }
-
- //
-
- public String getId()
- {
- return portletContainer.getId();
- }
-
- //
-
- public ManagedPortletApplication getManagedPortletApplication()
- {
- return kernelPortletApplication;
- }
-
- public PortletInfo getInfo()
- {
- return portletContainer.getInfo();
- }
-
- // PortletContainer implementation **********************************************************************************
-
- public PortletInvocationResponse dispatch(PortletInvocation invocation) throws PortletInvokerException, InvocationException
- {
- return portletContainer.dispatch(invocation);
- }
-
- public PortletApplication getApplication()
- {
- return kernelPortletApplication;
- }
-
- public PortletContainerContext getContext()
- {
- return this;
- }
-}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationContextImpl.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationContextImpl.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test;
+
+import org.jboss.portal.portlet.container.PortletApplicationContext;
+import org.jboss.portal.web.WebApp;
+
+import javax.servlet.ServletContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletApplicationContextImpl implements PortletApplicationContext
+{
+
+ /** . */
+ private final WebApp webApp;
+
+ public PortletApplicationContextImpl(WebApp webApp)
+ {
+ this.webApp = webApp;
+ }
+
+ public ServletContext getServletContext()
+ {
+ return webApp.getServletContext();
+ }
+
+ public String getContextPath()
+ {
+ return webApp.getContextPath();
+ }
+
+ public ClassLoader getClassLoader()
+ {
+ return webApp.getClassLoader();
+ }
+}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -23,15 +23,24 @@
package org.jboss.portal.portlet.test;
import org.apache.log4j.Logger;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.portlet.container.managed.PortletApplicationRegistry;
import org.jboss.portal.portlet.container.managed.ManagedPortletApplication;
+import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEventBroadcaster;
+import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEventListener;
+import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEvent;
+import org.jboss.portal.portlet.container.managed.ManagedObjectAddedEvent;
+import org.jboss.portal.portlet.container.managed.ManagedObjectEvent;
+import org.jboss.portal.portlet.container.managed.ManagedObject;
+import org.jboss.portal.portlet.container.managed.ManagedObjectLifeCycleEvent;
+import org.jboss.portal.portlet.container.managed.LifeCycleStatus;
+import org.jboss.portal.portlet.container.PortletContainerInvoker;
+import org.jboss.portal.portlet.container.PortletContainer;
import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
import static org.jboss.portal.portlet.impl.metadata.PortletMetaDataConstants.PORTLET_JSR_168_NS;
import static org.jboss.portal.portlet.impl.metadata.PortletMetaDataConstants.PORTLET_JSR_286_NS;
+import org.jboss.portal.portlet.impl.container.PortletApplicationLifeCycle;
+import org.jboss.portal.portlet.impl.container.PortletContainerLifeCycle;
import org.jboss.portal.portlet.test.metadata.factory.PortletApplicationModelFactory;
import org.jboss.portal.portlet.test.metadata.impl.AnnotationPortletApplication10MetaData;
import org.jboss.portal.portlet.test.metadata.impl.AnnotationPortletApplication20MetaData;
@@ -58,7 +67,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class PortletApplicationDeployer implements WebAppListener, KernelControllerContextAware, PortletApplicationRegistry
+public class PortletApplicationDeployer implements WebAppListener, PortletApplicationRegistry
{
static
@@ -90,17 +99,20 @@
private ServletContainer servletContainer;
/** . */
- private KernelControllerContext controllerContext;
-
- /** . */
private Map<String, PortletApplicationDeployment> deploymentMap = new HashMap<String, PortletApplicationDeployment>();
/** . */
private ClassLoader classLoader;
/** . */
- private final Map<String, KernelPortletApplication> applications = new HashMap<String, KernelPortletApplication>();
+ private final Map<String, PortletApplicationLifeCycle> applications = new HashMap<String, PortletApplicationLifeCycle>();
+ /** . */
+ private PortletContainerInvoker portletContainerInvoker;
+
+ /** . */
+ private ManagedObjectRegistryEventBroadcaster broadcaster;
+
public PortletApplicationRegistry getRegistry()
{
return registry;
@@ -121,6 +133,16 @@
this.servletContainer = servletContainer;
}
+ public PortletContainerInvoker getPortletContainerInvoker()
+ {
+ return portletContainerInvoker;
+ }
+
+ public void setPortletContainerInvoker(PortletContainerInvoker portletContainerInvoker)
+ {
+ this.portletContainerInvoker = portletContainerInvoker;
+ }
+
public void onEvent(WebAppEvent event)
{
if (event instanceof WebAppLifeCycleEvent)
@@ -160,10 +182,13 @@
try
{
Thread.currentThread().setContextClassLoader(classLoader);
- Kernel kernel = controllerContext.getKernel();
- PortletApplicationDeployment deployment = new PortletApplicationDeployment(kernel, webApp, metaData);
+ PortletApplicationDeployment deployment = new PortletApplicationDeployment(broadcaster, webApp, metaData);
deploymentMap.put(webApp.getContextPath(), deployment);
deployment.install();
+
+ //
+ PortletApplicationLifeCycle portletApplicationLifeCycle = deployment.getPortletApplicationLifeCycle();
+ applications.put(portletApplicationLifeCycle.getId(), portletApplicationLifeCycle);
}
finally
{
@@ -177,6 +202,10 @@
PortletApplicationDeployment deployment = deploymentMap.remove(webApp.getContextPath());
if (deployment != null)
{
+ PortletApplicationLifeCycle portletApplicationLifeCycle = deployment.getPortletApplicationLifeCycle();
+ applications.remove(portletApplicationLifeCycle.getId());
+
+ //
ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
try
{
@@ -190,36 +219,25 @@
}
}
- public void setKernelControllerContext(KernelControllerContext controllerContext) throws Exception
- {
- log.debug("Set controller context " + controllerContext);
-
- //
- this.controllerContext = controllerContext;
- }
-
- public void unsetKernelControllerContext(KernelControllerContext controllerContext) throws Exception
- {
- log.debug("Unset controller context " + controllerContext);
-
- //
- this.controllerContext = null;
- }
-
public void start()
{
+ broadcaster = new ManagedObjectRegistryEventBroadcaster();
classLoader = Thread.currentThread().getContextClassLoader();
//
+ broadcaster.addListener(bridgeToInvoker);
servletContainer.addWebAppListener(this);
}
public void stop()
{
+ // This should generate remove web app event and in cascade clear the registry
+ // as well as the portlet container invoker
servletContainer.removeWebAppListener(this);
//
classLoader = null;
+ broadcaster = null;
}
private PortletApplication10MetaData buildPortletApplicationMetaData(WebApp webApp)
@@ -267,53 +285,64 @@
return null;
}
- /**
- * Called by MC to install application.
- *
- * @param kernelPortletApplication kernel portlet application
- */
- public void addKernelPortletApplication(KernelPortletApplication kernelPortletApplication)
+ public Collection<? extends ManagedPortletApplication> getManagedPortletApplications()
{
- applications.put(kernelPortletApplication.getId(), kernelPortletApplication);
+ return applications.values();
}
- /**
- * Called by MC to uninstall application.
- *
- * @param kernelPortletApplication kernel portlet application
- */
- public void removeKernelPortletApplication(KernelPortletApplication kernelPortletApplication)
+ public ManagedPortletApplication getManagedPortletApplication(String id)
{
- applications.remove(kernelPortletApplication.getId());
+ return applications.get(id);
}
- /**
- * Called by MC to install application.
- *
- * @param kernelPortletContainer kernel portlet container
- */
- public void addKernelPortletContainer(KernelPortletContainer kernelPortletContainer)
+ public void addListener(ManagedObjectRegistryEventListener listener)
{
- // To be used for life cycle events
+ broadcaster.addListener(listener);
}
- /**
- * Called by MC to uninstall application.
- *
- * @param kernelPortletContainer kernel portlet container
- */
- public void removeKernelPortletContainer(KernelPortletContainer kernelPortletContainer)
+ public void removeListener(ManagedObjectRegistryEventListener listener)
{
- // To be used for life cycle events
+ broadcaster.addListener(listener);
}
- public Collection<? extends ManagedPortletApplication> getManagedPortletApplications()
+ /**
+ * Bridge managed object event to add/remove portlet container in portlet container invoker.
+ */
+ private final ManagedObjectRegistryEventListener bridgeToInvoker = new ManagedObjectRegistryEventListener()
{
- return applications.values();
- }
+ public void onEvent(ManagedObjectRegistryEvent event)
+ {
+ if (event instanceof ManagedObjectEvent)
+ {
+ ManagedObjectEvent managedObjectEvent = (ManagedObjectEvent)event;
+ ManagedObject managedObject = managedObjectEvent.getManagedObject();
- public ManagedPortletApplication getManagedPortletApplication(String id)
- {
- return applications.get(id);
- }
+ //
+ if (managedObject instanceof PortletContainerLifeCycle)
+ {
+ PortletContainerLifeCycle portletContainerLifeCycle = (PortletContainerLifeCycle)managedObject;
+ PortletContainer portletContainer = portletContainerLifeCycle.getPortletContainer();
+
+ //
+ if (managedObjectEvent instanceof ManagedObjectLifeCycleEvent)
+ {
+ ManagedObjectLifeCycleEvent lifeCycleEvent = (ManagedObjectLifeCycleEvent)managedObjectEvent;
+
+ //
+ LifeCycleStatus status = lifeCycleEvent.getStatus();
+
+ //
+ if (status == LifeCycleStatus.STARTED)
+ {
+ portletContainerInvoker.addPortletContainer(portletContainer);
+ }
+ else
+ {
+ portletContainerInvoker.removePortletContainer(portletContainer);
+ }
+ }
+ }
+ }
+ }
+ };
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -23,38 +23,29 @@
package org.jboss.portal.portlet.test;
import org.apache.log4j.Logger;
-import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
-import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
-import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
-import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
-import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
-import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
-import org.jboss.beans.metadata.plugins.AbstractInstallMetaData;
-import org.jboss.beans.metadata.plugins.ThisValueMetaData;
-import org.jboss.beans.metadata.spi.ParameterMetaData;
-import org.jboss.beans.metadata.spi.PropertyMetaData;
-import org.jboss.beans.metadata.spi.InstallMetaData;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.portal.common.util.Tools;
import org.jboss.portal.portlet.impl.info.ContainerInfoBuilder;
import org.jboss.portal.portlet.impl.info.ContainerInfoBuilderContext;
-import org.jboss.portal.portlet.impl.info.ContainerPortletApplicationInfo;
import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.info.ContainerFilterInfo;
import org.jboss.portal.portlet.impl.jsr168.ContainerInfoBuilderContextImpl;
-import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
+import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
+import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
+import org.jboss.portal.portlet.impl.jsr168.PortletFilterImpl;
+import org.jboss.portal.portlet.impl.jsr168.PortletAPIFactoryImpl;
import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
+import org.jboss.portal.portlet.impl.container.PortletApplicationLifeCycle;
+import org.jboss.portal.portlet.impl.container.PortletFilterLifeCycle;
+import org.jboss.portal.portlet.impl.container.PortletContainerLifeCycle;
+import org.jboss.portal.portlet.container.object.PortletApplicationObject;
+import org.jboss.portal.portlet.container.object.PortletContainerObject;
+import org.jboss.portal.portlet.container.object.PortletFilterObject;
+import org.jboss.portal.portlet.container.PortletApplicationContext;
+import org.jboss.portal.portlet.container.PortletContainerContext;
+import org.jboss.portal.portlet.container.PortletFilterContext;
+import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEventListener;
import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
import org.jboss.portal.web.WebApp;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.HashSet;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -66,172 +57,99 @@
private final Logger log;
/** . */
- private final Kernel kernel;
-
- /** . */
private final WebApp webApp;
/** . */
private final PortletApplication10MetaData metaData;
/** . */
- private final LinkedHashMap<String, KernelControllerContext> installed;
+ private final ManagedObjectRegistryEventListener listener;
- public PortletApplicationDeployment(Kernel kernel, WebApp webApp, PortletApplication10MetaData metaData)
+ /** . */
+ private PortletApplicationLifeCycle portletApplicationLifeCycle;
+
+ public PortletApplicationDeployment(
+ ManagedObjectRegistryEventListener listener,
+ WebApp webApp,
+ PortletApplication10MetaData metaData)
{
- this.kernel = kernel;
+ this.listener = listener;
this.webApp = webApp;
this.metaData = metaData;
this.log = Logger.getLogger(PortletApplicationDeployment.class + "." + webApp.getContextPath().replace('.', '_'));
- this.installed = new LinkedHashMap<String, KernelControllerContext>();
}
- public AbstractBeanMetaData createKernelPortletContainerMetaData(String kernelPortletContainerId, ContainerPortletInfo portletInfo)
+ public PortletApplicationLifeCycle getPortletApplicationLifeCycle()
{
- AbstractBeanMetaData beanMD = new AbstractBeanMetaData(kernelPortletContainerId, KernelPortletContainer.class.getName());
-
- //
- AbstractConstructorMetaData ctorMD = new AbstractConstructorMetaData();
- ctorMD.setParameters(Tools.toList((ParameterMetaData)new AbstractParameterMetaData(ContainerPortletInfo.class.getName(), portletInfo)));
- beanMD.setConstructor(ctorMD);
-
- //
- beanMD.setProperties(new HashSet<PropertyMetaData>());
- beanMD.setInstalls(new ArrayList<InstallMetaData>());
- beanMD.setUninstalls(new ArrayList<InstallMetaData>());
-
- //
- beanMD.setStart(new AbstractLifecycleMetaData("start"));
- beanMD.setStop(new AbstractLifecycleMetaData("stop"));
-
- //
- return beanMD;
+ return portletApplicationLifeCycle;
}
- public AbstractBeanMetaData createKernelPortletApplicationMetaData(ContainerPortletApplicationInfo portletApplicationInfo, String kernelPortletApplicationId)
- {
- AbstractBeanMetaData beanMD = new AbstractBeanMetaData(kernelPortletApplicationId, KernelPortletApplication.class.getName());
-
- //
- AbstractConstructorMetaData ctorMD = new AbstractConstructorMetaData();
- ctorMD.setParameters(Tools.toList(
- (ParameterMetaData)new AbstractParameterMetaData(ContainerPortletApplicationInfo.class.getName(), portletApplicationInfo),
- new AbstractParameterMetaData(PortletApplication10MetaData.class.getName(), metaData),
- new AbstractParameterMetaData(JBossApplicationMetaData.class.getName(), (Object)null),
- new AbstractParameterMetaData(PortletAPIFactory.class.getName(), new AbstractDependencyValueMetaData("PortletAPIFactory")),
- new AbstractParameterMetaData(WebApp.class.getName(), webApp)));
- beanMD.setConstructor(ctorMD);
-
- //
- beanMD.setProperties(new HashSet<PropertyMetaData>());
- beanMD.setInstalls(new ArrayList<InstallMetaData>());
- beanMD.setUninstalls(new ArrayList<InstallMetaData>());
-
- //
- beanMD.setStart(new AbstractLifecycleMetaData("start"));
- beanMD.setStop(new AbstractLifecycleMetaData("stop"));
-
- //
- return beanMD;
- }
-
void install()
{
log.debug("Starting installation");
//
- KernelController controller = kernel.getController();
-
- //
- String kernelPortletApplicationId = "PortletApplication[" + webApp.getContextPath() + "]";
-
- //
ContainerInfoBuilderContext builderContext = new ContainerInfoBuilderContextImpl(metaData, webApp);
ContainerInfoBuilder builder = new ContainerInfoBuilder(metaData, builderContext);
builder.build();
//
- List<AbstractBeanMetaData> toInstall = new ArrayList<AbstractBeanMetaData>();
+ PortletApplicationObject portletApplicationObject = new PortletApplicationImpl(
+ builder.getApplication(), metaData, new JBossApplicationMetaData(), new PortletAPIFactoryImpl());
+ PortletApplicationContext portletApplicationContext = new PortletApplicationContextImpl(webApp);
- //
- AbstractBeanMetaData kernelPortletApplicationMD = createKernelPortletApplicationMetaData(builder.getApplication(), kernelPortletApplicationId);
//
- toInstall.add(kernelPortletApplicationMD);
+ portletApplicationLifeCycle = new PortletApplicationLifeCycle(
+ listener,
+ portletApplicationContext,
+ portletApplicationObject);
//
- for (ContainerPortletInfo containerInfo : builder.getPortlets())
+ for (ContainerFilterInfo filterInfo : builder.getApplication().getFilters().values())
{
- //
- String kernelPortletContainerId = "PortletContainer[" + webApp.getContextPath() + "," + containerInfo.getName() + "]";
+ PortletFilterObject portletFilterObject = new PortletFilterImpl(filterInfo);
+ PortletFilterContext portletFilterContext = new PortletFilterContextImpl();
//
- AbstractBeanMetaData kernelPortletContainerMD = createKernelPortletContainerMetaData(kernelPortletContainerId, containerInfo);
-
- // Inject the kernel portlet application in the kernel portlet container
- AbstractDependencyValueMetaData kernelPortletApplicationDependencyMD = new AbstractDependencyValueMetaData(kernelPortletApplicationId);
-// kernelPortletApplicationDependencyMD.setDependentState(ControllerState.START);
- kernelPortletContainerMD.getProperties().add(new AbstractPropertyMetaData("kernelPortletApplication", kernelPortletApplicationDependencyMD));
-
- // Install the kernel portlet container on the kernel portlet application
- AbstractInstallMetaData installKernelPortletContainerMD = new AbstractInstallMetaData();
- installKernelPortletContainerMD.setBean(kernelPortletApplicationId);
- installKernelPortletContainerMD.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
- installKernelPortletContainerMD.setMethodName("addKernelPortletContainer");
-// installKernelPortletContainerMD.setState(ControllerState.st);
- kernelPortletContainerMD.getInstalls().add(installKernelPortletContainerMD);
-
- // Uninstall the kernel portlet container from the kernel portlet application
- AbstractInstallMetaData uninstallKernelPortletContainerMD = new AbstractInstallMetaData();
- uninstallKernelPortletContainerMD.setBean(kernelPortletApplicationId);
- uninstallKernelPortletContainerMD.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
- uninstallKernelPortletContainerMD.setMethodName("removeKernelPortletContainer");
-// uninstallKernelPortletContainerMD.setState(ControllerState.INSTANTIATED);
- kernelPortletContainerMD.getUninstalls().add(uninstallKernelPortletContainerMD);
-
- //
- toInstall.add(kernelPortletContainerMD);
+ portletApplicationLifeCycle.addPortletFilter(portletFilterContext, portletFilterObject);
}
- // Install beans
- for (AbstractBeanMetaData beanMetaData : toInstall)
+ //
+ for (ContainerPortletInfo containerInfo : builder.getPortlets())
{
- String beanName = beanMetaData.getName();
- try
+ PortletContainerObject portletContainerObject = new PortletContainerImpl(containerInfo);
+ PortletContainerContext portletContainerContext = new PortletContainerContextImpl();
+
+ //
+ PortletContainerLifeCycle portletContainerLifeCycle = portletApplicationLifeCycle.addPortletContainer(portletContainerContext, portletContainerObject);
+
+ // Now create deps
+ for (String filterRef : containerInfo.getFilterRefs())
{
-// beanMetaData.setMode(ControllerMode.MANUAL);
+ PortletFilterLifeCycle portletFilterLifeCycle = (PortletFilterLifeCycle)portletApplicationLifeCycle.getManagedPortletFilter(filterRef);
//
- log.debug("Installing bean " + beanName);
- KernelControllerContext kcc = controller.install(beanMetaData);
-
- //
- installed.put(beanName, kcc);
- log.debug("Installed bean " + beanName);
-
- //
- logBeanFailure(kcc);
+ if (portletFilterLifeCycle != null)
+ {
+ portletApplicationLifeCycle.addDependency(portletFilterLifeCycle, portletContainerLifeCycle);
+ }
+ else
+ {
+ // todo
+ }
}
- catch (Throwable throwable)
- {
- log.debug("Installation of bean " + beanName + " produced an error", throwable);
- }
}
- // Print bean names
- for (KernelControllerContext kcc : installed.values())
- {
+ //
+ portletApplicationLifeCycle.create();
- if (kcc.getState() == ControllerState.ERROR)
- {
- log.error("Bean " + kcc.getName() + " threw an error during start", kcc.getError());
- }
- else
- {
- log.debug("Bean " + kcc.getName() + " was installed with state" + kcc.getState());
- }
- }
+ //
+ portletApplicationLifeCycle.managedStart();
+
+ //
+
}
void uninstall()
@@ -239,37 +157,9 @@
log.debug("Uninstalling");
//
- KernelController controller = kernel.getController();
+ portletApplicationLifeCycle.managedStop();
//
- List<String> beanNames = new ArrayList<String>(installed.keySet());
- Collections.reverse(beanNames);
- for (String beanName : beanNames)
- {
- try
- {
- log.debug("Uninstalling bean " + beanName);
- controller.uninstall(beanName);
- log.debug("Uninstalled bean " + beanName);
- }
- catch (Throwable t)
- {
- // MC throws Error .... need to catch them here
-
- log.error("Bean " + beanName + " undeployment threw something", t);
- }
- }
-
- //
log.debug("Uninstalled");
}
-
- private void logBeanFailure(KernelControllerContext context)
- {
- Throwable t = context.getError();
- if (t != null)
- {
- log.debug("Installation of bean " + context.getName() + " produced an error", t);
- }
- }
}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletContainerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletContainerContextImpl.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletContainerContextImpl.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test;
+
+import org.jboss.portal.portlet.container.PortletContainerContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletContainerContextImpl implements PortletContainerContext
+{
+}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletFilterContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletFilterContextImpl.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletFilterContextImpl.java 2008-02-21 22:21:37 UTC (rev 10069)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test;
+
+import org.jboss.portal.portlet.container.PortletFilterContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletFilterContextImpl implements PortletFilterContext
+{
+}
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-02-21 22:21:37 UTC (rev 10069)
@@ -661,7 +661,7 @@
<taskdef name="jboss-unit" classname="org.jboss.unit.tooling.ant.JBossUnitTask" classpath="${plugin_classpath}"/>
- <jboss-unit jpda="false" jpdaPort="9000" jpdaSuspend="true" failOnError="false">
+ <jboss-unit jpda="true" jpdaPort="9000" jpdaSuspend="true" failOnError="false">
<tests config="${target}/test-classes/test/remote-jboss-unit.xml">
<property name="archivePath" value="${test.temp.lib}"/>
Modified: modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml 2008-02-21 22:21:37 UTC (rev 10069)
@@ -37,10 +37,7 @@
<bean name="PortletApplicationDeployer" class="org.jboss.portal.portlet.test.TestPortletApplicationDeployer">
<property name="servletContainer"><inject bean="ServletContainer"/></property>
<property name="driver"><inject bean="TestDriverServer"/></property>
- <incallback method="addKernelPortletApplication"/>
- <uncallback method="removeKernelPortletApplication"/>
- <incallback method="addKernelPortletContainer"/>
- <uncallback method="removeKernelPortletContainer"/>
+ <property name="portletContainerInvoker"><inject bean="PortletContainerInvoker"/></property>
</bean>
<bean name="PortletAPIFactory" class="org.jboss.portal.portlet.impl.jsr168.PortletAPIFactoryImpl"/>
@@ -98,8 +95,6 @@
<!-- The portlet container invoker -->
<bean name="PortletContainerInvoker" class="org.jboss.portal.portlet.container.PortletContainerInvoker">
<property name="stackFactory"><inject bean="ContainerStackFactory"/></property>
- <incallback method="addPortletContainer"/>
- <uncallback method="removePortletContainer"/>
</bean>
<!-- The producer persistence manager -->
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml 2008-02-21 12:49:52 UTC (rev 10068)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml 2008-02-21 22:21:37 UTC (rev 10069)
@@ -25,10 +25,7 @@
<bean name="PortletApplicationDeployer" class="org.jboss.portal.portlet.test.PortletApplicationDeployer">
<property name="servletContainer"><inject bean="ServletContainer"/></property>
- <incallback method="addKernelPortletApplication"/>
- <uncallback method="removeKernelPortletApplication"/>
- <incallback method="addKernelPortletContainer"/>
- <uncallback method="removeKernelPortletContainer"/>
+ <property name="portletContainerInvoker"><inject bean="PortletContainerInvoker"/></property>
</bean>
<bean name="PortletAPIFactory" class="org.jboss.portal.portlet.impl.jsr168.PortletAPIFactoryImpl"/>
@@ -86,8 +83,6 @@
<!-- The portlet container invoker -->
<bean name="PortletContainerInvoker" class="org.jboss.portal.portlet.container.PortletContainerInvoker">
<property name="stackFactory"><inject bean="ContainerStackFactory"/></property>
- <incallback method="addPortletContainer"/>
- <uncallback method="removePortletContainer"/>
</bean>
<!-- The producer persistence manager -->
16 years, 7 months