Generics for o.a.coyote
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 30 Nov 2008 15:59:48 +0000 (15:59 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 30 Nov 2008 15:59:48 +0000 (15:59 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@721835 13f79535-47bb-0310-9956-ffa450edef68

12 files changed:
java/org/apache/coyote/ProtocolHandler.java
java/org/apache/coyote/Request.java
java/org/apache/coyote/RequestGroupInfo.java
java/org/apache/coyote/ajp/AjpAprProcessor.java
java/org/apache/coyote/ajp/AjpAprProtocol.java
java/org/apache/coyote/ajp/AjpProcessor.java
java/org/apache/coyote/ajp/AjpProtocol.java
java/org/apache/coyote/http11/Http11AprProtocol.java
java/org/apache/coyote/http11/Http11NioProtocol.java
java/org/apache/coyote/http11/Http11Protocol.java
java/org/apache/coyote/http11/InternalOutputBuffer.java
java/org/apache/coyote/memory/MemoryProtocolHandler.java

index 0e81135..d2b392c 100644 (file)
@@ -42,7 +42,7 @@ public interface ProtocolHandler {
 
 
     public Object getAttribute(String name);
-    public Iterator getAttributeNames();
+    public Iterator<String> getAttributeNames();
 
     /**
      * The adapter, used to call the connector.
index 6c88973..8390d38 100644 (file)
@@ -135,7 +135,7 @@ public final class Request {
 
     private MessageBytes remoteUser=MessageBytes.newInstance();
     private MessageBytes authType=MessageBytes.newInstance();
-    private HashMap attributes=new HashMap();
+    private HashMap<String,Object> attributes=new HashMap<String,Object>();
 
     private Response response;
     private ActionHook hook;
@@ -377,7 +377,7 @@ public final class Request {
         attributes.put( name, o );
     }
 
-    public HashMap getAttributes() {
+    public HashMap<String,Object> getAttributes() {
         return attributes;
     }
 
index 41fa3fe..f0625e2 100644 (file)
@@ -24,7 +24,7 @@ import java.util.ArrayList;
  *  collected from each RequestProcessor thread.
  */
 public class RequestGroupInfo {
-    ArrayList processors=new ArrayList();
+    ArrayList<RequestInfo> processors=new ArrayList<RequestInfo>();
     private long deadMaxTime = 0;
     private long deadProcessingTime = 0;
     private int deadRequestCount = 0;
@@ -53,7 +53,7 @@ public class RequestGroupInfo {
     public synchronized long getMaxTime() {
         long maxTime=deadMaxTime;
         for( int i=0; i<processors.size(); i++ ) {
-            RequestInfo rp=(RequestInfo)processors.get( i );
+            RequestInfo rp=processors.get( i );
             if( maxTime < rp.getMaxTime() ) maxTime=rp.getMaxTime();
         }
         return maxTime;
@@ -63,7 +63,7 @@ public class RequestGroupInfo {
     public synchronized void setMaxTime(long maxTime) {
         deadMaxTime = maxTime;
         for( int i=0; i<processors.size(); i++ ) {
-            RequestInfo rp=(RequestInfo)processors.get( i );
+            RequestInfo rp=processors.get( i );
             rp.setMaxTime(maxTime);
         }
     }
@@ -71,7 +71,7 @@ public class RequestGroupInfo {
     public synchronized long getProcessingTime() {
         long time=deadProcessingTime;
         for( int i=0; i<processors.size(); i++ ) {
-            RequestInfo rp=(RequestInfo)processors.get( i );
+            RequestInfo rp=processors.get( i );
             time += rp.getProcessingTime();
         }
         return time;
@@ -80,7 +80,7 @@ public class RequestGroupInfo {
     public synchronized void setProcessingTime(long totalTime) {
         deadProcessingTime = totalTime;
         for( int i=0; i<processors.size(); i++ ) {
-            RequestInfo rp=(RequestInfo)processors.get( i );
+            RequestInfo rp=processors.get( i );
             rp.setProcessingTime( totalTime );
         }
     }
@@ -88,7 +88,7 @@ public class RequestGroupInfo {
     public synchronized int getRequestCount() {
         int requestCount=deadRequestCount;
         for( int i=0; i<processors.size(); i++ ) {
-            RequestInfo rp=(RequestInfo)processors.get( i );
+            RequestInfo rp=processors.get( i );
             requestCount += rp.getRequestCount();
         }
         return requestCount;
@@ -97,7 +97,7 @@ public class RequestGroupInfo {
     public synchronized void setRequestCount(int requestCount) {
         deadRequestCount = requestCount;
         for( int i=0; i<processors.size(); i++ ) {
-            RequestInfo rp=(RequestInfo)processors.get( i );
+            RequestInfo rp=processors.get( i );
             rp.setRequestCount( requestCount );
         }
     }
@@ -105,7 +105,7 @@ public class RequestGroupInfo {
     public synchronized int getErrorCount() {
         int requestCount=deadErrorCount;
         for( int i=0; i<processors.size(); i++ ) {
-            RequestInfo rp=(RequestInfo)processors.get( i );
+            RequestInfo rp=processors.get( i );
             requestCount += rp.getErrorCount();
         }
         return requestCount;
@@ -114,7 +114,7 @@ public class RequestGroupInfo {
     public synchronized void setErrorCount(int errorCount) {
         deadErrorCount = errorCount;
         for( int i=0; i<processors.size(); i++ ) {
-            RequestInfo rp=(RequestInfo)processors.get( i );
+            RequestInfo rp=processors.get( i );
             rp.setErrorCount( errorCount);
         }
     }
@@ -122,7 +122,7 @@ public class RequestGroupInfo {
     public synchronized long getBytesReceived() {
         long bytes=deadBytesReceived;
         for( int i=0; i<processors.size(); i++ ) {
-            RequestInfo rp=(RequestInfo)processors.get( i );
+            RequestInfo rp=processors.get( i );
             bytes += rp.getBytesReceived();
         }
         return bytes;
@@ -131,7 +131,7 @@ public class RequestGroupInfo {
     public synchronized void setBytesReceived(long bytesReceived) {
         deadBytesReceived = bytesReceived;
         for( int i=0; i<processors.size(); i++ ) {
-            RequestInfo rp=(RequestInfo)processors.get( i );
+            RequestInfo rp=processors.get( i );
             rp.setBytesReceived( bytesReceived );
         }
     }
@@ -139,7 +139,7 @@ public class RequestGroupInfo {
     public synchronized long getBytesSent() {
         long bytes=deadBytesSent;
         for( int i=0; i<processors.size(); i++ ) {
-            RequestInfo rp=(RequestInfo)processors.get( i );
+            RequestInfo rp=processors.get( i );
             bytes += rp.getBytesSent();
         }
         return bytes;
@@ -148,7 +148,7 @@ public class RequestGroupInfo {
     public synchronized void setBytesSent(long bytesSent) {
         deadBytesSent = bytesSent;
         for( int i=0; i<processors.size(); i++ ) {
-            RequestInfo rp=(RequestInfo)processors.get( i );
+            RequestInfo rp=processors.get( i );
             rp.setBytesSent( bytesSent );
         }
     }
index ada4452..baff663 100644 (file)
@@ -634,7 +634,7 @@ public class AjpAprProcessor implements ActionHook {
         // Translate the HTTP method code to a String.
         byte methodCode = requestHeaderMessage.getByte();
         if (methodCode != Constants.SC_M_JK_STORED) {
-            String methodName = Constants.methodTransArray[(int)methodCode - 1];
+            String methodName = Constants.methodTransArray[methodCode - 1];
             request.method().setString(methodName);
         }
 
@@ -894,7 +894,7 @@ public class AjpAprProcessor implements ActionHook {
             int port = 0;
             int mult = 1;
             for (int i = valueL - 1; i > colonPos; i--) {
-                int charValue = HexUtils.DEC[(int) valueB[i + valueS]];
+                int charValue = HexUtils.DEC[valueB[i + valueS]];
                 if (charValue == -1) {
                     // Invalid character
                     error = true;
index a51bb15..3160a77 100644 (file)
@@ -95,7 +95,8 @@ public class AjpAprProtocol
     /**
      * Configuration attributes.
      */
-    protected Hashtable attributes = new Hashtable();
+    protected Hashtable<String,Object> attributes =
+        new Hashtable<String,Object>();
 
 
     /**
@@ -131,7 +132,7 @@ public class AjpAprProtocol
     }
 
 
-    public Iterator getAttributeNames() {
+    public Iterator<String> getAttributeNames() {
         return attributes.keySet().iterator();
     }
 
@@ -447,7 +448,7 @@ public class AjpAprProtocol
                     try {
                         RequestInfo rp = processor.getRequest().getRequestProcessor();
                         rp.setGlobalProcessor(null);
-                        ObjectName rpName = (ObjectName) rp.getRpName();
+                        ObjectName rpName = rp.getRpName();
                         if (log.isDebugEnabled()) {
                             log.debug("Unregister " + rpName);
                         }
index 5c6eab9..ae07711 100644 (file)
@@ -640,7 +640,7 @@ public class AjpProcessor implements ActionHook {
         // Translate the HTTP method code to a String.
         byte methodCode = requestHeaderMessage.getByte();
         if (methodCode != Constants.SC_M_JK_STORED) {
-            String methodName = Constants.methodTransArray[(int)methodCode - 1];
+            String methodName = Constants.methodTransArray[methodCode - 1];
             request.method().setString(methodName);
         }
 
@@ -900,7 +900,7 @@ public class AjpProcessor implements ActionHook {
             int port = 0;
             int mult = 1;
             for (int i = valueL - 1; i > colonPos; i--) {
-                int charValue = HexUtils.DEC[(int) valueB[i + valueS]];
+                int charValue = HexUtils.DEC[valueB[i + valueS]];
                 if (charValue == -1) {
                     // Invalid character
                     error = true;
index 1ff2881..0d16632 100644 (file)
@@ -95,7 +95,8 @@ public class AjpProtocol
     /**
      * Configuration attributes.
      */
-    protected Hashtable attributes = new Hashtable();
+    protected Hashtable<String,Object> attributes =
+        new Hashtable<String,Object>();
 
 
     /**
@@ -131,7 +132,7 @@ public class AjpProtocol
     }
 
 
-    public Iterator getAttributeNames() {
+    public Iterator<String> getAttributeNames() {
         return attributes.keySet().iterator();
     }
 
@@ -433,7 +434,7 @@ public class AjpProtocol
                     try {
                         RequestInfo rp = processor.getRequest().getRequestProcessor();
                         rp.setGlobalProcessor(null);
-                        ObjectName rpName = (ObjectName) rp.getRpName();
+                        ObjectName rpName = rp.getRpName();
                         if (log.isDebugEnabled()) {
                             log.debug("Unregister " + rpName);
                         }
index c7c6c7d..0b4aeab 100644 (file)
@@ -85,7 +85,7 @@ public class Http11AprProtocol implements ProtocolHandler, MBeanRegistration {
         return attributes.get(key);
     }
 
-    public Iterator getAttributeNames() {
+    public Iterator<String> getAttributeNames() {
         return attributes.keySet().iterator();
     }
 
@@ -518,7 +518,7 @@ public class Http11AprProtocol implements ProtocolHandler, MBeanRegistration {
         }
 
         public SocketState event(long socket, SocketStatus status) {
-            Http11AprProcessor result = connections.get(socket);
+            Http11AprProcessor result = connections.get(Long.valueOf(socket));
             
             SocketState state = SocketState.CLOSED; 
             if (result != null) {
@@ -547,7 +547,7 @@ public class Http11AprProtocol implements ProtocolHandler, MBeanRegistration {
                         (sm.getString("http11protocol.proto.error"), e);
                 } finally {
                     if (state != SocketState.LONG) {
-                        connections.remove(socket);
+                        connections.remove(Long.valueOf(socket));
                         recycledProcessors.offer(result);
                         if (state == SocketState.OPEN) {
                             proto.endpoint.getPoller().add(socket);
@@ -576,7 +576,7 @@ public class Http11AprProtocol implements ProtocolHandler, MBeanRegistration {
                     // Associate the connection with the processor. The next request 
                     // processed by this thread will use either a new or a recycled
                     // processor.
-                    connections.put(socket, processor);
+                    connections.put(Long.valueOf(socket), processor);
                     proto.endpoint.getCometPoller().add(socket);
                 } else {
                     recycledProcessors.offer(processor);
@@ -655,7 +655,7 @@ public class Http11AprProtocol implements ProtocolHandler, MBeanRegistration {
                     try {
                         RequestInfo rp = processor.getRequest().getRequestProcessor();
                         rp.setGlobalProcessor(null);
-                        ObjectName rpName = (ObjectName) rp.getRpName();
+                        ObjectName rpName = rp.getRpName();
                         if (log.isDebugEnabled()) {
                             log.debug("Unregister " + rpName);
                         }
index b30ceef..e765eb6 100644 (file)
@@ -91,7 +91,7 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration
         return attributes.get(key);
     }
 
-    public Iterator getAttributeNames() {
+    public Iterator<String> getAttributeNames() {
         return attributes.keySet().iterator();
     }
 
@@ -209,7 +209,8 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration
     protected NioEndpoint ep=new NioEndpoint();
     protected boolean secure = false;
 
-    protected Hashtable attributes = new Hashtable();
+    protected Hashtable<String, Object> attributes =
+        new Hashtable<String, Object>();
 
     private int maxKeepAliveRequests=100; // as in Apache HTTPD server
     private int timeout = 300000;   // 5 minutes as in Apache HTTPD server
@@ -534,7 +535,7 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration
 
     public void setOomParachute(int oomParachute) {
         ep.setOomParachute(oomParachute);
-        setAttribute("oomParachute",oomParachute);
+        setAttribute("oomParachute", Integer.valueOf(oomParachute));
     }
 
     // --------------------  SSL related properties --------------------
@@ -812,7 +813,7 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration
                         if (log.isDebugEnabled()) log.debug("Deregister ["+processor+"] count="+registerCount.get());
                         RequestInfo rp = processor.getRequest().getRequestProcessor();
                         rp.setGlobalProcessor(null);
-                        ObjectName rpName = (ObjectName) rp.getRpName();
+                        ObjectName rpName = rp.getRpName();
                         Registry.getRegistry(null, null).unregisterComponent(rpName);
                         rp.setRpName(null);
                     } catch (Exception e) {
index b4740d4..784597a 100644 (file)
@@ -116,7 +116,7 @@ public class Http11Protocol
         return attributes.get(key);
     }
 
-    public Iterator getAttributeNames() {
+    public Iterator<String> getAttributeNames() {
         return attributes.keySet().iterator();
     }
 
@@ -667,7 +667,7 @@ public class Http11Protocol
                     try {
                         RequestInfo rp = processor.getRequest().getRequestProcessor();
                         rp.setGlobalProcessor(null);
-                        ObjectName rpName = (ObjectName) rp.getRpName();
+                        ObjectName rpName = rp.getRpName();
                         if (log.isDebugEnabled()) {
                             log.debug("Unregister " + rpName);
                         }
index efbfef8..0de094c 100644 (file)
@@ -451,8 +451,8 @@ public class InternalOutputBuffer
         // End the response status line
         if (org.apache.coyote.Constants.IS_SECURITY_ENABLED){
            AccessController.doPrivileged(
-                new PrivilegedAction(){
-                    public Object run(){
+                new PrivilegedAction<Void>(){
+                    public Void run(){
                         buf[pos++] = Constants.CR;
                         buf[pos++] = Constants.LF;
                         return null;
@@ -468,9 +468,9 @@ public class InternalOutputBuffer
 
     private String getMessage(final int message){
         if (org.apache.coyote.Constants.IS_SECURITY_ENABLED){
-           return (String)AccessController.doPrivileged(
-                new PrivilegedAction(){
-                    public Object run(){
+           return AccessController.doPrivileged(
+                new PrivilegedAction<String>(){
+                    public String run(){
                         return HttpMessages.getMessage(message); 
                     }
                 }
index bbb8fe9..b7da7ee 100644 (file)
@@ -53,7 +53,7 @@ public class MemoryProtocolHandler
         return null;
     }
 
-    public Iterator getAttributeNames() { return null ; }
+    public Iterator<String> getAttributeNames() { return null ; }
     /**
      * Associated adapter.
      */