Announcement Announcement Module
Collapse
No announcement yet.
Can we Share ClasspathXMLApplicationContext Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can we Share ClasspathXMLApplicationContext

    Hi..i have a few properties file which i want to share in different projects (these all projects run in same app server). i am putting thse files in my classpath as in

    <value>classpath*:/**/mydirpath.props</value>

    so that now when i create a ClasspathXMLApplicationContext object ApplicationContext context = new ClasspathXMLApplicationContext ("mydirpath.props");
    i will get a context object. now i want to share this context object with other projects (which can be web or simple java projects, but they all run in the same app server). is it possible...if yes then How to do it ??

  • #2
    There is nothing to stop you from instantiating an application context multiple times. This is in fact how the AbstractSessionBean subclasses work by default.

    If you want to have several projects share the same INSTANCE of an application context, you can use SingletonBeanFactoryLocator.

    Comment


    • #3
      now when i say
      ApplicationContext context = newClassPathXmlApplicationContext("mydirpath.props ");
      its saying that it cannot find mydirpath.props ....why is it so...
      i have delcated this mydirpath.props in the classpath of a different project. But both these projects run in the same app server.

      Comment


      • #4
        ClassPathXmlApplicationContext is for XML files. You need to use an application context which utilizes property files:

        Check out the javadoc for GenericApplicationContext. It has an example of loading a property file from the classpath.

        Comment

        Working...
        X