• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Configuring an object(which is outside of the application) in the applicationcontext xml file

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can I configure an object which is present outside of my application(Other module) in my apllication context xml file.

i.e.

If I write


It searches the classes inside x.y.z package and create instance of those.But this x.y.z is in my application (say e.g.MyJavaApp)
But I want to configure an object which is present in the (say e.g. p.q.r package) which is in different application (say e.g HisJavaApp).
Both MyJavaApp and HisJavaApp are different module but they are interdependent.

Please suggest.

Thanks in advance!
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spring will find all the classes in a package as long as the classes are in classpath. Let's say your package p.q.r contains a class called A, and you can compile and execute new p.q.r.A() in your application, then Spring should find A when it scans p.q.r package

You need to look at how you are packaging the applications. You haven't given enough information here. Are these web applications? Are these applications in seperate Wars in the same EAR? or seperate EARS?. Where are the classes? In jar files in the lib folder of the Ear? or in the WAR?

Java isolates EAR files from each other. A class packaged in one Ear won;t be available to other Ears. If Java is isolating the classes, Spring won;t find it
All the Jars in the EAR/lib are available to all the Wars, so if your p.q.r package is inside a jar in the Ear/lib folder, then Spring can load it from both Wars. However, if the class is inside the War, then only the application that is in that War will have access to the class.
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at ClassPathXmlApplicationContext,
http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/support/ClassPathXmlApplicationContext.html
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic