I provide a highly customisable application to my clients which is working totally by itself. But If one my client wants to overwrite any Controller, I want to replace my implementation by theirs. However just overwriting the controller causes an ambiguous definition of mappings.

I have been using Component Scanning to load beans.

The potential solutions came to my mind are:

  1. Using component scanner with excluding by a custom filter? (This seems not so easy)
  2. Using a xxxxPostProcessor to remove some beans? (How?)

Any help?

有帮助吗?

解决方案 2

I have followed these steps:

  1. Created a custom annotation: @Devoted
  2. Created a custom ImportBeanDefinitionRegistrar. Iterated already registered bean definitions to find out `@Devoted @Controller's and removed them.

Based on a request I will provide implementation details.

其他提示

If I got your Question properly,

You can differ implementation by changing URL to particular Implementation name

Say Telecom is interface and AirtelImpl and RelianceImpl are Controllers then

Your request mapping

@RequestMapping(value= "/airtel/doBilling")
@RequestMapping(value= "/reliance/doBilling")

In this way, Implementation flow will differ.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top