Hi again,
I have done some load testing on the MDB and what i notice is that spring will instansiate itself for every bean? Is there a way of getting my "messageService" bean only once from spring and then just resuse it on every MDB instance? Or is it a bad idea?
Here's some code from the MDB:
Code:
public static final String BEAN_FACTORY_PATH_ENVIRONMENT_KEY = "java:comp/env/ejb/BeanFactoryPath";
private BeanFactoryLocator itsBeanFactoryLocator;
private String itsBeanFactoryLocatorKey;
private BeanFactoryReference itsBeanFactoryReference;
private Service itsService;
public void ejbCreate() throws EJBException
{
loadBeanFactory();
}
void loadBeanFactory() throws BeansException
{
if (this.itsBeanFactoryLocator == null)
{
this.itsBeanFactoryLocator = new ContextJndiBeanFactoryLocator();
}
if (this.itsBeanFactoryLocatorKey == null)
{
this.itsBeanFactoryLocatorKey = BEAN_FACTORY_PATH_ENVIRONMENT_KEY;
}
this.itsBeanFactoryReference = this.itsBeanFactoryLocator.useBeanFactory(this.itsBeanFactoryLocatorKey);
ApplicationContext factory = (ApplicationContext) itsBeanFactoryReference.getFactory();
this.itsService = (Service) factory.getBean("messageService");
}
public void ejbRemove() throws EJBException
{
if (this.itsBeanFactoryReference != null)
{
this.itsBeanFactoryReference.release();
this.itsBeanFactoryReference = null;
}
}
any sugesstions?
regards,
-Kristoffer