Author: chris.laprun(a)jboss.com
Date: 2011-09-14 15:39:58 -0400 (Wed, 14 Sep 2011)
New Revision: 7428
Added:
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/PortletInvokerResolver.java
Removed:
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/NullInvokerHandler.java
Modified:
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/FederatingPortletInvoker.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:
- Renamed NullInvokerHandler to PortletInvokerResolver since it's more explicit that
way.
- Improved documentation.
Modified:
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/FederatingPortletInvoker.java
===================================================================
---
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/FederatingPortletInvoker.java 2011-09-14
19:23:49 UTC (rev 7427)
+++
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/FederatingPortletInvoker.java 2011-09-14
19:39:58 UTC (rev 7428)
@@ -50,7 +50,8 @@
/**
* Returns the registered FederatedPortletInvoker associated with the specified
identifier, delegating to the {@link
- * NullInvokerHandler} specified using {@link
#setNullInvokerHandler(NullInvokerHandler)} if it's not initially
+ * PortletInvokerResolver} specified using {@link
#setNullInvokerHandler(PortletInvokerResolver)} if it's not
+ * initially
* resolved or returns <code>null</code> if a FederatedPortletInvoker is
not found after going through the specified
* NullInvokerHandler resolution mechanism.
*
@@ -115,7 +116,7 @@
* Specifies which NullInvokerHandler to use to attempt retrieval of a federated
invoker when default resolution
* mechanism cannot find an associated invoker.
*
- * @param nullHandler
+ * @param portletResolver
*/
- void setNullInvokerHandler(NullInvokerHandler nullHandler);
+ void setNullInvokerHandler(PortletInvokerResolver portletResolver);
}
Deleted:
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/NullInvokerHandler.java
===================================================================
---
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/NullInvokerHandler.java 2011-09-14
19:23:49 UTC (rev 7427)
+++
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/NullInvokerHandler.java 2011-09-14
19:39:58 UTC (rev 7428)
@@ -1,89 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, 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.gatein.pc.federation;
-
-import org.gatein.pc.api.NoSuchPortletException;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * Encapsulates behavior to resolve FederatedPortletInvokers in the context of a
FederatingPortletInvoker when the
- * default resolution mechanism fails to retrieve an associated FederatedPortletInvoker.
- *
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public interface NullInvokerHandler
-{
- /**
- * Default handling mechanism: if we haven't found an invoker for the portlet id
in the first place, throw
- * NoSuchPortletException.
- */
- NullInvokerHandler DEFAULT_HANDLER = new NullInvokerHandler()
- {
- public FederatedPortletInvoker resolvePortletInvokerFor(String invokerId,
FederatingPortletInvoker callingInvoker, String compoundPortletId) throws
NoSuchPortletException
- {
- if (compoundPortletId != null)
- {
- throw new NoSuchPortletException(compoundPortletId);
- }
- else
- {
- return null;
- }
- }
-
- public boolean knows(String invokerId)
- {
- return false;
- }
-
- public Collection<String> getKnownInvokerIds()
- {
- return Collections.emptyList();
- }
- };
-
- /**
- * Attempts to resolve a FederatedPortletInvoker with the specified identifier in the
context of the specified
- * calling FederatingPortletInvoker, optionally trying to perform resolution to invoke
an action on the specified
- * portlet identifier.
- *
- * @param invokerId the identifier of the FederatedPortletInvoker to be
retrieved. Should match the optional
- * compound portlet identifier if one is specified.
- * @param callingInvoker the calling FederatingPortletInvoker which failed to
resolve a FederatedPortletInvoker
- * for the specified invoker identifier
- * @param compoundPortletId an optional portlet identifier for which we are trying to
resolve an invoker, if no such
- * portlet identifier is required for the resolution, this
argument should be
- * <code>null</code> and implementations should
be prepared for that case.
- * @return
- * @throws NoSuchPortletException
- */
- FederatedPortletInvoker resolvePortletInvokerFor(String invokerId,
FederatingPortletInvoker callingInvoker, String compoundPortletId) throws
NoSuchPortletException;
-
- boolean knows(String invokerId);
-
- Collection<String> getKnownInvokerIds();
-}
Copied:
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/PortletInvokerResolver.java
(from rev 7424,
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/NullInvokerHandler.java)
===================================================================
---
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/PortletInvokerResolver.java
(rev 0)
+++
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/PortletInvokerResolver.java 2011-09-14
19:39:58 UTC (rev 7428)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.gatein.pc.federation;
+
+import org.gatein.pc.api.NoSuchPortletException;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Encapsulates behavior to resolve FederatedPortletInvokers in the context of a
FederatingPortletInvoker when the
+ * default resolution mechanism fails to retrieve an associated FederatedPortletInvoker.
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public interface PortletInvokerResolver
+{
+ /**
+ * Default handling mechanism: if we haven't found an invoker for the portlet id
in the first place, throw
+ * NoSuchPortletException if we specified a portlet id or null if we didn't.
+ */
+ PortletInvokerResolver DEFAULT_RESOLVER = new PortletInvokerResolver()
+ {
+ public FederatedPortletInvoker resolvePortletInvokerFor(String invokerId,
FederatingPortletInvoker callingInvoker, String compoundPortletId) throws
NoSuchPortletException
+ {
+ if (compoundPortletId != null)
+ {
+ throw new NoSuchPortletException(compoundPortletId);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public boolean knows(String invokerId)
+ {
+ return false;
+ }
+
+ public Collection<String> getKnownInvokerIds()
+ {
+ return Collections.emptyList();
+ }
+ };
+
+ /**
+ * Attempts to resolve a FederatedPortletInvoker with the specified identifier in the
context of the specified
+ * calling FederatingPortletInvoker, optionally trying to perform resolution to invoke
an action on the specified
+ * portlet identifier.
+ *
+ * @param invokerId the identifier of the FederatedPortletInvoker to be
retrieved. Should match the optional
+ * compound portlet identifier if one is specified.
+ * @param callingInvoker the calling FederatingPortletInvoker which failed to
resolve a FederatedPortletInvoker
+ * for the specified invoker identifier
+ * @param compoundPortletId an optional portlet identifier for which we are trying to
resolve an invoker, if no such
+ * portlet identifier is required for the resolution, this
argument should be
+ * <code>null</code> and implementations should
be prepared for that case.
+ * @return the resolved FederatedPortletInvoker or <code>null</code> if
one couldn't be found
+ * @throws NoSuchPortletException if a PortletInvoker couldn't be found and a
compound portlet identifier was
+ * specified
+ */
+ FederatedPortletInvoker resolvePortletInvokerFor(String invokerId,
FederatingPortletInvoker callingInvoker, String compoundPortletId) throws
NoSuchPortletException;
+
+ boolean knows(String invokerId);
+
+ Collection<String> getKnownInvokerIds();
+}
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-09-14
19:23:49 UTC (rev 7427)
+++
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java 2011-09-14
19:39:58 UTC (rev 7428)
@@ -39,7 +39,7 @@
import org.gatein.pc.api.state.PropertyMap;
import org.gatein.pc.federation.FederatedPortletInvoker;
import org.gatein.pc.federation.FederatingPortletInvoker;
-import org.gatein.pc.federation.NullInvokerHandler;
+import org.gatein.pc.federation.PortletInvokerResolver;
import java.util.Collection;
import java.util.Collections;
@@ -65,7 +65,7 @@
/** The registred FederatedPortletInvokers. */
private volatile Map<String, FederatedPortletInvoker> invokerCache = new
HashMap<String, FederatedPortletInvoker>();
- private NullInvokerHandler nullHandler = NullInvokerHandler.DEFAULT_HANDLER;
+ private PortletInvokerResolver portletResolver =
PortletInvokerResolver.DEFAULT_RESOLVER;
public synchronized FederatedPortletInvoker registerInvoker(String federatedId,
PortletInvoker federatedInvoker)
{
@@ -95,7 +95,7 @@
{
throw new IllegalArgumentException("No null id accepted");
}
- if (!invokerCache.containsKey(federatedId) &&
!nullHandler.knows(federatedId))
+ if (!invokerCache.containsKey(federatedId) &&
!portletResolver.knows(federatedId))
{
throw new IllegalArgumentException("Attempting to unregister unknown
invoker " + federatedId);
}
@@ -127,7 +127,7 @@
FederatedPortletInvoker federatedPortletInvoker = invokerCache.get(federatedId);
if (federatedPortletInvoker == null)
{
- federatedPortletInvoker = nullHandler.resolvePortletInvokerFor(federatedId,
this, compoundPortletId);
+ federatedPortletInvoker = portletResolver.resolvePortletInvokerFor(federatedId,
this, compoundPortletId);
if (federatedPortletInvoker != null)
{
synchronized (this)
@@ -142,7 +142,7 @@
public Collection<String> getFederatedInvokerIds()
{
final Collection<String> resolvedIds = getResolvedInvokerIds();
- final Collection<String> resolvableIds = nullHandler.getKnownInvokerIds();
+ final Collection<String> resolvableIds =
portletResolver.getKnownInvokerIds();
final HashSet<String> ids = new HashSet<String>(resolvedIds.size() +
resolvableIds.size());
ids.addAll(resolvedIds);
ids.addAll(resolvableIds);
@@ -305,15 +305,15 @@
return federated.importPortlet(stateType, compoundPortletContext);
}
- public synchronized void setNullInvokerHandler(NullInvokerHandler nullHandler)
+ public synchronized void setNullInvokerHandler(PortletInvokerResolver
portletResolver)
{
- if (nullHandler == null)
+ if (portletResolver == null)
{
- this.nullHandler = NullInvokerHandler.DEFAULT_HANDLER;
+ this.portletResolver = PortletInvokerResolver.DEFAULT_RESOLVER;
}
else
{
- this.nullHandler = nullHandler;
+ this.portletResolver = portletResolver;
}
}
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-09-14
19:23:49 UTC (rev 7427)
+++
components/pc/trunk/federation/src/test/java/org/gatein/pc/federation/FederatingPortletInvokerTestCase.java 2011-09-14
19:39:58 UTC (rev 7428)
@@ -208,7 +208,7 @@
final String federatedId = "inexistent";
assertNull(federatingInvoker.getFederatedInvoker(federatedId));
- federatingInvoker.setNullInvokerHandler(new NullInvokerHandler()
+ federatingInvoker.setNullInvokerHandler(new PortletInvokerResolver()
{
public FederatedPortletInvoker resolvePortletInvokerFor(String invokerId,
FederatingPortletInvoker callingInvoker, String compoundPortletId) throws
NoSuchPortletException
{