java - How to "white label" spring beans -


We have a white labeled app (an app that supports a branded experience for multiple applications) custom components per customer To support, we want to be able to load the co-brand version of a component. For example something like:

  & lt ;! - Default service - & gt; & Lt; Bean id = "service" class = "com.blah.myService" primary = "true" & gt; & Lt; Property Name = "myBean" Ref = "Bean" /> & Lt; / Bean & gt; & Lt ;! - Custom service for customer 123 - & gt; & Lt; Bean id = "service_123" class = "com.blah.myService" & gt; & Lt; Property Name = "myBean" Ref = "Bean" /> & Lt; / Bean & gt; & Lt ;! - Default Bean - & gt; & Lt; Bean id = "bean" class = "com.blah.beean" primary = "true" /> & Lt ;! - Bean 123 for client - & gt; & Lt; Bean id = "Bean_123" class = "comm. Blah. Bean" />  

We have tried sub-classification, and it works for top-level bean, but healthy colleagues are wired and cashed during the loading of the spring.

For example, if I call getBean ("Service"), then I can block calls and return the service in my custom applicationcontract, but the "Bean" property is cached Uses version and getBean method again, thus I am unable to wired in custom version.

Is this type of runtime an easy way to gain custom injection?

First of all, for the implementation of such custom instantaneous logic, ApplicationContext Subclass is not required - You can choose a beanPost processor instead.

To solve the problem in the cached version of Bean, you can wrap the returned bean in some type of proxy - either AOP or Manually (see, for example, and its sub -classes).


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -