This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Other Application Frameworks and the fly likes Where to put the spring config for my ejb jar? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Where to put the spring config for my ejb jar?" Watch "Where to put the spring config for my ejb jar?" New topic
Author

Where to put the spring config for my ejb jar?

Sonny hodac
Greenhorn

Joined: Jan 31, 2008
Posts: 8
I build a back end services consist of multiple EJBs, service interfaces, DAO. All classes will be built to classes folder:

build/classes

I plan to load the spring context xml from my service contructor:

public class MyCustomInterfaceService {

/**
* DAO properties
*/
private InsuranceGroupDAO insGrpDAO;
private PayorTypeDAO payorTypeDAO;
private ProductCategoryDAO prodCatDAO;
private QueueDAO queueDAO;
private ApplicationContext context;

public MyCustomInterfaceService (){
context = new ClassPathXmlApplicationContext("beans-context.xml");
BeanFactory factory = (BeanFactory) context;
insGrpDAO = (InsuranceGroupDAO)factory.getBean("insuranceGroupDao");
payorTypeDAO = (PayorTypeDAO)factory.getBean("insuranceGroupDao");
prodCatDAO = (ProductCategoryDAO)factory.getBean("insuranceGroupDao");
queueDAO = (QueueDAO)factory.getBean("insuranceGroupDao");
}

// some interface business methods here
}

Where should I place my beans-context.xml? In build/classes, and jar them together with the ejb.jar? Anyone has experience with this please help. Also, this ejb will be deployed to websphere, any comment/input for this specific app server with what I'm doing will be greatly appreciated.

I also have another war for web end that has it separate spring config under WEB-INF/ folder.

Is it correct to have two separate bean config one in the web tier and one for the ejb tier like what I do? OR can we just put all beans config to web tier (WEB-INF/application-context.xml so they got pick up by the framework without explicitly load in my service constructor class?


Thanks,
 
wood burning stoves
 
subject: Where to put the spring config for my ejb jar?