Re: pluto 1.1: patch for pluto-portal-driver when upgrading to Spring 2.0M1
Stefan Armbruster <[email protected]>
| Newsgroups | gmane.comp.jakarta.pluto.user |
|---|---|
| Message-ID | <[email protected]> |
Hi David,
I've modified the patch in order not to introduce any new dependencies. I
small nested class "ServletContextResource" solves the job.
Regards,
Stefan
Am Montag, 2. Januar 2006 20:01 schrieb David H. DeWolf:
> I would prefer to fix this bug another way as this one change requires
> an entirely new dependency and we're trying to keep pluto "light weight".
>
> Other Thoughts?
>
> David
>
> Stefan Armbruster wrote:
> > Hi,
> >
> > recently the Spring team released Spring 2.0M1. I tried to use this with
> > pluto-portal-driver. When deploying the portal's war file, an
> > IllegalStateException occured. This is caused by
> > InputStreamResource.getInputStream being called twice. The attached patch
> > uses ServletContextResource instead and solves this problem. This patch
> > also contains the necessary version changes in pom.xml.
> >
> > Regards,
> > Stefan
> >
> >
> > ------------------------------------------------------------------------
> >
> > Index:
> > pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverCo
> >nfigurationFactory.java
> > =================================================================== ---
> > pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverCo
> >nfigurationFactory.java (Revision 359203) +++
> > pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverCo
> >nfigurationFactory.java (Arbeitskopie) @@ -20,6 +20,7 @@
> > import org.springframework.beans.factory.xml.XmlBeanFactory;
> > import org.springframework.beans.factory.NoSuchBeanDefinitionException;
> > import org.springframework.core.io.InputStreamResource;
> > +import org.springframework.web.context.support.ServletContextResource;
> >
> > import javax.servlet.ServletContext;
> > import java.io.InputStream;
> > @@ -106,9 +107,7 @@
> >
> > private XmlBeanFactory getBeanFactory(ServletContext context) {
> > if(beanFactory == null) {
> > - InputStream in =
> > - context.getResourceAsStream(DRIVER_CONFIG);
> > - beanFactory = new XmlBeanFactory(new InputStreamResource(in,
> > "Driver Configuration")); + beanFactory = new
> > XmlBeanFactory(new ServletContextResource(context, DRIVER_CONFIG)); }
> > return beanFactory;
> > }
> > Index: pluto-portal-driver/pom.xml
> > ===================================================================
> > --- pluto-portal-driver/pom.xml (Revision 359203)
> > +++ pluto-portal-driver/pom.xml (Arbeitskopie)
> > @@ -88,15 +88,21 @@
> > <dependency>
> > <groupId>org.springframework</groupId>
> > <artifactId>spring-core</artifactId>
> > - <version>1.2.5</version>
> > + <version>2.0-m1</version>
> > <scope>compile</scope>
> > </dependency>
> > <dependency>
> > <groupId>org.springframework</groupId>
> > <artifactId>spring-beans</artifactId>
> > - <version>1.2.5</version>
> > + <version>2.0-m1</version>
> > <scope>compile</scope>
> > </dependency>
> > + <dependency>
> > + <groupId>org.springframework</groupId>
> > + <artifactId>spring-web</artifactId>
> > + <version>2.0-m1</version>
> > + <scope>compile</scope>
> > + </dependency>
> > </dependencies>
> > <build>
> > <resources>
pluto-portal-driver.patch
(text/x-diff, 2.7 KB)
Index: src/main/java/org/apache/pluto/driver/config/DriverConfigurationFactory.java =================================================================== --- src/main/java/org/apache/pluto/driver/config/DriverConfigurationFactory.java (Revision 360482) +++ src/main/java/org/apache/pluto/driver/config/DriverConfigurationFactory.java (Arbeitskopie) @@ -15,15 +15,17 @@ */ package org.apache.pluto.driver.config; +import java.io.IOException; +import java.io.InputStream; + +import javax.servlet.ServletContext; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.xml.XmlBeanFactory; -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.core.io.InputStreamResource; +import org.springframework.core.io.AbstractResource; -import javax.servlet.ServletContext; -import java.io.InputStream; - /** * @author <a href="[email protected]">David H. DeWolf</a> * @version 1.0 @@ -106,12 +108,33 @@ private XmlBeanFactory getBeanFactory(ServletContext context) { if(beanFactory == null) { - InputStream in = - context.getResourceAsStream(DRIVER_CONFIG); - beanFactory = new XmlBeanFactory(new InputStreamResource(in, "Driver Configuration")); + beanFactory = new XmlBeanFactory(new ServletContextResource(context, DRIVER_CONFIG)); } return beanFactory; } + + public static class ServletContextResource extends AbstractResource { + private ServletContext sc; + private String fileName; + + public ServletContextResource(ServletContext sc, String fileName) { + this.sc = sc; + this.fileName = fileName; + } + public String getDescription() { + return null; + } + + public String getFilename() { + return fileName; + } + + public InputStream getInputStream() throws IOException { + return sc.getResourceAsStream(fileName); + } + + } + } Index: pom.xml =================================================================== --- pom.xml (Revision 360482) +++ pom.xml (Arbeitskopie) @@ -88,13 +88,13 @@ <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> - <version>1.2.5</version> + <version>2.0-m1</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> - <version>1.2.5</version> + <version>2.0-m1</version> <scope>compile</scope> </dependency> </dependencies>