You are viewing a plain text version of this content. The canonical link for it is here.
Posted to portalapps-dev@portals.apache.org by wo...@apache.org on 2009/10/07 12:50:47 UTC
svn commit: r822653 - in /portals/applications/webcontent/trunk:
webcontent-jar/
webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/
webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/util/
webconten...
Author: woonsan
Date: Wed Oct 7 10:50:47 2009
New Revision: 822653
URL: http://svn.apache.org/viewvc?rev=822653&view=rev
Log:
APA-17: Allows glob expression in setting reverse proxy configuration files.
Modified:
portals/applications/webcontent/trunk/webcontent-jar/pom.xml
portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/DefaultHttpReverseProxyServlet.java
portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/util/WebResourceUtils.java
portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/web.xml
Modified: portals/applications/webcontent/trunk/webcontent-jar/pom.xml
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/pom.xml?rev=822653&r1=822652&r2=822653&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/pom.xml (original)
+++ portals/applications/webcontent/trunk/webcontent-jar/pom.xml Wed Oct 7 10:50:47 2009
@@ -45,6 +45,7 @@
<commons-httpclient.version>3.0.1</commons-httpclient.version>
<commons-beanutils.version>1.8.0</commons-beanutils.version>
<commons-configuration.version>1.6</commons-configuration.version>
+ <oro.version>2.0.8</oro.version>
</properties>
<!-- Dependencies -->
@@ -174,6 +175,11 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>oro</groupId>
+ <artifactId>oro</artifactId>
+ <version>${oro.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
Modified: portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/DefaultHttpReverseProxyServlet.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/DefaultHttpReverseProxyServlet.java?rev=822653&r1=822652&r2=822653&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/DefaultHttpReverseProxyServlet.java (original)
+++ portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/DefaultHttpReverseProxyServlet.java Wed Oct 7 10:50:47 2009
@@ -692,11 +692,11 @@
if (configResourcePath == null)
{
- configResourcePath = "/WEB-INF/conf/reverseproxy.properties";
+ configResourcePath = "/WEB-INF/conf/reverseproxy*.properties";
}
- File configResourceFile =
- WebResourceUtils.getResourceAsFile(configResourcePath, Thread.currentThread().getContextClassLoader(), getServletContext());
+ File [] configResourceFiles =
+ WebResourceUtils.getResourcesAsFiles(configResourcePath, Thread.currentThread().getContextClassLoader(), getServletContext());
InputStream configInput = null;
@@ -704,9 +704,12 @@
{
configuration = new PropertiesConfiguration();
- if (configResourceFile != null)
+ if (configResourceFiles != null && configResourceFiles.length > 0)
{
- configuration.load(configResourceFile);
+ for (File configResourceFile : configResourceFiles)
+ {
+ configuration.load(configResourceFile);
+ }
if (configReloadingStrategy != null)
{
@@ -715,7 +718,7 @@
}
else
{
- configInput = WebResourceUtils.getResourceAsStream(configResourcePath.substring(10));
+ configInput = WebResourceUtils.getResourceAsStream(configResourcePath, Thread.currentThread().getContextClassLoader(), getServletContext());
configuration.load(configInput);
}
}
Modified: portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/util/WebResourceUtils.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/util/WebResourceUtils.java?rev=822653&r1=822652&r2=822653&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/util/WebResourceUtils.java (original)
+++ portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/util/WebResourceUtils.java Wed Oct 7 10:50:47 2009
@@ -18,6 +18,7 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
@@ -27,6 +28,7 @@
import javax.servlet.ServletContext;
import org.apache.commons.lang.StringUtils;
+import org.apache.oro.io.GlobFilenameFilter;
/**
* WebResourceUtils
@@ -155,11 +157,21 @@
{
if (context instanceof ServletContext)
{
- file = new File(((ServletContext) context).getRealPath(resourcePath));
+ String realPath = ((ServletContext) context).getRealPath(resourcePath);
+
+ if (realPath != null)
+ {
+ file = new File(realPath);
+ }
}
else if (context instanceof PortletContext)
{
- file = new File(((PortletContext) context).getRealPath(resourcePath));
+ String realPath = ((PortletContext) context).getRealPath(resourcePath);
+
+ if (realPath != null)
+ {
+ file = new File(realPath);
+ }
}
else
{
@@ -175,7 +187,30 @@
{
}
- return ((file != null && file.exists()) ? file : null);
+ return file;
+ }
+
+ public static File [] getResourcesAsFiles(String resourcePath)
+ {
+ return getResourcesAsFiles(resourcePath, null, null);
+ }
+
+ public static File [] getResourcesAsFiles(String resourcePath, ClassLoader classloader)
+ {
+ return getResourcesAsFiles(resourcePath, classloader, null);
+ }
+
+ public static File [] getResourcesAsFiles(String resourcePath, Object context)
+ {
+ return getResourcesAsFiles(resourcePath, null, context);
+ }
+
+ public static File [] getResourcesAsFiles(String resourcePath, ClassLoader classloader, Object context)
+ {
+ File file = getResourceAsFile(resourcePath, classloader, context);
+ File parent = file.getParentFile();
+ FilenameFilter filter = new GlobFilenameFilter(file.getName());
+ return parent.listFiles(filter);
}
public static InputStream getResourceAsStream(String resourcePath) throws IOException
Modified: portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/web.xml?rev=822653&r1=822652&r2=822653&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/web.xml (original)
+++ portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/web.xml Wed Oct 7 10:50:47 2009
@@ -53,7 +53,7 @@
<servlet-class>org.apache.portals.applications.webcontent.proxy.impl.DefaultHttpReverseProxyServlet</servlet-class>
<init-param>
<param-name>reverseproxy.configuration</param-name>
- <param-value>/WEB-INF/conf/reverseproxy.properties</param-value>
+ <param-value>/WEB-INF/conf/reverseproxy*.properties</param-value>
</init-param>
<init-param>
<param-name>reverseproxy.configuration.refresh.delay</param-name>