Author: julien(a)jboss.com
Date: 2007-02-05 09:12:51 -0500 (Mon, 05 Feb 2007)
New Revision: 6151
Added:
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/LocalPortletInvoker.java
Modified:
trunk/build/ide/intellij/idea60/modules/registration/registration.iml
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletState.java
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/StateManagementPolicyImpl.java
trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java
trunk/core/src/resources/portal-core-sar/conf/hibernate/portlet/domain.hbm.xml
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/state/jboss-beans.xml
trunk/portlet-federation/src/main/org/jboss/portal/portlet/federation/impl/FederatedPortlet.java
trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortlet.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/WSRPPortlet.java
Log:
started to implement test case of integration between portlet state manager and
registration objects
Modified: trunk/build/ide/intellij/idea60/modules/registration/registration.iml
===================================================================
--- trunk/build/ide/intellij/idea60/modules/registration/registration.iml 2007-02-03
11:08:49 UTC (rev 6150)
+++ trunk/build/ide/intellij/idea60/modules/registration/registration.iml 2007-02-05
14:12:51 UTC (rev 6151)
@@ -5,7 +5,6 @@
<exclude-output />
<content url="file://$MODULE_DIR$/../../../../../../registration">
<sourceFolder
url="file://$MODULE_DIR$/../../../../../../registration/src/main"
isTestSource="false" />
- <sourceFolder
url="file://$MODULE_DIR$/../../../../../../registration/src/main/org/jboss/portal/test"
isTestSource="true" />
<excludeFolder
url="file://$MODULE_DIR$/../../../../../../registration/output" />
</content>
<orderEntry type="inheritedJdk" />
Added:
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/LocalPortletInvoker.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/LocalPortletInvoker.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/LocalPortletInvoker.java 2007-02-05
14:12:51 UTC (rev 6151)
@@ -0,0 +1,184 @@
+/******************************************************************************
+ * 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.core.impl.portlet.state;
+
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.Portlet;
+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.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+
+import java.util.Set;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LocalPortletInvoker implements PortletInvoker
+{
+
+ /** . */
+ private static final ThreadLocal local = new ThreadLocal();
+
+ /** . */
+ private PortletInvoker portletInvoker;
+
+ public PortletInvoker getPortletInvoker()
+ {
+ return portletInvoker;
+ }
+
+ public void setPortletInvoker(PortletInvoker portletInvoker)
+ {
+ this.portletInvoker = portletInvoker;
+ }
+
+ public static boolean isLocal()
+ {
+ return Boolean.TRUE.equals(local.get());
+ }
+
+ public Set getPortlets() throws PortletInvokerException
+ {
+ try
+ {
+ local.set(Boolean.TRUE);
+
+ //
+ return portletInvoker.getPortlets();
+ }
+ finally
+ {
+ local.set(null);
+ }
+ }
+
+ public Portlet getPortlet(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException
+ {
+ try
+ {
+ local.set(Boolean.TRUE);
+
+ //
+ return portletInvoker.getPortlet(portletContext);
+ }
+ finally
+ {
+ local.set(null);
+ }
+ }
+
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws
IllegalArgumentException, PortletInvokerException
+ {
+ try
+ {
+ local.set(Boolean.TRUE);
+
+ //
+ return portletInvoker.invoke(invocation);
+ }
+ finally
+ {
+ local.set(null);
+ }
+ }
+
+ public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ try
+ {
+ local.set(Boolean.TRUE);
+
+ //
+ return portletInvoker.createClone(portletContext);
+ }
+ finally
+ {
+ local.set(null);
+ }
+ }
+
+ public List destroyClones(List portletContexts) throws IllegalArgumentException,
PortletInvokerException, UnsupportedOperationException
+ {
+ try
+ {
+ local.set(Boolean.TRUE);
+
+ //
+ return portletInvoker.destroyClones(portletContexts);
+ }
+ finally
+ {
+ local.set(null);
+ }
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext, Set keys) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ try
+ {
+ local.set(Boolean.TRUE);
+
+ //
+ return portletInvoker.getProperties(portletContext, keys);
+ }
+ finally
+ {
+ local.set(null);
+ }
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ try
+ {
+ local.set(Boolean.TRUE);
+
+ //
+ return portletInvoker.getProperties(portletContext);
+ }
+ finally
+ {
+ local.set(null);
+ }
+ }
+
+ public PortletContext setProperties(PortletContext portletContext, PropertyChange[]
changes) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ try
+ {
+ local.set(Boolean.TRUE);
+
+ //
+ return portletInvoker.setProperties(portletContext, changes);
+ }
+ finally
+ {
+ local.set(null);
+ }
+ }
+}
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletState.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletState.java 2007-02-03
11:08:49 UTC (rev 6150)
+++
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletState.java 2007-02-05
14:12:51 UTC (rev 6151)
@@ -59,7 +59,7 @@
protected Date terminationTime;
/** For now a registration id, later probably a one to many relationship with a
registration entry. */
- protected Long registrationId;
+ protected PersistentRegistration relatedRegistration;
/** The clones of this state. */
protected Set children;
@@ -77,7 +77,7 @@
this.entries = null;
this.creationTime = null;
this.terminationTime = null;
- this.registrationId = null;
+ this.relatedRegistration = null;
this.children = null;
this.parent = null;
this.ctx = null;
@@ -90,7 +90,7 @@
this.entries = new HashMap();
this.creationTime = Calendar.getInstance().getTime();
this.terminationTime = null;
- this.registrationId = null;
+ this.relatedRegistration = null;
this.children = new HashSet();
this.parent = null;
this.ctx = null;
@@ -159,14 +159,14 @@
this.terminationTime = terminationTime;
}
- public Long getRegistrationId()
+ public PersistentRegistration getRelatedRegistration()
{
- return registrationId;
+ return relatedRegistration;
}
- public void setRegistrationId(Long registrationId)
+ public void setRelatedRegistration(PersistentRegistration relatedRegistration)
{
- this.registrationId = registrationId;
+ this.relatedRegistration = relatedRegistration;
}
public Set getChildren()
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java 2007-02-03
11:08:49 UTC (rev 6150)
+++
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java 2007-02-05
14:12:51 UTC (rev 6151)
@@ -42,6 +42,7 @@
import org.jboss.portal.registration.RegistrationException;
import org.jboss.portal.registration.RegistrationPersistenceManager;
import org.jboss.portal.registration.RegistrationStatus;
+import org.jboss.portal.registration.RegistrationLocal;
import javax.naming.InitialContext;
import java.util.Collection;
@@ -96,7 +97,17 @@
// Create the persistent state
PersistentPortletState context = new PersistentPortletState(portletId,
propertyMap);
- session.save(context);
+ session.persist(context);
+
+ // Create relationship with registration if it exists
+ PersistentRegistration registration =
(PersistentRegistration)RegistrationLocal.getRegistration();
+ if (registration != null)
+ {
+ registration.getRelatedPortletStates().add(context);
+ context.setRelatedRegistration(registration);
+ }
+
+ //
session.flush();
//
@@ -127,6 +138,14 @@
parentContext.getChildren().add(context);
session.update(parentContext);
+ // Create relationship with registration if it exists
+ PersistentRegistration registration =
(PersistentRegistration)RegistrationLocal.getRegistration();
+ if (registration != null)
+ {
+ registration.getRelatedPortletStates().add(context);
+ context.setRelatedRegistration(registration);
+ }
+
//
session.flush();
@@ -154,6 +173,14 @@
parentContext.getChildren().add(context);
session.update(parentContext);
+ // Create relationship with registration if it exists
+ PersistentRegistration registration =
(PersistentRegistration)RegistrationLocal.getRegistration();
+ if (registration != null)
+ {
+ registration.getRelatedPortletStates().add(context);
+ context.setRelatedRegistration(registration);
+ }
+
//
session.flush();
@@ -196,6 +223,14 @@
Query query = session.createQuery(update).setLong("parent",
context.getKey().longValue());
query.executeUpdate();
+ // Destroy any relationship with registration
+ PersistentRegistration registration = context.getRelatedRegistration();
+ if (registration != null)
+ {
+ registration.getRelatedPortletStates().remove(context);
+ context.setRelatedRegistration(null);
+ }
+
// Delete the state
session.delete(context);
session.flush();
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java 2007-02-03
11:08:49 UTC (rev 6150)
+++
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java 2007-02-05
14:12:51 UTC (rev 6151)
@@ -31,6 +31,8 @@
import javax.xml.namespace.QName;
import java.util.Collections;
import java.util.Map;
+import java.util.HashSet;
+import java.util.Set;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -49,6 +51,7 @@
// Relationships
private PersistentConsumer relatedConsumer;
+ private Set relatedPortletStates;
// Wrapper
@@ -63,6 +66,7 @@
this.persistentStatus = null;
this.persistentProperties = null;
this.properties = new Properties();
+ this.relatedPortletStates = null;
}
public PersistentRegistration(Map properties, RegistrationStatus status)
@@ -73,6 +77,7 @@
this.persistentStatus = status;
this.persistentProperties = properties;
this.properties = new Properties();
+ this.relatedPortletStates = new HashSet();
// Perform properties validation
this.properties.validate();
@@ -90,6 +95,16 @@
this.key = key;
}
+ public Set getRelatedPortletStates()
+ {
+ return relatedPortletStates;
+ }
+
+ public void setRelatedPortletStates(Set relatedPortletStates)
+ {
+ this.relatedPortletStates = relatedPortletStates;
+ }
+
public String getPersistentHandle()
{
return persistentHandle;
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/StateManagementPolicyImpl.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/StateManagementPolicyImpl.java 2007-02-03
11:08:49 UTC (rev 6150)
+++
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/StateManagementPolicyImpl.java 2007-02-05
14:12:51 UTC (rev 6151)
@@ -22,7 +22,6 @@
******************************************************************************/
package org.jboss.portal.core.impl.portlet.state;
-import org.jboss.portal.portlet.aspects.portlet.LocalInterceptor;
import org.jboss.portal.portlet.state.StateManagementPolicy;
import org.jboss.portal.registration.Registration;
import org.jboss.portal.registration.RegistrationLocal;
@@ -38,18 +37,16 @@
{
public boolean persistLocally()
{
- boolean local = LocalInterceptor.isLocal();
+ // Otherwise the optional registration from the wsrp layer
+ Registration registration = RegistrationLocal.getRegistration();
- // If this is a local call we persist locally
- if (local)
+ // Persist locally if we are in the scope of an existing registration
+ if (registration != null)
{
return true;
}
- // Otherwise the optional registration from the wsrp layer
- Registration registration = RegistrationLocal.getRegistration();
-
- // And persist locally only in the scope of an existing registration
- return registration != null;
+ // Otherwise if this is a local call we persist locally
+ return LocalPortletInvoker.isLocal();
}
}
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 2007-02-03
11:08:49 UTC (rev 6150)
+++ trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java 2007-02-05
14:12:51 UTC (rev 6151)
@@ -40,9 +40,12 @@
import org.jboss.portal.core.impl.portlet.state.PersistentRegistration;
import
org.jboss.portal.core.impl.portlet.state.PersistentPortletStatePersistenceManager;
import org.jboss.portal.core.impl.portlet.state.ProducerPortletInvoker;
+import org.jboss.portal.core.impl.portlet.state.PersistentPortletState;
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.info.MetaInfo;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -63,6 +66,10 @@
import org.jboss.portal.portlet.test.support.PortletInvokerSupport;
import org.jboss.portal.portlet.test.support.PortletSupport;
import org.jboss.portal.registration.RegistrationStatus;
+import org.jboss.portal.registration.RegistrationLocal;
+import org.jboss.portal.registration.ConsumerGroup;
+import org.jboss.portal.registration.Consumer;
+import org.jboss.portal.registration.Registration;
import org.jboss.portal.test.framework.TestRuntimeContext;
import org.jboss.portal.test.framework.embedded.DataSourceSupport;
import org.jboss.portal.test.framework.embedded.HibernateSupport;
@@ -72,6 +79,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -100,6 +108,9 @@
return suite;
}
+ /** Whether we test registration or not. */
+ private boolean userRegistration;
+
/** . */
private TestRuntimeContext runtimeContext;
@@ -118,6 +129,9 @@
/** . */
private PortletInvokerSupport portletContainer;
+ /** . */
+ private PortletInvoker portletInvoker;
+
public String getName()
{
return super.getName() + ",ds=" + dataSourceConfigParameter.getName();
@@ -173,6 +187,16 @@
this.dataSourceConfigParameter = dataSourceConfigParameter;
}
+ public PortletInvoker getPortletInvoker()
+ {
+ return portletInvoker;
+ }
+
+ public void setPortletInvoker(PortletInvoker portletInvoker)
+ {
+ this.portletInvoker = portletInvoker;
+ }
+
public void setUp() throws Exception
{
runtimeContext = new
TestRuntimeContext("org/jboss/portal/test/core/state/jboss-beans.xml");
@@ -254,9 +278,47 @@
// Cleanup any pending transaction
TransactionAssert.endTransaction();
+ //
runtimeContext.stop();
}
+ private PortletContext clonePortlet(PortletContext context) throws
PortletInvokerException
+ {
+ TransactionAssert.beginTransaction();
+ PortletContext cloneCtx = portletInvoker.createClone(context);
+ TransactionAssert.commitTransaction();
+ return cloneCtx;
+ }
+
+ public void _testCloneNonExistingPortletWithinTx() throws Exception
+ {
+ try
+ {
+ TransactionAssert.beginTransaction();
+
portletInvoker.createClone(PortletContext.createPortletContext("UnknownPortlet"));
+ fail("Was expecting no such portlet exception");
+ }
+ catch (NoSuchPortletException e)
+ {
+ TransactionAssert.rollbackTransaction(true);
+ }
+
+ // todo check state
+
+// try
+// {
+// TransactionAssert.beginTransaction();
+// statefulPortletInvoker.createClone("_1");
+// fail("Was expecting no such portlet exception");
+// }
+// catch (NoSuchPortletException e)
+// {
+// TransactionAssert.rollbackTransaction(true);
+// }
+
+ // todo check state
+ }
+
public void testABC()
{
TransactionAssert.beginTransaction();
@@ -281,33 +343,50 @@
TransactionAssert.commitTransaction();
}
- public void _testCloneNonExistingPortletWithinTx() throws Exception
+ private String createrRegistration() throws Exception
{
+ Map registrationProperties = new HashMap();
+ registrationProperties.put(new QName("prop1"), "value1");
+ registrationProperties.put(new QName("prop2"), "value2");
+
+ TransactionAssert.beginTransaction();
+ ConsumerGroup cg = persistenceManager.createConsumerGroup("CG");
+ Consumer consumer = persistenceManager.createConsumer("fooConsumer",
"fooConsumer");
+ cg.addConsumer(consumer);
+ Registration reg = persistenceManager.addRegistrationFor("fooConsumer",
registrationProperties);
+ String regId = reg.getId();
+ TransactionAssert.commitTransaction();
+ return regId;
+ }
+
+ public void testCloneExistingPortletWithinTxWithRegistration() throws Exception
+ {
+ String regId = createrRegistration();
+
+ // Clone a POP
+ PortletContext cloneCtx = null;
try
{
TransactionAssert.beginTransaction();
-
producer.createClone(PortletContext.createPortletContext("UnknownPortlet"));
- fail("Was expecting no such portlet exception");
+ Registration reg = persistenceManager.getRegistration(regId);
+ assertNotNull(reg);
+ RegistrationLocal.setRegistration(reg);
+ cloneCtx =
portletInvoker.createClone(PortletContext.createPortletContext("SimplePortlet"));
+ TransactionAssert.commitTransaction();
}
- catch (NoSuchPortletException e)
+ finally
{
- TransactionAssert.rollbackTransaction(true);
+ RegistrationLocal.setRegistration(null);
}
- // todo check state
-
-// try
-// {
-// TransactionAssert.beginTransaction();
-// statefulPortletInvoker.createClone("_1");
-// fail("Was expecting no such portlet exception");
-// }
-// catch (NoSuchPortletException e)
-// {
-// TransactionAssert.rollbackTransaction(true);
-// }
-
- // todo check state
+ // Lookup
+ TransactionAssert.beginTransaction();
+ PersistentPortletState state =
(PersistentPortletState)persistenceManager.loadState(cloneCtx.getId().substring(1));
+ PersistentRegistration registration = state.getRelatedRegistration();
+ assertNotNull(registration);
+ assertNotNull(state);
+ assertEquals(regId, state.getId());
+ TransactionAssert.commitTransaction();
}
public void testCloneNullPortletWithinTx() throws Exception
@@ -315,7 +394,7 @@
try
{
TransactionAssert.beginTransaction();
- producer.createClone(null);
+ portletInvoker.createClone(null);
fail("Was expecting an IllegalArgumentException");
}
catch (IllegalArgumentException expected)
@@ -327,9 +406,7 @@
public void testCloneExistingPortletWithinTx() throws Exception
{
// Clone a POP
- TransactionAssert.beginTransaction();
- PortletContext cloneCtx =
producer.createClone(PortletContext.createPortletContext("SimplePortlet"));
- TransactionAssert.commitTransaction();
+ PortletContext cloneCtx =
clonePortlet(PortletContext.createPortletContext("SimplePortlet"));
// Check the clone state
TransactionAssert.beginTransaction();
@@ -353,9 +430,7 @@
TransactionAssert.commitTransaction();
// Clone the modified CCP
- TransactionAssert.beginTransaction();
- PortletContext cloneCloneCtx = producer.createClone(cloneCtx);
- TransactionAssert.commitTransaction();
+ PortletContext cloneCloneCtx = clonePortlet(cloneCtx);
// Check the clone clone state
TransactionAssert.beginTransaction();
@@ -375,7 +450,7 @@
public void testDestroyNonExistingPortletWithinTx() throws Exception
{
TransactionAssert.beginTransaction();
- List failures =
producer.destroyClones(Collections.singletonList(PortletContext.createPortletContext("_1")));
+ List failures =
portletInvoker.destroyClones(Collections.singletonList(PortletContext.createPortletContext("_1")));
assertEquals(Collections.singletonList(new DestroyCloneFailure("_1")),
failures);
TransactionAssert.commitTransaction();
}
@@ -385,7 +460,7 @@
try
{
TransactionAssert.beginTransaction();
- producer.destroyClones(null);
+ portletInvoker.destroyClones(null);
fail("Was expecting an IllegalArgumentException");
}
catch (IllegalArgumentException expected)
@@ -413,38 +488,34 @@
public void testDestroyCCPWithinTx() throws Exception
{
// Clone a POP 2 times
- TransactionAssert.beginTransaction();
- PortletContext cloneId1 =
producer.createClone(PortletContext.createPortletContext("SimplePortlet"));
- PortletContext cloneId2 =
producer.createClone(PortletContext.createPortletContext("SimplePortlet"));
- TransactionAssert.commitTransaction();
+ PortletContext cloneId1 =
clonePortlet(PortletContext.createPortletContext("SimplePortlet"));
+ PortletContext cloneId2 =
clonePortlet(PortletContext.createPortletContext("SimplePortlet"));
// Clone the modified CCP 2 times
- TransactionAssert.beginTransaction();
- PortletContext cloneCloneId1 = producer.createClone(cloneId1);
- PortletContext cloneCloneId2 = producer.createClone(cloneId1);
- TransactionAssert.commitTransaction();
+ PortletContext cloneCloneId1 = clonePortlet(cloneId1);
+ PortletContext cloneCloneId2 = clonePortlet(cloneId1);
// Destroy the clone 2
TransactionAssert.beginTransaction();
- List failures = producer.destroyClones(Collections.singletonList(cloneId2));
+ List failures = portletInvoker.destroyClones(Collections.singletonList(cloneId2));
assertEquals(Collections.EMPTY_LIST, failures);
TransactionAssert.commitTransaction();
// Destroy the clone of the clone 2
TransactionAssert.beginTransaction();
- failures = producer.destroyClones(Collections.singletonList(cloneCloneId2));
+ failures = portletInvoker.destroyClones(Collections.singletonList(cloneCloneId2));
assertEquals(Collections.EMPTY_LIST, failures);
TransactionAssert.commitTransaction();
// Destroy the clone 1
TransactionAssert.beginTransaction();
- failures = producer.destroyClones(Collections.singletonList(cloneId1));
+ failures = portletInvoker.destroyClones(Collections.singletonList(cloneId1));
assertEquals(Collections.EMPTY_LIST, failures);
TransactionAssert.commitTransaction();
// Destroy the clone of the clone 1
TransactionAssert.beginTransaction();
- failures = producer.destroyClones(Collections.singletonList(cloneCloneId1));
+ failures = portletInvoker.destroyClones(Collections.singletonList(cloneCloneId1));
assertEquals(Collections.EMPTY_LIST, failures);
TransactionAssert.commitTransaction();
}
@@ -457,7 +528,7 @@
action.setUserContext(new UserContextImpl("julien"));
InstanceContextImpl instanceContext = new InstanceContextImpl("whatever",
AccessMode.CLONE_BEFORE_WRITE);
action.setInstanceContext(instanceContext);
- producer.invoke(action);
+ portletInvoker.invoke(action);
TransactionAssert.commitTransaction();
// Check state
@@ -484,7 +555,7 @@
action.setUserContext(new UserContextImpl("julien"));
InstanceContextImpl instanceContext = new InstanceContextImpl("whatever",
AccessMode.READ_WRITE);
action.setInstanceContext(instanceContext);
- producer.invoke(action);
+ portletInvoker.invoke(action);
TransactionAssert.commitTransaction();
// Check state
@@ -502,7 +573,7 @@
action.setUserContext(new UserContextImpl("julien"));
InstanceContextImpl instanceContext = new InstanceContextImpl("whatever",
AccessMode.READ_ONLY);
action.setInstanceContext(instanceContext);
- producer.invoke(action);
+ portletInvoker.invoke(action);
TransactionAssert.commitTransaction();
// Check state
@@ -513,9 +584,7 @@
public void testInvokeCloneBeforeWriteCCPWithinTx() throws Exception
{
- TransactionAssert.beginTransaction();
- PortletContext cloningPortletId =
producer.createClone(PortletContext.createPortletContext("CloningPortlet"));
- TransactionAssert.commitTransaction();
+ PortletContext cloningPortletId =
clonePortlet(PortletContext.createPortletContext("CloningPortlet"));
// Modify the state of the CCP
TransactionAssert.beginTransaction();
@@ -532,7 +601,7 @@
action.setUserContext(new UserContextImpl("julien"));
InstanceContextImpl instanceContext = new InstanceContextImpl("whatever",
AccessMode.CLONE_BEFORE_WRITE);
action.setInstanceContext(instanceContext);
- producer.invoke(action);
+ portletInvoker.invoke(action);
TransactionAssert.commitTransaction();
// Check state
@@ -552,9 +621,7 @@
public void testInvokeReadWriteCCPWithinTx() throws Exception
{
- TransactionAssert.beginTransaction();
- PortletContext cloningPortletId =
producer.createClone(PortletContext.createPortletContext("CloningPortlet"));
- TransactionAssert.commitTransaction();
+ PortletContext cloningPortletId =
clonePortlet(PortletContext.createPortletContext("CloningPortlet"));
//
TransactionAssert.beginTransaction();
@@ -563,7 +630,7 @@
action.setUserContext(new UserContextImpl("julien"));
InstanceContextImpl instanceContext = new InstanceContextImpl("whatever",
AccessMode.READ_WRITE);
action.setInstanceContext(instanceContext);
- producer.invoke(action);
+ portletInvoker.invoke(action);
TransactionAssert.commitTransaction();
// Check state
@@ -582,9 +649,7 @@
public void testInvokeReadOnlyCCPWithinTx() throws Exception
{
- TransactionAssert.beginTransaction();
- PortletContext cloneFailedCloningPortletId =
producer.createClone(PortletContext.createPortletContext("CloneFailedCloningPortlet"));
- TransactionAssert.commitTransaction();
+ PortletContext cloneFailedCloningPortletId =
clonePortlet(PortletContext.createPortletContext("CloneFailedCloningPortlet"));
//
TransactionAssert.beginTransaction();
@@ -593,7 +658,7 @@
action.setUserContext(new UserContextImpl("julien"));
InstanceContextImpl instanceContext = new InstanceContextImpl("whatever",
AccessMode.READ_ONLY);
action.setInstanceContext(instanceContext);
- producer.invoke(action);
+ portletInvoker.invoke(action);
TransactionAssert.commitTransaction();
// Check state
@@ -613,7 +678,7 @@
action.setInstanceContext(instanceContext);
try
{
- producer.invoke(action);
+ portletInvoker.invoke(action);
fail("Was expecting RuntimeException");
}
catch (RuntimeException expected)
@@ -633,34 +698,25 @@
}
- public void _testSetProperties()
- {
-
- }
-
/** todo : should check the portlet metadata as well */
public void testGetCCP() throws Exception
{
// Clone a POP
- TransactionAssert.beginTransaction();
- PortletContext cloneContext =
producer.createClone(PortletContext.createPortletContext("SimplePortlet"));
- TransactionAssert.commitTransaction();
+ PortletContext cloneContext =
clonePortlet(PortletContext.createPortletContext("SimplePortlet"));
//
TransactionAssert.beginTransaction();
- Portlet portlet = producer.getPortlet(cloneContext);
+ Portlet portlet = portletInvoker.getPortlet(cloneContext);
assertEquals(cloneContext, portlet.getContext());
assertEquals("SimplePortlet",
portlet.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString());
TransactionAssert.commitTransaction();
// Clone the modified CCP
- TransactionAssert.beginTransaction();
- PortletContext cloneCloneContext = producer.createClone(cloneContext);
- TransactionAssert.commitTransaction();
+ PortletContext cloneCloneContext = clonePortlet(cloneContext);
//
TransactionAssert.beginTransaction();
- portlet = producer.getPortlet(cloneCloneContext);
+ portlet = portletInvoker.getPortlet(cloneCloneContext);
assertEquals(cloneCloneContext, portlet.getContext());
assertEquals("SimplePortlet",
portlet.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString());
TransactionAssert.commitTransaction();
Modified: trunk/core/src/resources/portal-core-sar/conf/hibernate/portlet/domain.hbm.xml
===================================================================
---
trunk/core/src/resources/portal-core-sar/conf/hibernate/portlet/domain.hbm.xml 2007-02-03
11:08:49 UTC (rev 6150)
+++
trunk/core/src/resources/portal-core-sar/conf/hibernate/portlet/domain.hbm.xml 2007-02-05
14:12:51 UTC (rev 6151)
@@ -43,11 +43,11 @@
column="PORTLET_ID"
not-null="true"
unique="false"/>
- <property
- name="registrationId"
+ <many-to-one
+ name="relatedRegistration"
column="REGISTRATION_ID"
- not-null="false"
- unique="false"/>
+
class="org.jboss.portal.core.impl.portlet.state.PersistentRegistration"
+ not-null="false"/>
<property
name="creationTime"
column="REGISTRATION_TIME"
@@ -253,5 +253,15 @@
class="org.jboss.portal.core.impl.portlet.state.PersistentConsumer"
not-null="true"
update="false"/>
+ <set
+ name="relatedPortletStates"
+ inverse="true"
+ cascade="save-update"
+ fetch="select"
+ lazy="extra">
+ <cache usage="@portal.hibernate.cache.usage(a)"/>
+ <key column="REGISTRATION_ID"/>
+ <one-to-many
class="org.jboss.portal.core.impl.portlet.state.PersistentPortletState"/>
+ </set>
</class>
</hibernate-mapping>
Modified:
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/state/jboss-beans.xml
===================================================================
---
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/state/jboss-beans.xml 2007-02-03
11:08:49 UTC (rev 6150)
+++
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/state/jboss-beans.xml 2007-02-05
14:12:51 UTC (rev 6151)
@@ -70,8 +70,7 @@
<bean name="StateConverter"
class="org.jboss.portal.portlet.impl.state.StateConverterService">
</bean>
- <bean name="StateManagementPolicy"
class="org.jboss.portal.portlet.impl.state.StateManagementPolicyService">
- <property name="persistLocally">true</property>
+ <bean name="StateManagementPolicy"
class="org.jboss.portal.core.impl.portlet.state.StateManagementPolicyImpl">
</bean>
<bean name="PersistenceManager"
class="org.jboss.portal.core.impl.portlet.state.PersistentPortletStatePersistenceManager">
@@ -88,6 +87,29 @@
<property name="stateConverter"><inject
bean="StateConverter"/></property>
</bean>
+<!--
+ <bean name="LocalInterceptor"
class="org.jboss.portal.portlet.aspects.portlet.LocalInterceptor">
+ </bean>
+
+ <bean name="InterceptorStack"
class="org.jboss.portal.server.impl.invocation.JBossInterceptorStack">
+ <constructor>
+ <parameter><array
class="[Lorg.jboss.portal.common.invocation.Interceptor;"
elementClass="org.jboss.portal.common.invocation.Interceptor">
+ <inject bean="LocalInterceptor"/>
+ </array></parameter>
+ </constructor>
+ </bean>
+
+ <bean name="InterceptorStackFactory"
class="org.jboss.portal.server.impl.invocation.JBossInterceptorStackFactory">
+ <constructor>
+ <parameter><inject
bean="InterceptorStack"/></parameter>
+ </constructor>
+ </bean>
+-->
+
+ <bean name="PortletInvoker"
class="org.jboss.portal.core.impl.portlet.state.LocalPortletInvoker">
+ <property name="portletInvoker"><inject
bean="Producer"/></property>
+ </bean>
+
<bean name="TestBean"
class="org.jboss.portal.test.core.state.ProducerTestCase">
<constructor factoryMethod="getBean">
<factory bean="BeanFactory"/>
@@ -97,5 +119,6 @@
<property name="persistenceManager"><inject
bean="PersistenceManager"/></property>
<property name="producer"><inject
bean="Producer"/></property>
<property name="portletContainer"><inject
bean="PortletContainer"/></property>
+ <property name="portletInvoker"><inject
bean="PortletInvoker"/></property>
</bean>
</deployment>
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortlet.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortlet.java 2007-02-03
11:08:49 UTC (rev 6150)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortlet.java 2007-02-05
14:12:51 UTC (rev 6151)
@@ -59,4 +59,9 @@
{
return delegate.isRemote();
}
+
+ public String toString()
+ {
+ return "ProducerPortlet[" + context + ",delegate=" + delegate +
"]";
+ }
}
Modified:
trunk/portlet-federation/src/main/org/jboss/portal/portlet/federation/impl/FederatedPortlet.java
===================================================================
---
trunk/portlet-federation/src/main/org/jboss/portal/portlet/federation/impl/FederatedPortlet.java 2007-02-03
11:08:49 UTC (rev 6150)
+++
trunk/portlet-federation/src/main/org/jboss/portal/portlet/federation/impl/FederatedPortlet.java 2007-02-05
14:12:51 UTC (rev 6151)
@@ -67,4 +67,9 @@
{
return portlet.isRemote();
}
+
+ public String toString()
+ {
+ return "FederatedPortlet[context=" + compoundContext +
",portlet=" + portlet + "]";
+ }
}
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 2007-02-03
11:08:49 UTC (rev 6150)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/WSRPPortlet.java 2007-02-05
14:12:51 UTC (rev 6151)
@@ -90,4 +90,10 @@
ParameterValidation.throwIllegalArgExceptionIfNull(context,
"PortletContext");
this.portletContext = context;
}
+
+
+ public String toString()
+ {
+ return "WSRPPortlet[context=" + portletContext + "]";
+ }
}