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 applicationcontexts.

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

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -