cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1154158 - /cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletContextResourceResolver.java
Date Fri, 05 Aug 2011 10:27:31 GMT
Author: sergeyb
Date: Fri Aug  5 10:27:31 2011
New Revision: 1154158

URL: http://svn.apache.org/viewvc?rev=1154158&view=rev
Log:
[CXF-3713] Replacing explicit InitialContext calls with reflection code

Modified:
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletContextResourceResolver.java

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletContextResourceResolver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletContextResourceResolver.java?rev=1154158&r1=1154157&r2=1154158&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletContextResourceResolver.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletContextResourceResolver.java
Fri Aug  5 10:27:31 2011
@@ -22,17 +22,16 @@ package org.apache.cxf.transport.servlet
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Method;
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import javax.servlet.ServletContext;
 
-
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.resource.ResourceResolver;
 
 
@@ -61,14 +60,17 @@ public class ServletContextResourceResol
         Object obj = null;
         try {
             if (entryName != null) {
-                InitialContext ic = new InitialContext();
+                Object ic = ClassLoaderUtils.loadClass("javax.naming.InitialContext", 
+                                                        this.getClass());
                 try {
-                    obj = ic.lookup(entryName);
+                    Method lookupMethod = ic.getClass().getMethod("lookup", new Class[]{String.class});
+                    obj = lookupMethod.invoke(ic, new Object[]{entryName});
                 } finally {
-                    ic.close();
+                    Method closeMethod = ic.getClass().getMethod("close", new Class[]{});
+                    closeMethod.invoke(ic, new Object[]{});
                 }
             }
-        } catch (NamingException e) {
+        } catch (Throwable e) {
             //do nothing
         }
 



Mime
View raw message