[gatein-commits] gatein SVN: r4640 - in components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer: handlers and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Oct 12 10:46:29 EDT 2010


Author: chris.laprun at jboss.com
Date: 2010-10-12 10:46:26 -0400 (Tue, 12 Oct 2010)
New Revision: 4640

Modified:
   components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducer.java
   components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java
   components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/ServiceDescriptionHandler.java
   components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/v1/WSRP1Producer.java
Log:
- GTNWSRP-45: Make ServiceDescriptionHandler extend ManagedObjectRegistryEventListener so that they can react to portlet deploy/undeploy events to 
   update the ServiceDescription cache. WSRPProducer also extends the interface so we can register it without polluting clients which already know about 
   the producer but not ServiceDescriptionHandler and then delegate event handling to that last one.
- Only skeletton code in ServiceDescriptionHandler so far.

Modified: components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducer.java
===================================================================
--- components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducer.java	2010-10-12 14:07:09 UTC (rev 4639)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducer.java	2010-10-12 14:46:26 UTC (rev 4640)
@@ -25,6 +25,7 @@
 
 import org.gatein.exports.ExportManager;
 import org.gatein.pc.api.PortletInvoker;
+import org.gatein.pc.portlet.container.managed.ManagedObjectRegistryEventListener;
 import org.gatein.registration.RegistrationManager;
 import org.gatein.wsrp.api.context.ProducerContext;
 import org.gatein.wsrp.producer.config.ProducerConfigurationChangeListener;
@@ -35,7 +36,7 @@
  * @version $Revision: 12020 $
  * @since 2.4
  */
-public interface WSRPProducer extends ProducerConfigurationChangeListener
+public interface WSRPProducer extends ProducerConfigurationChangeListener, ManagedObjectRegistryEventListener
 {
    /**
     * Retrieves the RegistrationManager used by this WSRPProducer.

Modified: components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java	2010-10-12 14:07:09 UTC (rev 4639)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java	2010-10-12 14:46:26 UTC (rev 4640)
@@ -30,6 +30,7 @@
 import org.gatein.pc.api.PortletInvoker;
 import org.gatein.pc.api.PortletInvokerException;
 import org.gatein.pc.api.info.RuntimeOptionInfo;
+import org.gatein.pc.portlet.container.managed.ManagedObjectRegistryEvent;
 import org.gatein.registration.Registration;
 import org.gatein.registration.RegistrationLocal;
 import org.gatein.registration.RegistrationManager;
@@ -564,4 +565,9 @@
    {
       return portletManagementHandler;
    }
+
+   public void onEvent(ManagedObjectRegistryEvent event)
+   {
+      serviceDescriptionHandler.onEvent(event);
+   }
 }

Modified: components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/ServiceDescriptionHandler.java
===================================================================
--- components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/ServiceDescriptionHandler.java	2010-10-12 14:07:09 UTC (rev 4639)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/ServiceDescriptionHandler.java	2010-10-12 14:46:26 UTC (rev 4640)
@@ -38,6 +38,13 @@
 import org.gatein.pc.api.info.PortletInfo;
 import org.gatein.pc.api.info.SecurityInfo;
 import org.gatein.pc.api.info.WindowStateInfo;
+import org.gatein.pc.portlet.container.managed.LifeCycleStatus;
+import org.gatein.pc.portlet.container.managed.ManagedObject;
+import org.gatein.pc.portlet.container.managed.ManagedObjectEvent;
+import org.gatein.pc.portlet.container.managed.ManagedObjectLifeCycleEvent;
+import org.gatein.pc.portlet.container.managed.ManagedObjectRegistryEvent;
+import org.gatein.pc.portlet.container.managed.ManagedObjectRegistryEventListener;
+import org.gatein.pc.portlet.container.managed.ManagedPortletContainer;
 import org.gatein.registration.Registration;
 import org.gatein.wsrp.WSRPTypeFactory;
 import org.gatein.wsrp.WSRPUtils;
@@ -79,7 +86,7 @@
  * @version $Revision: 12017 $
  * @since 2.4
  */
-public class ServiceDescriptionHandler extends ServiceHandler implements ServiceDescriptionInterface
+public class ServiceDescriptionHandler extends ServiceHandler implements ServiceDescriptionInterface, ManagedObjectRegistryEventListener
 {
    // JBPORTAL-1220: force call to initCookie... Required so that BEA version < 9.2 will behave properly as a Consumer
    private static final CookieProtocol BEA_8_CONSUMER_FIX = CookieProtocol.PER_USER;
@@ -172,8 +179,11 @@
     */
    static PortletDescription getPortletDescription(Portlet portlet, List<String> desiredLocales, ServiceDescriptionInfo sdi)
    {
-      org.gatein.pc.api.PortletContext context = portlet.getContext();
-      PortletInfo info = portlet.getInfo();
+      return getPortletDescription(portlet.getContext(), portlet.getInfo(), desiredLocales, sdi);
+   }
+
+   private static PortletDescription getPortletDescription(org.gatein.pc.api.PortletContext context, PortletInfo info, List<String> desiredLocales, ServiceDescriptionInfo sdi)
+   {
       String handle = context.getId();
       if (log.isDebugEnabled())
       {
@@ -317,6 +327,40 @@
       return desc;
    }
 
+   public void onEvent(ManagedObjectRegistryEvent event)
+   {
+      if (event instanceof ManagedObjectEvent)
+      {
+         ManagedObjectEvent managedObjectEvent = (ManagedObjectEvent)event;
+         ManagedObject managedObject = managedObjectEvent.getManagedObject();
+
+         if (managedObject instanceof ManagedPortletContainer)
+         {
+            ManagedPortletContainer portletContainer = (ManagedPortletContainer)managedObject;
+            String applicationId = portletContainer.getManagedPortletApplication().getId();
+            String containerId = portletContainer.getId();
+            // need PC 2.2.0-Beta06 API support
+//            org.gatein.pc.api.PortletContext pc = org.gatein.pc.api.PortletContext.createPortletContext(applicationId, containerId);
+
+            // todo: GTNWSRP-45: implement refreshing of ServiceDescriptionInfo
+            if (managedObjectEvent instanceof ManagedObjectLifeCycleEvent)
+            {
+               ManagedObjectLifeCycleEvent lifeCycleEvent = (ManagedObjectLifeCycleEvent)managedObjectEvent;
+               LifeCycleStatus status = lifeCycleEvent.getStatus();
+               if (LifeCycleStatus.STARTED.equals(status))
+               {
+                  // todo: add portlet description for newly started portlet container
+//                  getPortletDescription(pc, portletContainer.getInfo(), )
+               }
+               else
+               {
+                  // todo: remore portlet description for stopped portlet container
+               }
+            }
+         }
+      }
+   }
+
    private static List<String> getLocaleNamesFrom(Collection<Locale> locales)
    {
       if (locales == null || locales.isEmpty())

Modified: components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/v1/WSRP1Producer.java
===================================================================
--- components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/v1/WSRP1Producer.java	2010-10-12 14:07:09 UTC (rev 4639)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/v1/WSRP1Producer.java	2010-10-12 14:46:26 UTC (rev 4640)
@@ -25,6 +25,7 @@
 
 import org.gatein.exports.ExportManager;
 import org.gatein.pc.api.PortletInvoker;
+import org.gatein.pc.portlet.container.managed.ManagedObjectRegistryEvent;
 import org.gatein.registration.RegistrationManager;
 import org.gatein.wsrp.api.context.ProducerContext;
 import org.gatein.wsrp.producer.ProducerHolder;
@@ -787,4 +788,9 @@
          throw WSRP1ExceptionFactory.createWSException(V1OperationFailed.class, "Not supported", operationNotSupported);
       }
    }
+
+   public void onEvent(ManagedObjectRegistryEvent event)
+   {
+      producer.onEvent(event);
+   }
 }



More information about the gatein-commits mailing list