Multiple application context. How to get context per key?

150
February 21, 2018, at 7:17 PM

I have few problems during upgrade Spring version in application.

In legacy code we are using BeanFactoryLocator in order to get main context (registry) in which defined all other contexts. After I am getting BeanFactoryReference by name.

BeanFactoryLocator beanFactoryLocator = DefaultLocatorFactory.getInstance(k.getSelector() // name of the main context, kind of registry for other contexts);
            BeanFactoryReference factoryRef = beanFactoryLocator.useBeanFactory(k.getFactoryName() // name of the concrete context xml);
            BeanFactory factory = new FactoryWrapper(factoryRef.getFactory(), k.getFactoryName());
return factory;

In Spring 5.0 there is no BeanFactoryLocator, DefaultLocatorFactory objects. How I can implement it another way?

Answer 1

There is an interesting discussion here about the outdated mechanism of using beanFactoryLocator, Juergen Hoeller recommended to use

a custom static holder class for one or more ApplicationContexts, keyed by something that has a meaning for your use case, and with a proper lifecycle.

READ ALSO
Android Google map place(retrieve phone number of a poi)

Android Google map place(retrieve phone number of a poi)

I am making my project on Android,googleMap(TouristGuide)Now i want to retrieve the phone number when i click on a point of interest marker

119
When to disconnect MQTT service on an Android app which doesn't required MQTT on background

When to disconnect MQTT service on an Android app which doesn't required MQTT on background

I'm using Paho-Mqtt client on my current Android project to get live feeds from the serverAccording to my requirement, I only need MQTT service while the app is on the foreground

132
Count distinct value with 2 criteria

Count distinct value with 2 criteria

I am trying to find a JDBC MySQL query that will find distinct values in a particular field, count the number of occurrences of that Feedback and then store it in a array list(if possible or if there are better way to store)

178