Tuesday, August 7, 2012

When is this file created ***Factory.java during the EJB creation process?

Answer after the access bean is created. If you haven't created entity bean for a while like me and you could almost forget. If you are looking at creating access bean for a session bean. It does not work with copy helper and you have to select the Java bean wrapper. After the access bean is created for session bean using New wizard, and select EJB > Access Bean and click Next.


Select the appropriate bean type for the session bean in this case would be Java bean wrapper.



Once you are done with the wizard, it creates the ****AccessBean.java and ***Factory.java and ibm-ejb-access-bean.xmi is updated.
Sample block from ibm-ejb-access-bean.xmi

If you just need to regenerate access beans, you can do the following and then deploy.

Java EE->AccessBeans --> Regenerate access beans
Java EE->Prepare for Deployment.


Just want to also quickly touch upon why access beans are required?
Access beans provide a simpler interface to clients, caching of the home object, and reduced call traffic to the enterprise bean and also encapsulates all the complex logic.
At run time the access bean caches the enterprise bean home object because look ups to the home object are expensive, in terms of time and resource usage.
The access bean implements a copyHelper object that reduces the number of calls to the enterprise bean when commands get and set enterprise bean attributes. Only a single call to the enterprise bean is required when reading or writing multiple enterprise bean attributes.

Reference:
http://publib.boulder.ibm.com/infocenter/wchelp/v6r0m0/topic/com.ibm.commerce.developer.doc/concepts/csdaccessbeans.htm

No comments:

Post a Comment