Author: julien(a)jboss.com
Date: 2008-03-19 09:00:56 -0400 (Wed, 19 Mar 2008)
New Revision: 10332
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/ContainerPortletInvoker.java
Removed:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainerInvoker.java
Modified:
modules/portlet/trunk/bridge/src/main/java/org/jboss/portal/portlet/bridge/JBossServletContextProvider.java
modules/portlet/trunk/mc/src/main/java/org/jboss/portal/portlet/mc/PortletApplicationDeployer.java
modules/portlet/trunk/portal/src/main/resources/simple-portal-war/WEB-INF/jboss-beans.xml
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/EventPayloadInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/SecureTransportInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ValveInterceptor.java
modules/portlet/trunk/test/src/test/resources/portlet-tck-war/WEB-INF/jboss-beans.xml
modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml
Log:
JBPORTAL-1937 : Rename PortletContainerInvoker to ContainerPortletInvoker
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-03-19
12:46:15 UTC (rev 10331)
+++
modules/portlet/trunk/bridge/src/main/java/org/jboss/portal/portlet/bridge/JBossServletContextProvider.java 2008-03-19
13:00:56 UTC (rev 10332)
@@ -31,7 +31,7 @@
import org.apache.portals.bridges.common.ServletContextProvider;
import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.portlet.container.PortletContainerInvoker;
+import org.jboss.portal.portlet.container.ContainerPortletInvoker;
import org.jboss.portal.portlet.invocation.PortletInvocation;
/**
@@ -122,7 +122,7 @@
public BridgeInfo(PortletInvocation invocation)
{
- PortletContainer container =
(PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
PortletContainerInvoker.PORTLET_CONTAINER);
+ PortletContainer container =
(PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
ContainerPortletInvoker.PORTLET_CONTAINER);
//
this.invocation = invocation;
Modified:
modules/portlet/trunk/mc/src/main/java/org/jboss/portal/portlet/mc/PortletApplicationDeployer.java
===================================================================
---
modules/portlet/trunk/mc/src/main/java/org/jboss/portal/portlet/mc/PortletApplicationDeployer.java 2008-03-19
12:46:15 UTC (rev 10331)
+++
modules/portlet/trunk/mc/src/main/java/org/jboss/portal/portlet/mc/PortletApplicationDeployer.java 2008-03-19
13:00:56 UTC (rev 10332)
@@ -33,7 +33,7 @@
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.ContainerPortletInvoker;
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;
@@ -107,7 +107,7 @@
private final Map<String, PortletApplicationLifeCycle> applications = new
HashMap<String, PortletApplicationLifeCycle>();
/** . */
- private PortletContainerInvoker portletContainerInvoker;
+ private ContainerPortletInvoker containerPortletInvoker;
/** . */
private ManagedObjectRegistryEventBroadcaster broadcaster;
@@ -132,14 +132,14 @@
this.servletContainer = servletContainer;
}
- public PortletContainerInvoker getPortletContainerInvoker()
+ public ContainerPortletInvoker getContainerPortletInvoker()
{
- return portletContainerInvoker;
+ return containerPortletInvoker;
}
- public void setPortletContainerInvoker(PortletContainerInvoker
portletContainerInvoker)
+ public void setContainerPortletInvoker(ContainerPortletInvoker
containerPortletInvoker)
{
- this.portletContainerInvoker = portletContainerInvoker;
+ this.containerPortletInvoker = containerPortletInvoker;
}
public void onEvent(WebAppEvent event)
@@ -332,11 +332,11 @@
//
if (status == LifeCycleStatus.STARTED)
{
- portletContainerInvoker.addPortletContainer(portletContainer);
+ containerPortletInvoker.addPortletContainer(portletContainer);
}
else
{
- portletContainerInvoker.removePortletContainer(portletContainer);
+ containerPortletInvoker.removePortletContainer(portletContainer);
}
}
}
Modified:
modules/portlet/trunk/portal/src/main/resources/simple-portal-war/WEB-INF/jboss-beans.xml
===================================================================
---
modules/portlet/trunk/portal/src/main/resources/simple-portal-war/WEB-INF/jboss-beans.xml 2008-03-19
12:46:15 UTC (rev 10331)
+++
modules/portlet/trunk/portal/src/main/resources/simple-portal-war/WEB-INF/jboss-beans.xml 2008-03-19
13:00:56 UTC (rev 10332)
@@ -25,7 +25,7 @@
<bean name="PortletApplicationDeployer"
class="org.jboss.portal.portlet.mc.PortletApplicationDeployer">
<property name="servletContainer"><inject
bean="ServletContainer"/></property>
- <property name="portletContainerInvoker"><inject
bean="PortletContainerInvoker"/></property>
+ <property name="containerPortletInvoker"><inject
bean="ContainerPortletInvoker"/></property>
</bean>
<!-- The ServletContainerFactory -->
@@ -86,7 +86,7 @@
</bean>
<!-- The portlet container invoker -->
- <bean name="PortletContainerInvoker"
class="org.jboss.portal.portlet.container.PortletContainerInvoker">
+ <bean name="ContainerPortletInvoker"
class="org.jboss.portal.portlet.container.ContainerPortletInvoker">
<property name="stackFactory"><inject
bean="ContainerStackFactory"/></property>
</bean>
@@ -104,7 +104,7 @@
<!-- The producer portlet invoker -->
<bean name="ProducerPortletInvoker"
class="org.jboss.portal.portlet.state.producer.ProducerPortletInvoker">
- <property name="portletInvoker"><inject
bean="PortletContainerInvoker"/></property>
+ <property name="portletInvoker"><inject
bean="ContainerPortletInvoker"/></property>
<property name="persistenceManager"><inject
bean="ProducerPersistenceManager"/></property>
<property name="stateManagementPolicy"><inject
bean="ProducerStateManagementPolicy"/></property>
<property name="stateConverter"><inject
bean="ProducerStateConverter"/></property>
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-03-19
12:46:15 UTC (rev 10331)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ContextDispatcherInterceptor.java 2008-03-19
13:00:56 UTC (rev 10332)
@@ -25,7 +25,7 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.portlet.container.PortletApplication;
import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.portlet.container.PortletContainerInvoker;
+import org.jboss.portal.portlet.container.ContainerPortletInvoker;
import org.jboss.portal.web.RequestDispatchCallback;
import org.jboss.portal.web.ServletContainer;
import org.jboss.portal.web.ServletContainerFactory;
@@ -66,7 +66,7 @@
protected Object invoke(PortletInvocation invocation) throws Exception,
InvocationException
{
- PortletContainer container =
(PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
PortletContainerInvoker.PORTLET_CONTAINER);
+ PortletContainer container =
(PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
ContainerPortletInvoker.PORTLET_CONTAINER);
PortletApplication portletApplication = container.getPortletApplication();
ServerContext reqCtx = invocation.getServerContext();
ServletContext targetCtx = portletApplication.getContext().getServletContext();
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/EventPayloadInterceptor.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/EventPayloadInterceptor.java 2008-03-19
12:46:15 UTC (rev 10331)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/EventPayloadInterceptor.java 2008-03-19
13:00:56 UTC (rev 10332)
@@ -27,7 +27,7 @@
import org.jboss.portal.portlet.invocation.EventInvocation;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.portlet.container.PortletContainerInvoker;
+import org.jboss.portal.portlet.container.ContainerPortletInvoker;
import org.jboss.portal.portlet.container.PortletApplication;
import org.jboss.portal.portlet.container.PortletApplicationContext;
import org.jboss.portal.portlet.info.PortletInfo;
@@ -69,7 +69,7 @@
Serializable dstPayload = null;
if (srcPayload != null)
{
- PortletContainer container =
(PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
PortletContainerInvoker.PORTLET_CONTAINER);
+ PortletContainer container =
(PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
ContainerPortletInvoker.PORTLET_CONTAINER);
//
PortletApplication application = container.getPortletApplication();
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java 2008-03-19
12:46:15 UTC (rev 10331)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java 2008-03-19
13:00:56 UTC (rev 10332)
@@ -30,7 +30,7 @@
import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.portlet.container.PortletContainerInvoker;
+import org.jboss.portal.portlet.container.ContainerPortletInvoker;
import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
import org.jboss.portal.portlet.impl.info.ContainerOptionInfo;
import org.jboss.portal.portlet.ParametersStateString;
@@ -61,7 +61,7 @@
protected Object invoke(PortletInvocation invocation) throws Exception,
InvocationException
{
- PortletContainer container =
(PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
PortletContainerInvoker.PORTLET_CONTAINER);
+ PortletContainer container =
(PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
ContainerPortletInvoker.PORTLET_CONTAINER);
ContainerPortletInfo containerInfo = (ContainerPortletInfo)container.getInfo();
//
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/SecureTransportInterceptor.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/SecureTransportInterceptor.java 2008-03-19
12:46:15 UTC (rev 10331)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/SecureTransportInterceptor.java 2008-03-19
13:00:56 UTC (rev 10332)
@@ -24,7 +24,7 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.portlet.TransportGuarantee;
-import org.jboss.portal.portlet.container.PortletContainerInvoker;
+import org.jboss.portal.portlet.container.ContainerPortletInvoker;
import org.jboss.portal.portlet.container.PortletContainer;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.SecurityInfo;
@@ -44,7 +44,7 @@
protected Object invoke(PortletInvocation invocation) throws Exception,
InvocationException
{
- PortletContainer container =
(PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
PortletContainerInvoker.PORTLET_CONTAINER);
+ PortletContainer container =
(PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
ContainerPortletInvoker.PORTLET_CONTAINER);
PortletInfo containerInfo = container.getInfo();
SecurityInfo securityInfo = containerInfo.getSecurity();
SecurityContext securityContext = invocation.getSecurityContext();
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-03-19
12:46:15 UTC (rev 10331)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ValveInterceptor.java 2008-03-19
13:00:56 UTC (rev 10332)
@@ -24,7 +24,7 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.concurrent.Valve;
-import org.jboss.portal.portlet.container.PortletContainerInvoker;
+import org.jboss.portal.portlet.container.ContainerPortletInvoker;
import org.jboss.portal.portlet.container.PortletContainerContext;
import org.jboss.portal.portlet.container.managed.PortletApplicationRegistry;
import org.jboss.portal.portlet.invocation.PortletInterceptor;
@@ -61,7 +61,7 @@
protected Object invoke(PortletInvocation invocation) throws Exception,
InvocationException
{
- PortletContainerImpl container =
(PortletContainerImpl)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
PortletContainerInvoker.PORTLET_CONTAINER);
+ PortletContainerImpl container =
(PortletContainerImpl)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
ContainerPortletInvoker.PORTLET_CONTAINER);
//
Valve valve = container.getValve();
Copied:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/ContainerPortletInvoker.java
(from rev 10331,
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/ContainerPortletInvoker.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/ContainerPortletInvoker.java 2008-03-19
13:00:56 UTC (rev 10332)
@@ -0,0 +1,280 @@
+/******************************************************************************
+ * 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.container;
+
+import org.jboss.portal.common.invocation.InterceptorStackFactory;
+import org.jboss.portal.common.invocation.Invocation;
+import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.common.invocation.InvocationHandler;
+import org.jboss.portal.portlet.NoSuchPortletException;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.impl.info.ContainerPreferencesInfo;
+import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.info.ContainerPreferenceInfo;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.state.PropertyChange;
+import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.portlet.state.SimplePropertyMap;
+import org.jboss.portal.portlet.state.DestroyCloneFailure;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * An implementation of portlet invoker that makes a call to a portlet container.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7226 $
+ */
+public class ContainerPortletInvoker implements PortletInvoker
+{
+
+ /** The key under which the portlet container is stored in the request scope of the
invocation. */
+ public static final String PORTLET_CONTAINER = "PORTLET_CONTAINER";
+
+ /** . */
+ private InterceptorStackFactory stackFactory;
+
+ /** . */
+ private Map<String, Portlet> portlets = new HashMap<String, Portlet>();
+
+ /** . */
+ private InvocationHandler handler = new InvocationHandler()
+ {
+ public Object invoke(Invocation invocation) throws Exception,
org.jboss.portal.common.invocation.InvocationException
+ {
+ PortletInvocation portletInvocation = (PortletInvocation)invocation;
+
+ //
+ try
+ {
+ portletInvocation.setHandler(null);
+
+ //
+ PortletContainer container =
(PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
ContainerPortletInvoker.PORTLET_CONTAINER);
+ return container.dispatch(portletInvocation);
+ }
+ finally
+ {
+ portletInvocation.setHandler(this);
+ }
+ }
+ };
+
+ public InterceptorStackFactory getStackFactory()
+ {
+ return stackFactory;
+ }
+
+ public void setStackFactory(InterceptorStackFactory stackFactory)
+ {
+ this.stackFactory = stackFactory;
+ }
+
+ public void addPortletContainer(PortletContainer portletContainer)
+ {
+ Map<String, Portlet> portlets = new HashMap<String,
Portlet>(this.portlets);
+ PortletImpl portlet = new PortletImpl(portletContainer);
+ portlets.put(portlet.getContext().getId(), portlet);
+
+ //
+ this.portlets = portlets;
+ }
+
+ public void removePortletContainer(PortletContainer portletContainer)
+ {
+ Map<String, Portlet> portlets = new HashMap<String,
Portlet>(this.portlets);
+ PortletImpl portlet = new PortletImpl(portletContainer);
+ portlets.remove(portlet.getContext().getId());
+
+ //
+ this.portlets = portlets;
+ }
+
+ public void start() throws Exception
+ {
+ }
+
+ public void stop() throws Exception
+ {
+ }
+
+ public Set<Portlet> getPortlets()
+ {
+ return new HashSet<Portlet>(portlets.values());
+ }
+
+ public Portlet getPortlet(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException
+ {
+ if (portletContext == null)
+ {
+ throw new IllegalArgumentException("No null portlet id accepted");
+ }
+ String portletId = portletContext.getId();
+ PortletImpl portlet = (PortletImpl)portlets.get(portletId);
+ if (portlet == null)
+ {
+ throw new NoSuchPortletException(portletId);
+ }
+ return portlet;
+ }
+
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException, InvocationException
+ {
+ // Get portlet container
+ PortletContext ctx = invocation.getTarget();
+ PortletImpl portlet = (PortletImpl)getPortlet(ctx);
+ PortletContainer container = portlet.container;
+
+ //
+ InvocationHandler prevHandler = invocation.getHandler();
+ try
+ {
+
+ invocation.setHandler(handler);
+ invocation.setAttribute(PortletInvocation.INVOCATION_SCOPE,
ContainerPortletInvoker.PORTLET_CONTAINER, container);
+ return
(PortletInvocationResponse)invocation.invoke(stackFactory.getInterceptorStack());
+ }
+ catch (Exception e)
+ {
+ if (e instanceof PortletInvokerException)
+ {
+ throw (PortletInvokerException)e;
+ }
+ else if (e instanceof RuntimeException)
+ {
+ throw (RuntimeException)e;
+ }
+ else
+ {
+ throw new PortletInvokerException(e);
+ }
+ }
+ finally
+ {
+ invocation.setHandler(prevHandler);
+ invocation.removeAttribute(PortletInvocation.INVOCATION_SCOPE,
ContainerPortletInvoker.PORTLET_CONTAINER);
+ }
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext, Set<String>
keys) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ PortletImpl portlet = (PortletImpl)portlets.get(portletContext.getId());
+ if (portlet == null)
+ {
+ throw new NoSuchPortletException(portletContext.getId());
+ }
+ ContainerPortletInfo info = (ContainerPortletInfo)portlet.getInfo();
+ ContainerPreferencesInfo prefs = (ContainerPreferencesInfo)info.getPreferences();
+ PropertyMap result = new SimplePropertyMap();
+ for (String key : keys)
+ {
+ ContainerPreferenceInfo pref = prefs.getContainerPreference(key);
+ if (pref != null)
+ {
+ result.put(key, pref.getDefaultValue());
+ }
+ }
+ return result;
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ PortletImpl portlet = (PortletImpl)portlets.get(portletContext.getId());
+ if (portlet == null)
+ {
+ throw new NoSuchPortletException(portletContext.getId());
+ }
+ ContainerPortletInfo info = (ContainerPortletInfo)portlet.getInfo();
+ ContainerPreferencesInfo prefs = (ContainerPreferencesInfo)info.getPreferences();
+ PropertyMap result = new SimplePropertyMap();
+ for (String key : prefs.getKeys())
+ {
+ ContainerPreferenceInfo pref = prefs.getContainerPreference(key);
+ if (pref != null)
+ {
+ result.put(key, pref.getDefaultValue());
+ }
+ }
+ return result;
+ }
+
+ public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public List<DestroyCloneFailure> destroyClones(List<PortletContext>
portletContexts) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public PortletContext setProperties(PortletContext portletContext, PropertyChange[]
changes) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ private static class PortletImpl implements Portlet
+ {
+
+ /** . */
+ private final PortletContainer container;
+
+ /** . */
+ private final PortletContext context;
+
+ public PortletImpl(PortletContainer container)
+ {
+ this.container = container;
+ this.context =
PortletContext.createPortletContext(container.getPortletApplication().getId() +
"." + container.getId());
+ }
+
+ public PortletContext getContext()
+ {
+ return context;
+ }
+
+ public PortletInfo getInfo()
+ {
+ return container.getInfo();
+ }
+
+ public boolean isRemote()
+ {
+ return false;
+ }
+
+ public String toString()
+ {
+ return "Portlet[context=" + context + ",container=" +
container + "]";
+ }
+ }
+}
\ No newline at end of file
Property changes on:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/ContainerPortletInvoker.java
___________________________________________________________________
Name: svn:executable
+
Deleted:
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-03-19
12:46:15 UTC (rev 10331)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainerInvoker.java 2008-03-19
13:00:56 UTC (rev 10332)
@@ -1,280 +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.container;
-
-import org.jboss.portal.common.invocation.InterceptorStackFactory;
-import org.jboss.portal.common.invocation.Invocation;
-import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.common.invocation.InvocationHandler;
-import org.jboss.portal.portlet.NoSuchPortletException;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.impl.info.ContainerPreferencesInfo;
-import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
-import org.jboss.portal.portlet.impl.info.ContainerPreferenceInfo;
-import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.state.PropertyChange;
-import org.jboss.portal.portlet.state.PropertyMap;
-import org.jboss.portal.portlet.state.SimplePropertyMap;
-import org.jboss.portal.portlet.state.DestroyCloneFailure;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * An implementation of portlet invoker that makes a call to a portlet container.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 7226 $
- */
-public class PortletContainerInvoker implements PortletInvoker
-{
-
- /** The key under which the portlet container is stored in the request scope of the
invocation. */
- public static final String PORTLET_CONTAINER = "PORTLET_CONTAINER";
-
- /** . */
- private InterceptorStackFactory stackFactory;
-
- /** . */
- private Map<String, Portlet> portlets = new HashMap<String, Portlet>();
-
- /** . */
- private InvocationHandler handler = new InvocationHandler()
- {
- public Object invoke(Invocation invocation) throws Exception,
org.jboss.portal.common.invocation.InvocationException
- {
- PortletInvocation portletInvocation = (PortletInvocation)invocation;
-
- //
- try
- {
- portletInvocation.setHandler(null);
-
- //
- PortletContainer container =
(PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE,
PortletContainerInvoker.PORTLET_CONTAINER);
- return container.dispatch(portletInvocation);
- }
- finally
- {
- portletInvocation.setHandler(this);
- }
- }
- };
-
- public InterceptorStackFactory getStackFactory()
- {
- return stackFactory;
- }
-
- public void setStackFactory(InterceptorStackFactory stackFactory)
- {
- this.stackFactory = stackFactory;
- }
-
- public void addPortletContainer(PortletContainer portletContainer)
- {
- Map<String, Portlet> portlets = new HashMap<String,
Portlet>(this.portlets);
- PortletImpl portlet = new PortletImpl(portletContainer);
- portlets.put(portlet.getContext().getId(), portlet);
-
- //
- this.portlets = portlets;
- }
-
- public void removePortletContainer(PortletContainer portletContainer)
- {
- Map<String, Portlet> portlets = new HashMap<String,
Portlet>(this.portlets);
- PortletImpl portlet = new PortletImpl(portletContainer);
- portlets.remove(portlet.getContext().getId());
-
- //
- this.portlets = portlets;
- }
-
- public void start() throws Exception
- {
- }
-
- public void stop() throws Exception
- {
- }
-
- public Set<Portlet> getPortlets()
- {
- return new HashSet<Portlet>(portlets.values());
- }
-
- public Portlet getPortlet(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException
- {
- if (portletContext == null)
- {
- throw new IllegalArgumentException("No null portlet id accepted");
- }
- String portletId = portletContext.getId();
- PortletImpl portlet = (PortletImpl)portlets.get(portletId);
- if (portlet == null)
- {
- throw new NoSuchPortletException(portletId);
- }
- return portlet;
- }
-
- public PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException, InvocationException
- {
- // Get portlet container
- PortletContext ctx = invocation.getTarget();
- PortletImpl portlet = (PortletImpl)getPortlet(ctx);
- PortletContainer container = portlet.container;
-
- //
- InvocationHandler prevHandler = invocation.getHandler();
- try
- {
-
- invocation.setHandler(handler);
- invocation.setAttribute(PortletInvocation.INVOCATION_SCOPE,
PortletContainerInvoker.PORTLET_CONTAINER, container);
- return
(PortletInvocationResponse)invocation.invoke(stackFactory.getInterceptorStack());
- }
- catch (Exception e)
- {
- if (e instanceof PortletInvokerException)
- {
- throw (PortletInvokerException)e;
- }
- else if (e instanceof RuntimeException)
- {
- throw (RuntimeException)e;
- }
- else
- {
- throw new PortletInvokerException(e);
- }
- }
- finally
- {
- invocation.setHandler(prevHandler);
- invocation.removeAttribute(PortletInvocation.INVOCATION_SCOPE,
PortletContainerInvoker.PORTLET_CONTAINER);
- }
- }
-
- public PropertyMap getProperties(PortletContext portletContext, Set<String>
keys) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
- {
- PortletImpl portlet = (PortletImpl)portlets.get(portletContext.getId());
- if (portlet == null)
- {
- throw new NoSuchPortletException(portletContext.getId());
- }
- ContainerPortletInfo info = (ContainerPortletInfo)portlet.getInfo();
- ContainerPreferencesInfo prefs = (ContainerPreferencesInfo)info.getPreferences();
- PropertyMap result = new SimplePropertyMap();
- for (String key : keys)
- {
- ContainerPreferenceInfo pref = prefs.getContainerPreference(key);
- if (pref != null)
- {
- result.put(key, pref.getDefaultValue());
- }
- }
- return result;
- }
-
- public PropertyMap getProperties(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
- {
- PortletImpl portlet = (PortletImpl)portlets.get(portletContext.getId());
- if (portlet == null)
- {
- throw new NoSuchPortletException(portletContext.getId());
- }
- ContainerPortletInfo info = (ContainerPortletInfo)portlet.getInfo();
- ContainerPreferencesInfo prefs = (ContainerPreferencesInfo)info.getPreferences();
- PropertyMap result = new SimplePropertyMap();
- for (String key : prefs.getKeys())
- {
- ContainerPreferenceInfo pref = prefs.getContainerPreference(key);
- if (pref != null)
- {
- result.put(key, pref.getDefaultValue());
- }
- }
- return result;
- }
-
- public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
- {
- throw new UnsupportedOperationException();
- }
-
- public List<DestroyCloneFailure> destroyClones(List<PortletContext>
portletContexts) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
- {
- throw new UnsupportedOperationException();
- }
-
- public PortletContext setProperties(PortletContext portletContext, PropertyChange[]
changes) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
- {
- throw new UnsupportedOperationException();
- }
-
- private static class PortletImpl implements Portlet
- {
-
- /** . */
- private final PortletContainer container;
-
- /** . */
- private final PortletContext context;
-
- public PortletImpl(PortletContainer container)
- {
- this.container = container;
- this.context =
PortletContext.createPortletContext(container.getPortletApplication().getId() +
"." + container.getId());
- }
-
- public PortletContext getContext()
- {
- return context;
- }
-
- public PortletInfo getInfo()
- {
- return container.getInfo();
- }
-
- public boolean isRemote()
- {
- return false;
- }
-
- public String toString()
- {
- return "Portlet[context=" + context + ",container=" +
container + "]";
- }
- }
-}
\ No newline at end of file
Modified:
modules/portlet/trunk/test/src/test/resources/portlet-tck-war/WEB-INF/jboss-beans.xml
===================================================================
---
modules/portlet/trunk/test/src/test/resources/portlet-tck-war/WEB-INF/jboss-beans.xml 2008-03-19
12:46:15 UTC (rev 10331)
+++
modules/portlet/trunk/test/src/test/resources/portlet-tck-war/WEB-INF/jboss-beans.xml 2008-03-19
13:00:56 UTC (rev 10332)
@@ -38,7 +38,7 @@
<alias>PortletApplicationRegistry</alias>
<property name="servletContainer"><inject
bean="ServletContainer"/></property>
<property name="driver"><inject
bean="TestDriverServer"/></property>
- <property name="portletContainerInvoker"><inject
bean="PortletContainerInvoker"/></property>
+ <property name="containerPortletInvoker"><inject
bean="ContainerPortletInvoker"/></property>
</bean>
<!-- The ServletContainerFactory -->
@@ -101,7 +101,7 @@
</bean>
<!-- The portlet container invoker -->
- <bean name="PortletContainerInvoker"
class="org.jboss.portal.portlet.container.PortletContainerInvoker">
+ <bean name="ContainerPortletInvoker"
class="org.jboss.portal.portlet.container.ContainerPortletInvoker">
<property name="stackFactory"><inject
bean="ContainerStackFactory"/></property>
</bean>
@@ -119,7 +119,7 @@
<!-- The producer portlet invoker -->
<bean name="ProducerPortletInvoker"
class="org.jboss.portal.portlet.state.producer.ProducerPortletInvoker">
- <property name="portletInvoker"><inject
bean="PortletContainerInvoker"/></property>
+ <property name="portletInvoker"><inject
bean="ContainerPortletInvoker"/></property>
<property name="persistenceManager"><inject
bean="ProducerPersistenceManager"/></property>
<property name="stateManagementPolicy"><inject
bean="ProducerStateManagementPolicy"/></property>
<property name="stateConverter"><inject
bean="ProducerStateConverter"/></property>
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-03-19
12:46:15 UTC (rev 10331)
+++
modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml 2008-03-19
13:00:56 UTC (rev 10332)
@@ -38,7 +38,7 @@
<alias>PortletApplicationRegistry</alias>
<property name="servletContainer"><inject
bean="ServletContainer"/></property>
<property name="driver"><inject
bean="TestDriverServer"/></property>
- <property name="portletContainerInvoker"><inject
bean="PortletContainerInvoker"/></property>
+ <property name="containerPortletInvoker"><inject
bean="ContainerPortletInvoker"/></property>
</bean>
<!-- The ServletContainerFactory -->
@@ -101,7 +101,7 @@
</bean>
<!-- The portlet container invoker -->
- <bean name="PortletContainerInvoker"
class="org.jboss.portal.portlet.container.PortletContainerInvoker">
+ <bean name="ContainerPortletInvoker"
class="org.jboss.portal.portlet.container.ContainerPortletInvoker">
<property name="stackFactory"><inject
bean="ContainerStackFactory"/></property>
</bean>
@@ -119,7 +119,7 @@
<!-- The producer portlet invoker -->
<bean name="ProducerPortletInvoker"
class="org.jboss.portal.portlet.state.producer.ProducerPortletInvoker">
- <property name="portletInvoker"><inject
bean="PortletContainerInvoker"/></property>
+ <property name="portletInvoker"><inject
bean="ContainerPortletInvoker"/></property>
<property name="persistenceManager"><inject
bean="ProducerPersistenceManager"/></property>
<property name="stateManagementPolicy"><inject
bean="ProducerStateManagementPolicy"/></property>
<property name="stateConverter"><inject
bean="ProducerStateConverter"/></property>