Issue 1:
Geert Jan Sterenborg opened SPR-3184 and commented

Hi,

Currently we have a config-module for every specific implementation of our product. These config-modules contain our Spring configuration-files.

So we have a lot of duplicate bean-configs.

We initialize the configuration files like so:

---start of boot-strap.xml

[CODE]<bean id="core-services" class="....ServiceManager">

<constructor-arg>

<list>

<value>services/config-file.xml</value>

</list>

</constructor-arg>

</bean>[/CODE]

---end of boot-strap.xml

I'm trying to split these modules into a kernel-config-module (i.e. generic-config-modules) and several specific-config modules making use of the parent-child relationship.

The problem I'm running into is the following:

Generic config-file:

[CODE]

<bean id="a" class="...A">

<constructor-arg ref="c">

</bean>

<bean id="b" class="...B">

<constructor-arg ref="a">

</bean>

<bean id="c" class="...C"/>[/CODE]

Bean A - uses bean C in generic config-file

Bean B - uses bean A in generic config-file

Specific config-file:

[CODE]<bean id="a" parent="a">

<constructor-arg ref="d">

</bean>[/CODE]

<bean id="d" class="...D"/>

Bean A - overrides bean A in generic config-file so that it uses bean D (config: <bean id="a" parent="a">....)

Bean D - Some bean

And the boot-strap-files:

---start of boot-strap-kernel.xml

[CODE] <bean id="core-services-kernel" class="....ServiceManager">

<constructor-arg>

<list>

<value>services/config-file-kernel.xml</value>

</list>

</constructor-arg>

</bean>[/CODE]

---end of boot-strap-kernel.xml

---start of boot-strap-specific.xml

[CODE] <bean id="core-services" class="....ServiceManager">

<constructor-arg>

<list>

<value>services/config-file.xml</value>

</list>

</constructor-arg>

<constructor-arg ref="core-services-kernel"/><!--Generic is core-services' parent -->

</bean>[/CODE]

---end of boot-strap-kernel.xml

The problem is that generic-bean B still uses the generic-bean A.

In order to use generic-bean B without having to include it in all specific-config-modules I could add a generic-config-file,

include it in core-services and move bean B to this file:

---start of boot-strap-specific.xml

[CODE] <bean id="core-services" class="....ServiceManager">

<constructor-arg>

<list>

<value>services/config-file-kernel-shared.xml</value>

<value>services/config-file.xml</value>

</list>

</constructor-arg>

<constructor-arg ref="core-services-kernel"/><!--Generic is core-services' parent -->

</bean>[/CODE]

---end of boot-strap-kernel.xml

But what if I want to override bean B?

The alternative is to move bean B to the specific config-file. If there were other beans depending on B they would have to be moved (in this case duplicated) too.

Some forum-questions and issues regarding this matter all boil down to the fact that parent-contexts know nothing of their children.

I'm not entirely sure but I guess the goal is that bean-extension should compare to java class-extension.

However since I'm going through the child-context to access bean B that is configured in the parent-context it wouldn't be completely illogic to be able to override the parent-definition.

It would be nice to have an extension that would allow to do something like this:

[CODE]<bean id="a" .... parent="a">

<override/> <!--- override switch -->

<constructor-arg ref="d">

</bean>[/CODE]

The override tag should completely override bean A (in child-context as well as parent-context.)

I've posted this as a question on the forum (http://forum.springframework.org/showthread.php?t=34950), but perhaps it could be useful to others if it were included in the core.

No further details from SPR-3184

Issue 2:
Vladimiras Makarovas opened SPR-3316 and commented

spring-framework-2.0.4-with-dependencies-20070327-26.zip

trace:

javax.security.auth.login.LoginException: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [conf/netsvep-aas-context.xml]; nested exception is java.lang.IllegalArgumentException: Class [org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler] does not implement the NamespaceHandler interface

Caused by: java.lang.IllegalArgumentException: Class [org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler] does not implement the NamespaceHandler interface

at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.initHandlerMappings(DefaultNamespaceHandlerResolver.java:119)

at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.<init>(DefaultNamespaceHandlerResolver.java:96)

at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.<init>(DefaultNamespaceHandlerResolver.java:82)

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.createDefaultNamespaceHandlerResolver(XmlBeanDefinitionReader.java:489)

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.createReaderContext(XmlBeanDefinitionReader.java:478)

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:458)

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:353)

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280)

at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)

at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)

at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:173)

at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:112)

at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:79)

at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:100)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:298)

at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)

at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)

at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)

at com.asw.netsvep.modules.aas.DatabaseServerLoginModuleRC.getAuthService(Unknown Source)

code:

protected DatabaseServerAuthService getAuthService() {

String path = "classpath:conf/netsvep-aas-context.xml";

ApplicationContext ctx = new ClassPathXmlApplicationContext(path);

DatabaseServerAuthService auth = (DatabaseServerAuthService) ctx.getBean("authService");

return auth;

}

Affects: 2.0.4