Author: chris.laprun(a)jboss.com
Date: 2009-08-17 16:04:27 -0400 (Mon, 17 Aug 2009)
New Revision: 13772
Modified:
jbossexo/modules/portlet/trunk/federation/src/main/java/org/jboss/portal/portlet/federation/FederatingPortletInvoker.java
jbossexo/modules/portlet/trunk/federation/src/main/java/org/jboss/portal/portlet/federation/impl/FederatingPortletInvokerService.java
Log:
- Modify FederatingPortletInvoker implementation so that local invoker doesn't wrap
portlet contexts to add invoker id.
Modified:
jbossexo/modules/portlet/trunk/federation/src/main/java/org/jboss/portal/portlet/federation/FederatingPortletInvoker.java
===================================================================
---
jbossexo/modules/portlet/trunk/federation/src/main/java/org/jboss/portal/portlet/federation/FederatingPortletInvoker.java 2009-08-17
15:26:42 UTC (rev 13771)
+++
jbossexo/modules/portlet/trunk/federation/src/main/java/org/jboss/portal/portlet/federation/FederatingPortletInvoker.java 2009-08-17
20:04:27 UTC (rev 13772)
@@ -1,25 +1,25 @@
-/******************************************************************************
- * 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. *
- ******************************************************************************/
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
package org.jboss.portal.portlet.federation;
import org.jboss.portal.portlet.api.PortletInvoker;
@@ -35,10 +35,13 @@
*/
public interface FederatingPortletInvoker extends PortletInvoker
{
+ /** The identifier assigned to the local PortletInvoker. */
+ String LOCAL_PORTLET_INVOKER_ID = "local";
+
/**
* Registers an invoker.
*
- * @param federatedId the invoker id to register
+ * @param federatedId the invoker id to register
* @param registeredInvoker the invoker to register
* @throws IllegalArgumentException if the invoker is null or already registered
*/
Modified:
jbossexo/modules/portlet/trunk/federation/src/main/java/org/jboss/portal/portlet/federation/impl/FederatingPortletInvokerService.java
===================================================================
---
jbossexo/modules/portlet/trunk/federation/src/main/java/org/jboss/portal/portlet/federation/impl/FederatingPortletInvokerService.java 2009-08-17
15:26:42 UTC (rev 13771)
+++
jbossexo/modules/portlet/trunk/federation/src/main/java/org/jboss/portal/portlet/federation/impl/FederatingPortletInvokerService.java 2009-08-17
20:04:27 UTC (rev 13772)
@@ -59,7 +59,7 @@
private static final Logger log =
Logger.getLogger(FederatingPortletInvokerService.class);
/** The separator used in the id to route to the correct invoker. */
- static final String SEPARATOR = ".";
+ static final String SEPARATOR = ".:.";
/** The registred FederatedPortletInvokers. */
private volatile Map<String, FederatedPortletInvoker> registry = new
HashMap<String, FederatedPortletInvoker>();
@@ -68,17 +68,33 @@
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(federatedId,
"Federated PortletInvoker id", null);
ParameterValidation.throwIllegalArgExceptionIfNull(federatedInvoker,
"Federated PortletInvoker");
+
if (registry.containsKey(federatedId))
{
throw new IllegalArgumentException("Attempting dual registration of "
+ federatedId);
}
+
Map<String, FederatedPortletInvoker> copy = new HashMap<String,
FederatedPortletInvoker>(registry);
- FederatedPortletInvokerService invoker = new FederatedPortletInvokerService(this,
federatedId, federatedInvoker);
+
+ FederatedPortletInvoker invoker;
+ if (isLocalInvoker(federatedId))
+ {
+ invoker = new LocalFederatedPortletInvoker(federatedInvoker);
+ }
+ else
+ {
+ invoker = new FederatedPortletInvokerService(this, federatedId,
federatedInvoker);
+ }
copy.put(federatedId, invoker);
registry = copy;
return invoker;
}
+ private boolean isLocalInvoker(String federatedId)
+ {
+ return FederatingPortletInvoker.LOCAL_PORTLET_INVOKER_ID.equals(federatedId);
+ }
+
public synchronized void unregisterInvoker(String federatedId)
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(federatedId,
"Federated PortletInvoker id", null);
@@ -107,7 +123,7 @@
public Set<Portlet> getPortlets() throws PortletInvokerException
{
LinkedHashSet<Portlet> portlets = new LinkedHashSet<Portlet>();
- for (FederatedPortletInvoker federated : registry.values())
+ for (FederatedPortletInvoker federated : getFederatedInvokers())
{
try
{
@@ -209,15 +225,14 @@
//
String compoundPortletId = compoundPortletContext.getId();
- //
+ // extract the invoker id if it's present in the portlet context, otherwise
default to local invoker id
int pos = compoundPortletId.indexOf(SEPARATOR);
- if (pos == -1)
+ String invokerId = FederatingPortletInvoker.LOCAL_PORTLET_INVOKER_ID;
+ if (pos != -1)
{
- throw new IllegalArgumentException("Bad portlet id format " +
compoundPortletId);
+ invokerId = compoundPortletId.substring(0, pos);
}
- //
- String invokerId = compoundPortletId.substring(0, pos);
FederatedPortletInvoker federated = registry.get(invokerId);
if (federated == null)
{
@@ -227,4 +242,65 @@
//
return federated;
}
+
+ private static class LocalFederatedPortletInvoker implements FederatedPortletInvoker
+ {
+ private PortletInvoker invoker;
+
+ private LocalFederatedPortletInvoker(PortletInvoker invoker)
+ {
+ this.invoker = invoker;
+ }
+
+ public String getId()
+ {
+ return FederatingPortletInvoker.LOCAL_PORTLET_INVOKER_ID;
+ }
+
+ public PortletInvoker getPortletInvoker()
+ {
+ return invoker;
+ }
+
+
+ public Set<Portlet> getPortlets() throws PortletInvokerException
+ {
+ return invoker.getPortlets();
+ }
+
+ public Portlet getPortlet(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException
+ {
+ return invoker.getPortlet(portletContext);
+ }
+
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws
IllegalArgumentException, PortletInvokerException
+ {
+ return invoker.invoke(invocation);
+ }
+
+ public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ return invoker.createClone(portletContext);
+ }
+
+ public List<DestroyCloneFailure> destroyClones(List<PortletContext>
portletContexts) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ return invoker.destroyClones(portletContexts);
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext, Set<String>
keys) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ return invoker.getProperties(portletContext);
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ return invoker.getProperties(portletContext);
+ }
+
+ public PortletContext setProperties(PortletContext portletContext, PropertyChange[]
changes) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ return invoker.setProperties(portletContext, changes);
+ }
+ }
}