You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/10/22 21:25:56 UTC
svn commit: r1187756 [2/2] - in /tomcat/trunk/java/org/apache/catalina: ./
authenticator/ core/ ha/authenticator/ ha/session/ ha/tcp/ startup/ valves/
Modified: tomcat/trunk/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java Sat Oct 22 19:25:55 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -49,7 +49,7 @@ import org.apache.tomcat.util.res.String
* nodes. After all that, the session stickiness will work directly to the
* backup node and the traffic will not go back to the failed node after it is
* restarted!
- *
+ *
* <p>
* For this valve to function correctly, so that all nodes of the cluster
* receive the sessionid change notifications that it generates, the following
@@ -58,34 +58,34 @@ import org.apache.tomcat.util.res.String
* JvmRouteSessionIDBinderListener} since Tomcat 5.5.10, and both
* JvmRouteSessionIDBinderListener and JvmRouteSessionIDBinderLifecycleListener
* for earlier versions of Tomcat.
- *
+ *
* <p>
* Add this Valve to your host definition at conf/server.xml .
- *
+ *
* Since 5.5.10 as direct cluster valve:<br/>
- *
+ *
* <pre>
* <Cluster>
- * <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve" />
+ * <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve" />
* </Cluster>
* </pre>
- *
+ *
* <br />
* Before 5.5.10 as Host element:<br/>
- *
+ *
* <pre>
* <Host>
- * <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve" />
+ * <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve" />
* </Host>
* </pre>
- *
+ *
* <em>A Trick:</em><br/>
* You can enable this mod_jk turnover mode via JMX before you drop a node to
* all backup nodes! Set enable true on all JvmRouteBinderValve backups, disable
* worker at mod_jk and then drop node and restart it! Then enable mod_jk worker
* and disable JvmRouteBinderValves again. This use case means that only
* requested sessions are migrated.
- *
+ *
* @author Peter Rossbach
* @version $Id$
*/
@@ -95,11 +95,6 @@ public class JvmRouteBinderValve extends
public static final org.apache.juli.logging.Log log = org.apache.juli.logging.LogFactory
.getLog(JvmRouteBinderValve.class);
- /**
- * The descriptive information about this implementation.
- */
- protected static final String info = "org.apache.catalina.ha.session.JvmRouteBinderValve/1.2";
-
//------------------------------------------------------ Constructor
public JvmRouteBinderValve() {
super(true);
@@ -133,18 +128,8 @@ public class JvmRouteBinderValve extends
/*--Logic---------------------------------------------------*/
/**
- * Return descriptive information about this implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
-
- /**
* set session id attribute to failed node for request.
- *
+ *
* @return Returns the sessionIdAttribute.
*/
public String getSessionIdAttribute() {
@@ -153,7 +138,7 @@ public class JvmRouteBinderValve extends
/**
* get name of failed request session attribute
- *
+ *
* @param sessionIdAttribute
* The sessionIdAttribute to set.
*/
@@ -185,7 +170,7 @@ public class JvmRouteBinderValve extends
/**
* Detect possible the JVMRoute change at cluster backup node..
- *
+ *
* @param request
* tomcat request being processed
* @param response
@@ -203,7 +188,7 @@ public class JvmRouteBinderValve extends
request.getContext() != null &&
request.getContext().getDistributable() &&
!request.isAsyncDispatching()) {
- // valve cluster can access manager - other cluster handle turnover
+ // valve cluster can access manager - other cluster handle turnover
// at host level - hopefully!
Manager manager = request.getContext().getManager();
@@ -212,8 +197,9 @@ public class JvmRouteBinderValve extends
&& getCluster() != null
&& getCluster().getManager(((ClusterManager)manager).getName()) != null)
||
- (manager instanceof PersistentManager)))
- handlePossibleTurnover(request);
+ (manager instanceof PersistentManager))) {
+ handlePossibleTurnover(request);
+ }
}
// Pass this request on to the next valve in our pipeline
getNext().invoke(request, response);
@@ -221,7 +207,7 @@ public class JvmRouteBinderValve extends
/**
* handle possible session turn over.
- *
+ *
* @see JvmRouteBinderValve#handleJvmRoute(Request, String, String)
* @param request current request
*/
@@ -231,8 +217,9 @@ public class JvmRouteBinderValve extends
long t1 = System.currentTimeMillis();
String jvmRoute = getLocalJvmRoute(request);
if (jvmRoute == null) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("jvmRoute.missingJvmRouteAttribute"));
+ }
return;
}
handleJvmRoute( request, sessionID, jvmRoute);
@@ -246,30 +233,32 @@ public class JvmRouteBinderValve extends
/**
* get jvmroute from engine
- *
+ *
* @param request current request
* @return return jvmRoute from ManagerBase or null
*/
protected String getLocalJvmRoute(Request request) {
Manager manager = getManager(request);
- if(manager instanceof ManagerBase)
+ if(manager instanceof ManagerBase) {
return ((ManagerBase) manager).getJvmRoute();
+ }
return null ;
}
/**
* get Cluster DeltaManager
- *
+ *
* @param request current request
* @return manager or null
*/
protected Manager getManager(Request request) {
Manager manager = request.getContext().getManager();
if (log.isDebugEnabled()) {
- if(manager != null)
+ if(manager != null) {
log.debug(sm.getString("jvmRoute.foundManager", manager, request.getContext().getName()));
- else
+ } else {
log.debug(sm.getString("jvmRoute.notFoundManager", request.getContext().getName()));
+ }
}
return manager;
}
@@ -281,7 +270,7 @@ public class JvmRouteBinderValve extends
public CatalinaCluster getCluster() {
return cluster;
}
-
+
/**
* @param cluster The cluster to set.
*/
@@ -289,12 +278,12 @@ public class JvmRouteBinderValve extends
public void setCluster(CatalinaCluster cluster) {
this.cluster = cluster;
}
-
+
/**
* Handle jvmRoute stickiness after tomcat instance failed. After this
* correction a new Cookie send to client with new jvmRoute and the
* SessionID change propagate to the other cluster nodes.
- *
+ *
* @param request current request
* @param sessionId
* request SessionID from Cookie
@@ -348,7 +337,7 @@ public class JvmRouteBinderValve extends
/**
* change session id and send to all cluster nodes
- *
+ *
* @param request current request
* @param sessionId
* original session id
@@ -363,8 +352,9 @@ public class JvmRouteBinderValve extends
catalinaSession.setId(newSessionID, false);
// FIXME: Why we remove change data from other running request?
// setId also trigger resetDeltaRequest!!
- if (catalinaSession instanceof DeltaSession)
+ if (catalinaSession instanceof DeltaSession) {
((DeltaSession) catalinaSession).resetDeltaRequest();
+ }
changeRequestSessionID(request, sessionId, newSessionID);
// now sending the change to all other clusternodes!
@@ -374,7 +364,7 @@ public class JvmRouteBinderValve extends
if (log.isDebugEnabled()) {
log.debug(sm.getString("jvmRoute.changeSession", sessionId,
newSessionID));
- }
+ }
}
/**
@@ -397,10 +387,10 @@ public class JvmRouteBinderValve extends
request.setAttribute(sessionIdAttribute, sessionId);
}
}
-
+
/**
* Send the changed Sessionid to all clusternodes.
- *
+ *
* @see JvmRouteSessionIDBinderListener#messageReceived(
* org.apache.catalina.ha.ClusterMessage)
* @param sessionId
@@ -431,14 +421,15 @@ public class JvmRouteBinderValve extends
*/
@Override
protected synchronized void startInternal() throws LifecycleException {
-
+
if (cluster == null) {
Container hostContainer = getContainer();
// compatibility with JvmRouteBinderValve version 1.1
// ( setup at context.xml or context.xml.default )
if (!(hostContainer instanceof Host)) {
- if (log.isWarnEnabled())
+ if (log.isWarnEnabled()) {
log.warn(sm.getString("jvmRoute.configure.warn"));
+ }
hostContainer = hostContainer.getParent();
}
if (hostContainer instanceof Host
@@ -452,17 +443,18 @@ public class JvmRouteBinderValve extends
}
}
}
-
+
if (log.isInfoEnabled()) {
log.info(sm.getString("jvmRoute.valve.started"));
- if (cluster == null)
+ if (cluster == null) {
log.info(sm.getString("jvmRoute.noCluster"));
+ }
}
super.startInternal();
}
-
+
/**
* Stop this component and implement the requirements
* of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
@@ -477,8 +469,9 @@ public class JvmRouteBinderValve extends
cluster = null;
numberOfSessions = 0;
- if (log.isInfoEnabled())
+ if (log.isInfoEnabled()) {
log.info(sm.getString("jvmRoute.valve.stopped"));
+ }
}
Modified: tomcat/trunk/java/org/apache/catalina/ha/tcp/ReplicationValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/tcp/ReplicationValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/tcp/ReplicationValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ha/tcp/ReplicationValve.java Sat Oct 22 19:25:55 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -63,20 +63,13 @@ import org.apache.tomcat.util.res.String
public class ReplicationValve
extends ValveBase implements ClusterValve {
-
+
private static final org.apache.juli.logging.Log log =
org.apache.juli.logging.LogFactory.getLog( ReplicationValve.class );
// ----------------------------------------------------- Instance Variables
/**
- * The descriptive information related to this implementation.
- */
- private static final String info =
- "org.apache.catalina.ha.tcp.ReplicationValve/2.0";
-
-
- /**
* The StringManager for this package.
*/
protected static final StringManager sm =
@@ -85,21 +78,21 @@ public class ReplicationValve
private CatalinaCluster cluster = null ;
/**
- * Filter expression
+ * Filter expression
*/
protected Pattern filter = null;
-
+
/**
- * crossContext session container
+ * crossContext session container
*/
protected ThreadLocal<ArrayList<DeltaSession>> crossContextSessions =
new ThreadLocal<ArrayList<DeltaSession>>() ;
-
+
/**
* doProcessingStats (default = off)
*/
protected boolean doProcessingStats = false;
-
+
protected long totalRequestTime = 0;
protected long totalSendTime = 0;
protected long nrOfRequests = 0;
@@ -107,33 +100,23 @@ public class ReplicationValve
protected long nrOfFilterRequests = 0;
protected long nrOfSendRequests = 0;
protected long nrOfCrossContextSendRequests = 0;
-
+
/**
- * must primary change indicator set
+ * must primary change indicator set
*/
protected boolean primaryIndicator = false ;
-
+
/**
* Name of primary change indicator as request attribute
*/
protected String primaryIndicatorName = "org.apache.catalina.ha.tcp.isPrimarySession";
-
+
// ------------------------------------------------------------- Properties
public ReplicationValve() {
super(true);
}
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
- return (info);
-
- }
-
/**
* @return Returns the cluster.
*/
@@ -141,7 +124,7 @@ public class ReplicationValve
public CatalinaCluster getCluster() {
return cluster;
}
-
+
/**
* @param cluster The cluster to set.
*/
@@ -149,7 +132,7 @@ public class ReplicationValve
public void setCluster(CatalinaCluster cluster) {
this.cluster = cluster;
}
-
+
/**
* @return Returns the filter
*/
@@ -167,9 +150,10 @@ public class ReplicationValve
* The filter to set.
*/
public void setFilter(String filter) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("ReplicationValve.filter.loading", filter));
-
+ }
+
if (filter == null || filter.length() == 0) {
this.filter = null;
} else {
@@ -195,21 +179,21 @@ public class ReplicationValve
public void setPrimaryIndicator(boolean primaryIndicator) {
this.primaryIndicator = primaryIndicator;
}
-
+
/**
* @return Returns the primaryIndicatorName.
*/
public String getPrimaryIndicatorName() {
return primaryIndicatorName;
}
-
+
/**
* @param primaryIndicatorName The primaryIndicatorName to set.
*/
public void setPrimaryIndicatorName(String primaryIndicatorName) {
this.primaryIndicatorName = primaryIndicatorName;
}
-
+
/**
* Calc processing stats
*/
@@ -231,14 +215,14 @@ public class ReplicationValve
public long getLastSendTime() {
return lastSendTime;
}
-
+
/**
* @return Returns the nrOfRequests.
*/
public long getNrOfRequests() {
return nrOfRequests;
}
-
+
/**
* @return Returns the nrOfFilterRequests.
*/
@@ -266,7 +250,7 @@ public class ReplicationValve
public long getTotalRequestTime() {
return totalRequestTime;
}
-
+
/**
* @return Returns the totalSendTime.
*/
@@ -275,7 +259,7 @@ public class ReplicationValve
}
// --------------------------------------------------------- Public Methods
-
+
/**
* Register all cross context sessions inside endAccess.
* Use a list with contains check, that the Portlet API can include a lot of fragments from same or
@@ -287,10 +271,11 @@ public class ReplicationValve
List<DeltaSession> sessions = crossContextSessions.get();
if(sessions != null) {
if(!sessions.contains(session)) {
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug(sm.getString("ReplicationValve.crossContext.registerSession",
session.getIdInternal(),
session.getManager().getContainer().getName()));
+ }
sessions.add(session);
}
}
@@ -325,39 +310,43 @@ public class ReplicationValve
&& ((StandardContext) context).getCrossContext();
try {
if(isCrossContext) {
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug(sm.getString("ReplicationValve.crossContext.add"));
+ }
//FIXME add Pool of Arraylists
crossContextSessions.set(new ArrayList<DeltaSession>());
}
getNext().invoke(request, response);
if(context != null) {
- Manager manager = context.getManager();
+ Manager manager = context.getManager();
if (manager != null && manager instanceof ClusterManager) {
ClusterManager clusterManager = (ClusterManager) manager;
CatalinaCluster containerCluster = (CatalinaCluster) getContainer().getCluster();
if (containerCluster == null) {
- if (log.isWarnEnabled())
+ if (log.isWarnEnabled()) {
log.warn(sm.getString("ReplicationValve.nocluster"));
+ }
return;
}
- // valve cluster can access manager - other cluster handle replication
+ // valve cluster can access manager - other cluster handle replication
// at host level - hopefully!
- if(containerCluster.getManager(clusterManager.getName()) == null)
+ if(containerCluster.getManager(clusterManager.getName()) == null) {
return ;
+ }
if(containerCluster.hasMembers()) {
sendReplicationMessage(request, totalstart, isCrossContext, clusterManager, containerCluster);
} else {
resetReplicationRequest(request,isCrossContext);
- }
+ }
}
}
} finally {
- // Array must be remove: Current master request send endAccess at recycle.
+ // Array must be remove: Current master request send endAccess at recycle.
// Don't register this request session again!
if(isCrossContext) {
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug(sm.getString("ReplicationValve.crossContext.remove"));
+ }
// crossContextSessions.remove() only exist at Java 5
// register ArrayList at a pool
crossContextSessions.set(null);
@@ -365,9 +354,9 @@ public class ReplicationValve
}
}
-
+
/**
- * reset the active statistics
+ * reset the active statistics
*/
public void resetStatistics() {
totalRequestTime = 0 ;
@@ -378,7 +367,7 @@ public class ReplicationValve
nrOfSendRequests = 0;
nrOfCrossContextSendRequests = 0;
}
-
+
// --------------------------------------------------------- Protected Methods
@@ -398,12 +387,14 @@ public class ReplicationValve
try {
// send invalid sessions
// DeltaManager returns String[0]
- if (!(clusterManager instanceof DeltaManager))
+ if (!(clusterManager instanceof DeltaManager)) {
sendInvalidSessions(clusterManager, containerCluster);
+ }
// send replication
sendSessionReplicationMessage(request, clusterManager, containerCluster);
- if(isCrossContext)
+ if(isCrossContext) {
sendCrossContextSession(containerCluster);
+ }
} catch (Exception x) {
// FIXME we have a lot of sends, but the trouble with one node stops the correct replication to other nodes!
log.error(sm.getString("ReplicationValve.send.failure"), x);
@@ -422,11 +413,12 @@ public class ReplicationValve
protected void sendCrossContextSession(CatalinaCluster containerCluster) {
List<DeltaSession> sessions = crossContextSessions.get();
if(sessions != null && sessions.size() >0) {
- for(Iterator<DeltaSession> iter = sessions.iterator(); iter.hasNext() ;) {
+ for(Iterator<DeltaSession> iter = sessions.iterator(); iter.hasNext() ;) {
Session session = iter.next();
- if(log.isDebugEnabled())
- log.debug(sm.getString("ReplicationValve.crossContext.sendDelta",
+ if(log.isDebugEnabled()) {
+ log.debug(sm.getString("ReplicationValve.crossContext.sendDelta",
session.getManager().getContainer().getName() ));
+ }
sendMessage(session,(ClusterManager)session.getManager(),containerCluster);
if(doStatistics()) {
nrOfCrossContextSendRequests++;
@@ -434,7 +426,7 @@ public class ReplicationValve
}
}
}
-
+
/**
* Fix memory leak for long sessions with many changes, when no backup member exists!
* @param request current request after response is generated
@@ -450,15 +442,16 @@ public class ReplicationValve
List<DeltaSession> sessions = crossContextSessions.get();
if(sessions != null && sessions.size() >0) {
Iterator<DeltaSession> iter = sessions.iterator();
- for(; iter.hasNext() ;) {
+ for(; iter.hasNext() ;) {
Session session = iter.next();
resetDeltaRequest(session);
- if(session instanceof DeltaSession)
+ if(session instanceof DeltaSession) {
((DeltaSession)contextSession).setPrimarySession(true);
+ }
}
}
- }
+ }
}
/**
@@ -467,7 +460,7 @@ public class ReplicationValve
*/
protected void resetDeltaRequest(Session session) {
if(log.isDebugEnabled()) {
- log.debug(sm.getString("ReplicationValve.resetDeltaRequest" ,
+ log.debug(sm.getString("ReplicationValve.resetDeltaRequest" ,
session.getManager().getContainer().getName() ));
}
((DeltaSession)session).resetDeltaRequest();
@@ -486,18 +479,20 @@ public class ReplicationValve
String uri = request.getDecodedRequestURI();
// request without session change
if (!isRequestWithoutSessionChange(uri)) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("ReplicationValve.invoke.uri", uri));
+ }
sendMessage(session,manager,cluster);
} else
- if(doStatistics())
+ if(doStatistics()) {
nrOfFilterRequests++;
+ }
}
}
/**
- * Send message delta message from request session
+ * Send message delta message from request session
* @param session current session
* @param manager session manager
* @param cluster replication cluster
@@ -522,11 +517,12 @@ public class ReplicationValve
ClusterMessage msg = manager.requestCompleted(sessionId);
if (msg != null) {
cluster.send(msg);
- if(doStatistics())
+ if(doStatistics()) {
nrOfSendRequests++;
+ }
}
}
-
+
/**
* check for session invalidations
* @param manager
@@ -544,7 +540,7 @@ public class ReplicationValve
}
}
}
-
+
/**
* is request without possible session change
* @param uri The request uri
@@ -589,7 +585,7 @@ public class ReplicationValve
/**
* Mark Request that processed at primary node with attribute
* primaryIndicatorName
- *
+ *
* @param request
* @throws IOException
*/
@@ -600,11 +596,12 @@ public class ReplicationValve
Session session = manager.findSession(id);
if (session instanceof ClusterSession) {
ClusterSession cses = (ClusterSession) session;
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString(
"ReplicationValve.session.indicator", request.getContext().getName(),id,
primaryIndicatorName,
Boolean.valueOf(cses.isPrimarySession())));
+ }
request.setAttribute(primaryIndicatorName, cses.isPrimarySession()?Boolean.TRUE:Boolean.FALSE);
} else {
if (log.isDebugEnabled()) {
Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Sat Oct 22 19:25:55 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -112,7 +112,7 @@ public class ContextConfig
implements LifecycleListener {
private static final Log log = LogFactory.getLog( ContextConfig.class );
-
+
private static final String SCI_LOCATION =
"META-INF/services/javax.servlet.ServletContainerInitializer";
@@ -132,7 +132,7 @@ public class ContextConfig
* context files.
*/
protected static Digester contextDigester = null;
-
+
/**
* The set of Authenticators that we know how to configure. The key is
@@ -198,14 +198,14 @@ public class ContextConfig
* The default web application's context file location.
*/
protected String defaultContextXml = null;
-
-
+
+
/**
* The default web application's deployment descriptor location.
*/
protected String defaultWebXml = null;
-
-
+
+
/**
* Track any fatal errors during startup configuration processing.
*/
@@ -216,14 +216,14 @@ public class ContextConfig
* Original docBase.
*/
protected String originalDocBase = null;
-
+
/**
* Map of ServletContainerInitializer to classes they expressed interest in.
*/
protected Map<ServletContainerInitializer, Set<Class<?>>> initializerClassMap =
new LinkedHashMap<ServletContainerInitializer, Set<Class<?>>>();
-
+
/**
* Map of Types to ServletContainerInitializer that are interested in those
* types.
@@ -243,7 +243,7 @@ public class ContextConfig
*/
protected Digester webFragmentDigester = null;
-
+
// ------------------------------------------------------------- Properties
/**
* Return the location of the default deployment descriptor
@@ -361,11 +361,11 @@ public class ContextConfig
* Process the application classes annotations, if it exists.
*/
protected void applicationAnnotationsConfig() {
-
+
long t1=System.currentTimeMillis();
-
+
WebAnnotationSet.loadApplicationAnnotations(context);
-
+
long t2=System.currentTimeMillis();
if (context instanceof StandardContext) {
((StandardContext) context).setStartupTime(t2-t1+
@@ -398,9 +398,10 @@ public class ContextConfig
}
// Has an authenticator been configured already?
- if (context.getAuthenticator() != null)
+ if (context.getAuthenticator() != null) {
return;
-
+ }
+
if (!(context instanceof ContainerBase)) {
return; // Cannot install a Valve even if it would be needed
}
@@ -490,7 +491,7 @@ public class ContextConfig
*/
public void createWebXmlDigester(boolean namespaceAware,
boolean validation) {
-
+
if (!namespaceAware && !validation) {
if (webDigesters[0] == null) {
webDigesters[0] = DigesterFactory.newDigester(validation,
@@ -502,7 +503,7 @@ public class ContextConfig
}
webDigester = webDigesters[0];
webFragmentDigester = webFragmentDigesters[0];
-
+
} else if (!namespaceAware && validation) {
if (webDigesters[1] == null) {
webDigesters[1] = DigesterFactory.newDigester(validation,
@@ -514,7 +515,7 @@ public class ContextConfig
}
webDigester = webDigesters[1];
webFragmentDigester = webFragmentDigesters[1];
-
+
} else if (namespaceAware && !validation) {
if (webDigesters[2] == null) {
webDigesters[2] = DigesterFactory.newDigester(validation,
@@ -526,7 +527,7 @@ public class ContextConfig
}
webDigester = webDigesters[2];
webFragmentDigester = webFragmentDigesters[2];
-
+
} else {
if (webDigesters[3] == null) {
webDigesters[3] = DigesterFactory.newDigester(validation,
@@ -541,7 +542,7 @@ public class ContextConfig
}
}
-
+
/**
* Create (if necessary) and return a Digester configured to process the
* context configuration descriptor for an application.
@@ -572,18 +573,20 @@ public class ContextConfig
return System.getProperty(Globals.CATALINA_BASE_PROP);
}
-
+
/**
* Process the default configuration file, if it exists.
*/
protected void contextConfig() {
-
+
// Open the default context.xml file, if it exists
if( defaultContextXml==null && context instanceof StandardContext ) {
defaultContextXml = ((StandardContext)context).getDefaultContextXml();
}
// set the default if we don't have any overrides
- if( defaultContextXml==null ) getDefaultContextXml();
+ if( defaultContextXml==null ) {
+ getDefaultContextXml();
+ }
if (!context.getOverride()) {
File defaultContextFile = new File(defaultContextXml);
@@ -599,7 +602,7 @@ public class ContextConfig
"contextConfig.badUrl", defaultContextFile), e);
}
}
-
+
File hostContextFile = new File(getConfigBase(),
getHostConfigPath(Constants.HostContextXml));
if (hostContextFile.exists()) {
@@ -612,20 +615,22 @@ public class ContextConfig
}
}
}
- if (context.getConfigFile() != null)
+ if (context.getConfigFile() != null) {
processContextConfig(context.getConfigFile());
-
+ }
+
}
-
+
/**
* Process a context.xml.
*/
protected void processContextConfig(URL contextXml) {
-
- if (log.isDebugEnabled())
- log.debug("Processing context [" + context.getName()
+
+ if (log.isDebugEnabled()) {
+ log.debug("Processing context [" + context.getName()
+ "] configuration file [" + contextXml + "]");
+ }
InputSource source = null;
InputStream stream = null;
@@ -633,7 +638,7 @@ public class ContextConfig
try {
source = new InputSource(contextXml.toString());
stream = contextXml.openStream();
-
+
// Add as watched resource so that cascade reload occurs if a default
// config file is modified/added/removed
if ("file".equals(contextXml.getProtocol())) {
@@ -641,12 +646,13 @@ public class ContextConfig
(new File(contextXml.toURI())).getAbsolutePath());
}
} catch (Exception e) {
- log.error(sm.getString("contextConfig.contextMissing",
+ log.error(sm.getString("contextConfig.contextMissing",
contextXml) , e);
}
-
- if (source == null)
+
+ if (source == null) {
return;
+ }
synchronized (contextDigester) {
try {
source.setByteStream(stream);
@@ -662,9 +668,10 @@ public class ContextConfig
errorHandler.logFindings(log, contextXml.toString());
ok = false;
}
- if (log.isDebugEnabled())
- log.debug("Successfully processed context [" + context.getName()
+ if (log.isDebugEnabled()) {
+ log.debug("Successfully processed context [" + context.getName()
+ "] configuration file [" + contextXml + "]");
+ }
} catch (SAXParseException e) {
log.error(sm.getString("contextConfig.contextParse",
context.getName()), e);
@@ -689,13 +696,13 @@ public class ContextConfig
}
}
-
+
/**
* Adjust docBase.
*/
protected void fixDocBase()
throws IOException {
-
+
Host host = (Host) context.getParent();
File appBase = host.getAppBaseFile();
@@ -718,7 +725,7 @@ public class ContextConfig
}
file = new File(docBase);
String origDocBase = docBase;
-
+
ContextName cn = new ContextName(context.getPath(),
context.getWebappVersion());
String pathName = cn.getBaseName();
@@ -778,17 +785,18 @@ public class ContextConfig
context.setDocBase(docBase);
}
-
-
+
+
protected void antiLocking() {
- if ((context instanceof StandardContext)
+ if ((context instanceof StandardContext)
&& ((StandardContext) context).getAntiResourceLocking()) {
-
+
Host host = (Host) context.getParent();
String docBase = context.getDocBase();
- if (docBase == null)
+ if (docBase == null) {
return;
+ }
if (originalDocBase == null) {
originalDocBase = docBase;
} else {
@@ -798,7 +806,7 @@ public class ContextConfig
if (!docBaseFile.isAbsolute()) {
docBaseFile = new File(host.getAppBaseFile(), docBase);
}
-
+
String path = context.getPath();
if (path == null) {
return;
@@ -812,24 +820,25 @@ public class ContextConfig
file = new File(System.getProperty("java.io.tmpdir"),
deploymentCount++ + "-" + docBase + ".war");
} else {
- file = new File(System.getProperty("java.io.tmpdir"),
+ file = new File(System.getProperty("java.io.tmpdir"),
deploymentCount++ + "-" + docBase);
}
-
- if (log.isDebugEnabled())
- log.debug("Anti locking context[" + context.getName()
+
+ if (log.isDebugEnabled()) {
+ log.debug("Anti locking context[" + context.getName()
+ "] setting docBase to " + file);
-
+ }
+
// Cleanup just in case an old deployment is lying around
ExpandWar.delete(file);
if (ExpandWar.copy(docBaseFile, file)) {
context.setDocBase(file.getAbsolutePath());
}
-
+
}
-
+
}
-
+
/**
* Process a "init" event for this Context.
@@ -842,13 +851,14 @@ public class ContextConfig
contextDigester.getParser();
}
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("contextConfig.init"));
+ }
context.setConfigured(false);
ok = true;
-
+
contextConfig();
-
+
createWebXmlDigester(context.getXmlNamespaceAware(),
context.getXmlValidation());
@@ -858,28 +868,29 @@ public class ContextConfig
log.error(sm.getString(
"contextConfig.fixDocBase", context.getName()), e);
}
-
+
}
-
-
+
+
/**
* Process a "before start" event for this Context.
*/
protected synchronized void beforeStart() {
-
+
antiLocking();
}
-
-
+
+
/**
* Process a "contextConfig" event for this Context.
*/
protected synchronized void configureStart() {
// Called from StandardContext.start()
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("contextConfig.start"));
+ }
if (log.isDebugEnabled()) {
log.debug(sm.getString("contextConfig.xmlSettings",
@@ -887,7 +898,7 @@ public class ContextConfig
Boolean.valueOf(context.getXmlValidation()),
Boolean.valueOf(context.getXmlNamespaceAware())));
}
-
+
webConfig();
if (!context.getIgnoreAnnotations()) {
@@ -898,28 +909,30 @@ public class ContextConfig
}
// Configure an authenticator if we need one
- if (ok)
+ if (ok) {
authenticatorConfig();
+ }
// Dump the contents of this pipeline if requested
if ((log.isDebugEnabled()) && (context instanceof ContainerBase)) {
log.debug("Pipeline Configuration:");
Pipeline pipeline = ((ContainerBase) context).getPipeline();
Valve valves[] = null;
- if (pipeline != null)
+ if (pipeline != null) {
valves = pipeline.getValves();
+ }
if (valves != null) {
for (int i = 0; i < valves.length; i++) {
- log.debug(" " + valves[i].getInfo());
+ log.debug(" " + valves[i].getClass().getName());
}
}
log.debug("======================");
}
// Make our application available if no problems were encountered
- if (ok)
+ if (ok) {
context.setConfigured(true);
- else {
+ } else {
log.error(sm.getString("contextConfig.unavailable"));
context.setConfigured(false);
}
@@ -932,8 +945,9 @@ public class ContextConfig
*/
protected synchronized void configureStop() {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("contextConfig.stop"));
+ }
int i;
@@ -1081,53 +1095,55 @@ public class ContextConfig
// No need to log failure - it is expected in this case
ExpandWar.delete(docBaseFile, false);
}
-
+
// Reset ServletContextInitializer scanning
initializerClassMap.clear();
typeInitializerMap.clear();
-
+
ok = true;
}
-
-
+
+
/**
* Process a "destroy" event for this Context.
*/
protected synchronized void destroy() {
// Called from StandardContext.destroy()
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("contextConfig.destroy"));
+ }
// Skip clearing the work directory if Tomcat is being shutdown
Server s = getServer();
if (s != null && !s.getState().isAvailable()) {
return;
}
-
+
// Changed to getWorkPath per Bugzilla 35819.
String workDir = ((StandardContext) context).getWorkPath();
- if (workDir != null)
+ if (workDir != null) {
ExpandWar.delete(new File(workDir));
+ }
}
-
-
+
+
private Server getServer() {
Container c = context;
while (c != null && !(c instanceof Engine)) {
c = c.getParent();
}
-
+
if (c == null) {
return null;
}
-
+
Service s = ((Engine)c).getService();
-
+
if (s == null) {
return null;
}
-
+
return s.getServer();
}
@@ -1179,25 +1195,27 @@ public class ContextConfig
* Get config base.
*/
protected File getConfigBase() {
- File configBase =
+ File configBase =
new File(System.getProperty(Globals.CATALINA_BASE_PROP), "conf");
if (!configBase.exists()) {
return null;
}
return configBase;
- }
+ }
+
-
protected String getHostConfigPath(String resourceName) {
StringBuilder result = new StringBuilder();
Container container = context;
Container host = null;
Container engine = null;
while (container != null) {
- if (container instanceof Host)
+ if (container instanceof Host) {
host = container;
- if (container instanceof Engine)
+ }
+ if (container instanceof Engine) {
engine = container;
+ }
container = container.getParent();
}
if (engine != null) {
@@ -1225,7 +1243,7 @@ public class ContextConfig
* everything else takes priority
* - Mark Servlets as overridable so SCI configuration can replace
* configuration from the defaults
- */
+ */
Set<WebXml> defaults = new HashSet<WebXml>();
defaults.add(getDefaultWebXmlFragment());
@@ -1234,7 +1252,7 @@ public class ContextConfig
// Parse context level web.xml
InputSource contextWebXml = getContextWebXmlSource();
parseWebXml(contextWebXml, webXml, false);
-
+
if (webXml.getMajorVersion() >= 3) {
// Ordering is important here
@@ -1249,12 +1267,12 @@ public class ContextConfig
if (!webXml.isMetadataComplete()) {
// Step 2. Order the fragments.
orderedFragments = WebXml.orderWebFragments(webXml, fragments);
-
+
// Step 3. Look for ServletContainerInitializer implementations
if (ok) {
processServletContainerInitializers(orderedFragments);
}
-
+
// Step 4. Process /WEB-INF/classes for annotations
// This will add any matching classes to the typeInitializerMap
if (ok) {
@@ -1268,20 +1286,20 @@ public class ContextConfig
"contextConfig.webinfClassesUrl"), e);
}
}
-
+
// Step 5. Process JARs for annotations - only need to process
// those fragments we are going to use
// This will add any matching classes to the typeInitializerMap
if (ok) {
processAnnotations(orderedFragments);
}
-
+
// Step 6. Merge web-fragment.xml files into the main web.xml
// file.
if (ok) {
ok = webXml.merge(orderedFragments);
}
-
+
// Step 7. Apply global defaults
// Have to merge defaults before JSP conversion since defaults
// provide JSP servlet definition.
@@ -1291,11 +1309,11 @@ public class ContextConfig
if (ok) {
convertJsps(webXml);
}
-
+
// Step 9. Apply merged web.xml to Context
if (ok) {
webXml.configureContext(context);
-
+
// Step 9a. Make the merged web.xml available to other
// components, specifically Jasper, to save those components
// from having to re-generate it.
@@ -1312,7 +1330,7 @@ public class ContextConfig
webXml.merge(defaults);
webXml.configureContext(context);
}
-
+
// Always need to look for static resources
// Step 10. Look for static resources packaged in JARs
if (ok) {
@@ -1333,7 +1351,7 @@ public class ContextConfig
// See also StandardContext.resourcesStart() for
// WEB-INF/classes/META-INF/resources configuration
}
-
+
// Only look for ServletContainerInitializer if metadata is not
// complete
if (!webXml.isMetadataComplete()) {
@@ -1341,7 +1359,7 @@ public class ContextConfig
// context
if (ok) {
for (Map.Entry<ServletContainerInitializer,
- Set<Class<?>>> entry :
+ Set<Class<?>>> entry :
initializerClassMap.entrySet()) {
if (entry.getValue().isEmpty()) {
context.addServletContainerInitializer(
@@ -1367,13 +1385,13 @@ public class ContextConfig
Host host = (Host) context.getParent();
DefaultWebXmlCacheEntry entry = hostWebXmlCache.get(host);
-
+
InputSource globalWebXml = getGlobalWebXmlSource();
InputSource hostWebXml = getHostWebXmlSource();
-
+
long globalTimeStamp = 0;
long hostTimeStamp = 0;
-
+
if (globalWebXml != null) {
try {
File f = new File(new URI(globalWebXml.getSystemId()));
@@ -1382,7 +1400,7 @@ public class ContextConfig
globalTimeStamp = -1;
}
}
-
+
if (hostWebXml != null) {
try {
File f = new File(new URI(hostWebXml.getSystemId()));
@@ -1391,12 +1409,12 @@ public class ContextConfig
hostTimeStamp = -1;
}
}
-
+
if (entry != null && entry.getGlobalTimeStamp() == globalTimeStamp &&
entry.getHostTimeStamp() == hostTimeStamp) {
return entry.getWebXml();
}
-
+
// Parsing global web.xml is relatively expensive. Use a sync block to
// make sure it only happens once
synchronized (host) {
@@ -1423,13 +1441,13 @@ public class ContextConfig
} else {
parseWebXml(globalWebXml, webXmlDefaultFragment, false);
}
-
+
// Parse host level web.xml if present
// Additive apart from welcome pages
webXmlDefaultFragment.setReplaceWelcomeFiles(true);
-
+
parseWebXml(hostWebXml, webXmlDefaultFragment, false);
-
+
// Don't update the cache if an error occurs
if (globalTimeStamp != -1 && hostTimeStamp != -1) {
entry = new DefaultWebXmlCacheEntry(webXmlDefaultFragment,
@@ -1470,9 +1488,10 @@ public class ContextConfig
String jspFile = servletDef.getJspFile();
if ((jspFile != null) && !jspFile.startsWith("/")) {
if (context.isServlet22()) {
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug(sm.getString("contextConfig.jspFile.warning",
jspFile));
+ }
jspFile = "/" + jspFile;
} else {
throw new IllegalArgumentException
@@ -1496,7 +1515,7 @@ public class ContextConfig
*/
protected void processServletContainerInitializers(
Set<WebXml> fragments) {
-
+
for (WebXml fragment : fragments) {
URL url = fragment.getURL();
Jar jar = null;
@@ -1534,13 +1553,13 @@ public class ContextConfig
jar.close();
}
}
-
+
if (sci == null) {
continue;
}
initializerClassMap.put(sci, new HashSet<Class<?>>());
-
+
HandlesTypes ht =
sci.getClass().getAnnotation(HandlesTypes.class);
if (ht != null) {
@@ -1560,12 +1579,12 @@ public class ContextConfig
}
}
-
-
+
+
/**
* Extract the name of the ServletContainerInitializer.
- *
- * @param is The resource where the name is defined
+ *
+ * @param is The resource where the name is defined
* @return The class name
* @throws IOException
*/
@@ -1573,7 +1592,7 @@ public class ContextConfig
InputStream is) throws IOException {
String className = null;
-
+
if (is != null) {
String line = null;
try {
@@ -1588,7 +1607,7 @@ public class ContextConfig
// If it does - ignore & return null
}
}
-
+
ServletContainerInitializer sci = null;
try {
Class<?> clazz = Class.forName(className,true,
@@ -1604,11 +1623,11 @@ public class ContextConfig
log.error(sm.getString("contextConfig.invalidSci", className), e);
throw new IOException(e);
}
-
+
return sci;
}
-
+
/**
* Scan JARs that contain web-fragment.xml files that will be used to
* configure this application to see if they also contain static resources.
@@ -1637,8 +1656,8 @@ public class ContextConfig
}
}
}
-
-
+
+
/**
* Identify the default web.xml to be used and obtain an input source for
* it.
@@ -1649,7 +1668,9 @@ public class ContextConfig
defaultWebXml = ((StandardContext) context).getDefaultWebXml();
}
// Set the default if we don't have any overrides
- if (defaultWebXml == null) getDefaultWebXml();
+ if (defaultWebXml == null) {
+ getDefaultWebXml();
+ }
// Is it explicitly suppressed, e.g. in embedded environment?
if (Constants.NoDefaultWebXml.equals(defaultWebXml)) {
@@ -1657,20 +1678,21 @@ public class ContextConfig
}
return getWebXmlSource(defaultWebXml, getBaseDir());
}
-
-
+
+
/**
* Identify the host web.xml to be used and obtain an input source for
* it.
*/
protected InputSource getHostWebXmlSource() {
String resourceName = getHostConfigPath(Constants.HostWebXml);
-
+
// In an embedded environment, configBase might not be set
File configBase = getConfigBase();
- if (configBase == null)
+ if (configBase == null) {
return null;
-
+ }
+
String basePath = null;
try {
basePath = configBase.getCanonicalPath();
@@ -1681,7 +1703,7 @@ public class ContextConfig
return getWebXmlSource(resourceName, basePath);
}
-
+
/**
* Identify the application web.xml to be used and obtain an input source
* for it.
@@ -1690,7 +1712,7 @@ public class ContextConfig
InputStream stream = null;
InputSource source = null;
URL url = null;
-
+
String altDDName = null;
// Open the application web.xml file, if it exists
@@ -1728,15 +1750,15 @@ public class ContextConfig
source = new InputSource(url.toExternalForm());
source.setByteStream(stream);
}
-
+
return source;
}
-
+
/**
- *
+ *
* @param filename Name of the file (possibly with one or more leading path
* segments) to read
- * @param path Location that filename is relative to
+ * @param path Location that filename is relative to
*/
protected InputSource getWebXmlSource(String filename, String path) {
File file = new File(filename);
@@ -1756,7 +1778,7 @@ public class ContextConfig
source =
new InputSource(getClass().getClassLoader().getResource(
filename).toURI().toString());
- }
+ }
} else {
source = new InputSource(file.getAbsoluteFile().toURI().toString());
stream = new FileInputStream(file);
@@ -1777,8 +1799,10 @@ public class ContextConfig
protected void parseWebXml(InputSource source, WebXml dest,
boolean fragment) {
-
- if (source == null) return;
+
+ if (source == null) {
+ return;
+ }
XmlErrorHandler handler = new XmlErrorHandler();
@@ -1794,14 +1818,14 @@ public class ContextConfig
digester = webDigester;
ruleSet = webRuleSet;
}
-
+
// Sync on the ruleSet since the same ruleSet is shared across all four
// digesters
synchronized(ruleSet) {
-
+
digester.push(dest);
digester.setErrorHandler(handler);
-
+
if(log.isDebugEnabled()) {
log.debug(sm.getString("contextConfig.applicationStart",
source.getSystemId()));
@@ -1840,17 +1864,17 @@ public class ContextConfig
* will be parsed before being added to the map. Every JAR will be added and
* <code>null</code> will be used if no web-fragment.xml was found. Any JARs
* known not contain fragments will be skipped.
- *
+ *
* @return A map of JAR name to processed web fragment (if any)
*/
protected Map<String,WebXml> processJarsForWebFragments() {
-
+
JarScanner jarScanner = context.getJarScanner();
FragmentJarScannerCallback callback = new FragmentJarScannerCallback();
-
+
jarScanner.scan(context.getServletContext(),
context.getLoader().getClassLoader(), callback, null);
-
+
return callback.getFragments();
}
@@ -1888,7 +1912,7 @@ public class ContextConfig
log.error(sm.getString("contextConfig.unknownUrlProtocol",
url.getProtocol(), url));
}
-
+
}
@@ -1896,10 +1920,10 @@ public class ContextConfig
Jar jar = null;
InputStream is;
-
+
try {
jar = JarFactory.newInstance(url);
-
+
jar.nextEntry();
String entryName = jar.getEntryName();
while (entryName != null) {
@@ -1933,7 +1957,7 @@ public class ContextConfig
}
}
-
+
protected void processAnnotationsJndi(URL url, WebXml fragment) {
try {
URLConnection urlConn = url.openConnection();
@@ -1943,10 +1967,10 @@ public class ContextConfig
sm.getString("contextConfig.jndiUrlNotDirContextConn", url);
return;
}
-
+
dcUrlConn = (DirContextURLConnection) urlConn;
dcUrlConn.setUseCaches(false);
-
+
String type = dcUrlConn.getHeaderField(ResourceAttributes.TYPE);
if (ResourceAttributes.COLLECTION_TYPE.equals(type)) {
// Collection
@@ -1956,7 +1980,7 @@ public class ContextConfig
URL dirUrl = new URL(url.toString() + '/' + dir);
processAnnotationsJndi(dirUrl, fragment);
}
-
+
} else {
// Single file
if (url.getPath().endsWith(".class")) {
@@ -1982,10 +2006,10 @@ public class ContextConfig
log.error(sm.getString("contextConfig.jndiUrl", url), e);
}
}
-
-
+
+
protected void processAnnotationsFile(File file, WebXml fragment) {
-
+
if (file.isDirectory()) {
String[] dirs = file.list();
for (String dir : dirs) {
@@ -2014,14 +2038,14 @@ public class ContextConfig
protected void processAnnotationsStream(InputStream is, WebXml fragment)
throws ClassFormatException, IOException {
-
+
ClassParser parser = new ClassParser(is, null);
JavaClass clazz = parser.parse();
-
+
checkHandlesTypes(clazz);
-
+
String className = clazz.getClassName();
-
+
AnnotationEntry[] annotationsEntries = clazz.getAnnotationEntries();
for (AnnotationEntry ae : annotationsEntries) {
@@ -2045,14 +2069,15 @@ public class ContextConfig
* @param javaClass
*/
protected void checkHandlesTypes(JavaClass javaClass) {
-
+
// Skip this if we can
- if (typeInitializerMap.size() == 0)
+ if (typeInitializerMap.size() == 0) {
return;
-
+ }
+
// No choice but to load the class
String className = javaClass.getClassName();
-
+
Class<?> clazz = null;
try {
clazz = context.getLoader().getClassLoader().loadClass(className);
@@ -2079,9 +2104,9 @@ public class ContextConfig
// Skip
return;
}
-
+
boolean match = false;
-
+
for (Map.Entry<Class<?>, Set<ServletContainerInitializer>> entry :
typeInitializerMap.entrySet()) {
if (entry.getKey().isAnnotation()) {
@@ -2109,7 +2134,7 @@ public class ContextConfig
if (!internalForm.startsWith("L")) {
return internalForm;
}
-
+
// Assume starts with L, ends with ; and uses / rather than .
return internalForm.substring(1,
internalForm.length() - 1).replace('/', '.');
@@ -2132,7 +2157,7 @@ public class ContextConfig
servletName = className;
}
ServletDef servletDef = fragment.getServlets().get(servletName);
-
+
boolean isWebXMLservletDef;
if (servletDef == null) {
servletDef = new ServletDef();
@@ -2374,7 +2399,7 @@ public class ContextConfig
String[] result = new String[values.size()];
return values.toArray(result);
}
-
+
protected Map<String,String> processAnnotationWebInitParams(
ElementValue ev) {
Map<String, String> result = new HashMap<String,String>();
@@ -2402,16 +2427,16 @@ public class ContextConfig
}
return result;
}
-
+
private class FragmentJarScannerCallback implements JarScannerCallback {
private static final String FRAGMENT_LOCATION =
"META-INF/web-fragment.xml";
- private Map<String,WebXml> fragments = new HashMap<String,WebXml>();
-
+ private final Map<String,WebXml> fragments = new HashMap<String,WebXml>();
+
@Override
public void scan(JarURLConnection jarConn) throws IOException {
-
+
URL url = jarConn.getURL();
URL resourceURL = jarConn.getJarFileURL();
Jar jar = null;
@@ -2456,7 +2481,7 @@ public class ContextConfig
InputStream stream = null;
WebXml fragment = new WebXml();
-
+
try {
File fragmentFile = new File(file, FRAGMENT_LOCATION);
if (fragmentFile.isFile()) {
@@ -2481,7 +2506,7 @@ public class ContextConfig
fragments.put(fragment.getName(), fragment);
}
}
-
+
public Map<String,WebXml> getFragments() {
return fragments;
}
Modified: tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java Sat Oct 22 19:25:55 2011
@@ -183,13 +183,6 @@ public class AccessLogValve extends Valv
/**
- * The descriptive information about this implementation.
- */
- protected static final String info =
- "org.apache.catalina.valves.AccessLogValve/2.2";
-
-
- /**
* enabled this component
*/
protected boolean enabled = true;
@@ -628,15 +621,6 @@ public class AccessLogValve extends Valv
/**
- * Return descriptive information about this implementation.
- */
- @Override
- public String getInfo() {
- return (info);
- }
-
-
- /**
* Return the format pattern.
*/
public String getPattern() {
Modified: tomcat/trunk/java/org/apache/catalina/valves/CometConnectionManagerValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/CometConnectionManagerValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/CometConnectionManagerValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/CometConnectionManagerValve.java Sat Oct 22 19:25:55 2011
@@ -62,14 +62,6 @@ public class CometConnectionManagerValve
// ----------------------------------------------------- Instance Variables
-
- /**
- * The descriptive information related to this implementation.
- */
- protected static final String info =
- "org.apache.catalina.valves.CometConnectionManagerValve/1.0";
-
-
/**
* List of current Comet connections.
*/
@@ -154,16 +146,6 @@ public class CometConnectionManagerValve
// --------------------------------------------------------- Public Methods
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
- return (info);
- }
-
-
/**
* Register requests for tracking, whenever needed.
*
Modified: tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java Sat Oct 22 19:25:55 2011
@@ -53,33 +53,9 @@ public class ErrorReportValve extends Va
super(true);
}
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The descriptive information related to this implementation.
- */
- private static final String info =
- "org.apache.catalina.valves.ErrorReportValve/1.0";
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
-
// --------------------------------------------------------- Public Methods
-
/**
* Invoke the next Valve in the sequence. When the invoke returns, check
* the response state, and output an error report is necessary.
Modified: tomcat/trunk/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/ExtendedAccessLogValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/ExtendedAccessLogValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/ExtendedAccessLogValve.java Sat Oct 22 19:25:55 2011
@@ -144,21 +144,6 @@ public class ExtendedAccessLogValve exte
"org.apache.catalina.valves.ExtendedAccessLogValve/2.1";
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Return descriptive information about this implementation.
- */
- @Override
- public String getInfo() {
- return (extendedAccessLogInfo);
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
// -------------------------------------------------------- Private Methods
/**
Modified: tomcat/trunk/java/org/apache/catalina/valves/PersistentValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/PersistentValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/PersistentValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/PersistentValve.java Sat Oct 22 19:25:55 2011
@@ -51,33 +51,9 @@ public class PersistentValve extends Val
super(true);
}
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The descriptive information related to this implementation.
- */
- private static final String info =
- "org.apache.catalina.valves.PersistentValve/1.0";
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
-
// --------------------------------------------------------- Public Methods
-
/**
* Select the appropriate child Context to process this request,
* based on the specified request URI. If no matching Context can
Modified: tomcat/trunk/java/org/apache/catalina/valves/RemoteAddrValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/RemoteAddrValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/RemoteAddrValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/RemoteAddrValve.java Sat Oct 22 19:25:55 2011
@@ -32,38 +32,10 @@ import org.apache.catalina.connector.Res
* @author Craig R. McClanahan
* @version $Id$
*/
-
-public final class RemoteAddrValve
- extends RequestFilterValve {
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The descriptive information related to this implementation.
- */
- private static final String info =
- "org.apache.catalina.valves.RemoteAddrValve/1.0";
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
-
+public final class RemoteAddrValve extends RequestFilterValve {
// --------------------------------------------------------- Public Methods
-
/**
* Extract the desired request property, and pass it (along with the
* specified request and response objects) to the protected
@@ -83,6 +55,4 @@ public final class RemoteAddrValve
process(request.getRequest().getRemoteAddr(), request, response);
}
-
-
}
Modified: tomcat/trunk/java/org/apache/catalina/valves/RemoteHostValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/RemoteHostValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/RemoteHostValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/RemoteHostValve.java Sat Oct 22 19:25:55 2011
@@ -32,38 +32,10 @@ import org.apache.catalina.connector.Res
* @author Craig R. McClanahan
* @version $Id$
*/
-
-public final class RemoteHostValve
- extends RequestFilterValve {
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The descriptive information related to this implementation.
- */
- private static final String info =
- "org.apache.catalina.valves.RemoteHostValve/1.0";
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
-
+public final class RemoteHostValve extends RequestFilterValve {
// --------------------------------------------------------- Public Methods
-
/**
* Extract the desired request property, and pass it (along with the
* specified request and response objects) to the protected
@@ -83,6 +55,4 @@ public final class RemoteHostValve
process(request.getRequest().getRemoteHost(), request, response);
}
-
-
}
Modified: tomcat/trunk/java/org/apache/catalina/valves/RemoteIpValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/RemoteIpValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/RemoteIpValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/RemoteIpValve.java Sat Oct 22 19:25:55 2011
@@ -353,11 +353,6 @@ public class RemoteIpValve extends Valve
private static final Pattern commaSeparatedValuesPattern = Pattern.compile("\\s*,\\s*");
/**
- * The descriptive information related to this implementation.
- */
- private static final String info = "org.apache.catalina.valves.RemoteIpValve/1.0";
-
- /**
* Logger
*/
private static final Log log = LogFactory.getLog(RemoteIpValve.class);
@@ -495,14 +490,6 @@ public class RemoteIpValve extends Valve
}
/**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
- return info;
- }
-
- /**
* @see #setInternalProxies(String)
* @return Regular expression that defines the internal proxies
*/
Modified: tomcat/trunk/java/org/apache/catalina/valves/RequestFilterValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/RequestFilterValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/RequestFilterValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/RequestFilterValve.java Sat Oct 22 19:25:55 2011
@@ -64,19 +64,9 @@ public abstract class RequestFilterValve
super(true);
}
- // ----------------------------------------------------- Class Variables
-
-
- /**
- * The descriptive information related to this implementation.
- */
- private static final String info =
- "org.apache.catalina.valves.RequestFilterValve/1.0";
-
// ----------------------------------------------------- Instance Variables
-
/**
* The regular expression used to test for allowed requests.
*/
@@ -150,20 +140,8 @@ public abstract class RequestFilterValve
}
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
-
-
// --------------------------------------------------------- Public Methods
-
/**
* Extract the desired request property, and pass it (along with the
* specified request and response objects) to the protected
Modified: tomcat/trunk/java/org/apache/catalina/valves/SemaphoreValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/SemaphoreValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/SemaphoreValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/SemaphoreValve.java Sat Oct 22 19:25:55 2011
@@ -46,15 +46,8 @@ public class SemaphoreValve extends Valv
super(true);
}
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The descriptive information related to this implementation.
- */
- private static final String info =
- "org.apache.catalina.valves.SemaphoreValve/1.0";
+ // ----------------------------------------------------- Instance Variables
/**
* Semaphore.
@@ -131,16 +124,6 @@ public class SemaphoreValve extends Valv
// --------------------------------------------------------- Public Methods
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
- return (info);
- }
-
-
/**
* Do concurrency control on the request using the semaphore.
*
Modified: tomcat/trunk/java/org/apache/catalina/valves/StuckThreadDetectionValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/StuckThreadDetectionValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/StuckThreadDetectionValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/StuckThreadDetectionValve.java Sat Oct 22 19:25:55 2011
@@ -45,11 +45,6 @@ import org.apache.tomcat.util.res.String
public class StuckThreadDetectionValve extends ValveBase {
/**
- * The descriptive information related to this implementation.
- */
- private static final String info =
- "org.apache.catalina.valves.StuckThreadDetectionValve/1.0";
- /**
* Logger
*/
private static final Log log = LogFactory.getLog(StuckThreadDetectionValve.class);
@@ -123,14 +118,6 @@ public class StuckThreadDetectionValve e
}
}
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
- return info;
- }
-
private void notifyStuckThreadDetected(MonitoredThread monitoredThread,
long activeTime, int numStuckThreads) {
if (log.isWarnEnabled()) {
Modified: tomcat/trunk/java/org/apache/catalina/valves/ValveBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/ValveBase.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/ValveBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/ValveBase.java Sat Oct 22 19:25:55 2011
@@ -79,14 +79,6 @@ public abstract class ValveBase extends
/**
- * Descriptive information about this Valve implementation. This value
- * should be overridden by subclasses.
- */
- protected static final String info =
- "org.apache.catalina.core.ValveBase/1.0";
-
-
- /**
* The next Valve in the pipeline this Valve is a component of.
*/
protected Valve next = null;
@@ -138,17 +130,6 @@ public abstract class ValveBase extends
/**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
-
-
- /**
* Return the next Valve in this pipeline, or <code>null</code> if this
* is the last Valve in the pipeline.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org