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,