We have an opportunity in our org. to introduce a web based project. We don't have App. server but the idea is to get WebLogic in the future. Our confusion is that if we start with JavaBeans/servlets/JSP for a proof of concept, would it be possible to convert JavaBeans to EJB in the future without much trouble? Thanks in advance for any help.
Hi Dewang, Simple Java beans are totally different from EJBs. So you have to re-code all the logic again. U will have the logic but the only trouble will be the re-coding and that also on different concept. cheers.
If you are building a web app, it is perfectly legit to simply use JavaBeans/servlets/JSP for the proof of concept on something like Tomcat. Even if you move to using EJBs in the future, you will still need the JavaBeans to act as the model for the presentation layer. Personally, I like to use a combination of interfaces for the business objects and controllers or factories that create instances of those interfaces. Then my JavaBeans implement those interfaces. In an implementation without EJBs the factories call on back-end data access objects or other back-end components ... to move to EJBs I simply swap out the back-end components with EJBs.
Hiya Dewang. In terms of the Beans to EJB conversion, there really is no easy method - at least none that I have discovered. However, I recently explored a little codegen called Jostraca (http://sourceforge.net/projects/jostraca/) that we used to generate EJB's as well as JavaBeans. It's Platform independent & GNU independent licensed. Jostraca's flexible enough to allow for customization in any J2EE project, yet lightweight & relatively easy to learn. In essence, it's an XML format for specifying attributes fields that can be easily specified after development. If you start your project off using this codegen (or one that is similar), you can initially use it to generate your Java Beans, and future "conversion" to EJB's should go a lot faster.
Melissa Web Engineer
"...Our confusion is that if we start with JavaBeans/servlets/JSP for a proof of concept, would it be possible to convert JavaBeans to EJB in the future without much trouble? Thanks in advance for any help...."
It depends about volume of work and the size of the project. If it is something simple and short I would say that JavaBeans with some classes with static methods for database would be just fine and fast to build and to execute. However if it is large project you should consider EJB - no handling transactions and connection pooling manually (extra time) + CMP and that looks fine. They are more robust and good choice for large projects. Usually JavaBeans in web app are just wrapper classes with some minor business logic - to convert that to EJB you would have a lots of fun! Also I have experience with both soultinos under Oracle, mySQL and Access. These last two and similar databases are usually not a problem because there is no hard load on it. However Oracle was usually on the seperate machine and connection pooling was needed because those were large applications with a lot of users on it - that case EJB.
Joined: Apr 05, 2001
Thanks everyone for your help. Much appreciated. Dewang Shahu, SCJP