geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1145482 - in /geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi: KernelContextGBean.java binding/ResourceBinding.java
Date Tue, 12 Jul 2011 08:08:09 GMT
Author: xuhaihong
Date: Tue Jul 12 08:08:09 2011
New Revision: 1145482

URL: http://svn.apache.org/viewvc?rev=1145482&view=rev
Log:
GERONIMO-5904 Reference bound in JNDI is not dereferenced properly when lookup (Patch from
Fang Sheng Hao)

Modified:
    geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/KernelContextGBean.java
    geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/ResourceBinding.java

Modified: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/KernelContextGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/KernelContextGBean.java?rev=1145482&r1=1145481&r2=1145482&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/KernelContextGBean.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/KernelContextGBean.java
Tue Jul 12 08:08:09 2011
@@ -55,11 +55,11 @@ import org.osgi.framework.ServiceReferen
 public class KernelContextGBean implements GBeanLifecycle {
     private static final Logger log = LoggerFactory.getLogger(KernelContextGBean.class);
 
-    private final Kernel kernel;
+    protected final Kernel kernel;
     private final AbstractNameQuery abstractNameQuery;
     private final LifecycleListener listener = new ContextLifecycleListener();
     private final Map<AbstractName, Set<Name>> bindingsByAbstractName = new HashMap<AbstractName,
Set<Name>>();
-    private BundleContext bundleContext;
+    protected BundleContext bundleContext;
     private String nameInNamespace;
     private Context context;
     

Modified: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/ResourceBinding.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/ResourceBinding.java?rev=1145482&r1=1145481&r2=1145482&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/ResourceBinding.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/ResourceBinding.java
Tue Jul 12 08:08:09 2011
@@ -16,19 +16,19 @@
  */
 package org.apache.geronimo.gjndi.binding;
 
+import javax.naming.Name;
+import javax.naming.NamingException;
+
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.OsgiService;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
 import org.apache.geronimo.gbean.annotation.ParamSpecial;
 import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.naming.ResourceSource;
-
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NamingException;
-
+import org.apache.geronimo.naming.reference.ResourceReference;
 import org.osgi.framework.BundleContext;
 
 /**
@@ -62,6 +62,14 @@ public class ResourceBinding extends GBe
             return null;
         }
         try {
+            if (value.getClass().getAnnotation(OsgiService.class) != null) {
+                String osgiJndiName = kernel.getNaming().toOsgiJndiName(abstractName);
+                String query = "(osgi.jndi.service.name=" + osgiJndiName + ')';
+                ResourceReference reference = new ResourceReference(query, value.getClass().getName());
+                reference.setBundle(bundleContext.getBundle());
+                reference.setKernel(kernel);
+                return reference;
+            }
             return ((ResourceSource) value).$getResource();
         } catch (Throwable throwable) {
             log.info("Could not get resource from gbean at " + abstractName,throwable);



Mime
View raw message