[gatein-commits] gatein SVN: r4193 - components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Sep 14 12:47:03 EDT 2010


Author: chris.laprun at jboss.com
Date: 2010-09-14 12:47:03 -0400 (Tue, 14 Sep 2010)
New Revision: 4193

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/FederatingPortletInvokerService.java
Log:
- Made reference and dereference methods static and moved them to FederatingPortletInvokerService so that they can be used by client classes if needed (in particular, WSRPConsumerImpl ^_^)

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	2010-09-14 14:57:36 UTC (rev 4192)
+++ components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java	2010-09-14 16:47:03 UTC (rev 4193)
@@ -28,7 +28,6 @@
 import org.gatein.pc.api.PortletInvokerException;
 import org.gatein.pc.api.PortletStateType;
 import org.gatein.pc.api.StateEvent;
-import org.gatein.pc.api.StatefulPortletContext;
 import org.gatein.pc.api.invocation.InvocationException;
 import org.gatein.pc.api.invocation.PortletInvocation;
 import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
@@ -191,7 +190,7 @@
       {
          DestroyCloneFailure failure = failures.get(i);
          String cloneId = failure.getPortletId();
-         failure = new DestroyCloneFailure(reference(cloneId));
+         failure = new DestroyCloneFailure(FederatingPortletInvokerService.reference(cloneId, id));
          failures.set(i, failure);
       }
 
@@ -220,13 +219,13 @@
 
 
    public PortletContext exportPortlet(PortletStateType stateType, PortletContext compoundPortletContext)
-         throws PortletInvokerException
+      throws PortletInvokerException
    {
       PortletContext portletContext = dereference(compoundPortletContext);
       portletContext = portletInvoker.exportPortlet(stateType, portletContext);
       return reference(portletContext);
    }
-   
+
    public PortletContext importPortlet(PortletStateType stateType, PortletContext compoundPortletContext) throws PortletInvokerException
    {
       PortletContext portletContext = dereference(compoundPortletContext);
@@ -236,35 +235,13 @@
 
    private PortletContext dereference(PortletContext compoundPortletContext)
    {
-      String portletId = compoundPortletContext.getId().substring(id.length() + 1);
-      if (compoundPortletContext instanceof StatefulPortletContext)
-      {
-         StatefulPortletContext<?> compoundStatefulPortletContext = (StatefulPortletContext<?>)compoundPortletContext;
-         return StatefulPortletContext.create(portletId, compoundStatefulPortletContext);
-      }
-      else
-      {
-         return PortletContext.createPortletContext(portletId);
-      }
+      return FederatingPortletInvokerService.dereference(compoundPortletContext, id);
    }
 
    private PortletContext reference(PortletContext portletContext)
    {
-      String compoundPortletId = reference(portletContext.getId());
-      if (portletContext instanceof StatefulPortletContext)
-      {
-         StatefulPortletContext<?> statefulPortletContext = (StatefulPortletContext<?>)portletContext;
-         return StatefulPortletContext.create(compoundPortletId, statefulPortletContext);
-      }
-      else
-      {
-         return PortletContext.createPortletContext(compoundPortletId);
-      }
+      return FederatingPortletInvokerService.reference(portletContext, id);
    }
 
-   private String reference(String portletId)
-   {
-      return id + FederatingPortletInvokerService.SEPARATOR + portletId;
-   }
 }
                         
\ No newline at end of file

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	2010-09-14 14:57:36 UTC (rev 4192)
+++ components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java	2010-09-14 16:47:03 UTC (rev 4193)
@@ -31,6 +31,7 @@
 import org.gatein.pc.api.PortletInvoker;
 import org.gatein.pc.api.PortletInvokerException;
 import org.gatein.pc.api.PortletStateType;
+import org.gatein.pc.api.StatefulPortletContext;
 import org.gatein.pc.api.invocation.PortletInvocation;
 import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
 import org.gatein.pc.api.state.DestroyCloneFailure;
@@ -68,6 +69,39 @@
 
    private NullInvokerHandler nullHandler = NullInvokerHandler.DEFAULT_HANDLER;
 
+   public static PortletContext dereference(PortletContext compoundPortletContext, String invokerId)
+   {
+      String portletId = compoundPortletContext.getId().substring(invokerId.length() + 1);
+      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)
@@ -232,19 +266,19 @@
    }
 
    public PortletContext exportPortlet(PortletStateType stateType, PortletContext compoundPortletContext)
-         throws PortletInvokerException
+      throws PortletInvokerException
    {
       PortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
       return federated.exportPortlet(stateType, compoundPortletContext);
    }
 
    public PortletContext importPortlet(PortletStateType stateType, PortletContext compoundPortletContext)
-   throws PortletInvokerException
+      throws PortletInvokerException
    {
       PortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
       return federated.importPortlet(stateType, compoundPortletContext);
    }
-   
+
    public synchronized void setNullInvokerHandler(NullInvokerHandler nullHandler)
    {
       if (nullHandler == null)



More information about the gatein-commits mailing list