java - new ClassPathXmlApplicationContext() creating new set of beans -
does loading application context in following manner mean creating context apart context created contextloader?
i require application context loaded non-bean class.
private static applicationcontext applicationcontext = new classpathxmlapplicationcontext( "channel-integration-context.xml");
it seems creates bean context according observation. if better workaround.
please help.
unless special reason, there's no point of creating multiple applicationcontext
s.
you can create singleton:
public class applicationcontextwrapper { private static applicationcontext instance = null; private applicationcontextwrapper() { } public static applicationcontext getintance() { if (instance == null) { //note can add more spring xml configuration filenames in array string[] contexts = new string[] {"channel-integration-context.xml"}; instance = new classpathapplicationcontext(contexts); } return instance; } }
and can use with:
private static applicationcontext applicationcontext = applicationcontextwrapper.getinstance();
Comments
Post a Comment