I had a peculiar doubt that why do we all the way need an EJB?. After all, its making code verbose. What are all the things we can do in EJB can be done with other options like Hibernate and Struts or Spring framework that can also run in non-managed environment. In the J2EE environment, EJB is safe, secure and transactional. But there are other ways to achieve these features..still why do we need an EJB.
After all, its making code verbose. What are all the things we can do in EJB can be done with other options like Hibernate and Struts or Spring framework that can also run in non-managed environment.
A comparison between EJB and Struts is pointless, they share no common functionality. I would use Hibernate with EJBs (or at least, a JPA provider) so that code would be pretty much identical in either deployment. Is Spring less verbose than EJB3?
It depends entirely upon what you are doing. Your question implies you desire to keep everything as simple as possible, which is good. There is a good book addressing this "Faster, Better, Lighter Java". I would stick with Tomcat if it did everything I needed, however moving to an application server has made our lives easier because it is better suited to support the work we are doing. In particular it is easier to manage more complex applications that rely on multiple underlying projects. It has also allowed us to move to a service oriented architecture utilizing RMI/IIOP and to integrate easily with other applications such as JBPM.
posted 10 years ago
You are right..that i cant make everything as simple as possible. What i am saying is that what a session bean is doing in an Enterprise application can be written in Struts Action class..I can use APIs to give its transactional and security issues..isnt it?
Why we need an session bean to wrap up our code and looking up JNDI code to get the service..isnt it an overhead?? thats i am asking guys..
Or im entirely wrong understanding these things...
What i am saying is that what a session bean is doing in an Enterprise application can be written in Struts Action class
No, it can't at least not easily. To replicate all the container provider services (and applicaiton management tools available in EJB containers) yourself is non-trivial. I think you may have a slightly oversimplified understanding of what functionality EJBs provide.
I think i understand EJB has something to be worth considering...but i have a requirement to build a web application. Now In which scenario i should go for EJB and in which i should not..Because i can integrate Struts-hibernate-jsp/servlet and Database to complete my project..
Give me an exact example or scenario in which i must use EJB..
Thats what i am asking you guys..for which container services i should go for EJB? Or can I replace EJB?
For an Enterprise application, i have business tier.. I understand i should use EJB for the business tier..isnt it??? my question is that can i use other technologies(i dont know other technologies exist) to replace EJB?
No, your business logic can go wherever it makes architectural sense for it to go. If you are writing a simple web application EJB may very well be a considerable overhead. There are a lot of questions you can ask yourself which might point you in the direction of EJBs (or a simmilar technology); these are far to many to list completely here which is why I'm asking you what you think you might need. Since you use EJB for the container provided services EJBs give you access to, you need to ask which of these services will I be using? If the answer is "none" then you probably don't need EJBs (or Spring for that matter). If the answer is "I don't know" then you probably need to take a little time to review your overall architecture and have a think about it.
Well you have plain old java objects calling third party APIs that replace container provided services, or Spring (which is kind of the same thing). Again though neither of these routes are applicable if you don't need the container provided services in the first place.
Then can i conclude from your discussion that EJB is mere provider of container services? Because i thought it is that way it seems...So when i need container services for my application, i can use EJBs..??
Thanks for your so-far-clarification..
I didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad: