Expose the global naming context for all Server implementations
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 8 Mar 2011 15:58:53 +0000 (15:58 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 8 Mar 2011 15:58:53 +0000 (15:58 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1079405 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/Server.java
java/org/apache/catalina/core/StandardServer.java
java/org/apache/catalina/manager/ManagerServlet.java
java/org/apache/catalina/realm/DataSourceRealm.java
java/org/apache/catalina/realm/UserDatabaseRealm.java

index 5e36f05..6b4a054 100644 (file)
@@ -76,6 +76,12 @@ public interface Server extends Lifecycle {
 
 
     /**
+     * Return the global naming resources context.
+     */
+    public javax.naming.Context getGlobalNamingContext();
+
+
+    /**
      * Return the port number we listen to for shutdown commands.
      */
     public int getPort();
index f529ab7..7c8ec0c 100644 (file)
@@ -173,6 +173,7 @@ public final class StandardServer extends LifecycleMBeanBase implements Server {
     /**
      * Return the global naming resources context.
      */
+    @Override
     public javax.naming.Context getGlobalNamingContext() {
 
         return (this.globalNamingContext);
index bf1e8f5..72cf687 100644 (file)
@@ -457,8 +457,8 @@ public class ManagerServlet extends HttpServlet implements ContainerServlet {
 
         // Acquire global JNDI resources if available
         Server server = ((Engine)host.getParent()).getService().getServer();
-        if ((server != null) && (server instanceof StandardServer)) {
-            global = ((StandardServer) server).getGlobalNamingContext();
+        if (server != null) {
+            global = server.getGlobalNamingContext();
         }
 
         // Calculate the directory into which we will be deploying applications
index e013bce..4777251 100644 (file)
@@ -30,7 +30,6 @@ import javax.naming.Context;
 import javax.sql.DataSource;
 
 import org.apache.catalina.LifecycleException;
-import org.apache.catalina.core.StandardServer;
 import org.apache.naming.ContextBindings;
 
 /**
@@ -390,8 +389,7 @@ public class DataSourceRealm
                 context = ContextBindings.getClassLoader();
                 context = (Context) context.lookup("comp/env");
             } else {
-                context =
-                    ((StandardServer)getServer()).getGlobalNamingContext();
+                context = getServer().getGlobalNamingContext();
             }
             DataSource dataSource = (DataSource)context.lookup(dataSourceName);
         return dataSource.getConnection();
index 2f8af43..bc07925 100644 (file)
@@ -32,7 +32,6 @@ import org.apache.catalina.Role;
 import org.apache.catalina.User;
 import org.apache.catalina.UserDatabase;
 import org.apache.catalina.Wrapper;
-import org.apache.catalina.core.StandardServer;
 import org.apache.tomcat.util.ExceptionUtils;
 
 
@@ -252,8 +251,7 @@ public class UserDatabaseRealm
     protected void startInternal() throws LifecycleException {
 
         try {
-            Context context =
-                ((StandardServer)getServer()).getGlobalNamingContext();
+            Context context = getServer().getGlobalNamingContext();
             database = (UserDatabase) context.lookup(resourceName);
         } catch (Throwable e) {
             ExceptionUtils.handleThrowable(e);