o.a.c.startup generics changes
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 26 Dec 2008 18:13:57 +0000 (18:13 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 26 Dec 2008 18:13:57 +0000 (18:13 +0000)
Various other fixes (casts, unused code, comment typos etc)

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@729519 13f79535-47bb-0310-9956-ffa450edef68

16 files changed:
java/org/apache/catalina/startup/Bootstrap.java
java/org/apache/catalina/startup/CatalinaProperties.java
java/org/apache/catalina/startup/ClassLoaderFactory.java
java/org/apache/catalina/startup/ClusterRuleSetFactory.java
java/org/apache/catalina/startup/ContextConfig.java
java/org/apache/catalina/startup/Embedded.java
java/org/apache/catalina/startup/ExpandWar.java
java/org/apache/catalina/startup/HomesUserDatabase.java
java/org/apache/catalina/startup/LifecycleListenerRule.java
java/org/apache/catalina/startup/PasswdUserDatabase.java
java/org/apache/catalina/startup/TldConfig.java
java/org/apache/catalina/startup/Tool.java
java/org/apache/catalina/startup/UserConfig.java
java/org/apache/catalina/startup/UserDatabase.java
java/org/apache/catalina/startup/WebAnnotationSet.java
java/org/apache/catalina/startup/WebRuleSet.java

index 2e6933f..2d1d778 100644 (file)
@@ -110,8 +110,8 @@ public final class Bootstrap {
         if ((value == null) || (value.equals("")))
             return parent;
 
-        ArrayList repositoryLocations = new ArrayList();
-        ArrayList repositoryTypes = new ArrayList();
+        ArrayList<String> repositoryLocations = new ArrayList<String>();
+        ArrayList<Integer> repositoryTypes = new ArrayList<Integer>();
         int i;
  
         StringTokenizer tokenizer = new StringTokenizer(value, ",");
@@ -168,8 +168,8 @@ public final class Bootstrap {
             }
         }
 
-        String[] locations = (String[]) repositoryLocations.toArray(new String[0]);
-        Integer[] types = (Integer[]) repositoryTypes.toArray(new Integer[0]);
+        String[] locations = repositoryLocations.toArray(new String[0]);
+        Integer[] types = repositoryTypes.toArray(new Integer[0]);
  
         ClassLoader classLoader = ClassLoaderFactory.createClassLoader
             (locations, types, parent);
@@ -213,7 +213,7 @@ public final class Bootstrap {
         // Load our startup class and call its process() method
         if (log.isDebugEnabled())
             log.debug("Loading startup class");
-        Class startupClass =
+        Class<?> startupClass =
             catalinaLoader.loadClass
             ("org.apache.catalina.startup.Catalina");
         Object startupInstance = startupClass.newInstance();
@@ -222,7 +222,7 @@ public final class Bootstrap {
         if (log.isDebugEnabled())
             log.debug("Setting startup class properties");
         String methodName = "setParentClassLoader";
-        Class paramTypes[] = new Class[1];
+        Class<?> paramTypes[] = new Class[1];
         paramTypes[0] = Class.forName("java.lang.ClassLoader");
         Object paramValues[] = new Object[1];
         paramValues[0] = sharedLoader;
@@ -244,7 +244,7 @@ public final class Bootstrap {
         // Call the load() method
         String methodName = "load";
         Object param[];
-        Class paramTypes[];
+        Class<?> paramTypes[];
         if (arguments==null || arguments.length==0) {
             paramTypes = null;
             param = null;
@@ -323,7 +323,7 @@ public final class Bootstrap {
         throws Exception {
 
         Object param[];
-        Class paramTypes[];
+        Class<?> paramTypes[];
         if (arguments==null || arguments.length==0) {
             paramTypes = null;
             param = null;
@@ -346,7 +346,7 @@ public final class Bootstrap {
     public void setAwait(boolean await)
         throws Exception {
 
-        Class paramTypes[] = new Class[1];
+        Class<?> paramTypes[] = new Class[1];
         paramTypes[0] = Boolean.TYPE;
         Object paramValues[] = new Object[1];
         paramValues[0] = new Boolean(await);
@@ -359,7 +359,7 @@ public final class Bootstrap {
     public boolean getAwait()
         throws Exception
     {
-        Class paramTypes[] = new Class[0];
+        Class<?> paramTypes[] = new Class[0];
         Object paramValues[] = new Object[0];
         Method method =
             catalinaDaemon.getClass().getMethod("getAwait", paramTypes);
index a3bc765..4fd66f6 100644 (file)
@@ -132,7 +132,7 @@ public class CatalinaProperties {
         }
 
         // Register the properties as system properties
-        Enumeration enumeration = properties.propertyNames();
+        Enumeration<?> enumeration = properties.propertyNames();
         while (enumeration.hasMoreElements()) {
             String name = (String) enumeration.nextElement();
             String value = properties.getProperty(name);
index 5394349..2827b06 100644 (file)
@@ -112,7 +112,7 @@ public final class ClassLoaderFactory {
             log.debug("Creating new class loader");
 
         // Construct the "class path" for this class loader
-        ArrayList list = new ArrayList();
+        ArrayList<URL> list = new ArrayList<URL>();
 
         // Add unpacked directories
         if (unpacked != null) {
@@ -150,7 +150,7 @@ public final class ClassLoaderFactory {
         }
 
         // Construct the class loader itself
-        URL[] array = (URL[]) list.toArray(new URL[list.size()]);
+        URL[] array = list.toArray(new URL[list.size()]);
         StandardClassLoader classLoader = null;
         if (parent == null)
             classLoader = new StandardClassLoader(array);
@@ -185,7 +185,7 @@ public final class ClassLoaderFactory {
             log.debug("Creating new class loader");
 
         // Construct the "class path" for this class loader
-        ArrayList list = new ArrayList();
+        ArrayList<URL> list = new ArrayList<URL>();
 
         if (locations != null && types != null && locations.length == types.length) {
             for (int i = 0; i < locations.length; i++)  {
@@ -242,7 +242,7 @@ public final class ClassLoaderFactory {
         }
 
         // Construct the class loader itself
-        URL[] array = (URL[]) list.toArray(new URL[list.size()]);
+        URL[] array = list.toArray(new URL[list.size()]);
         if (log.isDebugEnabled())
             for (int i = 0; i < array.length; i++) {
                 log.debug("  location " + i + " is " + array[i]);
index ea1494d..7d78cc0 100644 (file)
@@ -74,8 +74,8 @@ public class ClusterRuleSetFactory {
         throws ClassNotFoundException, InstantiationException, 
                NoSuchMethodException,IllegalAccessException,
                InvocationTargetException {
-        Class clazz = Class.forName(className,true,cl);
-        Constructor cons = clazz.getConstructor(new Class[] {String.class});
+        Class<?> clazz = Class.forName(className,true,cl);
+        Constructor<?> cons = clazz.getConstructor(new Class[] {String.class});
         return (RuleSetBase)cons.newInstance(prefix);
     }
     
index 11fd2db..6fa6dff 100644 (file)
@@ -79,7 +79,7 @@ public class ContextConfig
     /**
      * Custom mappings of login methods to authenticators
      */
-    protected Map customAuthenticators;
+    protected Map<String,Authenticator> customAuthenticators;
 
 
     /**
@@ -233,7 +233,8 @@ public class ContextConfig
      * @param customAuthenticators Custom mappings of login methods to
      * authenticators
      */
-    public void setCustomAuthenticators(Map customAuthenticators) {
+    public void setCustomAuthenticators(
+            Map<String,Authenticator> customAuthenticators) {
         this.customAuthenticators = customAuthenticators;
     }
 
@@ -259,9 +260,9 @@ public class ContextConfig
         // Process the event that has occurred
         if (event.getType().equals(Lifecycle.START_EVENT)) {
             start();
-        } else if (event.getType().equals(StandardContext.BEFORE_START_EVENT)) {
+        } else if (event.getType().equals(Lifecycle.BEFORE_START_EVENT)) {
             beforeStart();
-        } else if (event.getType().equals(StandardContext.AFTER_START_EVENT)) {
+        } else if (event.getType().equals(Lifecycle.AFTER_START_EVENT)) {
             // Restore docBase for management tools
             if (originalDocBase != null) {
                 String docBase = context.getDocBase();
@@ -487,7 +488,7 @@ public class ContextConfig
 
             // Instantiate and install an Authenticator of the requested class
             try {
-                Class authenticatorClass = Class.forName(authenticatorName);
+                Class<?> authenticatorClass = Class.forName(authenticatorName);
                 authenticator = (Valve) authenticatorClass.newInstance();
             } catch (Throwable t) {
                 log.error(sm.getString(
index d3e21ff..65379bf 100644 (file)
@@ -101,7 +101,7 @@ import org.apache.tomcat.util.log.SystemLogHandler;
  * @version $Revision$ $Date$
  */
 
-public class Embedded  extends StandardService implements Lifecycle {
+public class Embedded  extends StandardService {
     private static Log log = LogFactory.getLog(Embedded.class);
 
     // ----------------------------------------------------------- Constructors
@@ -157,7 +157,7 @@ public class Embedded  extends StandardService implements Lifecycle {
     /**
      * Custom mappings of login methods to authenticators
      */
-    protected HashMap authenticators;
+    protected HashMap<String,Authenticator> authenticators;
 
 
     /**
@@ -175,7 +175,7 @@ public class Embedded  extends StandardService implements Lifecycle {
 
     /**
      * The default realm to be used by all containers associated with
-     * this compoennt.
+     * this component.
      */
     protected Realm realm = null;
 
@@ -653,7 +653,7 @@ public class Embedded  extends StandardService implements Lifecycle {
         while (true) {
             int n = -1;
             for (int i = 0; i < connectors.length; i++) {
-                if (connectors[i].getContainer() == (Container) engine) {
+                if (connectors[i].getContainer() == engine) {
                     n = i;
                     break;
                 }
@@ -746,7 +746,7 @@ public class Embedded  extends StandardService implements Lifecycle {
         if (authenticators == null) {
             synchronized (this) {
                 if (authenticators == null) {
-                    authenticators = new HashMap();
+                    authenticators = new HashMap<String,Authenticator>();
                 }
             }
         }
index a091268..9233970 100644 (file)
@@ -139,9 +139,9 @@ public class ExpandWar {
         InputStream input = null;
         try {
             jarFile = juc.getJarFile();
-            Enumeration jarEntries = jarFile.entries();
+            Enumeration<JarEntry> jarEntries = jarFile.entries();
             while (jarEntries.hasMoreElements()) {
-                JarEntry jarEntry = (JarEntry) jarEntries.nextElement();
+                JarEntry jarEntry = jarEntries.nextElement();
                 String name = jarEntry.getName();
                 int last = name.lastIndexOf('/');
                 if (last >= 0) {
index 0707123..7157cd4 100644 (file)
@@ -56,7 +56,7 @@ public final class HomesUserDatabase
     /**
      * The set of home directories for all defined users, keyed by username.
      */
-    private Hashtable homes = new Hashtable();
+    private Hashtable<String,String> homes = new Hashtable<String,String>();
 
 
     /**
@@ -101,7 +101,7 @@ public final class HomesUserDatabase
      */
     public String getHome(String user) {
 
-        return ((String) homes.get(user));
+        return homes.get(user);
 
     }
 
@@ -109,7 +109,7 @@ public final class HomesUserDatabase
     /**
      * Return an enumeration of the usernames defined on this server.
      */
-    public Enumeration getUsers() {
+    public Enumeration<String> getUsers() {
 
         return (homes.keys());
 
index 6bb169c..250df97 100644 (file)
@@ -89,7 +89,7 @@ public class LifecycleListenerRule extends Rule {
             if (value != null)
                 className = value;
         }
-        Class clazz = Class.forName(className);
+        Class<?> clazz = Class.forName(className);
         LifecycleListener listener =
             (LifecycleListener) clazz.newInstance();
 
index 82e6ec8..a99227e 100644 (file)
@@ -63,7 +63,7 @@ public final class PasswdUserDatabase
     /**
      * The set of home directories for all defined users, keyed by username.
      */
-    private Hashtable homes = new Hashtable();
+    private Hashtable<String,String> homes = new Hashtable<String,String>();
 
 
     /**
@@ -108,7 +108,7 @@ public final class PasswdUserDatabase
      */
     public String getHome(String user) {
 
-        return ((String) homes.get(user));
+        return homes.get(user);
 
     }
 
@@ -116,7 +116,7 @@ public final class PasswdUserDatabase
     /**
      * Return an enumeration of the usernames defined on this server.
      */
-    public Enumeration getUsers() {
+    public Enumeration<String> getUsers() {
 
         return (homes.keys());
 
index fd891c7..32ce34e 100644 (file)
@@ -344,7 +344,7 @@ public final class TldConfig  implements LifecycleListener {
 
         Iterator<String> paths = resourcePaths.iterator();
         while (paths.hasNext()) {
-            String path = (String) paths.next();
+            String path = paths.next();
             URL url = context.getServletContext().getResource(path);
             if (url == null) {
                 log.debug( "Null url "+ path );
@@ -527,11 +527,6 @@ public final class TldConfig  implements LifecycleListener {
                         resourcePath));
             }
             inputSource = new InputSource(stream);
-            if (inputSource == null) {
-                throw new IllegalArgumentException
-                    (sm.getString("contextConfig.tldResourcePath",
-                                  resourcePath));
-            }
             tldScanStream(inputSource);
         } catch (Exception e) {
              throw new ServletException
index 91c52c2..6816bde 100644 (file)
@@ -155,8 +155,8 @@ public final class Tool {
         // Construct the class loader we will be using
         ClassLoader classLoader = null;
         try {
-            ArrayList packed = new ArrayList();
-            ArrayList unpacked = new ArrayList();
+            ArrayList<File> packed = new ArrayList<File>();
+            ArrayList<File> unpacked = new ArrayList<File>();
             unpacked.add(new File(catalinaHome, "classes"));
             packed.add(new File(catalinaHome, "lib"));
             if (common) {
@@ -179,8 +179,8 @@ public final class Tool {
             }
             classLoader =
                 ClassLoaderFactory.createClassLoader
-                ((File[]) unpacked.toArray(new File[0]),
-                 (File[]) packed.toArray(new File[0]),
+                (unpacked.toArray(new File[0]),
+                 packed.toArray(new File[0]),
                  null);
         } catch (Throwable t) {
             log.error("Class loader creation threw exception", t);
@@ -189,7 +189,7 @@ public final class Tool {
         Thread.currentThread().setContextClassLoader(classLoader);
 
         // Load our application class
-        Class clazz = null;
+        Class<?> clazz = null;
         String className = args[index++];
         try {
             if (log.isDebugEnabled())
@@ -208,7 +208,7 @@ public final class Tool {
             if (log.isDebugEnabled())
                 log.debug("Identifying main() method");
             String methodName = "main";
-            Class paramTypes[] = new Class[1];
+            Class<?> paramTypes[] = new Class[1];
             paramTypes[0] = params.getClass();
             method = clazz.getMethod(methodName, paramTypes);
         } catch (Throwable t) {
index 5889cab..f426e5f 100644 (file)
@@ -249,7 +249,7 @@ public final class UserConfig
         // Load the user database object for this host
         UserDatabase database = null;
         try {
-            Class clazz = Class.forName(userClass);
+            Class<?> clazz = Class.forName(userClass);
             database = (UserDatabase) clazz.newInstance();
             database.setUserConfig(this);
         } catch (Exception e) {
@@ -258,9 +258,9 @@ public final class UserConfig
         }
 
         // Deploy the web application (if any) for each defined user
-        Enumeration users = database.getUsers();
+        Enumeration<String> users = database.getUsers();
         while (users.hasMoreElements()) {
-            String user = (String) users.nextElement();
+            String user = users.nextElement();
             String home = database.getHome(user);
             deploy(user, home);
         }
@@ -293,7 +293,7 @@ public final class UserConfig
 
         // Deploy the web application for this user
         try {
-            Class clazz = Class.forName(contextClass);
+            Class<?> clazz = Class.forName(contextClass);
             Context context =
               (Context) clazz.newInstance();
             context.setPath(contextPath);
index 580143a..72ca092 100644 (file)
@@ -64,7 +64,7 @@ public interface UserDatabase {
     /**
      * Return an enumeration of the usernames defined on this server.
      */
-    public Enumeration getUsers();
+    public Enumeration<String> getUsers();
 
 
 }
index 18e57cb..1b427ca 100644 (file)
@@ -93,7 +93,7 @@ public class WebAnnotationSet {
         
         ClassLoader classLoader = context.getLoader().getClassLoader();
         StandardWrapper wrapper = null;
-        Class classClass = null;
+        Class<?> classClass = null;
         
         Container[] children = context.findChildren();
         for (int i = 0; i < children.length; i++) {
@@ -122,8 +122,7 @@ public class WebAnnotationSet {
                  * the deployment descriptor
                  */
                 if (classClass.isAnnotationPresent(RunAs.class)) {
-                    RunAs annotation = (RunAs) 
-                        classClass.getAnnotation(RunAs.class);
+                    RunAs annotation = classClass.getAnnotation(RunAs.class);
                     wrapper.setRunAs(annotation.value());
                 }
             }
@@ -139,7 +138,7 @@ public class WebAnnotationSet {
     protected static void loadClassAnnotation(Context context, String fileString) {
         
         ClassLoader classLoader = context.getLoader().getClassLoader();
-        Class classClass = null;
+        Class<?> classClass = null;
         
         try {
             classClass = classLoader.loadClass(fileString);
@@ -156,16 +155,14 @@ public class WebAnnotationSet {
         // Initialize the annotations
         
         if (classClass.isAnnotationPresent(Resource.class)) {
-            Resource annotation = (Resource) 
-                classClass.getAnnotation(Resource.class);
+            Resource annotation = classClass.getAnnotation(Resource.class);
             addResource(context, annotation);
         }
         /* Process Resources annotation.
          * Ref JSR 250
          */
         if (classClass.isAnnotationPresent(Resources.class)) {
-            Resources annotation = (Resources) 
-                classClass.getAnnotation(Resources.class);
+            Resources annotation = classClass.getAnnotation(Resources.class);
             for (int i = 0; annotation.value() != null && i < annotation.value().length; i++) {
                 addResource(context, annotation.value()[i]);
             }
@@ -242,7 +239,7 @@ public class WebAnnotationSet {
          * the deployment descriptor
          */
         if (classClass.isAnnotationPresent(DeclareRoles.class)) {
-            DeclareRoles annotation = (DeclareRoles) 
+            DeclareRoles annotation =
                 classClass.getAnnotation(DeclareRoles.class);
             for (int i = 0; annotation.value() != null && i < annotation.value().length; i++) {
                 context.addSecurityRole(annotation.value()[i]);
index a65a7a2..d6291a8 100644 (file)
@@ -652,9 +652,8 @@ final class SetPublicIdRule extends Rule {
     public void begin(String namespace, String name, Attributes attributes)
         throws Exception {
 
-        Context context = (Context) digester.peek(digester.getCount() - 1);
         Object top = digester.peek();
-        Class paramClasses[] = new Class[1];
+        Class<?> paramClasses[] = new Class[1];
         paramClasses[0] = "String".getClass();
         String paramValues[] = new String[1];
         paramValues[0] = digester.getPublicId();
@@ -721,10 +720,11 @@ final class CallParamMultiRule extends CallParamRule {
     public void end(String namespace, String name) {
         if (bodyTextStack != null && !bodyTextStack.empty()) {
             // what we do now is push one parameter onto the top set of parameters
-            Object parameters[] = (Object[]) digester.peekParams();
-            ArrayList params = (ArrayList) parameters[paramIndex];
+            ArrayList<String> parameters[] =
+                (ArrayList<String>[]) digester.peekParams();
+            ArrayList<String> params = parameters[paramIndex];
             if (params == null) {
-                params = new ArrayList();
+                params = new ArrayList<String>();
                 parameters[paramIndex] = params;
             }
             params.add(bodyTextStack.pop());
@@ -763,10 +763,10 @@ final class CallMethodMultiRule extends CallMethodRule {
         if (paramCount > 0) {
             parameters = (Object[]) digester.popParams();
         } else {
-            super.end();
+            super.end(namespace, name);
         }
         
-        ArrayList multiParams = (ArrayList) parameters[multiParamIndex];
+        ArrayList<?> multiParams = (ArrayList<?>) parameters[multiParamIndex];
         
         // Construct the parameter values array we will need
         // We only do the conversion if the param value is a String and