Question

let's say my app has a feature which can be enabled or disabled:

  • if disabled, spring beans (including endpoint mappings) will be loaded from main.xml
  • if enabled, spring beans (including endpoint mappings) will be loaded from main.xml and extra.xml.

The problem is my endpoint mapping has an id of "mynamespaceEndpointMapping". This bean is of the type org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping.

How do i define this bean in such a way that when it's loaded from main.xml it has only one endpoint but when it's loaded from extra.xml it has 10 endpoints? (I don't want all the 10 endpoints defined in main.xml if i have no use for them there) I could use bean inheritance but this would break the namespace naming convention since i would probably need different ids for the beans...

Thanks, Teo

Was it helpful?

Solution

You need to override the spring bean. Like in this answer: Spring's overriding bean

But this is only possible with XML configuration and not with annotations.

EDIT: I meant the accepted answer. But I tested it with my own code.

I got 2 id's. In test1.xml

<bean id="test" class="Test1" />

and in test2.xml

<bean id="test" class="Test2" />

During startup is use both "test1.xml", "test2.xml" (in that order) in the ApplicationContext en when I get the Spring bean test it's of class Test2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top