Author: chris.laprun(a)jboss.com
Date: 2011-04-11 06:29:34 -0400 (Mon, 11 Apr 2011)
New Revision: 6187
Modified:
components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletContext.java
components/pc/trunk/api/src/main/java/org/gatein/pc/api/StatefulPortletContext.java
components/pc/trunk/api/src/test/java/org/gatein/pc/api/PortletContextTestCase.java
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java
components/pc/trunk/federation/src/test/java/org/gatein/pc/federation/FederatingPortletInvokerTestCase.java
Log:
- GTNPC-58:
+ Moved logic for federated portlet context creation to PortletContext. Still needs to
be better abstracted (in particular, reference and dereference methods).
+ Changed PortletContextComponents to an interface and introduced
UninterpretedPortletContextComponents so that now a PortletContext always has components,
interpreted or not.
Modified: components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletContext.java
===================================================================
--- components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletContext.java 2011-04-08
20:59:33 UTC (rev 6186)
+++ components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletContext.java 2011-04-11
10:29:34 UTC (rev 6187)
@@ -37,6 +37,8 @@
private static final String PREFIX = "/";
private static final char SEPARATOR = '.';
+ /** The separator used in the id to route to the correct invoker. */
+ public static final String INVOKER_SEPARATOR = "+";
public static final String PRODUCER_CLONE_ID_PREFIX = "_";
public static final int PRODUCER_CLONE_PREFIX_LENGTH =
PRODUCER_CLONE_ID_PREFIX.length();
@@ -47,10 +49,9 @@
public static final String CONSUMER_CLONE_DUMMY_STATE_ID = "dumbvalue";
public static final String CONSUMER_CLONE_ID = PRODUCER_CLONE_ID_PREFIX +
CONSUMER_CLONE_DUMMY_STATE_ID;
- public final static PortletContext LOCAL_CONSUMER_CLONE =
PortletContext.createPortletContext(PortletInvoker.LOCAL_PORTLET_INVOKER_ID + SEPARATOR +
CONSUMER_CLONE_ID);
+ public final static PortletContext LOCAL_CONSUMER_CLONE =
PortletContext.createPortletContext(PortletInvoker.LOCAL_PORTLET_INVOKER_ID +
INVOKER_SEPARATOR + CONSUMER_CLONE_ID);
public static final String INVALID_PORTLET_CONTEXT = "Invalid portlet context:
";
- protected final String id;
private final PortletContextComponents components;
protected PortletContext(String id) throws IllegalArgumentException
@@ -86,14 +87,14 @@
isSimpleAppPortlet = separator != -1 && appName.length() > 0
&& portletName.length() > 0;
if (isSimpleAppPortlet)
{
- components = new PortletContextComponents(null, appName, portletName,
null);
+ components = new InterpretedPortletContextComponents(null, appName,
portletName, null);
}
}
else
{
if (!(trimmedId.startsWith(PRODUCER_CLONE_ID_PREFIX) ||
trimmedId.startsWith(CONSUMER_CLONE_ID_PREFIX)))
{
- int invoker = trimmedId.indexOf(SEPARATOR);
+ int invoker = trimmedId.indexOf(INVOKER_SEPARATOR);
int prefix = trimmedId.indexOf(PREFIX);
if (prefix != -1)
@@ -113,7 +114,7 @@
isCompoundAppPortlet = invokerId.length() > 0 &&
applicationName.length() > 0 && portletName.length() > 0;
if (isCompoundAppPortlet)
{
- components = new PortletContextComponents(invokerId,
applicationName, portletName, null);
+ components = new
InterpretedPortletContextComponents(invokerId, applicationName, portletName, null);
}
}
}
@@ -139,13 +140,13 @@
if (portletNameOrStateId.length() > 0)
{
isCloned = true;
- components = new PortletContextComponents(invokerId,
null, portletNameOrStateId, isProducerClone);
+ components = new
InterpretedPortletContextComponents(invokerId, null, portletNameOrStateId,
isProducerClone);
}
}
else
{
isOpaquePortlet = true;
- components = new PortletContextComponents(invokerId, null,
portletNameOrStateId, null);
+ components = new
InterpretedPortletContextComponents(invokerId, null, portletNameOrStateId, null);
}
}
}
@@ -162,7 +163,7 @@
if (trimmedId.length() > 0)
{
isCloned = true;
- components = new PortletContextComponents(null, null, trimmedId,
isProducerClone);
+ components = new InterpretedPortletContextComponents(null, null,
trimmedId, isProducerClone);
}
}
}
@@ -173,6 +174,10 @@
throw new IllegalArgumentException(INVALID_PORTLET_CONTEXT + id, e);
}
}
+ else
+ {
+ components = new UninterpretedPortletContextComponents(id);
+ }
if (interpret && !(isSimpleAppPortlet || isCompoundAppPortlet ||
isOpaquePortlet || isCloned))
{
@@ -180,16 +185,47 @@
}
this.components = components;
- this.id = components != null ? components.getId() : id;
}
protected PortletContext(PortletContextComponents components)
{
ParameterValidation.throwIllegalArgExceptionIfNull(components, "portlet
context components");
this.components = components;
- this.id = components.getId();
}
+ public static PortletContext dereference(String invokerId, PortletContext
compoundPortletContext)
+ {
+ String portletId = compoundPortletContext.getId().substring(invokerId.length() +
INVOKER_SEPARATOR.length());
+ if (compoundPortletContext instanceof StatefulPortletContext)
+ {
+ StatefulPortletContext<?> compoundStatefulPortletContext =
(StatefulPortletContext<?>)compoundPortletContext;
+ return StatefulPortletContext.create(portletId,
compoundStatefulPortletContext);
+ }
+ else
+ {
+ return createPortletContext(portletId);
+ }
+ }
+
+ public static PortletContext reference(String invokerId, PortletContext
portletContext)
+ {
+ String compoundPortletId = reference(portletContext.getId(), invokerId);
+ if (portletContext instanceof StatefulPortletContext)
+ {
+ StatefulPortletContext<?> statefulPortletContext =
(StatefulPortletContext<?>)portletContext;
+ return StatefulPortletContext.create(compoundPortletId,
statefulPortletContext);
+ }
+ else
+ {
+ return createPortletContext(compoundPortletId);
+ }
+ }
+
+ private static String reference(String portletId, String invokerId)
+ {
+ return invokerId + INVOKER_SEPARATOR + portletId;
+ }
+
public boolean equals(Object o)
{
if (this == o)
@@ -199,24 +235,24 @@
if (o instanceof PortletContext)
{
PortletContext that = (PortletContext)o;
- return id.equals(that.id);
+ return getId().equals(that.getId());
}
return false;
}
public int hashCode()
{
- return id.hashCode();
+ return getId().hashCode();
}
public String getId()
{
- return id;
+ return components.getId();
}
public String toString()
{
- return "PortletContext[" + id + "]";
+ return "PortletContext[" + getId() + "]";
}
/**
@@ -289,7 +325,7 @@
applicationName = applicationName.substring(1);
}
- return new PortletContext(new PortletContextComponents(null, applicationName,
portletName, null));
+ return new PortletContext(new InterpretedPortletContextComponents(null,
applicationName, portletName, null));
}
public PortletContextComponents getComponents()
@@ -297,14 +333,36 @@
return components;
}
- public static class PortletContextComponents
+ public static interface PortletContextComponents
{
+ public String getApplicationName();
+
+ public String getPortletName();
+
+ public String getInvokerName();
+
+ public boolean isCloned();
+
+ public boolean isProducerCloned();
+
+ public boolean isConsumerCloned();
+
+ public String getStateId();
+
+ public String getId();
+
+ public boolean isInterpreted();
+ }
+
+ private static class InterpretedPortletContextComponents implements
PortletContextComponents
+ {
private final String applicationName;
private final String portletName;
private final String invokerName;
private final Boolean producerCloned;
+ private final String id;
- public PortletContextComponents(String invokerName, String applicationName, String
portletNameOrStateId, Boolean producerCloned)
+ public InterpretedPortletContextComponents(String invokerName, String
applicationName, String portletNameOrStateId, Boolean producerCloned)
{
this.producerCloned = producerCloned;
@@ -316,6 +374,10 @@
this.applicationName = applicationName;
this.portletName = portletNameOrStateId;
this.invokerName = invokerName;
+
+ id = (invokerName == null ? "" : invokerName + INVOKER_SEPARATOR)
+ + (applicationName == null ? "" : PREFIX + applicationName +
SEPARATOR)
+ + (portletName == null ? "" : (producerCloned != null ?
(producerCloned ? PRODUCER_CLONE_ID_PREFIX : CONSUMER_CLONE_ID_PREFIX) : "") +
portletName);
}
public String getApplicationName()
@@ -355,9 +417,68 @@
public String getId()
{
- return (invokerName == null ? "" : invokerName + SEPARATOR)
- + (applicationName == null ? "" : PREFIX + applicationName +
SEPARATOR)
- + (portletName == null ? "" : (producerCloned != null ?
(producerCloned ? PRODUCER_CLONE_ID_PREFIX : CONSUMER_CLONE_ID_PREFIX) : "") +
portletName);
+ return id;
}
+
+ public boolean isInterpreted()
+ {
+ return true;
+ }
}
+
+ private static class UninterpretedPortletContextComponents implements
PortletContextComponents
+ {
+ private static final String ERROR = "This PortletContext was not intepreted,
only the portlet name is available!";
+ private final String portletName;
+
+ private UninterpretedPortletContextComponents(String portletName)
+ {
+ this.portletName = portletName;
+ }
+
+ public String getApplicationName()
+ {
+ throw new IllegalStateException(ERROR);
+ }
+
+ public String getPortletName()
+ {
+ return portletName;
+ }
+
+ public String getInvokerName()
+ {
+ throw new IllegalStateException(ERROR);
+ }
+
+ public boolean isCloned()
+ {
+ throw new IllegalStateException(ERROR);
+ }
+
+ public boolean isProducerCloned()
+ {
+ throw new IllegalStateException(ERROR);
+ }
+
+ public boolean isConsumerCloned()
+ {
+ throw new IllegalStateException(ERROR);
+ }
+
+ public String getStateId()
+ {
+ throw new IllegalStateException(ERROR);
+ }
+
+ public String getId()
+ {
+ return portletName;
+ }
+
+ public boolean isInterpreted()
+ {
+ return false;
+ }
+ }
}
Modified:
components/pc/trunk/api/src/main/java/org/gatein/pc/api/StatefulPortletContext.java
===================================================================
---
components/pc/trunk/api/src/main/java/org/gatein/pc/api/StatefulPortletContext.java 2011-04-08
20:59:33 UTC (rev 6186)
+++
components/pc/trunk/api/src/main/java/org/gatein/pc/api/StatefulPortletContext.java 2011-04-11
10:29:34 UTC (rev 6187)
@@ -67,8 +67,9 @@
this.state = state;
}
- public PortletStateType<S> getType() {
- return type;
+ public PortletStateType<S> getType()
+ {
+ return type;
}
public boolean equals(Object o)
@@ -114,6 +115,6 @@
public String toString()
{
- return "StatefulPortletContext[" + id + "," +
type.toString(state) + "]";
+ return "StatefulPortletContext[" + getId() + "," +
type.toString(state) + "]";
}
}
Modified:
components/pc/trunk/api/src/test/java/org/gatein/pc/api/PortletContextTestCase.java
===================================================================
---
components/pc/trunk/api/src/test/java/org/gatein/pc/api/PortletContextTestCase.java 2011-04-08
20:59:33 UTC (rev 6186)
+++
components/pc/trunk/api/src/test/java/org/gatein/pc/api/PortletContextTestCase.java 2011-04-11
10:29:34 UTC (rev 6187)
@@ -37,6 +37,7 @@
assertEquals("/applicationName.portletName", context.getId());
PortletContext.PortletContextComponents components = context.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertNull(components.getInvokerName());
assertEquals("applicationName", components.getApplicationName());
assertEquals("portletName", components.getPortletName());
@@ -47,6 +48,7 @@
assertEquals("/applicationName.portletName", context.getId());
components = context.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertNull(components.getInvokerName());
assertEquals("applicationName", components.getApplicationName());
assertEquals("portletName", components.getPortletName());
@@ -63,10 +65,12 @@
// expected
}
- context =
PortletContext.createPortletContext("applicationName.portletName");
- assertEquals("applicationName.portletName", context.getId());
+ String portletId = "applicationName" + PortletContext.INVOKER_SEPARATOR +
"portletName";
+ context = PortletContext.createPortletContext(portletId);
+ assertEquals(portletId, context.getId());
components = context.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertEquals("applicationName", components.getInvokerName());
assertNull(components.getApplicationName());
assertEquals("portletName", components.getPortletName());
@@ -77,6 +81,7 @@
assertEquals("/applicationName.portlet.Name", context.getId());
components = context.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertNull(components.getInvokerName());
assertEquals("applicationName", components.getApplicationName());
assertEquals("portlet.Name", components.getPortletName());
@@ -97,6 +102,7 @@
assertEquals("/applicationName.portlet Name", context.getId());
components = context.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertNull(components.getInvokerName());
assertEquals("applicationName", components.getApplicationName());
assertEquals("portlet Name", components.getPortletName());
@@ -106,40 +112,47 @@
public void testPortletContextWithInvokerId()
{
- PortletContext context =
PortletContext.createPortletContext("local./foo.bar");
- assertEquals("local./foo.bar", context.getId());
+ String id = "local" + PortletContext.INVOKER_SEPARATOR +
"/foo.bar";
+ PortletContext context = PortletContext.createPortletContext(id);
+ assertEquals(id, context.getId());
PortletContext.PortletContextComponents components = context.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertEquals("local", components.getInvokerName());
assertEquals("foo", components.getApplicationName());
assertEquals("bar", components.getPortletName());
assertFalse(components.isCloned());
assertNull(components.getStateId());
- context = PortletContext.createPortletContext(" local\t . / foo \t. \t\n
bar");
- assertEquals("local./foo.bar", context.getId());
+ context = PortletContext.createPortletContext(" local\t " +
PortletContext.INVOKER_SEPARATOR + " / foo \t. \t\n bar");
+ assertEquals("local" + PortletContext.INVOKER_SEPARATOR +
"/foo.bar", context.getId());
components = context.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertEquals("local", components.getInvokerName());
assertEquals("foo", components.getApplicationName());
assertEquals("bar", components.getPortletName());
assertFalse(components.isCloned());
assertNull(components.getStateId());
- context = PortletContext.createPortletContext("local.foo.bar");
- assertEquals("local.foo.bar", context.getId());
+ id = "local" + PortletContext.INVOKER_SEPARATOR + "foo.bar";
+ context = PortletContext.createPortletContext(id);
+ assertEquals(id, context.getId());
components = context.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertEquals("local", components.getInvokerName());
assertNull(components.getApplicationName());
assertEquals("foo.bar", components.getPortletName());
assertFalse(components.isCloned());
assertNull(components.getStateId());
- context = PortletContext.createPortletContext("local./foo");
- assertEquals("local./foo", context.getId());
+ id = "local" + PortletContext.INVOKER_SEPARATOR + "/foo";
+ context = PortletContext.createPortletContext(id);
+ assertEquals(id, context.getId());
components = context.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertEquals("local", components.getInvokerName());
assertNull(components.getApplicationName());
assertEquals("/foo", components.getPortletName());
@@ -155,6 +168,7 @@
assertEquals("/applicationName.portletName", context.getId());
PortletContext.PortletContextComponents components = context.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertNull(components.getInvokerName());
assertEquals("applicationName", components.getApplicationName());
assertEquals("portletName", components.getPortletName());
@@ -171,6 +185,7 @@
assertEquals("/applicationName.portletName", context.getId());
PortletContext.PortletContextComponents components = context.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertNull(components.getInvokerName());
assertEquals("applicationName", components.getApplicationName());
assertEquals("portletName", components.getPortletName());
@@ -182,8 +197,72 @@
public void testShouldWorkWithoutInterpretation()
{
PortletContext context = PortletContext.createPortletContext("foo",
false);
- assertNull(context.getComponents());
+ PortletContext.PortletContextComponents components = context.getComponents();
+ assertNotNull(components);
+ assertFalse(components.isInterpreted());
assertEquals("foo", context.getId());
+ assertEquals("foo", components.getPortletName());
+ assertEquals(components.getId(), context.getId());
+
+ try
+ {
+ components.getApplicationName();
+ fail("Unintrepreted so only component available is portlet name");
+ }
+ catch (IllegalStateException e)
+ {
+ // expected
+ }
+
+ try
+ {
+ components.getInvokerName();
+ fail("Unintrepreted so only component available is portlet name");
+ }
+ catch (IllegalStateException e)
+ {
+ // expected
+ }
+
+ try
+ {
+ components.getStateId();
+ fail("Unintrepreted so only component available is portlet name");
+ }
+ catch (IllegalStateException e)
+ {
+ // expected
+ }
+
+ try
+ {
+ components.isCloned();
+ fail("Unintrepreted so only component available is portlet name");
+ }
+ catch (IllegalStateException e)
+ {
+ // expected
+ }
+
+ try
+ {
+ components.isConsumerCloned();
+ fail("Unintrepreted so only component available is portlet name");
+ }
+ catch (IllegalStateException e)
+ {
+ // expected
+ }
+
+ try
+ {
+ components.isProducerCloned();
+ fail("Unintrepreted so only component available is portlet name");
+ }
+ catch (IllegalStateException e)
+ {
+ // expected
+ }
}
public void testAcceptProducerClones()
@@ -193,10 +272,12 @@
checkClones(PortletContext.PRODUCER_CLONE_ID_PREFIX);
- context = PortletContext.createPortletContext("foo." +
PortletContext.CONSUMER_CLONE_ID);
- assertEquals("foo." + PortletContext.CONSUMER_CLONE_ID,
context.getId());
+ String id = "foo" + PortletContext.INVOKER_SEPARATOR +
PortletContext.CONSUMER_CLONE_ID;
+ context = PortletContext.createPortletContext(id);
+ assertEquals(id, context.getId());
components = context.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertEquals("foo", components.getInvokerName());
assertNull(components.getApplicationName());
assertNull(components.getPortletName());
@@ -212,26 +293,30 @@
assertEquals(clonePrefix + "clone", context.getId());
components = context.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertNull(components.getInvokerName());
assertNull(components.getApplicationName());
assertNull(components.getPortletName());
assertTrue(components.isCloned());
assertEquals("clone", components.getStateId());
- context = PortletContext.createPortletContext("foo." + clonePrefix +
"clone");
- assertEquals("foo." + clonePrefix + "clone", context.getId());
+ String id = "foo" + PortletContext.INVOKER_SEPARATOR + clonePrefix +
"clone";
+ context = PortletContext.createPortletContext(id);
+ assertEquals(id, context.getId());
components = context.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertEquals("foo", components.getInvokerName());
assertNull(components.getApplicationName());
assertNull(components.getPortletName());
assertTrue(components.isCloned());
assertEquals("clone", components.getStateId());
- context = PortletContext.createPortletContext("foo \t \n. " +
clonePrefix + " \t\nclone");
- assertEquals("foo." + clonePrefix + "clone", context.getId());
+ context = PortletContext.createPortletContext("foo \t \n " +
PortletContext.INVOKER_SEPARATOR + " \t" + clonePrefix + "
\t\nclone");
+ assertEquals(id, context.getId());
components = context.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertEquals("foo", components.getInvokerName());
assertNull(components.getApplicationName());
assertNull(components.getPortletName());
@@ -248,6 +333,7 @@
{
PortletContext.PortletContextComponents components =
PortletContext.LOCAL_CONSUMER_CLONE.getComponents();
assertNotNull(components);
+ assertTrue(components.isInterpreted());
assertEquals(PortletInvoker.LOCAL_PORTLET_INVOKER_ID,
components.getInvokerName());
assertNull(components.getApplicationName());
assertNull(components.getPortletName());
Modified:
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java
===================================================================
---
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java 2011-04-08
20:59:33 UTC (rev 6186)
+++
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java 2011-04-11
10:29:34 UTC (rev 6187)
@@ -197,7 +197,7 @@
{
DestroyCloneFailure failure = failures.get(i);
String cloneId = failure.getPortletId();
- failure = new
DestroyCloneFailure(FederatingPortletInvokerService.reference(cloneId, id));
+ failure = new DestroyCloneFailure(PortletContext.reference(id,
PortletContext.createPortletContext(cloneId)).getId());
failures.set(i, failure);
}
@@ -242,12 +242,12 @@
private PortletContext dereference(PortletContext compoundPortletContext)
{
- return FederatingPortletInvokerService.dereference(compoundPortletContext, id);
+ return PortletContext.dereference(id, compoundPortletContext);
}
private PortletContext reference(PortletContext portletContext)
{
- return FederatingPortletInvokerService.reference(portletContext, id);
+ return PortletContext.reference(id, portletContext);
}
}
Modified:
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java
===================================================================
---
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java 2011-04-08
20:59:33 UTC (rev 6186)
+++
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java 2011-04-11
10:29:34 UTC (rev 6187)
@@ -62,47 +62,11 @@
/** . */
private static final Logger log =
LoggerFactory.getLogger(FederatingPortletInvokerService.class);
- /** The separator used in the id to route to the correct invoker. */
- public static final String SEPARATOR = ".";
-
/** The registred FederatedPortletInvokers. */
private volatile Map<String, FederatedPortletInvoker> registry = new
HashMap<String, FederatedPortletInvoker>();
private NullInvokerHandler nullHandler = NullInvokerHandler.DEFAULT_HANDLER;
- public static PortletContext dereference(PortletContext compoundPortletContext, String
invokerId)
- {
- String portletId = compoundPortletContext.getId().substring(invokerId.length() +
SEPARATOR.length());
- if (compoundPortletContext instanceof StatefulPortletContext)
- {
- StatefulPortletContext<?> compoundStatefulPortletContext =
(StatefulPortletContext<?>)compoundPortletContext;
- return StatefulPortletContext.create(portletId,
compoundStatefulPortletContext);
- }
- else
- {
- return PortletContext.createPortletContext(portletId);
- }
- }
-
- public static PortletContext reference(PortletContext portletContext, String
invokerId)
- {
- String compoundPortletId = reference(portletContext.getId(), invokerId);
- if (portletContext instanceof StatefulPortletContext)
- {
- StatefulPortletContext<?> statefulPortletContext =
(StatefulPortletContext<?>)portletContext;
- return StatefulPortletContext.create(compoundPortletId,
statefulPortletContext);
- }
- else
- {
- return PortletContext.createPortletContext(compoundPortletId);
- }
- }
-
- static String reference(String portletId, String invokerId)
- {
- return invokerId + SEPARATOR + portletId;
- }
-
public synchronized FederatedPortletInvoker registerInvoker(String federatedId,
PortletInvoker federatedInvoker)
{
if (federatedId == null)
Modified:
components/pc/trunk/federation/src/test/java/org/gatein/pc/federation/FederatingPortletInvokerTestCase.java
===================================================================
---
components/pc/trunk/federation/src/test/java/org/gatein/pc/federation/FederatingPortletInvokerTestCase.java 2011-04-08
20:59:33 UTC (rev 6186)
+++
components/pc/trunk/federation/src/test/java/org/gatein/pc/federation/FederatingPortletInvokerTestCase.java 2011-04-11
10:29:34 UTC (rev 6187)
@@ -54,8 +54,8 @@
private static final PortletContext PORTLET =
PortletContext.createPortletContext("/webapp.portlet", false);
private static final String INVOKER_ID = "foo";
private static final PortletContext LOCAL_PORTLET =
PortletContext.createPortletContext("/web.local", false);
- private static final PortletContext REFERENCED_PORTLET =
FederatingPortletInvokerService.reference(PORTLET, INVOKER_ID);
- private static final PortletContext REFERENCED_LOCAL_PORTLET =
FederatingPortletInvokerService.reference(LOCAL_PORTLET,
PortletInvoker.LOCAL_PORTLET_INVOKER_ID);
+ private static final PortletContext REFERENCED_PORTLET =
PortletContext.reference(INVOKER_ID, PORTLET);
+ private static final PortletContext REFERENCED_LOCAL_PORTLET =
PortletContext.reference(PortletInvoker.LOCAL_PORTLET_INVOKER_ID, LOCAL_PORTLET);
/** . */
private FederatingPortletInvoker federatingInvoker;
@@ -231,8 +231,8 @@
}
});
- assertEquals(portlet,
federatingInvoker.getPortlet(PortletContext.createPortletContext(federatedId +
FederatingPortletInvokerService.SEPARATOR + context.getId())));
- assertEquals(portlet,
federatingInvoker.getPortlet(FederatingPortletInvokerService.reference(context,
federatedId)));
+ assertEquals(portlet,
federatingInvoker.getPortlet(PortletContext.createPortletContext(federatedId +
PortletContext.INVOKER_SEPARATOR + context.getId())));
+ assertEquals(portlet,
federatingInvoker.getPortlet(PortletContext.reference(federatedId, context)));
}
private class TestFederatedPortletInvoker extends PortletInvokerSupport implements
FederatedPortletInvoker
@@ -248,9 +248,9 @@
{
// fake dereferencing of compound portlet id
String portletId = portletContext.getId();
- if (portletId.startsWith(getId() + FederatingPortletInvokerService.SEPARATOR))
+ if (portletId.startsWith(getId() + PortletContext.INVOKER_SEPARATOR))
{
- return
super.getPortlet(PortletContext.createPortletContext(portletId.substring(portletId.indexOf(FederatingPortletInvokerService.SEPARATOR)
+ 1)));
+ return
super.getPortlet(PortletContext.createPortletContext(portletId.substring(portletId.indexOf(PortletContext.INVOKER_SEPARATOR)
+ 1)));
}
else
{