Author: julien(a)jboss.com
Date: 2008-02-19 09:07:50 -0500 (Tue, 19 Feb 2008)
New Revision: 10030
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/
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
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/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/impl/jsr168/PortletApplicationImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
Log:
- move wiring / service concerns of application/containers to dedicated interfaces
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-19
13:23:47 UTC (rev 10029)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ValveInterceptor.java 2008-02-19
14:07:50 UTC (rev 10030)
@@ -22,12 +22,10 @@
******************************************************************************/
package org.jboss.portal.portlet.aspects.portlet;
-import org.jboss.portal.common.concurrent.Valve;
import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.portlet.container.PortletApplication;
-import org.jboss.portal.portlet.container.PortletApplicationContext;
import org.jboss.portal.portlet.container.PortletContainer;
import org.jboss.portal.portlet.container.PortletContainerInvoker;
+import org.jboss.portal.portlet.container.PortletContainerContext;
import org.jboss.portal.portlet.invocation.PortletInterceptor;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
@@ -45,47 +43,27 @@
*/
public class ValveInterceptor extends PortletInterceptor
{
+
protected Object invoke(PortletInvocation invocation) throws Exception,
InvocationException
{
-/*
- PortletContainer container =
(PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
PortletContainerInvoker.PORTLET_CONTAINER);
- Valve valve = container.getValve();
+ PortletInvocationResponse response =
(PortletInvocationResponse)invocation.invokeNext();
- // Try to aquire the valve
- if (valve.beforeInvocation())
+ // Stop the container if necessary
+ if (response instanceof UnavailableResponse)
{
- PortletInvocationResponse response = null;
+ // This call will wait until all the current threads have exited the component
valve.
+ // Perhaps this should be done asynchronously as it may lead to a long delay ?
+ // It could be made parametrizable too, so the deployer can choose what mode is
preferable
+ PortletContainer container =
(PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
PortletContainerInvoker.PORTLET_CONTAINER);
- try
- {
- response = (PortletInvocationResponse)invocation.invokeNext();
- }
- finally
- {
- // Release the valve
- valve.afterInvocation();
- }
+ // Get the context
+ PortletContainerContext context = container.getContext();
- // Stop the container if necessary
- if (response instanceof UnavailableResponse)
- {
- // This call will wait until all the current threads have exited the
component valve.
- // Perhaps this should be done asynchronously as it may lead to a long delay
?
- // It could be made parametrizable too, so the deployer can choose what mode
is preferable
- PortletApplication application = container.getApplication();
- PortletApplicationContext applicationContext = application.getContext();
- applicationContext.stopPortletContainer(container.getId());
- }
-
- //
- return response;
+ // Invoke stop
+ context.invokeStop();
}
- else
- {
- return new UnavailableResponse();
- }
-*/
- return invocation.invokeNext();
+ //
+ return response;
}
}
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-19
13:23:47 UTC (rev 10029)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletApplication.java 2008-02-19
14:07:50 UTC (rev 10030)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.container;
+import javax.servlet.ServletContext;
import java.util.Collection;
/**
@@ -40,34 +41,6 @@
String getId();
/**
- * Set the context required by that application.
- *
- * @param context the context
- */
- void setContext(PortletApplicationContext context);
-
- /**
- * Returns the context related to this application.
- *
- * @return the context
- */
- PortletApplicationContext getContext();
-
- /**
- * Wire a container.
- *
- * @param container the container
- */
- void addContainer(PortletContainer container);
-
- /**
- * Unwire a container.
- *
- * @param container the container
- */
- void removeContainer(PortletContainer container);
-
- /**
* Returns the set of related portlet containers.
*
* @return the portlet containers
@@ -82,15 +55,7 @@
*/
PortletContainer getPortletContainer(String containerId);
- /**
- * Starts the application only. It does not take care of starting its components.
- *
- * @throws Exception any exception preventing the start
- */
- void start() throws Exception;
+ PortletApplicationContext getContext();
- /**
- * Stops the application only. It does not take care of stopping its components.
- */
- void stop();
+
}
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-19
13:23:47 UTC (rev 10029)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainer.java 2008-02-19
14:07:50 UTC (rev 10030)
@@ -22,7 +22,6 @@
******************************************************************************/
package org.jboss.portal.portlet.container;
-import org.jboss.portal.common.concurrent.Valve;
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.PortletInfo;
@@ -51,27 +50,6 @@
PortletInfo getInfo();
/**
- * Wire the application.
- *
- * @param application the related application
- */
- void setApplication(PortletApplication application);
-
- /**
- * Returns the wired application.
- *
- * @return the application
- */
- PortletApplication getApplication();
-
- /**
- * Wire the portlet container context.
- *
- * @param context the context
- */
- void setContext(PortletContainerContext context);
-
- /**
* Invoke the portlet container.
*
* @param invocation the portlet invocation
@@ -82,14 +60,11 @@
PortletInvocationResponse dispatch(PortletInvocation invocation) throws
PortletInvokerException, InvocationException;
/**
- * Starts the portlet container.
+ * Returns the wired application.
*
- * @throws Exception any exception preventing the start
+ * @return the application
*/
- void start() throws Exception;
+ PortletApplication getApplication();
- /**
- * Stops the portlet container.
- */
- void stop();
+ 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-19
13:23:47 UTC (rev 10029)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainerInvoker.java 2008-02-19
14:07:50 UTC (rev 10030)
@@ -119,11 +119,11 @@
this.portlets = portlets;
}
- public synchronized void start() throws Exception
+ public void start() throws Exception
{
}
- public synchronized void stop() throws Exception
+ public void stop() throws Exception
{
}
Added:
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
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletApplicationObject.java 2008-02-19
14:07:50 UTC (rev 10030)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * 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.PortletApplicationContext;
+import org.jboss.portal.portlet.container.PortletContainer;
+import org.jboss.portal.portlet.container.PortletApplication;
+
+/**
+ * Contains life cycle and wiring details for the kernel environment.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface PortletApplicationObject extends PortletApplication
+{
+
+ /**
+ * Set the context required by that application.
+ *
+ * @param context the context
+ */
+ void setContext(PortletApplicationContext context);
+
+ /**
+ * Returns the context related to this application.
+ *
+ * @return the context
+ */
+ PortletApplicationContext getContext();
+
+ /**
+ * Wire a container.
+ *
+ * @param container the container
+ */
+ void addContainer(PortletContainer container);
+
+ /**
+ * Unwire a container.
+ *
+ * @param container the container
+ */
+ void removeContainer(PortletContainer container);
+
+ /**
+ * Starts the application only. It does not take care of starting its components.
+ *
+ * @throws Exception any exception preventing the start
+ */
+ void start() throws Exception;
+
+ /**
+ * Stops the application only. It does not take care of stopping its components.
+ */
+ void stop();
+}
Added:
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
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/object/PortletContainerObject.java 2008-02-19
14:07:50 UTC (rev 10030)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * 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.PortletContainerContext;
+import org.jboss.portal.portlet.container.PortletContainer;
+
+/**
+ * Contains life cycle and wiring details for the kernel environment.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface PortletContainerObject extends PortletContainer
+{
+
+ /**
+ * Wire the application.
+ *
+ * @param application the related application
+ */
+ void setApplication(PortletApplication application);
+
+ /**
+ * Wire the portlet container context.
+ *
+ * @param context the context
+ */
+ void setContext(PortletContainerContext context);
+
+ /**
+ * Starts the portlet container.
+ *
+ * @throws Exception any exception preventing the start
+ */
+ void start() throws Exception;
+
+ /**
+ * Stops the portlet container.
+ */
+ void stop();
+}
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-19
13:23:47 UTC (rev 10029)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-02-19
14:07:50 UTC (rev 10030)
@@ -35,6 +35,7 @@
import org.jboss.portal.portlet.container.PortletApplicationContext;
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;
@@ -59,7 +60,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 7226 $
*/
-public class PortletApplicationImpl implements PortletApplication
+public class PortletApplicationImpl implements PortletApplicationObject
{
private static final EnumMap<LifeCyclePhase, Class<? extends
PortletFilter>> phaseToType =
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-19
13:23:47 UTC (rev 10029)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-02-19
14:07:50 UTC (rev 10030)
@@ -28,9 +28,9 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor;
import org.jboss.portal.portlet.container.PortletApplication;
-import org.jboss.portal.portlet.container.PortletContainer;
import org.jboss.portal.portlet.container.PortletInitializationException;
import org.jboss.portal.portlet.container.PortletContainerContext;
+import org.jboss.portal.portlet.container.object.PortletContainerObject;
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.PortletConfigImpl;
@@ -91,7 +91,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 6365 $
*/
-public class PortletContainerImpl implements PortletContainer
+public class PortletContainerImpl implements PortletContainerObject
{
/** Logger. */
@@ -164,6 +164,11 @@
this.context = context;
}
+ public PortletContainerContext getContext()
+ {
+ return context;
+ }
+
public ContainerPortletInfo getInfo()
{
if (started)
@@ -428,6 +433,26 @@
public PortletInvocationResponse dispatch(PortletInvocation invocation) throws
PortletInvokerException, InvocationException
{
+ if (valve.beforeInvocation())
+ {
+ try
+ {
+ return invokeDispatch(invocation);
+ }
+ finally
+ {
+ // Release the valve
+ valve.afterInvocation();
+ }
+ }
+ else
+ {
+ return new UnavailableResponse();
+ }
+ }
+
+ private PortletInvocationResponse invokeDispatch(PortletInvocation invocation) throws
PortletInvokerException, InvocationException
+ {
HttpServletRequest dreq = invocation.getDispatchedRequest();
HttpServletResponse dresp = invocation.getDispatchedResponse();