You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2008/06/04 16:29:20 UTC

svn commit: r663123 - in /geronimo/server/branches/2.1/plugins/debugviews/debugviews-portlets: pom.xml src/main/java/org/apache/geronimo/console/jndiview/JNDIViewPortlet.java

Author: gawor
Date: Wed Jun  4 07:29:20 2008
New Revision: 663123

URL: http://svn.apache.org/viewvc?rev=663123&view=rev
Log:
ensure jndi context is associated with the thread before quering it (GERONIMO-3976)

Modified:
    geronimo/server/branches/2.1/plugins/debugviews/debugviews-portlets/pom.xml
    geronimo/server/branches/2.1/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/jndiview/JNDIViewPortlet.java

Modified: geronimo/server/branches/2.1/plugins/debugviews/debugviews-portlets/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/debugviews/debugviews-portlets/pom.xml?rev=663123&r1=663122&r2=663123&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/debugviews/debugviews-portlets/pom.xml (original)
+++ geronimo/server/branches/2.1/plugins/debugviews/debugviews-portlets/pom.xml Wed Jun  4 07:29:20 2008
@@ -72,6 +72,13 @@
 
         <dependency>
             <groupId>org.apache.geronimo.framework</groupId>
+            <artifactId>geronimo-naming</artifactId>
+            <version>${version}</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.framework</groupId>
             <artifactId>geronimo-management</artifactId>
             <version>${version}</version>
             <scope>provided</scope>

Modified: geronimo/server/branches/2.1/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/jndiview/JNDIViewPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/jndiview/JNDIViewPortlet.java?rev=663123&r1=663122&r2=663123&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/jndiview/JNDIViewPortlet.java (original)
+++ geronimo/server/branches/2.1/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/jndiview/JNDIViewPortlet.java Wed Jun  4 07:29:20 2008
@@ -17,8 +17,12 @@
 package org.apache.geronimo.console.jndiview;
 
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.naming.java.RootContext;
 import org.apache.geronimo.gbean.AbstractName;
 import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameClassPair;
+import javax.naming.NamingEnumeration;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -32,6 +36,8 @@
 
 import org.apache.geronimo.console.BasePortlet;
 import org.apache.geronimo.console.util.StringTree;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -44,6 +50,8 @@
 
 public class JNDIViewPortlet extends BasePortlet {
 
+    private static final Log log = LogFactory.getLog(JNDIViewPortlet.class);
+        
     private static final String NORMALVIEW_JSP = "/WEB-INF/view/jndiview/view.jsp";
 
     private static final String MAXIMIZEDVIEW_JSP = "/WEB-INF/view/jndiview/view.jsp";
@@ -55,7 +63,7 @@
     private PortletRequestDispatcher maximizedView;
 
     private PortletRequestDispatcher helpView;
-
+  
     public void processAction(ActionRequest actionRequest,
             ActionResponse actionResponse) throws PortletException, IOException {
     }
@@ -322,22 +330,34 @@
         }
     }
 
-    public void buildContext(StringTree node, Context ctx, String nodeCurr) {
+    public void buildContext(StringTree node, Context compCtx, String nodeCurr) {
+        Context oldCtx = RootContext.getComponentContext();
+        RootContext.setComponentContext(compCtx);
+        try {
+            InitialContext ctx = new InitialContext();
+            buildContextSub(node, (Context)ctx.lookup("java:comp"), nodeCurr);
+        } catch (Exception e) {
+            log.warn("Error looking up java:comp context", e);
+        } finally {        
+            RootContext.setComponentContext(oldCtx);
+        }
+    }
+    
+    private void buildContextSub(StringTree node, Context ctx, String nodeCurr) {
         try {
-            javax.naming.NamingEnumeration enumName = ctx.list("");
+            NamingEnumeration enumName = ctx.list("");
             while (enumName.hasMoreElements()) {
-                javax.naming.NameClassPair pair = (javax.naming.NameClassPair) enumName
-                        .next();
+                NameClassPair pair = (NameClassPair) enumName.next();
                 Object obj = ctx.lookup(pair.getName());
                 if (obj instanceof Context) {
-                    buildContext(node, (Context) obj, nodeCurr + "/"
+                    buildContextSub(node, (Context) obj, nodeCurr + "/"
                             + pair.getName());
                 } else {
                     node.addChild(new StringTree(nodeCurr + "/" + pair.getName()));
                 }
             }
         } catch (Exception e) {
-            e.printStackTrace();
+            log.warn("Error listing context", e);
         }
     }
 
@@ -425,4 +445,4 @@
         buildAppClientModule(kernel, arryList, entApp);
         return arryList;
     }
-}
\ No newline at end of file
+}