incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r1041596 - /incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java
Date Thu, 02 Dec 2010 21:44:03 GMT
Author: not
Date: Thu Dec  2 21:44:03 2010
New Revision: 1041596

URL: http://svn.apache.org/viewvc?rev=1041596&view=rev
Log:
ARIES-468 When an ICFB or OFB is registered when our JNDI bundle starts find the class name
of the existing one for the error message.

Modified:
    incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java

Modified: incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java?rev=1041596&r1=1041595&r2=1041596&view=diff
==============================================================================
--- incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java
(original)
+++ incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java
Thu Dec  2 21:44:03 2010
@@ -78,7 +78,7 @@ public class Activator implements Bundle
         } catch (NamingException e) {
             LOGGER.log(Level.INFO, "Cannot set the InitialContextFactoryBuilder.", e);
         } catch (IllegalStateException e) {
-            LOGGER.log(Level.INFO, "Cannot set the InitialContextFactoryBuilder. Another
builder is already installed", e);
+            LOGGER.log(Level.INFO, "Cannot set the InitialContextFactoryBuilder. Another
builder " + getClassName(InitialContextFactoryBuilder.class) + " is already installed", e);
         }
     
         try {
@@ -88,7 +88,7 @@ public class Activator implements Bundle
         } catch (NamingException e) {
             LOGGER.log(Level.INFO, "Cannot set the ObjectFactoryBuilder.", e);
         } catch (IllegalStateException e) {
-            LOGGER.log(Level.INFO, "Cannot set the ObjectFactoryBuilder. Another builder
is already installed", e);
+            LOGGER.log(Level.INFO, "Cannot set the ObjectFactoryBuilder. Another builder
" + getClassName(InitialContextFactoryBuilder.class) + " is already installed", e);
         }
         
         context.registerService(JNDIProviderAdmin.class.getName(), 
@@ -104,6 +104,22 @@ public class Activator implements Bundle
                                 null);
     }
 
+    private String getClassName(Class<?> expectedType) 
+    {
+      try {
+        for (Field field : NamingManager.class.getDeclaredFields()) {
+            if (expectedType.equals(field.getType())) {
+                field.setAccessible(true);
+                Object icf = field.get(null);
+                return icf.getClass().getName();
+            }
+        }
+      } catch (Throwable t) {
+          // Ignore
+      }
+      return "";
+    }
+
     private ServiceTracker initServiceTracker(BundleContext context,
         Class<?> type, ServiceTrackerCustomizer custom) 
     {



Mime
View raw message