[jboss-svn-commits] JBoss Portal SVN: r5226 - in trunk: core/src/main/org/jboss/portal/core/impl/model/instance core/src/main/org/jboss/portal/core/portlet/management core/src/main/org/jboss/portal/core/portlet/management/actions core/src/main/org/jboss/portal/test/core/model/instance core/src/main/org/jboss/portal/test/core/state federation/src/main/org/jboss/portal/federation/impl portlet/src/main/org/jboss/portal/portlet portlet/src/main/org/jboss/portal/portlet/container portlet/src/main/org/jboss/portal/portlet/state/consumer portlet/src/main/org/jboss/portal/portlet/state/producer portlet/src/main/org/jboss/portal/portlet/tck portlet/src/main/org/jboss/portal/portlet/test portlet/src/main/org/jboss/portal/portlet/test/support portlet/src/main/org/jboss/portal/test/portlet/state wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer wsrp/src/main/org/jboss/portal/wsrp/consumer wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet wsrp/src/main/org/jboss/portal/wsrp/producer
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Sep 19 13:37:59 EDT 2006
Author: julien at jboss.com
Date: 2006-09-19 13:37:18 -0400 (Tue, 19 Sep 2006)
New Revision: 5226
Added:
trunk/portlet/src/main/org/jboss/portal/portlet/StatefulPortletContext.java
Removed:
trunk/portlet/src/main/org/jboss/portal/portlet/stateful/
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.java
trunk/core/src/main/org/jboss/portal/core/portlet/management/InstanceManagerBean.java
trunk/core/src/main/org/jboss/portal/core/portlet/management/PortletManagerBean.java
trunk/core/src/main/org/jboss/portal/core/portlet/management/actions/CreateInstanceAction.java
trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java
trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java
trunk/federation/src/main/org/jboss/portal/federation/impl/FederatedPortlet.java
trunk/federation/src/main/org/jboss/portal/federation/impl/FederatedPortletInvokerService.java
trunk/federation/src/main/org/jboss/portal/federation/impl/FederatingPortletInvokerService.java
trunk/portlet/src/main/org/jboss/portal/portlet/Portlet.java
trunk/portlet/src/main/org/jboss/portal/portlet/PortletContext.java
trunk/portlet/src/main/org/jboss/portal/portlet/PortletInvoker.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistryImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainer.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerInvoker.java
trunk/portlet/src/main/org/jboss/portal/portlet/state/consumer/ConsumerPortletInvoker.java
trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java
trunk/portlet/src/main/org/jboss/portal/portlet/tck/TCKPortletController.java
trunk/portlet/src/main/org/jboss/portal/portlet/test/InstanceContextImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java
trunk/portlet/src/main/org/jboss/portal/portlet/test/TestPortletInvoker.java
trunk/portlet/src/main/org/jboss/portal/portlet/test/TestSecurityInterceptor.java
trunk/portlet/src/main/org/jboss/portal/portlet/test/support/PortletInvokerSupport.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/ServiceDescriptionTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/WSRPPortlet.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
Log:
remove the stateful portlet invoker that was replicating the same interface than portlet invoker
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceImpl.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceImpl.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -185,7 +185,7 @@
{
PersistentInstanceContainer container = (PersistentInstanceContainer)context.getContainer();
PortletInvoker invoker = container.getPortletInvoker();
- return invoker.getPortlet(portletRef);
+ return invoker.getPortlet(new PortletContext(portletRef));
}
public void setProperties(PropertyChange[] changes) throws PortletInvokerException
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -236,7 +236,7 @@
log.debug("Creating instance " + id + " of portlet " + portletId);
// Check that the portlet exist before creating an instance of it
- portletInvoker.getPortlet(portletId);
+ portletInvoker.getPortlet(new PortletContext(portletId));
//
InstanceImpl instance = null;
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/management/InstanceManagerBean.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/management/InstanceManagerBean.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/management/InstanceManagerBean.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -37,6 +37,7 @@
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.info.PreferencesInfo;
import org.jboss.portal.portlet.info.MetaInfo;
import org.jboss.portal.security.AuthorizationDomainRegistry;
@@ -242,7 +243,7 @@
Instance instance = (Instance)i.next();
try
{
- Portlet portlet = instanceContainer.getPortletInvoker().getPortlet(instance.getPortletRef());
+ Portlet portlet = instanceContainer.getPortletInvoker().getPortlet(new PortletContext(instance.getPortletRef()));
Object[] line = new Object[]
{
instance,
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/management/PortletManagerBean.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/management/PortletManagerBean.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/management/PortletManagerBean.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -35,6 +35,7 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.info.PreferenceInfo;
import org.jboss.portal.portlet.info.PreferencesInfo;
import org.jboss.portal.portlet.info.MetaInfo;
@@ -266,7 +267,7 @@
{
try
{
- return getPortletInvoker().getPortlet(selectedPortletId);
+ return getPortletInvoker().getPortlet(new PortletContext(selectedPortletId));
}
catch (PortletInvokerException e)
{
@@ -380,8 +381,8 @@
}
if (column.equals("id"))
{
- return ascending ? p1.getId().compareToIgnoreCase(p2.getId()) : p2.getId()
- .compareToIgnoreCase(p1.getId());
+ return ascending ? p1.getContext().getId().compareToIgnoreCase(p2.getContext().getId()) : p2.getContext().getId()
+ .compareToIgnoreCase(p1.getContext().getId());
}
if (column.equals("name"))
{
@@ -443,7 +444,7 @@
Portlet portlet = getSelectedPortlet();
if (portlet != null)
{
- return portlet.getId();
+ return portlet.getContext().getId();
}
else
{
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/management/actions/CreateInstanceAction.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/management/actions/CreateInstanceAction.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/management/actions/CreateInstanceAction.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -94,7 +94,7 @@
InstanceContainer container = instanceMgr.getInstanceContainer();
try
{
- Instance instance = container.createInstance(instanceId, portlet.getId());
+ Instance instance = container.createInstance(instanceId, portlet.getContext().getId());
instanceMgr.setSelectedId(instanceId);
//
Modified: trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -459,14 +459,14 @@
TransactionAssert.beginTransaction();
InstanceImpl instanceImpl = (InstanceImpl)instanceContainer.getInstance("MyInstance");
String instancePortletRefId = instanceImpl.getPortletRef();
- assertNotNull(producer.getPortlet(instancePortletRefId));
+ assertNotNull(producer.getPortlet(new PortletContext(instancePortletRefId)));
assertNotNull(instance);
Set children = instanceImpl.getUserInstances();
assertNotNull(children);
assertEquals(1, children.size());
UserInstance userInstance = (UserInstance)children.iterator().next();
String userPortletRefId = userInstance.getPortletRef();
- assertNotNull(producer.getPortlet(userPortletRefId));
+ assertNotNull(producer.getPortlet(new PortletContext(userPortletRefId)));
assertNotNull(userInstance);
TransactionAssert.commitTransaction();
@@ -479,7 +479,7 @@
TransactionAssert.beginTransaction();
try
{
- producer.getPortlet(userPortletRefId);
+ producer.getPortlet(new PortletContext(userPortletRefId));
fail("Was expecting a NoSuchPortletException");
}
catch (NoSuchPortletException expected)
@@ -487,7 +487,7 @@
}
try
{
- producer.getPortlet(instancePortletRefId);
+ producer.getPortlet(new PortletContext(instancePortletRefId));
fail("Was expecting a NoSuchPortletException");
}
catch (NoSuchPortletException expected)
Modified: trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -591,8 +591,8 @@
//
TransactionAssert.beginTransaction();
- Portlet portlet = producer.getPortlet(cloneId.getId());
- assertEquals("SimplePortlet", portlet.getId());
+ Portlet portlet = producer.getPortlet(new PortletContext(cloneId.getId()));
+ assertEquals("SimplePortlet", portlet.getContext().getId());
TransactionAssert.commitTransaction();
// Clone the modified CCP
@@ -602,8 +602,8 @@
//
TransactionAssert.beginTransaction();
- portlet = producer.getPortlet(cloneCloneId.getId());
- assertEquals("SimplePortlet", portlet.getId());
+ portlet = producer.getPortlet(new PortletContext(cloneCloneId.getId()));
+ assertEquals("SimplePortlet", portlet.getContext().getId());
TransactionAssert.commitTransaction();
}
Modified: trunk/federation/src/main/org/jboss/portal/federation/impl/FederatedPortlet.java
===================================================================
--- trunk/federation/src/main/org/jboss/portal/federation/impl/FederatedPortlet.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/federation/src/main/org/jboss/portal/federation/impl/FederatedPortlet.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -22,6 +22,7 @@
package org.jboss.portal.federation.impl;
import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.info.PortletInfo;
/**
@@ -32,14 +33,14 @@
{
/** . */
- String compoundId;
+ final PortletContext compoundContext;
/** . */
- Portlet portlet;
+ final Portlet portlet;
- public FederatedPortlet(String compoundId, Portlet portlet)
+ public FederatedPortlet(PortletContext compoundContext, Portlet portlet)
{
- if (compoundId == null)
+ if (compoundContext == null)
{
throw new IllegalArgumentException("No null id accepted");
}
@@ -47,13 +48,13 @@
{
throw new IllegalArgumentException("No null portlet accepted");
}
- this.compoundId = compoundId;
+ this.compoundContext = compoundContext;
this.portlet = portlet;
}
- public String getId()
+ public PortletContext getContext()
{
- return compoundId;
+ return compoundContext;
}
public PortletInfo getInfo()
Modified: trunk/federation/src/main/org/jboss/portal/federation/impl/FederatedPortletInvokerService.java
===================================================================
--- trunk/federation/src/main/org/jboss/portal/federation/impl/FederatedPortletInvokerService.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/federation/src/main/org/jboss/portal/federation/impl/FederatedPortletInvokerService.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -31,6 +31,7 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateEvent;
import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.StatefulPortletContext;
import org.jboss.portal.portlet.state.AccessMode;
import org.jboss.portal.portlet.state.PropertyChange;
import org.jboss.portal.portlet.state.PortletClonedEvent;
@@ -86,22 +87,22 @@
for (Iterator i = portletInvoker.getPortlets().iterator(); i.hasNext();)
{
Portlet portlet = (Portlet)i.next();
- Portlet federatedPortlet = new FederatedPortlet(reference(portlet.getId()), portlet);
+ Portlet federatedPortlet = new FederatedPortlet(reference(portlet.getContext()), portlet);
federatedPortlets.add(federatedPortlet);
}
return federatedPortlets;
}
- public Portlet getPortlet(String compoundPortletId) throws IllegalArgumentException, PortletInvokerException
+ public Portlet getPortlet(PortletContext compoundPortletContext) throws IllegalArgumentException, PortletInvokerException
{
- // Get portlet id
- String portletId = dereference(compoundPortletId);
+ // Get portlet context
+ PortletContext portletContext = dereference(compoundPortletContext);
// Retrieve wrapped portlet
- Portlet portlet = portletInvoker.getPortlet(portletId);
+ Portlet portlet = portletInvoker.getPortlet(portletContext);
// Return correct result
- return new FederatedPortlet(compoundPortletId, portlet);
+ return new FederatedPortlet(compoundPortletContext, portlet);
}
private class FederatedInstanceContext implements InstanceContext
@@ -220,19 +221,33 @@
return reference(portletContext);
}
- private String dereference(String compoundPortletId)
- {
- return compoundPortletId.substring(id.length() + 1);
- }
- private PortletContext dereference(PortletContext compoundPortlet)
+ private PortletContext dereference(PortletContext compoundPortletContext)
{
- return new PortletContext(dereference(compoundPortlet.getId()), compoundPortlet.getMarshalldState());
+ String portletId = compoundPortletContext.getId().substring(id.length() + 1);
+ if (compoundPortletContext instanceof StatefulPortletContext)
+ {
+ StatefulPortletContext statefulCompoundPortletContext = (StatefulPortletContext)compoundPortletContext;
+ return new StatefulPortletContext(portletId, statefulCompoundPortletContext.getMarshalldState());
+ }
+ else
+ {
+ return new PortletContext(portletId);
+ }
}
private PortletContext reference(PortletContext portletContext)
{
- return new PortletContext(reference(portletContext.getId()), portletContext.getMarshalldState());
+ String compoundPortletId = reference(portletContext.getId());
+ if (portletContext instanceof StatefulPortletContext)
+ {
+ StatefulPortletContext statefulPortletContext = (StatefulPortletContext)portletContext;
+ return new StatefulPortletContext(compoundPortletId, statefulPortletContext.getMarshalldState());
+ }
+ else
+ {
+ return new PortletContext(compoundPortletId);
+ }
}
private String reference(String portletId)
Modified: trunk/federation/src/main/org/jboss/portal/federation/impl/FederatingPortletInvokerService.java
===================================================================
--- trunk/federation/src/main/org/jboss/portal/federation/impl/FederatingPortletInvokerService.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/federation/src/main/org/jboss/portal/federation/impl/FederatingPortletInvokerService.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -132,12 +132,12 @@
return portlets;
}
- public Portlet getPortlet(String compoundPortletId) throws IllegalArgumentException, PortletInvokerException
+ public Portlet getPortlet(PortletContext compoundPortletContext) throws IllegalArgumentException, PortletInvokerException
{
FederatedPortletInvoker federated;
try
{
- federated = getFederatedPortletInvokerFor(compoundPortletId);
+ federated = getFederatedPortletInvokerFor(compoundPortletContext);
}
catch (NoSuchPortletException e)
{
@@ -146,22 +146,22 @@
}
//
- Portlet portlet = federated.getPortlet(compoundPortletId);
+ Portlet portlet = federated.getPortlet(compoundPortletContext);
//
- return new FederatedPortlet(compoundPortletId, portlet);
+ return new FederatedPortlet(compoundPortletContext, portlet);
}
public void invoke(PortletInvocation invocation) throws PortletInvokerException
{
PortletContext compoundPortletContext = (PortletContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
- FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext.getId());
+ FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
federated.invoke(invocation);
}
public PortletContext createClone(PortletContext compoundPortletContext) throws PortletInvokerException
{
- FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext.getId());
+ FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
return federated.createClone(compoundPortletContext);
}
@@ -198,19 +198,19 @@
public PropertyMap getProperties(PortletContext compoundPortletContext, Set keys) throws PortletInvokerException
{
- FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext.getId());
+ FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
return federated.getProperties(compoundPortletContext, keys);
}
public PropertyMap getProperties(PortletContext compoundPortletContext) throws PortletInvokerException
{
- FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext.getId());
+ FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
return federated.getProperties(compoundPortletContext);
}
public PortletContext setProperties(PortletContext compoundPortletContext, PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
- FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext.getId());
+ FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
return federated.setProperties(compoundPortletContext, changes);
}
@@ -219,18 +219,31 @@
/**
* Retrieves the portlet invoker associated with the specified compound portlet id or null if it is not found.
*
- * @param compoundPortletId the portlet id for which the invoker is to be retrieved
+ * @param compoundPortletContext the portlet context for which the invoker is to be retrieved
* @return the portlet invoker associated with the specified compound portlet id
* @throws IllegalArgumentException if the compound portlet id is not well formed or null
*/
- private FederatedPortletInvoker getFederatedPortletInvokerFor(String compoundPortletId) throws IllegalArgumentException, NoSuchPortletException
+ private FederatedPortletInvoker getFederatedPortletInvokerFor(PortletContext compoundPortletContext) throws IllegalArgumentException, NoSuchPortletException
{
- if (compoundPortletId == null)
+ if (compoundPortletContext == null)
{
throw new IllegalArgumentException("No null portlet id accepted");
}
//
+ return getFederatedPortletInvokerFor(compoundPortletContext.getId());
+ }
+
+ /**
+ * Retrieves the portlet invoker associated with the specified compound portlet id or null if it is not found.
+ *
+ * @param compoundPortletId the portlet id for which the invoker is to be retrieved
+ * @return the portlet invoker associated with the specified compound portlet id
+ * @throws IllegalArgumentException if the compound portlet id is not well formed or null
+ */
+ private FederatedPortletInvoker getFederatedPortletInvokerFor(String compoundPortletId) throws IllegalArgumentException, NoSuchPortletException
+ {
+ //
int pos = compoundPortletId.indexOf(SEPARATOR);
if (pos == -1)
{
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/Portlet.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/Portlet.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/Portlet.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -32,12 +32,16 @@
public interface Portlet
{
/**
- * Return the portlet identifier.
+ * Return the portlet context.
+ *
+ * @return the portlet context
*/
- String getId();
+ PortletContext getContext();
/**
* Return the portlet info.
+ *
+ * @return the portlet info
*/
PortletInfo getInfo();
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/PortletContext.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/PortletContext.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/PortletContext.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -31,24 +31,15 @@
{
/** . */
- private final String id;
+ protected final String id;
- /** . */
- private final byte[] marshalldState;
-
- public PortletContext(String id)
+ public PortletContext(String id) throws IllegalArgumentException
{
- this(id, null);
- }
-
- public PortletContext(String id, byte[] state)
- {
if (id == null)
{
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Id must not be null");
}
this.id = id;
- this.marshalldState = state;
}
public String getId()
@@ -56,11 +47,6 @@
return id;
}
- public byte[] getMarshalldState()
- {
- return marshalldState;
- }
-
public String toString()
{
return "PortletContext[" + id + "]";
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/PortletInvoker.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/PortletInvoker.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/PortletInvoker.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -47,11 +47,11 @@
/**
* Get information about a specific portlet.
*
- * @param portletId the portlet identifier in the context of this invoker
+ * @param portletContext the portlet context in the scope of this invoker
* @return the <code>PortletInfo</code> for the specified portlet
- * @throws IllegalArgumentException if the portletId is null
+ * @throws IllegalArgumentException if the portlet context is null
*/
- Portlet getPortlet(String portletId) throws IllegalArgumentException, PortletInvokerException;
+ Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException;
/**
* Invoke an operation on a specific portlet.
Added: trunk/portlet/src/main/org/jboss/portal/portlet/StatefulPortletContext.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/StatefulPortletContext.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/StatefulPortletContext.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class StatefulPortletContext extends PortletContext
+{
+
+ /** . */
+ private final byte[] marshalldState;
+
+ public StatefulPortletContext(String id) throws IllegalArgumentException
+ {
+ this(id, null);
+ }
+
+ public StatefulPortletContext(String id, byte[] marshalldState) throws IllegalArgumentException
+ {
+ super(id);
+
+ //
+ if (marshalldState == null)
+ {
+ throw new IllegalArgumentException("State cannot be null");
+ }
+
+ this.marshalldState = marshalldState;
+ }
+
+ public byte[] getMarshalldState()
+ {
+ return marshalldState;
+ }
+
+ public String toString()
+ {
+ return "StatefulPortletContext[" + id + "," + marshalldState.length + "]";
+ }
+}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistryImpl.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistryImpl.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistryImpl.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -83,7 +83,7 @@
synchronized (this)
{
Map componentsCopy = new HashMap(portlets);
- componentsCopy.put(portlet.getId(), portlet);
+ componentsCopy.put(portlet.getContext().getId(), portlet);
portlets = componentsCopy;
}
}
@@ -97,7 +97,7 @@
synchronized (this)
{
Map componentsCopy = new HashMap(portlets);
- componentsCopy.remove(portlet.getId());
+ componentsCopy.remove(portlet.getContext().getId());
portlets = componentsCopy;
}
}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainer.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainer.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainer.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -25,6 +25,7 @@
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.PortletContext;
import org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor;
import org.jboss.portal.portlet.container.info.ContainerPortletInfo;
import org.jboss.portal.portlet.container.info.ContentTypes;
@@ -113,6 +114,9 @@
/** Return info. */
protected PortletInfo info;
+ /** . */
+ protected PortletContext portletContext;
+
/**
* The preference validator, this is not exposed as runtime meta data as it is only used by the JSR 168 portlet
* container implementation.
@@ -127,6 +131,7 @@
this.valve = new Valve();
this.log = Logger.getLogger("org.jboss.portal.portlet.container." + metaData.getClassName().replace('.', '_'));
this.started = false;
+ this.portletContext = new PortletContext(application.getId() + "." + metaData.getName());
}
public PortletInfo getInfo()
@@ -134,9 +139,9 @@
return info;
}
- public String getId()
+ public PortletContext getContext()
{
- return application.getId() + "." + metaData.getName();
+ return portletContext;
}
public boolean isRemote()
@@ -371,7 +376,7 @@
public String toString()
{
- return "[PortletContainer=" + getId() + "]";
+ return "[PortletContainer=" + getContext() + "]";
}
/** Initialize the portlet. */
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerInvoker.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerInvoker.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerInvoker.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -27,10 +27,11 @@
import org.jboss.portal.common.invocation.InvocationHandler;
import org.jboss.portal.portlet.state.PropertyMap;
import org.jboss.portal.portlet.state.PropertyChange;
-import org.jboss.portal.portlet.stateful.PortletInvoker;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.container.info.ContainerPortletInfo;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.jems.as.system.AbstractJBossService;
@@ -112,12 +113,13 @@
return containers;
}
- public Portlet getPortlet(String portletId) throws NoSuchPortletException
+ public Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
{
- if (portletId == null)
+ if (portletContext == null)
{
throw new IllegalArgumentException("No null portlet id accepted");
}
+ String portletId = portletContext.getId();
PortletContainer container = registry.getPortletContainer(portletId);
if (container == null)
{
@@ -155,27 +157,27 @@
}
}
- public String createClone(String portletId) throws NoSuchPortletException
+ public PortletContext createClone(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
- public List destroyClones(List portletIds) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public List destroyClones(List portletContexts) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
- public PropertyMap getProperties(String portletId, Set keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PropertyMap getProperties(PortletContext portletContext, Set keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
- public PropertyMap getProperties(String portletId) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PropertyMap getProperties(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
- public void setProperties(String portletId, PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PortletContext setProperties(PortletContext portletContext, PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/state/consumer/ConsumerPortletInvoker.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/state/consumer/ConsumerPortletInvoker.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/state/consumer/ConsumerPortletInvoker.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -34,6 +34,7 @@
import org.jboss.portal.portlet.state.NoSuchStateException;
import org.jboss.portal.portlet.state.InvalidStateIdException;
import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.StatefulPortletContext;
import org.jboss.portal.portlet.state.PortletClonedEvent;
import org.jboss.portal.portlet.state.PortletModifiedEvent;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -48,7 +49,7 @@
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class ConsumerPortletInvoker implements org.jboss.portal.portlet.stateful.PortletInvoker
+public class ConsumerPortletInvoker implements PortletInvoker
{
/** . */
@@ -124,10 +125,10 @@
return producer.getPortlets();
}
- public Portlet getPortlet(String portletId) throws IllegalArgumentException, PortletInvokerException
+ public Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
{
- PortletContext portletCtx = getPortletContext(portletId);
- return producer.getPortlet(portletCtx.getId());
+ ConsumerContext cpc = getConsumerContext(portletContext);
+ return producer.getPortlet(cpc.portletContext);
}
public void invoke(PortletInvocation invocation) throws IllegalArgumentException, PortletInvokerException
@@ -138,14 +139,14 @@
throw new IllegalArgumentException();
}
- String portletId = (String)resolver.getAttribute(PortletInvocation.PORTLET_ID_ATTRIBUTE);
- if (portletId == null)
+ PortletContext portletContext = (PortletContext)resolver.getAttribute(PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
+ if (portletContext == null)
{
throw new IllegalArgumentException();
}
//
- ConsumerPortletContext portletContext = getPortletContext(portletId);
+ ConsumerContext consumerContext = getConsumerContext(portletContext);
//
InstanceContext cictx = invocation.getInstanceContext();
@@ -153,8 +154,7 @@
try
{
- resolver.setAttribute(PortletInvocation.PORTLET_ID_ATTRIBUTE, null);
- resolver.setAttribute(PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portletContext);
+ resolver.setAttribute(PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, consumerContext.portletContext);
invocation.setInstanceContext(pictx);
//
@@ -163,30 +163,32 @@
//
if (pictx.clonedContext != null)
{
- if (pictx.clonedContext.getMarshalldState() != null)
+ if (pictx.clonedContext instanceof StatefulPortletContext)
{
// Save the clone state
- ConsumerState state = new ConsumerState(pictx.clonedContext.getId(), pictx.clonedContext.getMarshalldState());
+ StatefulPortletContext statefulClonedContext = (StatefulPortletContext)pictx.clonedContext;
+ ConsumerState state = new ConsumerState(statefulClonedContext.getId(), statefulClonedContext.getMarshalldState());
String stateId = persistenceManager.createState(state);
String clonedId = CLONE_ID_PREFIX + stateId;
- org.jboss.portal.portlet.stateful.PortletClonedEvent event = new org.jboss.portal.portlet.stateful.PortletClonedEvent(clonedId);
+ PortletClonedEvent event = new PortletClonedEvent(new PortletContext(clonedId));
cictx.onStateEvent(event);
}
else
{
- org.jboss.portal.portlet.stateful.PortletClonedEvent event = new org.jboss.portal.portlet.stateful.PortletClonedEvent(pictx.clonedContext.getId());
+ PortletClonedEvent event = new PortletClonedEvent(new PortletContext(pictx.clonedContext.getId()));
cictx.onStateEvent(event);
}
}
else if (pictx.modifiedContext != null)
{
// Save
- if (pictx.modifiedContext.getMarshalldState() != null)
+ if (pictx.modifiedContext instanceof StatefulPortletContext)
{
try
{
- ConsumerState state = new ConsumerState(pictx.modifiedContext.getId(), pictx.modifiedContext.getMarshalldState());
- persistenceManager.updateState(portletContext.stateId, state);
+ StatefulPortletContext statefulModifiedContext = (StatefulPortletContext)pictx.modifiedContext;
+ ConsumerState state = new ConsumerState(statefulModifiedContext.getId(), statefulModifiedContext.getMarshalldState());
+ persistenceManager.updateState(consumerContext.stateId, state);
}
catch (NoSuchStateException e)
{
@@ -201,49 +203,49 @@
}
finally
{
- resolver.setAttribute(PortletInvocation.PORTLET_ID_ATTRIBUTE, portletId);
- resolver.setAttribute(PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, null);
+ resolver.setAttribute(PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portletContext);
invocation.setInstanceContext(cictx);
}
}
- public String createClone(String portletId) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PortletContext createClone(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
- PortletContext portletCtx = getPortletContext(portletId);
+ ConsumerContext consumerContext = getConsumerContext(portletContext);
//
- PortletContext cloneContext = producer.createClone(portletCtx);
+ PortletContext clonedContext = producer.createClone(consumerContext.portletContext);
//
- if (cloneContext.getMarshalldState() != null)
+ if (clonedContext instanceof StatefulPortletContext)
{
- ConsumerState state = new ConsumerState(cloneContext.getId(), cloneContext.getMarshalldState());
+ StatefulPortletContext statefulClonedContext = (StatefulPortletContext)clonedContext;
+ ConsumerState state = new ConsumerState(statefulClonedContext.getId(), statefulClonedContext.getMarshalldState());
String id = persistenceManager.createState(state);
- return CLONE_ID_PREFIX + id;
+ return new PortletContext(CLONE_ID_PREFIX + id);
}
else
{
- return cloneContext.getId();
+ return clonedContext;
}
}
- public List destroyClones(List portletIds) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public List destroyClones(List portletContexts) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
- if (portletIds == null)
+ if (portletContexts == null)
{
throw new IllegalArgumentException();
}
- List portletContexts = new ArrayList(portletIds);
+ portletContexts = new ArrayList(portletContexts);
for (int i = 0; i < portletContexts.size(); i++)
{
- String portletId = (String)portletContexts.get(i);
- ConsumerPortletContext portletContext = getPortletContext(portletId);
- portletContexts.set(i, portletContext);
- if (portletContext.stateId != null)
+ PortletContext portletContext = (PortletContext)portletContexts.get(i);
+ ConsumerContext consumerContext = getConsumerContext(portletContext);
+ portletContexts.set(i, consumerContext.portletContext);
+ if (consumerContext.stateId != null)
{
try
{
- persistenceManager.destroyState(portletContext.stateId);
+ persistenceManager.destroyState(consumerContext.stateId);
}
catch (NoSuchStateException e)
{
@@ -269,38 +271,39 @@
return failures;
}
- public PropertyMap getProperties(String portletId, Set keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PropertyMap getProperties(PortletContext portletContext, Set keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
- PortletContext portletContext = getPortletContext(portletId);
- return producer.getProperties(portletContext, keys);
+ ConsumerContext consumerContext = getConsumerContext(portletContext);
+ return producer.getProperties(consumerContext.portletContext, keys);
}
- public PropertyMap getProperties(String portletId) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PropertyMap getProperties(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
- PortletContext portletContext = getPortletContext(portletId);
- return producer.getProperties(portletContext);
+ ConsumerContext consumerContext = getConsumerContext(portletContext);
+ return producer.getProperties(consumerContext.portletContext);
}
- public void setProperties(String portletId, PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PortletContext setProperties(PortletContext portletContext, PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
- ConsumerPortletContext portletContext = getPortletContext(portletId);
+ ConsumerContext consumerContext = getConsumerContext(portletContext);
//
- PortletContext updatedPortletContext = producer.setProperties(portletContext, changes);
+ PortletContext updatedPortletContext = producer.setProperties(consumerContext.portletContext, changes);
//
- if (updatedPortletContext.getMarshalldState() != null)
+ if (updatedPortletContext instanceof StatefulPortletContext)
{
- if (portletContext.stateId == null)
+ if (consumerContext.stateId == null)
{
throw new NotYetImplemented();
}
//
- ConsumerState state = new ConsumerState(updatedPortletContext.getId(), updatedPortletContext.getMarshalldState());
+ StatefulPortletContext updatedStatefulPortletContext = (StatefulPortletContext)updatedPortletContext;
+ ConsumerState state = new ConsumerState(updatedStatefulPortletContext.getId(), updatedStatefulPortletContext.getMarshalldState());
try
{
- persistenceManager.updateState(portletContext.stateId, state);
+ persistenceManager.updateState(consumerContext.stateId, state);
}
catch (NoSuchStateException e)
{
@@ -313,11 +316,14 @@
}
else
{
- if (portletContext.stateId != null)
+ if (consumerContext.stateId != null)
{
throw new NotYetImplemented();
}
}
+
+ // As the point is to make it constant we can simply return it
+ return portletContext;
}
private static class StatefulInstanceContextImpl implements InstanceContext
@@ -362,19 +368,24 @@
}
}
- private ConsumerPortletContext getPortletContext(String portletId) throws IllegalArgumentException, NoSuchPortletException, InvalidPortletIdException
+ private ConsumerContext getConsumerContext(PortletContext portletContext) throws IllegalArgumentException, NoSuchPortletException, InvalidPortletIdException
{
- if (portletId == null)
+ if (portletContext == null)
{
throw new IllegalArgumentException();
}
+
+ //
+ String portletId = portletContext.getId();
+
+ //
if (portletId.startsWith(CLONE_ID_PREFIX))
{
String stateId = portletId.substring(1);
try
{
ConsumerStateContext stateCtx = persistenceManager.loadState(stateId);
- return new ConsumerPortletContext(stateId, stateCtx.getPortletId(), stateCtx.getBytes());
+ return new ConsumerContext(stateId, stateCtx.getPortletId(), stateCtx.getBytes());
}
catch (NoSuchStateException e)
{
@@ -387,26 +398,27 @@
}
else
{
- return new ConsumerPortletContext(null, portletId);
+ return new ConsumerContext(portletContext, null);
}
}
- private class ConsumerPortletContext extends PortletContext
+ private class ConsumerContext
{
+ private final PortletContext portletContext;
+
/** . */
private final String stateId;
- public ConsumerPortletContext(String stateId, String id)
+ public ConsumerContext(PortletContext portletContext, String stateId)
{
- super(id);
+ this.portletContext = portletContext;
this.stateId = stateId;
}
- public ConsumerPortletContext(String stateId, String id, byte[] state)
+ public ConsumerContext(String stateId, String id, byte[] state)
{
- super(id, state);
- this.stateId = stateId;
+ this(new StatefulPortletContext(id, state), stateId);
}
}
}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -31,6 +31,7 @@
import org.jboss.portal.portlet.InvalidPortletIdException;
import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.StatefulPortletContext;
import org.jboss.portal.portlet.spi.InstanceContext;
import org.jboss.portal.portlet.state.AccessMode;
import org.jboss.portal.portlet.state.AbstractPropertyContext;
@@ -62,12 +63,15 @@
{
/** . */
- private static final String CLONE_ID_PREFIX = "_";
+ private static final String PRODUCER_CLONE_ID_PREFIX = "_";
/** . */
- private org.jboss.portal.portlet.stateful.PortletInvoker portletInvoker;
+ private static final String CONSUMER_CLONE_ID = "_dumbvalue";
/** . */
+ private PortletInvoker portletInvoker;
+
+ /** . */
private ProducerPersistenceManager persistenceManager;
/** . */
@@ -76,12 +80,12 @@
/** . */
private StateConverter stateConverter;
- public org.jboss.portal.portlet.stateful.PortletInvoker getPortletInvoker()
+ public PortletInvoker getPortletInvoker()
{
return portletInvoker;
}
- public void setPortletInvoker(org.jboss.portal.portlet.stateful.PortletInvoker portletInvoker)
+ public void setPortletInvoker(PortletInvoker portletInvoker)
{
this.portletInvoker = portletInvoker;
}
@@ -122,7 +126,7 @@
{
throw new IllegalArgumentException();
}
- if (wrappedCCPCtx.getId().startsWith(CLONE_ID_PREFIX) == false)
+ if (wrappedCCPCtx.getId().startsWith(PRODUCER_CLONE_ID_PREFIX) == false)
{
throw new InvalidPortletIdException(wrappedCCPCtx.getId());
}
@@ -144,7 +148,7 @@
{
throw new IllegalArgumentException();
}
- return new PortletContext(CLONE_ID_PREFIX + ccpId);
+ return new PortletContext(PRODUCER_CLONE_ID_PREFIX + ccpId);
}
public PortletContext wrapPOP(String popId) throws InvalidPortletIdException
@@ -153,9 +157,9 @@
{
throw new IllegalArgumentException();
}
- if (popId.startsWith(CLONE_ID_PREFIX))
+ if (popId.startsWith(PRODUCER_CLONE_ID_PREFIX))
{
- throw new IllegalArgumentException("Must not start with " + CLONE_ID_PREFIX);
+ throw new IllegalArgumentException("Must not start with " + PRODUCER_CLONE_ID_PREFIX);
}
return new PortletContext(popId);
}
@@ -165,18 +169,32 @@
return portletInvoker.getPortlets();
}
- public Portlet getPortlet(String portletId) throws PortletInvokerException
+ public Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
{
- if (portletId == null)
+ if (portletContext == null)
{
throw new IllegalArgumentException("No null portlet id accepted");
}
- if (portletId.startsWith(CLONE_ID_PREFIX))
+ String portletId = portletContext.getId();
+ if (CONSUMER_CLONE_ID.equals(portletId))
{
+ if (portletContext instanceof StatefulPortletContext)
+ {
+ StatefulPortletContext statefulPortletContext = (StatefulPortletContext)portletContext;
+ ProducerState state = stateConverter.unmarshall(statefulPortletContext.getMarshalldState());
+ return portletInvoker.getPortlet(new PortletContext(state.getPortletId()));
+ }
+ else
+ {
+ throw new InvalidPortletIdException("", portletId);
+ }
+ }
+ else if (portletId.startsWith(PRODUCER_CLONE_ID_PREFIX))
+ {
try
{
ProducerState state = persistenceManager.loadState(portletId.substring(1));
- return portletInvoker.getPortlet(state.getPortletId());
+ return portletInvoker.getPortlet(new PortletContext(state.getPortletId()));
}
catch (NoSuchStateException e)
{
@@ -189,14 +207,14 @@
}
else
{
- return portletInvoker.getPortlet(portletId);
+ return portletInvoker.getPortlet(portletContext);
}
}
public void invoke(PortletInvocation invocation) throws PortletInvokerException, InvocationException
{
// Get the context of the portlet that the client want to use
- PortletContext portletContext = (PortletContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
+ final PortletContext portletContext = (PortletContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
if (portletContext == null)
{
throw new InvocationException("No portlet context provided");
@@ -210,14 +228,14 @@
PropertyMap propertyMap = null;
// The next portlet to invoke
- String portletId = portletContext.getId();
+ String targetPortletId = portletContext.getId();
// Try to get state
ProducerState state = getState(portletContext);
if (state != null)
{
propertyMap = state.getProperties();
- portletId = state.getPortletId();
+ targetPortletId = state.getPortletId();
}
else
{
@@ -229,10 +247,10 @@
}
// Get the portlet container and set it on invocation
- Portlet portlet = portletInvoker.getPortlet(portletId);
+ Portlet portlet = portletInvoker.getPortlet(new PortletContext(targetPortletId));
if (portlet == null)
{
- throw new NoSuchPortletException("Portlet " + portletId + " not found", portletId);
+ throw new NoSuchPortletException("Portlet " + targetPortletId + " not found", targetPortletId);
}
PortletInfo info = portlet.getInfo();
@@ -245,7 +263,7 @@
//
try
{
- invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_ID_ATTRIBUTE, portletId);
+ invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, new PortletContext(targetPortletId));
invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PREFERENCES_ATTRIBUTE, prefs);
invocation.setInfo(info);
@@ -254,7 +272,7 @@
}
finally
{
- invocation.removeAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_ID_ATTRIBUTE);
+ invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portletContext);
invocation.removeAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PREFERENCES_ATTRIBUTE);
invocation.setInfo(null);
}
@@ -284,7 +302,7 @@
String cloneStateId = persistenceManager.cloneState(portletStateId, newPrefs);
// Return the clone context
- String cloneId = CLONE_ID_PREFIX + cloneStateId;
+ String cloneId = PRODUCER_CLONE_ID_PREFIX + cloneStateId;
PortletContext clonedCtx = new PortletContext(cloneId);
PortletClonedEvent event = new PortletClonedEvent(clonedCtx);
instanceCtx.onStateEvent(event);
@@ -302,8 +320,7 @@
{
ProducerState cloneState = new ProducerState(state.getPortletId(), newPrefs);
byte[] bytes = stateConverter.marshall(cloneState);
- String cloneId = CLONE_ID_PREFIX + "dumbvalue";
- PortletContext clonedCtx = new PortletContext(cloneId, bytes);
+ PortletContext clonedCtx = new StatefulPortletContext(CONSUMER_CLONE_ID, bytes);
PortletClonedEvent event = new PortletClonedEvent(clonedCtx);
instanceCtx.onStateEvent(event);
}
@@ -325,10 +342,10 @@
}
// Create the new state
- String cloneStateId = persistenceManager.createState(portletId, newPrefs);
+ String cloneStateId = persistenceManager.createState(targetPortletId, newPrefs);
// Return the clone context
- String cloneId = CLONE_ID_PREFIX + cloneStateId;
+ String cloneId = PRODUCER_CLONE_ID_PREFIX + cloneStateId;
PortletContext clonedCtx = new PortletContext(cloneId);
PortletClonedEvent event = new PortletClonedEvent(clonedCtx);
instanceCtx.onStateEvent(event);
@@ -336,7 +353,7 @@
}
else if (access == AccessMode.READ_WRITE)
{
- if (portletContext.getMarshalldState() == null)
+ if (portletContext instanceof StatefulPortletContext == false)
{
// Update the state
try
@@ -355,9 +372,9 @@
}
else
{
- ProducerState cloneState = new ProducerState(portletId, newPrefs);
+ ProducerState cloneState = new ProducerState(targetPortletId, newPrefs);
byte[] bytes = stateConverter.marshall(cloneState);
- PortletContext modifiedCtx = new PortletContext(portletId, bytes);
+ PortletContext modifiedCtx = new StatefulPortletContext(targetPortletId, bytes);
PortletModifiedEvent event = new PortletModifiedEvent(modifiedCtx);
instanceCtx.onStateEvent(event);
}
@@ -389,7 +406,7 @@
try
{
String stateId = portletId.substring(1);
- String cloneId = CLONE_ID_PREFIX + persistenceManager.cloneState(stateId);
+ String cloneId = PRODUCER_CLONE_ID_PREFIX + persistenceManager.cloneState(stateId);
return new PortletContext(cloneId);
}
catch (NoSuchStateException e)
@@ -403,9 +420,9 @@
}
else
{
- String cloneId = CLONE_ID_PREFIX + "dumbvalue";
+ String cloneId = PRODUCER_CLONE_ID_PREFIX + "dumbvalue";
byte[] marshalledState = stateConverter.marshall(state);
- return new PortletContext(cloneId, marshalledState);
+ return new StatefulPortletContext(cloneId, marshalledState);
}
}
else
@@ -421,14 +438,14 @@
if (useStore)
{
String cloneId = persistenceManager.createState(portletId, newState);
- return new PortletContext(CLONE_ID_PREFIX + cloneId);
+ return new PortletContext(PRODUCER_CLONE_ID_PREFIX + cloneId);
}
else
{
- String cloneId = CLONE_ID_PREFIX + "dumbvalue";
+ String cloneId = PRODUCER_CLONE_ID_PREFIX + "dumbvalue";
ProducerState sstate = new ProducerState(portletId, newState);
byte[] marshalledState = stateConverter.marshall(sstate);
- return new PortletContext(cloneId, marshalledState);
+ return new StatefulPortletContext(cloneId, marshalledState);
}
}
}
@@ -447,10 +464,10 @@
PortletContext portletContext = (PortletContext)i.next();
// We only take care of producer hosted state
- if (portletContext.getMarshalldState() == null)
+ if (portletContext instanceof StatefulPortletContext == false)
{
String portletId = portletContext.getId();
- if (portletId.startsWith(CLONE_ID_PREFIX) == false)
+ if (portletId.startsWith(PRODUCER_CLONE_ID_PREFIX) == false)
{
log.debug("Attempt to destroy a producer offered portlet " + portletId);
DestroyCloneFailure failure = new DestroyCloneFailure(portletId, "Cannot destroy POP");
@@ -513,7 +530,7 @@
String referencedPortletId = state.getPortletId();
// Get the container
- Portlet referencedPortlet = portletInvoker.getPortlet(referencedPortletId);
+ Portlet referencedPortlet = portletInvoker.getPortlet(new PortletContext(referencedPortletId));
// We need the referenced portlet
if (referencedPortlet == null)
@@ -580,7 +597,7 @@
String referencedPortletId = state.getPortletId();
// Get the container
- Portlet referencedPortlet = portletInvoker.getPortlet(referencedPortletId);
+ Portlet referencedPortlet = portletInvoker.getPortlet(new PortletContext(referencedPortletId));
// We need the referenced portlet
if (referencedPortlet == null)
@@ -626,7 +643,7 @@
}
//
- if (portletContext.getMarshalldState() == null)
+ if (portletContext instanceof StatefulPortletContext == false)
{
String stateId = ((ProducerStateContext)state).getId();
try
@@ -647,7 +664,7 @@
{
ProducerState sstate = new ProducerState(referencedPortletId, properties);
byte[] marshalledState = stateConverter.marshall(sstate);
- return new PortletContext(portletId, marshalledState);
+ return new StatefulPortletContext(portletId, marshalledState);
}
}
@@ -661,7 +678,7 @@
private PropertyMap getPropertiesFromMetaData(String portletId) throws PortletInvokerException
{
//
- Portlet portlet = portletInvoker.getPortlet(portletId);
+ Portlet portlet = portletInvoker.getPortlet(new PortletContext(portletId));
// The prefs info
PreferencesInfo prefs = portlet.getInfo().getPreferences();
@@ -690,10 +707,10 @@
*/
private ProducerState getState(PortletContext portletContext) throws NoSuchPortletException, InvalidPortletIdException
{
- if (portletContext.getMarshalldState() == null)
+ if (portletContext instanceof StatefulPortletContext == false)
{
String portletId = portletContext.getId();
- if (portletContext.getId().startsWith(CLONE_ID_PREFIX) == true)
+ if (portletContext.getId().startsWith(PRODUCER_CLONE_ID_PREFIX) == true)
{
String stateId = portletId.substring(1);
try
@@ -716,7 +733,8 @@
}
else
{
- byte[] marshalledState = portletContext.getMarshalldState();
+ StatefulPortletContext statefulPortletContext = (StatefulPortletContext)portletContext;
+ byte[] marshalledState = statefulPortletContext.getMarshalldState();
ProducerState state = stateConverter.unmarshall(marshalledState);
return state;
}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/tck/TCKPortletController.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/tck/TCKPortletController.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/tck/TCKPortletController.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -23,6 +23,7 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.test.PortletController;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.request.RequestParameter;
@@ -64,7 +65,7 @@
for (Iterator i = portletIds.iterator(); i.hasNext();)
{
String portletId = (String)i.next();
- Portlet portlet = portletInvoker.getPortlet(portletId);
+ Portlet portlet = portletInvoker.getPortlet(new PortletContext(portletId));
portlets.add(portlet);
}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/test/InstanceContextImpl.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/test/InstanceContextImpl.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/test/InstanceContextImpl.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -42,9 +42,6 @@
private final AccessMode accessMode;
/** . */
- private String clonedId;
-
- /** . */
private PortletContext clonedContext;
/** . */
@@ -93,18 +90,8 @@
PortletModifiedEvent pme = (PortletModifiedEvent)event;
modifiedContext = pme.getModifiedContext();
}
- else if (event instanceof org.jboss.portal.portlet.stateful.PortletClonedEvent)
- {
- org.jboss.portal.portlet.stateful.PortletClonedEvent pce = (org.jboss.portal.portlet.stateful.PortletClonedEvent)event;
- clonedId = pce.getClonedId();
- }
}
- public String getClonedId()
- {
- return clonedId;
- }
-
public PortletContext getClonedContext()
{
return clonedContext;
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -31,7 +31,6 @@
import org.jboss.portal.portlet.Parameters;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.stateful.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.PortletRequestDecoder;
import org.jboss.portal.portlet.PortletURL;
@@ -39,6 +38,7 @@
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.StateEvent;
import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.impl.spi.AbstractPortletInvocationContext;
import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
@@ -134,7 +134,7 @@
{
// Get the portlet
String portletId = requestPath.substring("/portlet/".length());
- Portlet portlet = portletInvoker.getPortlet(portletId);
+ Portlet portlet = portletInvoker.getPortlet(new PortletContext(portletId));
PortletRequestDecoder decoder = new PortletRequestDecoder();
decoder.decode(invocation.getServerContext().getParameterMap());
@@ -142,7 +142,7 @@
if (decoder.getType() == PortletRequestDecoder.ACTION_TYPE)
{
// Get the navigational state if it exist
- ParametersStateString navigationalState = (ParametersStateString)invocation.getAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getId());
+ ParametersStateString navigationalState = (ParametersStateString)invocation.getAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext().getId());
//
ActionContextImpl actionContext = new ActionContextImpl(
@@ -196,7 +196,7 @@
}
else
{
- invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getId(), renderResult.getNavigationalState());
+ invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext().getId(), renderResult.getNavigationalState());
}
}
if (result instanceof HTTPRedirectionResult)
@@ -230,18 +230,18 @@
else
{
//
- invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getId(), decoder.getNavigationalstate());
+ invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext().getId(), decoder.getNavigationalstate());
//
if (decoder.getMode() != null)
{
- invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getId() + "_mode", decoder.getMode());
+ invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext() + "_mode", decoder.getMode());
}
//
if (decoder.getWindowState() != null)
{
- invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getId() + "_windowstate", decoder.getWindowState());
+ invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext() + "_windowstate", decoder.getWindowState());
}
}
@@ -256,17 +256,17 @@
Portlet portlet = (Portlet)i.next();
// Get the navigational state
- StateString ns = (StateString)invocation.getAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getId());
+ StateString ns = (StateString)invocation.getAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext().getId());
// Get the mode
- Mode mode = (Mode)invocation.getAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getId() + "_mode");
+ Mode mode = (Mode)invocation.getAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext() + "_mode");
if (mode == null)
{
mode = Mode.VIEW;
}
// Get the window state
- WindowState windowState = (WindowState)invocation.getAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getId() + "_windowstate");
+ WindowState windowState = (WindowState)invocation.getAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext() + "_windowstate");
if (windowState == null)
{
windowState = WindowState.NORMAL;
@@ -400,9 +400,9 @@
public InstanceContextImpl(Portlet portlet, HttpServletRequest req)
{
- this.portletContext = new PortletContext(portlet.getId());
+ this.portletContext = portlet.getContext();
this.req = req;
- this.cloneContext = (PortletContext)req.getSession().getAttribute(CLONE_OF + portlet.getId());
+ this.cloneContext = (PortletContext)req.getSession().getAttribute(CLONE_OF + portlet.getContext().getId());
this.accessMode = cloneContext == null ? AccessMode.CLONE_BEFORE_WRITE : AccessMode.READ_WRITE;
}
@@ -538,7 +538,7 @@
{
public String getId()
{
- return invocationContext.portlet.getId();
+ return invocationContext.portlet.getContext().getId();
}
};
@@ -645,7 +645,7 @@
AbstractServerURL serverURL = new AbstractServerURL();
//
- String id = portlet.getId();
+ String id = portlet.getContext().getId();
serverURL.setPortalRequestPath("/portlet/" + id);
//
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/test/TestPortletInvoker.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/test/TestPortletInvoker.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/test/TestPortletInvoker.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -26,8 +26,9 @@
import org.jboss.portal.common.invocation.Invocation;
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.stateful.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.state.PropertyMap;
import org.jboss.portal.portlet.state.PropertyChange;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -94,9 +95,9 @@
return producer.getPortlets();
}
- public Portlet getPortlet(String portletId) throws PortletInvokerException
+ public Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
{
- return producer.getPortlet(portletId);
+ return producer.getPortlet(portletContext);
}
public void invoke(PortletInvocation invocation) throws PortletInvokerException
@@ -128,27 +129,27 @@
}
}
- public String createClone(String portletId) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PortletContext createClone(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
- public List destroyClones(List portletIds) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public List destroyClones(List portletContexts) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
- public PropertyMap getProperties(String portletId, Set keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PropertyMap getProperties(PortletContext portletContext, Set keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
- public PropertyMap getProperties(String portletId) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PropertyMap getProperties(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
- public void setProperties(String portletId, PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PortletContext setProperties(PortletContext portletContext, PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/test/TestSecurityInterceptor.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/test/TestSecurityInterceptor.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/test/TestSecurityInterceptor.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -25,6 +25,7 @@
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.result.InsufficientPrivilegesResult;
import org.jboss.portal.portlet.security.PortletPermission;
+import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
@@ -57,7 +58,8 @@
try
{
PortalAuthorizationManager authMgr = pamf.getManager();
- String portletId = (String)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_ID_ATTRIBUTE);
+ PortletContext portletContext = (PortletContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
+ String portletId = portletContext.getId();
PortletPermission perm = new PortletPermission(portletId, PortletPermission.VIEW_MASK);
boolean authorized = authMgr.checkPermission(perm);
if (authorized == false)
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/test/support/PortletInvokerSupport.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/test/support/PortletInvokerSupport.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/test/support/PortletInvokerSupport.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -21,11 +21,12 @@
*/
package org.jboss.portal.portlet.test.support;
-import org.jboss.portal.portlet.stateful.PortletInvoker;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.InvalidPortletIdException;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.test.support.info.PortletInfoSupport;
import org.jboss.portal.portlet.state.PropertyMap;
import org.jboss.portal.portlet.state.PropertyChange;
@@ -84,7 +85,7 @@
throw new IllegalArgumentException();
}
InternalPortlet portlet = new InternalPortlet(portletId, support);
- if (portlets.put(portlet.getId(), portlet) != null)
+ if (portlets.put(portletId, portlet) != null)
{
throw new IllegalStateException();
}
@@ -105,24 +106,25 @@
return new HashSet(portlets.values());
}
- public Portlet getPortlet(String portletId) throws PortletInvokerException
+ public Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
{
- return internalGetPortlet(portletId);
+ return internalGetPortlet(portletContext);
}
public void invoke(PortletInvocation invocation) throws PortletInvokerException
{
- String portletId = (String)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_ID_ATTRIBUTE);
- InternalPortlet portlet = internalGetPortlet(portletId);
+ PortletContext portletContext = (PortletContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
+ InternalPortlet portlet = internalGetPortlet(portletContext);
portlet.support.invoke(invocation);
}
- private InternalPortlet internalGetPortlet(String portletId) throws IllegalArgumentException, PortletInvokerException
+ private InternalPortlet internalGetPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
{
- if (portletId == null)
+ if (portletContext == null)
{
throw new IllegalArgumentException();
}
+ String portletId = portletContext.getId();
InternalPortlet portlet = (InternalPortlet)portlets.get(portletId);
if (portlet == null)
{
@@ -139,7 +141,7 @@
{
/** . */
- private final String id;
+ private final PortletContext portletContext;
/** . */
private final PortletSupport support;
@@ -147,9 +149,9 @@
/** . */
private boolean valid;
- public InternalPortlet(String id, PortletSupport support)
+ public InternalPortlet(String portletId, PortletSupport support)
{
- if (id == null)
+ if (portletId == null)
{
throw new IllegalArgumentException();
}
@@ -157,14 +159,14 @@
{
throw new IllegalArgumentException();
}
- this.id = id;
+ this.portletContext = new PortletContext(portletId);
this.support = support;
this.valid = true;
}
- public String getId()
+ public PortletContext getContext()
{
- return id;
+ return portletContext;
}
public PortletInfo getInfo()
@@ -188,27 +190,27 @@
}
}
- public String createClone(String portletId) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PortletContext createClone(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
- public List destroyClones(List portletIds) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public List destroyClones(List portletContexts) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
- public PropertyMap getProperties(String portletId, Set keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PropertyMap getProperties(PortletContext portletContext, Set keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
- public PropertyMap getProperties(String portletId) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PropertyMap getProperties(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
- public void setProperties(String portletId, PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PortletContext setProperties(PortletContext portletContext, PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -23,6 +23,7 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.impl.state.producer.ProducerPersistenceManagerService;
@@ -106,36 +107,36 @@
protected Portlet getPortlet(Object portletRef) throws PortletInvokerException
{
- return consumer.getPortlet((String)portletRef);
+ return consumer.getPortlet((PortletContext)portletRef);
}
protected Object createPOPRef(PortletSupport portletSupport) throws PortletInvokerException
{
container.addPortlet("PortletId", portletSupport);
Portlet portlet = getSinglePOP();
- return portlet.getId();
+ return portlet.getContext();
}
protected Object createNonExistingPOPRef() throws PortletInvokerException
{
container.addPortlet("NonExistingPortletId", new PortletInfoSupport());
- String popId = getSinglePOP().getId();
+ PortletContext popContext = getSinglePOP().getContext();
container.removePortlet("NonExistingPortletId");
- return popId;
+ return popContext;
}
protected Object createInvalidPOPRef() throws PortletInvokerException
{
container.addPortlet("InvalidPortletId", new PortletInfoSupport());
- String popId = getSinglePOP().getId();
+ PortletContext popContext = getSinglePOP().getContext();
container.setValid("InvalidPortletId", false);
- return popId;
+ return popContext;
}
protected Object createLocalClone(Object portletRef) throws Exception
{
stateManagementPolicy.setPersistLocally(true);
- String cloneRef = consumer.createClone((String)portletRef);
+ PortletContext cloneRef = consumer.createClone((PortletContext)portletRef);
stateManagementPolicy.setPersistLocally(persistLocally);
return cloneRef;
}
@@ -152,23 +153,23 @@
protected Object createClone(Object portletRef) throws PortletInvokerException
{
- return consumer.createClone((String)portletRef);
+ return consumer.createClone((PortletContext)portletRef);
}
protected Object setProperties(Object portletRef, PropertyChange[] changes) throws PortletInvokerException
{
- consumer.setProperties((String)portletRef, changes);
+ consumer.setProperties((PortletContext)portletRef, changes);
return portletRef;
}
protected PropertyMap getProperties(Object portletRef) throws PortletInvokerException
{
- return consumer.getProperties((String)portletRef);
+ return consumer.getProperties((PortletContext)portletRef);
}
protected PropertyMap getProperties(Object portletRef, Set keys) throws PortletInvokerException
{
- return consumer.getProperties((String)portletRef, keys);
+ return consumer.getProperties((PortletContext)portletRef, keys);
}
protected List destroyClones(List portletRefs) throws PortletInvokerException
@@ -178,7 +179,7 @@
protected String getPortletId(Object portletRef) throws PortletInvokerException
{
- return (String)portletRef;
+ return ((PortletContext)portletRef).getId();
}
protected void invoke(PortletInvocation invocation) throws PortletInvokerException
@@ -194,19 +195,19 @@
//
ActionInvocation action = new ActionInvocation(actionCtx);
action.setInstanceContext(instanceCtx);
- action.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_ID_ATTRIBUTE, portletRef);
+ action.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portletRef);
return action;
}
protected Object getImplicitClonedRef(ActionInvocation action)
{
InstanceContextImpl instanceCtx = (InstanceContextImpl)action.getInstanceContext();
- return instanceCtx.getClonedId();
+ return instanceCtx.getClonedContext();
}
protected Object getModifiedPortletRef(ActionInvocation action)
{
- return action.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_ID_ATTRIBUTE);
+ return action.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
}
private Portlet getSinglePOP() throws PortletInvokerException
Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -26,11 +26,8 @@
import org.jboss.portal.portlet.state.PropertyChange;
import org.jboss.portal.portlet.state.PropertyMap;
import org.jboss.portal.portlet.state.AccessMode;
-import org.jboss.portal.portlet.state.PortletClonedEvent;
-import org.jboss.portal.portlet.state.PortletModifiedEvent;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.StateEvent;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.impl.state.producer.ProducerPersistenceManagerService;
@@ -103,13 +100,13 @@
{
container.addPortlet("PortletId", portletSupport);
Portlet portlet = getSinglePOP();
- return new PortletContext(portlet.getId());
+ return portlet.getContext();
}
protected Object createNonExistingPOPRef()
{
container.addPortlet("NonExistingPortletId", new PortletInfoSupport());
- PortletContext popCtx = new PortletContext(getSinglePOP().getId());
+ PortletContext popCtx = getSinglePOP().getContext();
container.removePortlet("NonExistingPortletId");
return popCtx;
}
@@ -117,7 +114,7 @@
protected Object createInvalidPOPRef()
{
container.addPortlet("InvalidPortletId", new PortletInfoSupport());
- PortletContext popCtx = new PortletContext(getSinglePOP().getId());
+ PortletContext popCtx = getSinglePOP().getContext();
container.setValid("InvalidPortletId", false);
return popCtx;
}
@@ -168,7 +165,7 @@
}
else
{
- return producer.getPortlet(((PortletContext)portletRef).getId());
+ return producer.getPortlet((PortletContext)portletRef);
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/ServiceDescriptionTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/ServiceDescriptionTestCase.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/ServiceDescriptionTestCase.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -22,6 +22,7 @@
package org.jboss.portal.test.wsrp.v1.consumer;
import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
import java.util.Set;
@@ -50,17 +51,17 @@
Portlet p1 = portletArray[0];
Portlet p2 = portletArray[1];
- assertTrue((p1.getId().equals(SOF.PORTLET_HANDLE_1) && p2.getId().equals(SOF.PORTLET_HANDLE_2)) ||
- (p2.getId().equals(SOF.PORTLET_HANDLE_1) && p1.getId().equals(SOF.PORTLET_HANDLE_2)));
+ assertTrue((p1.getContext().getId().equals(SOF.PORTLET_HANDLE_1) && p2.getContext().getId().equals(SOF.PORTLET_HANDLE_2)) ||
+ (p2.getContext().getId().equals(SOF.PORTLET_HANDLE_1) && p1.getContext().getId().equals(SOF.PORTLET_HANDLE_2)));
}
public void testGetPortlet() throws Exception
{
//obtain one portlet
- Portlet portlet = consumer.getPortlet(SOF.PORTLET_HANDLE_1);
+ Portlet portlet = consumer.getPortlet(new PortletContext(SOF.PORTLET_HANDLE_1));
checkPortlet(portlet, "", SOF.PORTLET_HANDLE_1);
- portlet = consumer.getPortlet(SOF.PORTLET_HANDLE_2);
+ portlet = consumer.getPortlet(new PortletContext(SOF.PORTLET_HANDLE_2));
checkPortlet(portlet, "2", SOF.PORTLET_HANDLE_2);
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -38,7 +38,7 @@
protected void checkPortlet(Portlet portlet, String suffix, String handle)
{
MetaInfo meta = portlet.getInfo().getMeta();
- assertEquals(handle, portlet.getId());
+ assertEquals(handle, portlet.getContext().getId());
assertEquals(SOF.SAMPLE_DESCRIPTION + suffix, SOF.extractString(meta.getMetaValue(MetaInfo.DESCRIPTION)));
assertEquals(SOF.SAMPLE_TITLE + suffix, SOF.extractString(meta.getMetaValue(MetaInfo.TITLE)));
assertEquals(SOF.SAMPLE_SHORTTITLE + suffix, SOF.extractString(meta.getMetaValue(MetaInfo.SHORT_TITLE)));
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -148,8 +148,17 @@
}
}
- public Portlet getPortlet(String portletId) throws PortletInvokerException
+ public Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
{
+ if (portletContext == null)
+ {
+ throw new IllegalArgumentException("No null portlet context accepted");
+ }
+ return getPortlet(portletContext.getId());
+ }
+
+ private Portlet getPortlet(String portletId) throws PortletInvokerException
+ {
if (portletId == null)
{
throw new IllegalArgumentException("No null portlet id accepted");
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/WSRPPortlet.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/WSRPPortlet.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/WSRPPortlet.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -22,6 +22,7 @@
package org.jboss.portal.wsrp.consumer.portlet;
import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.wsrp.consumer.portlet.info.WSRPPortletInfo;
@@ -55,9 +56,9 @@
/** Portlet interface implemented methods */
- public String getId()
+ public PortletContext getContext()
{
- return id;
+ return new PortletContext(id);
}
public PortletInfo getInfo()
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -189,8 +189,7 @@
WSRPUtils.getJSR168WindowStateFromWSRPName(markupRequest.getWindowState()));
RenderInvocation render = new RenderInvocation(renderContext);
renderContext.contextualize(render);
- render.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE,
- new org.jboss.portal.portlet.PortletContext(portlet.getId()));
+ render.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portlet.getContext());
try
{
@@ -284,7 +283,7 @@
final Portlet portlet;
try
{
- portlet = invoker.getPortlet(portletHandle);
+ portlet = invoker.getPortlet(new org.jboss.portal.portlet.PortletContext(portletHandle));
}
catch (PortletInvokerException e)
{
@@ -362,8 +361,7 @@
markupRequest.getCharacterSet(), markupRequest.getMimeType());
ActionInvocation invocation = new ActionInvocation(context);
context.contextualize(invocation);
- invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE,
- new org.jboss.portal.portlet.PortletContext(portlet.getId()));
+ invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portlet.getContext());
try
{
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -122,7 +122,7 @@
for (Iterator iterator = portlets.iterator(); iterator.hasNext();)
{
Portlet portlet = (Portlet)iterator.next();
- PortletDescription desc = createPortletDescriptionFrom(portlet.getInfo(), desiredLocales, portlet.getId());
+ PortletDescription desc = createPortletDescriptionFrom(portlet.getInfo(), desiredLocales, portlet.getContext().getId());
offeredPortletDescriptions.add(desc);
}
@@ -140,7 +140,7 @@
{
throw WSRPUtils.createOperationFailedFault(e);
}
- return createPortletDescriptionFrom(portlet.getInfo(), desiredLocales, portlet.getId());
+ return createPortletDescriptionFrom(portlet.getInfo(), desiredLocales, portlet.getContext().getId());
}
/**
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-09-18 22:34:16 UTC (rev 5225)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-09-19 17:37:18 UTC (rev 5226)
@@ -380,7 +380,7 @@
Portlet portlet;
try
{
- portlet = invoker.getPortlet(handle);
+ portlet = invoker.getPortlet(new org.jboss.portal.portlet.PortletContext(handle));
}
catch (NoSuchPortletException e)
{
@@ -404,11 +404,11 @@
for (Iterator iterator = allPortlets.iterator(); iterator.hasNext();)
{
Portlet portlet = (Portlet)iterator.next();
- log.debug("Found portlet: " + portlet.getId());
+ log.debug("Found portlet: " + portlet.getContext());
if (isRemotable(portlet))
{
remotablePortlets.add(portlet);
- log.debug("Adding remotable portlet to set: " + portlet.getId());
+ log.debug("Adding remotable portlet to set: " + portlet.getContext());
}
}
return remotablePortlets;
@@ -548,7 +548,7 @@
{
PortletInfo portletInfo = portlet.getInfo();
Boolean remotable = portletInfo.isRemotable();
- log.debug("Portlet " + portlet.getId() + " remotable: " + remotable);
+ log.debug("Portlet " + portlet.getContext() + " remotable: " + remotable);
if (remotable != null)
{
More information about the jboss-svn-commits
mailing list