Author: pferraro
Date: 2009-01-23 11:11:56 -0500 (Fri, 23 Jan 2009)
New Revision: 2205
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/config/MCMPHandlerConfiguration.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/config/ModClusterConfig.java
trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml
trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java
Log:
Add excludedContexts config property to enumerate web contexts to exclude from httpd
auto-registration.
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java 2009-01-23
11:03:46 UTC (rev 2204)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java 2009-01-23
16:11:56 UTC (rev 2205)
@@ -24,7 +24,9 @@
import java.io.IOException;
import java.net.InetSocketAddress;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
@@ -51,7 +53,8 @@
*/
public class DefaultJBossWebEventHandler implements JBossWebEventHandler
{
- static Logger log = Logger.getLogger(DefaultJBossWebEventHandler.class);
+ private static final String ROOT_CONTEXT = "ROOT";
+ static final Logger log = Logger.getLogger(DefaultJBossWebEventHandler.class);
// ----------------------------------------------------------------- Fields
@@ -66,7 +69,7 @@
private final MCMPRequestFactory requestFactory;
private final AdvertiseListenerFactory listenerFactory;
private final LoadBalanceFactorProviderFactory loadBalanceFactorProviderFactory;
-// private final Set<String> excludedContexts = new HashSet<String>();
+ private final Set<String> excludedContextPaths = new HashSet<String>();
private volatile boolean init;
@@ -92,17 +95,20 @@
{
List<InetSocketAddress> initialProxies =
Utils.parseProxies(this.mcmpConfig.getProxyList());
this.mcmpHandler.init(initialProxies);
-/*
+
String contexts = this.mcmpConfig.getExcludedContexts();
- if (contexts != null)
+ if ((contexts != null) && (contexts.length() > 0))
{
for (String context: contexts.split(","))
{
- this.excludedContexts.add(context);
+ String trimmedContext = context.trim();
+ String path = trimmedContext.equals(ROOT_CONTEXT) ? "" :
"/" + trimmedContext;
+
+ this.excludedContextPaths.add(path);
}
}
-*/
+
this.loadBalanceFactorProvider =
this.loadBalanceFactorProviderFactory.createLoadBalanceFactorProvider();
Boolean advertise = this.mcmpConfig.getAdvertise();
@@ -144,7 +150,7 @@
}
this.mcmpHandler.shutdown();
-// this.excludedContexts.clear();
+ this.excludedContextPaths.clear();
}
/**
@@ -234,8 +240,8 @@
String path = context.getPath();
-// if (!this.excludedContexts.contains(path))
-// {
+ if (!this.excludedContextPaths.contains(path))
+ {
log.debug(this.sm.getString("modcluster.context.enable", path,
context.getParent().getName()));
// Send ENABLE-APP if state is started
@@ -245,12 +251,8 @@
this.mcmpHandler.sendRequest(request);
}
-/* }
- else
- {
- log.debug("Exluding context: " + path);
}
-*/ }
+ }
public void startContext(Context context)
{
@@ -258,20 +260,16 @@
String path = context.getPath();
-// if (!this.excludedContexts.contains(path))
-// {
+ if (!this.excludedContextPaths.contains(path))
+ {
log.debug(this.sm.getString("modcluster.context.start", path,
context.getParent().getName()));
// Send ENABLE-APP
MCMPRequest request = this.requestFactory.createEnableRequest(context);
this.mcmpHandler.sendRequest(request);
-/* }
- else
- {
- log.debug("Exluding context: " + path);
}
-*/ }
+ }
public void stopContext(Context context)
{
@@ -279,20 +277,16 @@
String path = context.getPath();
-// if (!this.excludedContexts.contains(path))
-// {
+ if (!this.excludedContextPaths.contains(path))
+ {
log.debug(this.sm.getString("modcluster.context.stop", path,
context.getParent().getName()));
// Send STOP-APP
MCMPRequest request = this.requestFactory.createStopRequest(context);
this.mcmpHandler.sendRequest(request);
-/* }
- else
- {
- log.debug("Exluding context: " + path);
}
-*/ }
+ }
public void removeContext(Context context)
{
@@ -300,8 +294,8 @@
String path = context.getPath();
-// if (!this.excludedContexts.contains(path))
-// {
+ if (!this.excludedContextPaths.contains(path))
+ {
log.debug(this.sm.getString("modcluster.context.disable", path,
context.getParent().getName()));
// JVMRoute can be null here if nothing was ever initialized
@@ -311,12 +305,8 @@
this.mcmpHandler.sendRequest(request);
}
-/* }
- else
- {
- log.debug("Exluding context: " + path);
}
-*/ }
+ }
protected void removeAll(Engine engine)
{
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/config/MCMPHandlerConfiguration.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/config/MCMPHandlerConfiguration.java 2009-01-23
11:03:46 UTC (rev 2204)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/config/MCMPHandlerConfiguration.java 2009-01-23
16:11:56 UTC (rev 2205)
@@ -69,5 +69,7 @@
/**
* Advertise security key.
*/
- String getAdvertiseSecurityKey();
+ String getAdvertiseSecurityKey();
+
+ String getExcludedContexts();
}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/config/ModClusterConfig.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/config/ModClusterConfig.java 2009-01-23
11:03:46 UTC (rev 2204)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/config/ModClusterConfig.java 2009-01-23
16:11:56 UTC (rev 2205)
@@ -67,6 +67,10 @@
public boolean isSsl() { return this.ssl; }
public void setSsl(boolean ssl) { this.ssl = ssl; }
+ private String excludedContexts = null;
+ public String getExcludedContexts() { return this.excludedContexts; }
+ public void setExcludedContexts(String excludedContexts) { this.excludedContexts =
excludedContexts; }
+
// ----------------------------------------------------- SSLConfiguration
private String sslCiphers = null;
Modified: trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml
===================================================================
--- trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml 2009-01-23 11:03:46
UTC (rev 2204)
+++ trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml 2009-01-23 16:11:56
UTC (rev 2205)
@@ -36,6 +36,10 @@
<!-- Port to listen to for advertisements -->
<property
name="advertisePort">${jboss.modcluster.advertise.port:23364}</property>
+ <!-- List of contexts that should not be auto-registered with httpd delimited by
commas. -->
+ <!-- ROOT indicates the root context. -->
+ <property
name="excludedContexts">invoker,jbossws,jmx-console,juddi,web-console</property>
+
<!-- Security key the proxy is going to send with advertise messages.
Default is none. -->
<!--property name="advertiseSecurityKey"></property-->
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java 2009-01-23
11:03:46 UTC (rev 2204)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java 2009-01-23
16:11:56 UTC (rev 2205)
@@ -35,7 +35,6 @@
import org.apache.catalina.Server;
import org.apache.catalina.Service;
import org.apache.catalina.connector.Connector;
-import org.easymock.Capture;
import org.easymock.EasyMock;
import org.jboss.modcluster.advertise.AdvertiseListener;
import org.jboss.modcluster.advertise.AdvertiseListenerFactory;
@@ -47,7 +46,6 @@
import org.jboss.modcluster.mcmp.MCMPHandler;
import org.jboss.modcluster.mcmp.MCMPRequest;
import org.jboss.modcluster.mcmp.MCMPRequestFactory;
-import org.jboss.modcluster.mcmp.MCMPRequestType;
import org.jboss.modcluster.mcmp.MCMPServerState;
import org.junit.Assert;
import org.junit.Before;
@@ -89,7 +87,7 @@
this.mcmpHandler.init(Collections.singletonList(new InetSocketAddress(localAddress,
8000)));
-// EasyMock.expect(this.mcmpConfig.getExcludedContexts()).andReturn(null);
+ EasyMock.expect(this.mcmpConfig.getExcludedContexts()).andReturn(null);
EasyMock.expect(this.lbfProviderFactory.createLoadBalanceFactorProvider()).andReturn(this.lbfProvider);
@@ -114,7 +112,7 @@
this.mcmpHandler.init(Collections.singletonList(new InetSocketAddress(localAddress,
8000)));
-// EasyMock.expect(this.mcmpConfig.getExcludedContexts()).andReturn("");
+ EasyMock.expect(this.mcmpConfig.getExcludedContexts()).andReturn("");
EasyMock.expect(this.lbfProviderFactory.createLoadBalanceFactorProvider()).andReturn(this.lbfProvider);
@@ -143,7 +141,7 @@
this.mcmpHandler.init(Collections.singletonList(new InetSocketAddress(localAddress,
8000)));
-//
EasyMock.expect(this.mcmpConfig.getExcludedContexts()).andReturn("/ignored");
+
EasyMock.expect(this.mcmpConfig.getExcludedContexts()).andReturn("ignored");
EasyMock.expect(this.lbfProviderFactory.createLoadBalanceFactorProvider()).andReturn(this.lbfProvider);
@@ -167,7 +165,7 @@
this.mcmpHandler.init(emptyList);
-//
EasyMock.expect(this.mcmpConfig.getExcludedContexts()).andReturn("/ignored,/");
+
EasyMock.expect(this.mcmpConfig.getExcludedContexts()).andReturn("ignored,ROOT");
EasyMock.expect(this.lbfProviderFactory.createLoadBalanceFactorProvider()).andReturn(this.lbfProvider);
@@ -241,7 +239,7 @@
EasyMock.verify(context);
EasyMock.reset(context);
}
-/*
+
@Test
public void addContextIgnored() throws IOException
{
@@ -258,7 +256,7 @@
EasyMock.verify(context);
EasyMock.reset(context);
}
-*/
+
@Test
public void addContextNotStarted() throws IOException
{
@@ -331,7 +329,7 @@
EasyMock.verify(context);
EasyMock.reset(context);
}
-/*
+
@Test
public void startContextIgnored() throws IOException
{
@@ -349,7 +347,7 @@
EasyMock.verify(context);
EasyMock.reset(context);
}
-*/
+
@Test
public void startContext() throws IOException
{
@@ -397,7 +395,7 @@
EasyMock.verify(context);
EasyMock.reset(context);
}
-/*
+
@Test
public void stopContextIgnored() throws IOException
{
@@ -415,7 +413,7 @@
EasyMock.verify(context);
EasyMock.reset(context);
}
-*/
+
@Test
public void stopContext() throws IOException
{
@@ -463,7 +461,7 @@
EasyMock.verify(context);
EasyMock.reset(context);
}
-/*
+
@Test
public void removeContextIgnored() throws IOException
{
@@ -481,7 +479,7 @@
EasyMock.verify(context);
EasyMock.reset(context);
}
-*/
+
@Test
public void removeContextNoJvmRoute() throws IOException
{