You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by xu...@apache.org on 2010/04/09 04:09:55 UTC

svn commit: r932213 - /geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatInstanceManager.java

Author: xuhaihong
Date: Fri Apr  9 02:09:55 2010
New Revision: 932213

URL: http://svn.apache.org/viewvc?rev=932213&view=rev
Log:
Convert RuntimeException to InstantiationException, and remove the UnsupportedOperationException thrown by newIntance method

Modified:
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatInstanceManager.java

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatInstanceManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatInstanceManager.java?rev=932213&r1=932212&r2=932213&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatInstanceManager.java (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatInstanceManager.java Fri Apr  9 02:09:55 2010
@@ -46,11 +46,27 @@ public class TomcatInstanceManager imple
     }
 
     public Object newInstance(String fqcn, ClassLoader classLoader) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException {
-        return holder.newInstance(fqcn, classLoader, context);
+        try {
+            return holder.newInstance(fqcn, classLoader, context);
+        } catch (IllegalAccessException e) {
+            throw e;
+        } catch (InstantiationException e) {
+            throw e;
+        } catch (Exception e) {
+            throw (InstantiationException) new InstantiationException().initCause(e);
+        }
     }
-	
+
     public Object newInstance(String className) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException {
-        return holder.newInstance(className, classLoader, context);
+        try {
+            return holder.newInstance(className, classLoader, context);
+        } catch (IllegalAccessException e) {
+            throw e;
+        } catch (InstantiationException e) {
+            throw e;
+        } catch (Exception e) {
+            throw (InstantiationException) new InstantiationException().initCause(e);
+        }
     }
 
     public void destroyInstance(Object o) throws IllegalAccessException, InvocationTargetException {
@@ -60,8 +76,12 @@ public class TomcatInstanceManager imple
             throw new InvocationTargetException(e, "Attempted to destroy instance");
         }
     }
-    
-    public void newInstance(Object o) throws IllegalAccessException,  InvocationTargetException, NamingException {
-	throw new UnsupportedOperationException("separate instantiation and injection is not supported");
+
+    public void newInstance(Object o) throws IllegalAccessException, InvocationTargetException, NamingException {
+        //Spec 4.4.3.5 from my understanding, there are two scenario that current method is invoked,
+        //a.  The users use create*** method to create Servlet/Filter/Listener to create the instance, then use add***(String name, ***  instance)
+        //b. The users create the instances by themselves, then use add***(String name, *** instance)
+        //For a, we should have done the resource injections, for b, we are not need to do the resource injections
+        //Correct me if I miss anything !
     }
 }