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 23:08:52 UTC
svn commit: r1187787 [4/5] - /tomcat/trunk/java/org/apache/catalina/core/
Modified: tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java?rev=1187787&r1=1187786&r2=1187787&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java Sat Oct 22 21:08:51 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.
@@ -113,12 +113,12 @@ public class StandardWrapper extends Con
* servlet is considered permanent.
*/
protected long available = 0L;
-
+
/**
- * The broadcaster that sends j2ee notifications.
+ * The broadcaster that sends j2ee notifications.
*/
protected NotificationBroadcasterSupport broadcaster = null;
-
+
/**
* The count of allocations that are currently active (even if they
* are for the same instance, as will be true on a non-STM servlet).
@@ -223,12 +223,12 @@ public class StandardWrapper extends Con
*/
protected Stack<Servlet> instancePool = null;
-
+
/**
* Wait time for servlet unload in ms.
*/
protected long unloadDelay = 2000;
-
+
/**
* True if this StandardWrapper is for the JspServlet
@@ -251,12 +251,12 @@ public class StandardWrapper extends Con
protected StandardWrapperValve swValve;
protected long loadTime=0;
protected int classLoadTime=0;
-
+
/**
* Multipart config
*/
protected MultipartConfigElement multipartConfigElement = null;
-
+
/**
* Async support
*/
@@ -270,22 +270,22 @@ public class StandardWrapper extends Con
protected volatile boolean servletSecurityAnnotationScanRequired = false;
private boolean overridable = false;
-
+
/**
- * Static class array used when the SecurityManager is turned on and
+ * Static class array used when the SecurityManager is turned on and
* <code>Servlet.init</code> is invoked.
*/
protected static Class<?>[] classType = new Class[]{ServletConfig.class};
-
-
+
+
/**
- * Static class array used when the SecurityManager is turned on and
+ * Static class array used when the SecurityManager is turned on and
* <code>Servlet.service</code> is invoked.
- */
+ */
protected static Class<?>[] classTypeUsedInService = new Class[]{
ServletRequest.class,
ServletResponse.class};
-
+
// ------------------------------------------------------------- Properties
@@ -548,11 +548,11 @@ public class StandardWrapper extends Con
// Short-cuts
// If singleThreadModel is true, must have already checked this
- // If instance != null, must have already loaded
+ // If instance != null, must have already loaded
if (singleThreadModel || instance != null) {
return singleThreadModel;
}
-
+
// The logic to determine this safely is more complex than one might
// expect. allocate() already has the necessary logic so re-use it.
try {
@@ -599,7 +599,7 @@ public class StandardWrapper extends Con
public String[] getServletMethods() throws ServletException {
instance = loadServlet();
-
+
Class<? extends Servlet> servletClazz = instance.getClass();
if (!javax.servlet.http.HttpServlet.class.isAssignableFrom(
servletClazz)) {
@@ -639,8 +639,8 @@ public class StandardWrapper extends Con
public Servlet getServlet() {
return instance;
}
-
-
+
+
/**
* Set the associated servlet instance.
*/
@@ -649,7 +649,7 @@ public class StandardWrapper extends Con
instance = servlet;
}
-
+
/**
* {@inheritDoc}
*/
@@ -669,19 +669,19 @@ public class StandardWrapper extends Con
@Override
public void backgroundProcess() {
super.backgroundProcess();
-
+
if (!getState().isAvailable())
return;
-
+
if (getServlet() != null && (getServlet() instanceof PeriodicEventListener)) {
((PeriodicEventListener) getServlet()).periodicEvent();
}
}
-
-
+
+
/**
* Extract the root cause from a servlet exception.
- *
+ *
* @param e The servlet exception
*/
public static Throwable getRootCause(ServletException e) {
@@ -801,7 +801,7 @@ public class StandardWrapper extends Con
(sm.getString("standardWrapper.unloading", getName()));
boolean newInstance = false;
-
+
// If not SingleThreadedModel, return the same instance every time
if (!singleThreadModel) {
@@ -1021,7 +1021,7 @@ public class StandardWrapper extends Con
@Override
public synchronized void load() throws ServletException {
instance = loadServlet();
-
+
if (!instanceInitialized) {
initServlet(instance);
}
@@ -1029,12 +1029,12 @@ public class StandardWrapper extends Con
if (isJspServlet) {
StringBuilder oname =
new StringBuilder(MBeanUtils.getDomain(getParent()));
-
+
oname.append(":type=JspMonitor,name=");
oname.append(getName());
-
+
oname.append(getWebModuleKeyProperties());
-
+
try {
jspMonitorON = new ObjectName(oname.toString());
Registry.getRegistry(null, null)
@@ -1147,7 +1147,7 @@ public class StandardWrapper extends Con
/**
* {@inheritDoc}
- * @throws ClassNotFoundException
+ * @throws ClassNotFoundException
*/
@Override
public void servletSecurityAnnotationScan() throws ServletException {
@@ -1172,7 +1172,7 @@ public class StandardWrapper extends Con
servletSecurityAnnotationScanRequired = false;
Context ctxt = (Context) getParent();
-
+
if (ctxt.getIgnoreAnnotations()) {
return;
}
@@ -1188,7 +1188,7 @@ public class StandardWrapper extends Con
private synchronized void initServlet(Servlet servlet)
throws ServletException {
-
+
if (instanceInitialized && !singleThreadModel) return;
// Call the initialization method of this servlet
@@ -1383,28 +1383,28 @@ public class StandardWrapper extends Con
if (swallowOutput) {
SystemLogHandler.startCapture();
}
-
+
// Call the servlet destroy() method
try {
instanceSupport.fireInstanceEvent
(InstanceEvent.BEFORE_DESTROY_EVENT, instance);
-
+
if( Globals.IS_SECURITY_ENABLED) {
SecurityUtil.doAsPrivilege("destroy",
instance);
- SecurityUtil.remove(instance);
+ SecurityUtil.remove(instance);
} else {
instance.destroy();
}
-
+
instanceSupport.fireInstanceEvent
(InstanceEvent.AFTER_DESTROY_EVENT, instance);
-
+
// Annotation processing
if (!((Context) getParent()).getIgnoreAnnotations()) {
((StandardContext)getParent()).getInstanceManager().destroyInstance(instance);
}
-
+
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
instanceSupport.fireInstanceEvent
@@ -1445,7 +1445,7 @@ public class StandardWrapper extends Con
Servlet s = instancePool.pop();
if (Globals.IS_SECURITY_ENABLED) {
SecurityUtil.doAsPrivilege("destroy", s);
- SecurityUtil.remove(instance);
+ SecurityUtil.remove(instance);
} else {
s.destroy();
}
@@ -1608,7 +1608,7 @@ public class StandardWrapper extends Con
public boolean isAsyncSupported() {
return asyncSupported;
}
-
+
@Override
public void setAsyncSupported(boolean asyncSupported) {
this.asyncSupported = asyncSupported;
@@ -1618,7 +1618,7 @@ public class StandardWrapper extends Con
public boolean isEnabled() {
return enabled;
}
-
+
@Override
public void setEnabled(boolean enabled) {
this.enabled = enabled;
@@ -1694,24 +1694,24 @@ public class StandardWrapper extends Con
*/
@Override
protected synchronized void startInternal() throws LifecycleException {
-
- // Send j2ee.state.starting notification
+
+ // Send j2ee.state.starting notification
if (this.getObjectName() != null) {
- Notification notification = new Notification("j2ee.state.starting",
- this.getObjectName(),
+ Notification notification = new Notification("j2ee.state.starting",
+ this.getObjectName(),
sequenceNumber++);
broadcaster.sendNotification(notification);
}
-
+
// Start up this component
super.startInternal();
setAvailable(0L);
- // Send j2ee.state.running notification
+ // Send j2ee.state.running notification
if (this.getObjectName() != null) {
- Notification notification =
- new Notification("j2ee.state.running", this.getObjectName(),
+ Notification notification =
+ new Notification("j2ee.state.running", this.getObjectName(),
sequenceNumber++);
broadcaster.sendNotification(notification);
}
@@ -1730,15 +1730,15 @@ public class StandardWrapper extends Con
protected synchronized void stopInternal() throws LifecycleException {
setAvailable(Long.MAX_VALUE);
-
- // Send j2ee.state.stopping notification
+
+ // Send j2ee.state.stopping notification
if (this.getObjectName() != null) {
- Notification notification =
- new Notification("j2ee.state.stopping", this.getObjectName(),
+ Notification notification =
+ new Notification("j2ee.state.stopping", this.getObjectName(),
sequenceNumber++);
broadcaster.sendNotification(notification);
}
-
+
// Shut down our servlet instance (if it has been initialized)
try {
unload();
@@ -1750,39 +1750,39 @@ public class StandardWrapper extends Con
// Shut down this component
super.stopInternal();
- // Send j2ee.state.stoppped notification
+ // Send j2ee.state.stoppped notification
if (this.getObjectName() != null) {
- Notification notification =
- new Notification("j2ee.state.stopped", this.getObjectName(),
+ Notification notification =
+ new Notification("j2ee.state.stopped", this.getObjectName(),
sequenceNumber++);
broadcaster.sendNotification(notification);
}
-
- // Send j2ee.object.deleted notification
- Notification notification =
- new Notification("j2ee.object.deleted", this.getObjectName(),
+
+ // Send j2ee.object.deleted notification
+ Notification notification =
+ new Notification("j2ee.object.deleted", this.getObjectName(),
sequenceNumber++);
broadcaster.sendNotification(notification);
}
-
+
@Override
protected String getObjectNameKeyProperties() {
StringBuilder keyProperties =
new StringBuilder("j2eeType=Servlet,name=");
-
+
keyProperties.append(getName());
-
+
keyProperties.append(getWebModuleKeyProperties());
return keyProperties.toString();
}
-
+
private String getWebModuleKeyProperties() {
-
+
StringBuilder keyProperties = new StringBuilder(",WebModule=//");
String hostName = getParent().getParent().getName();
if (hostName == null) {
@@ -1790,7 +1790,7 @@ public class StandardWrapper extends Con
} else {
keyProperties.append(hostName);
}
-
+
String contextName = ((Context) getParent()).getName();
if (!contextName.startsWith("/")) {
keyProperties.append('/');
@@ -1801,7 +1801,7 @@ public class StandardWrapper extends Con
if (parent instanceof StandardContext) {
ctx = (StandardContext) getParent();
}
-
+
keyProperties.append(",J2EEApplication=");
if (ctx == null) {
keyProperties.append("none");
@@ -1814,22 +1814,22 @@ public class StandardWrapper extends Con
} else {
keyProperties.append(ctx.getJ2EEServer());
}
-
+
return keyProperties.toString();
}
-
-
- /* Remove a JMX notficationListener
+
+
+ /* Remove a JMX notficationListener
* @see javax.management.NotificationEmitter#removeNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)
*/
@Override
- public void removeNotificationListener(NotificationListener listener,
+ public void removeNotificationListener(NotificationListener listener,
NotificationFilter filter, Object object) throws ListenerNotFoundException {
broadcaster.removeNotificationListener(listener,filter,object);
}
-
+
protected MBeanNotificationInfo[] notificationInfo;
-
+
/* Get JMX Broadcaster Info
* @TODO use StringManager for international support!
* @TODO This two events we not send j2ee.state.failed and j2ee.attribute.changed!
@@ -1844,7 +1844,7 @@ public class StandardWrapper extends Con
"j2ee.object.created"},
Notification.class.getName(),
"servlet is created"
- ),
+ ),
new MBeanNotificationInfo(new String[] {
"j2ee.state.starting"},
Notification.class.getName(),
@@ -1875,40 +1875,40 @@ public class StandardWrapper extends Con
return notificationInfo;
}
-
-
+
+
/* Add a JMX-NotificationListener
* @see javax.management.NotificationBroadcaster#addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)
*/
@Override
- public void addNotificationListener(NotificationListener listener,
+ public void addNotificationListener(NotificationListener listener,
NotificationFilter filter, Object object) throws IllegalArgumentException {
broadcaster.addNotificationListener(listener,filter,object);
}
-
-
+
+
/**
- * Remove a JMX-NotificationListener
+ * Remove a JMX-NotificationListener
* @see javax.management.NotificationBroadcaster#removeNotificationListener(javax.management.NotificationListener)
*/
@Override
- public void removeNotificationListener(NotificationListener listener)
+ public void removeNotificationListener(NotificationListener listener)
throws ListenerNotFoundException {
broadcaster.removeNotificationListener(listener);
}
-
-
+
+
// ------------------------------------------------------------- Attributes
-
-
+
+
public boolean isEventProvider() {
return false;
}
-
+
public boolean isStateManageable() {
return false;
}
-
+
public boolean isStatisticsProvider() {
return false;
}
Modified: tomcat/trunk/java/org/apache/catalina/core/StandardWrapperFacade.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardWrapperFacade.java?rev=1187787&r1=1187786&r2=1187787&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardWrapperFacade.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardWrapperFacade.java Sat Oct 22 21:08:51 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.
Modified: tomcat/trunk/java/org/apache/catalina/core/StandardWrapperValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardWrapperValve.java?rev=1187787&r1=1187786&r2=1187787&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardWrapperValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardWrapperValve.java Sat Oct 22 21:08:51 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.
@@ -56,7 +56,7 @@ final class StandardWrapperValve
public StandardWrapperValve() {
super(true);
}
-
+
// ----------------------------------------------------- Instance Variables
@@ -103,7 +103,7 @@ final class StandardWrapperValve
StandardWrapper wrapper = (StandardWrapper) getContainer();
Servlet servlet = null;
Context context = (Context) wrapper.getParent();
-
+
// Check for the application being marked unavailable
if (!context.getAvailable()) {
response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE,
@@ -165,15 +165,15 @@ final class StandardWrapperValve
// Identify if the request is Comet related now that the servlet has been allocated
boolean comet = false;
- if (servlet instanceof CometProcessor
+ if (servlet instanceof CometProcessor
&& request.getAttribute("org.apache.tomcat.comet.support") == Boolean.TRUE) {
comet = true;
request.setComet(true);
}
-
+
MessageBytes requestPathMB = request.getRequestPathMB();
DispatcherType dispatcherType = DispatcherType.REQUEST;
- if (request.getDispatcherType()==DispatcherType.ASYNC) dispatcherType = DispatcherType.ASYNC;
+ if (request.getDispatcherType()==DispatcherType.ASYNC) dispatcherType = DispatcherType.ASYNC;
request.setAttribute
(ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
dispatcherType);
@@ -185,7 +185,7 @@ final class StandardWrapperValve
ApplicationFilterFactory.getInstance();
ApplicationFilterChain filterChain =
factory.createFilterChain(request, wrapper, servlet);
-
+
// Reset comet flag value after creating the filter chain
request.setComet(false);
@@ -199,12 +199,12 @@ final class StandardWrapperValve
SystemLogHandler.startCapture();
if (request.isAsyncDispatching()) {
//TODO SERVLET3 - async
- ((AsyncContextImpl)request.getAsyncContext()).doInternalDispatch();
+ ((AsyncContextImpl)request.getAsyncContext()).doInternalDispatch();
} else if (comet) {
filterChain.doFilterEvent(request.getEvent());
request.setComet(true);
} else {
- filterChain.doFilter(request.getRequest(),
+ filterChain.doFilter(request.getRequest(),
response.getResponse());
}
} finally {
@@ -330,7 +330,7 @@ final class StandardWrapperValve
/**
* Process a Comet event. The main differences here are to not use sendError
* (the response is committed), to avoid creating a new filter chain
- * (which would work but be pointless), and a few very minor tweaks.
+ * (which would work but be pointless), and a few very minor tweaks.
*
* @param request The servlet request to be processed
* @param response The servlet response to be created
@@ -343,13 +343,13 @@ final class StandardWrapperValve
@Override
public void event(Request request, Response response, CometEvent event)
throws IOException, ServletException {
-
+
// Initialize local variables we may need
Throwable throwable = null;
// This should be a Request attribute...
long t1=System.currentTimeMillis();
// FIXME: Add a flag to count the total amount of events processed ? requestCount++;
-
+
StandardWrapper wrapper = (StandardWrapper) getContainer();
if (wrapper == null) {
// Context has been shutdown. Nothing to do here.
@@ -361,7 +361,7 @@ final class StandardWrapperValve
// Check for the application being marked unavailable
boolean unavailable = !context.getAvailable() || wrapper.isUnavailable();
-
+
// Allocate a servlet instance to process this request
try {
if (!unavailable) {
@@ -391,7 +391,7 @@ final class StandardWrapperValve
(ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
requestPathMB);
// Get the current (unchanged) filter chain for this request
- ApplicationFilterChain filterChain =
+ ApplicationFilterChain filterChain =
(ApplicationFilterChain) request.getFilterChain();
// Call the filter chain for this request
@@ -556,7 +556,7 @@ final class StandardWrapperValve
public void setErrorCount(int errorCount) {
this.errorCount = errorCount;
}
-
+
@Override
protected void initInternal() throws LifecycleException {
// NOOP - Don't register this Valve in JMX
Modified: tomcat/trunk/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java?rev=1187787&r1=1187786&r2=1187787&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java Sat Oct 22 21:08:51 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.
@@ -48,9 +48,9 @@ import org.apache.tomcat.util.threads.Th
* pool after executing their task, see
* {@link org.apache.tomcat.util.threads.ThreadPoolExecutor}.afterExecute().
* </p>
- *
+ *
* This listener must be declared in server.xml to be active.
- *
+ *
*/
public class ThreadLocalLeakPreventionListener implements LifecycleListener,
ContainerListener {
@@ -186,7 +186,7 @@ public class ThreadLocalLeakPreventionLi
/**
* Updates each ThreadPoolExecutor with the current time, which is the time
* when a context is being stopped.
- *
+ *
* @param context
* the context being stopped, used to discover all the Connectors
* of its parent Service.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org