geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r430865 - in /geronimo/xbean/trunk/xbean-server/src: main/java/org/apache/xbean/server/spring/configuration/SpringConfiguration.java test/resources/org/apache/xbean/server/spring/loader/classpath-xbean.xml
Date Fri, 11 Aug 2006 19:12:49 GMT
Author: gnodet
Date: Fri Aug 11 12:12:49 2006
New Revision: 430865

URL: http://svn.apache.org/viewvc?rev=430865&view=rev
Log:
XBEAN-41: Improper abstract bean definitions handling

Modified:
    geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/configuration/SpringConfiguration.java
    geronimo/xbean/trunk/xbean-server/src/test/resources/org/apache/xbean/server/spring/loader/classpath-xbean.xml

Modified: geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/configuration/SpringConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/configuration/SpringConfiguration.java?rev=430865&r1=430864&r2=430865&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/configuration/SpringConfiguration.java
(original)
+++ geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/configuration/SpringConfiguration.java
Fri Aug 11 12:12:49 2006
@@ -30,6 +30,8 @@
 import org.apache.xbean.kernel.StringServiceName;
 import org.apache.xbean.spring.context.SpringApplicationContext;
 import org.apache.xbean.server.spring.loader.SpringLoader;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
 
 /**
  * SpringConfiguration that registers and unregisters services that have been defined in
a SpringApplicationContext.
@@ -142,14 +144,34 @@
     }
 
     private static Map buildServiceNameIndex(SpringApplicationContext applicationContext)
{
-        String[] beanNames = applicationContext.getBeanDefinitionNames();
-        Map serviceNameIndex = new HashMap(beanNames.length);
-        for (int i = 0; i < beanNames.length; i++) {
-            String beanName = beanNames[i];
-            ServiceName serviceName = new StringServiceName(beanName);
-            serviceNameIndex.put(beanName, serviceName);
+        BeanDefinitionRegistry registry = null;
+        if (applicationContext instanceof BeanDefinitionRegistry) {
+            registry = (BeanDefinitionRegistry) applicationContext;
+        } else if (applicationContext.getBeanFactory() instanceof BeanDefinitionRegistry)
{
+            registry = (BeanDefinitionRegistry) applicationContext.getBeanFactory(); 
+        }
+        if (registry != null) {
+            String[] beanNames = registry.getBeanDefinitionNames();
+            Map serviceNameIndex = new HashMap(beanNames.length);
+            for (int i = 0; i < beanNames.length; i++) {
+                String beanName = beanNames[i];
+                BeanDefinition def = registry.getBeanDefinition(beanName);
+                if (!def.isAbstract()) {
+                    ServiceName serviceName = new StringServiceName(beanName);
+                    serviceNameIndex.put(beanName, serviceName);
+                }
+            }
+            return serviceNameIndex;
+        } else {
+            String[] beanNames = applicationContext.getBeanDefinitionNames();
+            Map serviceNameIndex = new HashMap(beanNames.length);
+            for (int i = 0; i < beanNames.length; i++) {
+                String beanName = beanNames[i];
+                ServiceName serviceName = new StringServiceName(beanName);
+                serviceNameIndex.put(beanName, serviceName);
+            }
+            return serviceNameIndex;
         }
-        return serviceNameIndex;
     }
 
     protected static ClassLoader getClassLoader(SpringApplicationContext applicationContext)
{

Modified: geronimo/xbean/trunk/xbean-server/src/test/resources/org/apache/xbean/server/spring/loader/classpath-xbean.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-server/src/test/resources/org/apache/xbean/server/spring/loader/classpath-xbean.xml?rev=430865&r1=430864&r2=430865&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-server/src/test/resources/org/apache/xbean/server/spring/loader/classpath-xbean.xml
(original)
+++ geronimo/xbean/trunk/xbean-server/src/test/resources/org/apache/xbean/server/spring/loader/classpath-xbean.xml
Fri Aug 11 12:12:49 2006
@@ -10,5 +10,15 @@
   <bean name="FileSystemRepository" class="org.apache.xbean.server.repository.FileSystemRepository">
     <property name="root" value="${xbean.base.dir}/repository"/>
   </bean>
+  
+  <bean id="inheritedTestBean" abstract="true" class="javax.swing.JComponent">
+    <property name="autoscrolls" value="true"/>
+  </bean>
+
+  <bean id="inheritsWithDifferentClass" class="javax.swing.JButton"
+        parent="inheritedTestBean">
+    <property name="autoscrolls" value="false"/>
+  </bean>
+
 </beans>
 <!-- END SNIPPET: xml -->



Mime
View raw message