We have a home page that contains several components (widgets), like a portal containing portlets. Advertising banks from other teams will be delivered to some of these widgets, and some of them will need to manage some beans using Spring. One solution might be to import spring contexts using the import statement with the wildcard i (for example, import all contexts into the classpath corresponding to context-widget - *. Xml).
However, I prefer a more software solution, where I check each widget, what context they need to load (from the class path). I did not find a single blog or one that explains this, but I found some forum posts that explain that this will be a parent-child context, and it will only be one-way; unfortunately in my case it has to be bidirectional.
So, after some viewing in the API, I managed to come up with something working, but I'm not sure if this is a good solution, or there are some pitfalls that I did not think about. Perhaps there is another (better) solution for this scenario?
public class WidgetManager implements ApplicationContextAware { @Autowired private WidgetService widgetService; @Override public void setApplicationContext(ApplicationContext parentApplicationContext) throws BeansException {
source share