You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrp4j-dev@portals.apache.org by es...@apache.org on 2007/07/27 07:03:46 UTC

svn commit: r560101 - in /portals/wsrp4j/branches/wsrp4j-pluto11/src: java/org/apache/wsrp4j/producer/provider/pluto/driver/ProviderImpl.java webapp/WEB-INF/web.xml

Author: esm
Date: Thu Jul 26 22:03:45 2007
New Revision: 560101

URL: http://svn.apache.org/viewvc?view=rev&rev=560101
Log:
Hack to give the pluto provider impl access to the servlet context for pluto container init.

Modified:
    portals/wsrp4j/branches/wsrp4j-pluto11/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/ProviderImpl.java
    portals/wsrp4j/branches/wsrp4j-pluto11/src/webapp/WEB-INF/web.xml

Modified: portals/wsrp4j/branches/wsrp4j-pluto11/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/ProviderImpl.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/branches/wsrp4j-pluto11/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/ProviderImpl.java?view=diff&rev=560101&r1=560100&r2=560101
==============================================================================
--- portals/wsrp4j/branches/wsrp4j-pluto11/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/ProviderImpl.java (original)
+++ portals/wsrp4j/branches/wsrp4j-pluto11/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/ProviderImpl.java Thu Jul 26 22:03:45 2007
@@ -15,6 +15,10 @@
  */
 package org.apache.wsrp4j.producer.provider.pluto.driver;
 
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pluto.PortletContainer;
@@ -30,14 +34,13 @@
 import org.apache.wsrp4j.commons.producer.provider.interfaces.PortletRegistrationFilterWriter;
 import org.apache.wsrp4j.commons.producer.provider.interfaces.PortletStateManager;
 import org.apache.wsrp4j.commons.producer.provider.interfaces.URLComposer;
-import org.apache.wsrp4j.commons.producer.util.ServletAccess;
 import org.apache.wsrp4j.producer.provider.pluto.interfaces.PlutoProvider;
 
 
 /**
  * @version $Id$
  */
-public class ProviderImpl implements PlutoProvider 
+public class ProviderImpl implements PlutoProvider, ServletContextListener 
 {
     
     /**
@@ -95,10 +98,22 @@
      */
     private PortletRegistrationFilterWriter filterWriter = null;
     
-    ProviderImpl( RequiredContainerServices requiredContainerServices, URLComposer urlComposer,
-            DescriptionHandler descHandler, PortletPool portletPool, PortletRegistryService portletRegistrySvc,
-            PortletRegistrationFilter filterReader, PortletRegistrationFilterWriter filterWriter ) 
+    /**
+     * Required Container Services
+     */
+    private RequiredContainerServices requiredContainerServices = null;
+    
+    /**
+     * Servlet Context
+     */
+    private static ServletContext servletContext = null;
+
+    public ProviderImpl( )
+//    ProviderImpl( RequiredContainerServices requiredContainerServices, URLComposer urlComposer,
+//            DescriptionHandler descHandler, PortletPool portletPool, PortletRegistryService portletRegistrySvc,
+//            PortletRegistrationFilter filterReader, PortletRegistrationFilterWriter filterWriter ) 
     { 
+        /*
         if ( requiredContainerServices == null )
         {
             final String msg = "Required container services must not be null";
@@ -147,7 +162,7 @@
             LOG.error( msg );
             throw new IllegalArgumentException( msg );
         }
-        
+        */
         // For now, the portletInvoker is not injected, it is instantiated
         // by this impl.
 //        if ( portletInvoker == null )
@@ -157,25 +172,27 @@
 //            throw new IllegalArgumentException( msg );
 //        }
         
-        LOG.info( "*** Initializing the WSRP4J Pluto Provider ***" );
         
-        init( requiredContainerServices );
+        
+        //init( requiredContainerServices );
+        /*
+        this.requiredContainerServices = requiredContainerServices;
         this.urlComposer = urlComposer;
         this.descriptionHandler = descHandler;
         this.portletPool = portletPool;
         this.portletRegistrySvc = portletRegistrySvc;
         this.filterReader = filterReader;
         this.filterWriter = filterWriter;
+        */
         
-        LOG.info( "*** Initialization complete ***" );
     }
     
     /**
      * Initialize Provider
      */
-    private void init( RequiredContainerServices requiredServices ) 
+    private void init( ServletContext context, RequiredContainerServices requiredServices ) 
     {
-        
+        LOG.info( "*** Initializing the WSRP4J Pluto Provider ***" );
         LOG.debug( "Instantiating the portlet container factory." );
         PortletContainerFactory containerFactory = PortletContainerFactory.getInstance();                
                 
@@ -185,7 +202,7 @@
             this.portletContainer = containerFactory.createContainer( "wsrp4j-producer", requiredServices );
             
             LOG.debug( "Initializing the portlet container" );
-            this.portletContainer.init( ServletAccess.getServletContext() );
+            this.portletContainer.init( context );
         } 
         catch ( PortletContainerException e ) 
         {
@@ -193,7 +210,7 @@
             LOG.fatal( msg, e );
             throw new RuntimeException( msg, e );
         }
-        
+        LOG.info( "*** Initialization complete ***" );
     }
         
     /**
@@ -281,6 +298,53 @@
     public URLComposer getURLComposer() 
     {          
         return urlComposer;        
+    }
+
+    public void contextDestroyed( ServletContextEvent e )
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void contextInitialized( ServletContextEvent e )
+    {        
+        this.servletContext = e.getServletContext();
+    }
+
+    public void setDescriptionHandler( DescriptionHandler descriptionHandler )
+    {
+        this.descriptionHandler = descriptionHandler;
+    }
+
+    public void setFilterReader( PortletRegistrationFilter filterReader )
+    {
+        this.filterReader = filterReader;
+    }
+
+    public void setFilterWriter( PortletRegistrationFilterWriter filterWriter )
+    {
+        this.filterWriter = filterWriter;
+    }
+
+    public void setPortletPool( PortletPool portletPool )
+    {
+        this.portletPool = portletPool;
+    }
+
+    public void setPortletRegistrySvc( PortletRegistryService portletRegistrySvc )
+    {
+        this.portletRegistrySvc = portletRegistrySvc;
+    }
+
+    public void setRequiredContainerServices( RequiredContainerServices requiredContainerServices )
+    {
+        this.requiredContainerServices = requiredContainerServices;
+        init( servletContext, requiredContainerServices );
+    }
+
+    public void setUrlComposer( URLComposer urlComposer )
+    {
+        this.urlComposer = urlComposer;
     }
     
 }

Modified: portals/wsrp4j/branches/wsrp4j-pluto11/src/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/portals/wsrp4j/branches/wsrp4j-pluto11/src/webapp/WEB-INF/web.xml?view=diff&rev=560101&r1=560100&r2=560101
==============================================================================
--- portals/wsrp4j/branches/wsrp4j-pluto11/src/webapp/WEB-INF/web.xml (original)
+++ portals/wsrp4j/branches/wsrp4j-pluto11/src/webapp/WEB-INF/web.xml Thu Jul 26 22:03:45 2007
@@ -33,9 +33,13 @@
     </context-param>
 
     <listener>
-      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+      <listener-class>org.apache.wsrp4j.producer.provider.pluto.driver.ProviderImpl</listener-class>
     </listener>    
 
+    <listener>
+        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>        
+    </listener>
+    
     <!-- Uncomment the following <filter> and <filter-mapping> if you want to 
          activate Hibernate based db persistence. You must also specify the
          persistent factory class on wrp4j-config.properties (see README.txt