Monday, April 16, 2012

What is an Enterprise Java Bean EJB and benefits of EJB

What is Enterprise Java Beans ( EJB ):

EJB is written in Java programming language and it is server side component that encapsulates the business logic of an java application from customers. Business logic code is managed in EJB that fulfills the purpose of the java applications. For example, in an eCommerce web application, the enterprise java beans might implement the business logic in methods called checkAvailableItem and orderProduct.

Benefits of Enterprise Java Beans EJB

EJB technology enables rapid and simplified the process of distributed, transactional, secure and portable java desktop applications development and Java ee web applications development because
  • EJB container provides System level services to enterprise java beans.
  • EJB developer just focus on business logic and on solving business problems.
  • Because business logic lies in EJB, so Front end developer can focus on the presentation of client interface.
  • The client developer does not have to code the routines that implement business rules or access databases. As a result, clients side has less codes which is  particularly important for clients that run on small devices.
  • Java Beans are portable components which enable the java application assembler to build new applications from existing java beans.
  • EJB is a standard API due to which applications build on EJB can run on any complaint Java EE web application server.

Types of Enterprise Java Beans:

There are two main types of  EJBs
1- Session Beans
2- Message Driven Beans

1- Session Beans

A session bean encapsulates business logic that can be invoked programmatically by a client over local, remote, or web service client views. A session bean is not persistent, means its data is not saved to a database. EJB Session Beans has three types which are

Stateful  Session Bean

In stateful session bean, the state of an object consists of the values of its instance variables. In a stateful session bean, the instance variables represent the state of a unique client / bean session.

Stateless Session Bean

In EJB stateless session bean conversational state is not maintained with client. When a client invokes the methods of a stateless bean, the bean’s instance variables may contain a state specific to that client but only for the duration of the invocation.

Single tone Session Bean

A singleton session bean is instantiated once per application and exists for the whole lifecycle of the java application. A single enterprise bean instance is shared across all the applications clients and it is concurrently accessed by clients

2- Message Driven Bean (MDB)

Message Driven Beans ( MDBs ) also known as Message Beans. Message Driven Beans are business objects whose execution is triggered by messages instead of by method calls.

When to Use Enterprise Java Beans EJB

EJB can be used in any java application which are simple or complicated. Java applications can be developed with out EJB. Now answer to question " when to use EJB" is that  EJB should be used if your application has any of the following requirements.
  • For Scalable Java Applications: The application must be scalable. To accommodate a growing number of users, you may need to distribute an application’s components across multiple machines. Not only can the enterprise beans of an application run on different machines, but also their location will remain transparent to the clients.
  • For Transactional java applications:  In application transactions must ensure data integrity. Enterprise java beans support transactions, the mechanisms that manage the concurrent access of shared objects.
  • Java Application with different Client like Desktop, Web, Mobile etc: The java application will have a variety of clients. With only a few lines of code, remote EJB clients can easily locate enterprise java beans. These clients can be thin, various, and numerous.
Find below slides to learn more about Enterprise Java Beans.


  1. very informative

  2. there is also another type of bean entity bean

  3. Thanks for your informative article on Java. It is most popular and reliable software development platform for creating mobile application.

  4. I have learned much from your post. I would definitely bookmark your site to be updated with your upcoming articles. Great job! So much information.


  5. Nice blog, here I had an opportunity to learn something new in my interested domain about java bean benefits. I have an expectation about your future post so please keep updates.
    JAVA Training in Chennai

  6. Your posts is really helpful for me.Thanks for your wonderful post. I am very happy to read your post.
    Android Training in chennai | Android Training chennai | Android course in chennai | Android course chennai

  7. Thanks for sharing this great article..Its really nice and useful for us..Website Design Companies Bangalore | Web Designing Bangalore

  8. Hi, This is Jaman from Chennai. I have read your blog and I got some knowledgeable information through this blog. Really useful blog. Keep update your blog.
    iOS Training in Chennai | Informatica Training in Chennai

  9. The information you have given here are most worthy for me. I have implemented in my training program as well, thanks for sharing.

    Hadoop Training Chennai
    Hadoop Training in Chennai

  10. The information you have deliver here is really useful to make my knowledge good. Thanks for your heavenly post. It is truly supportive for us and I have accumulated some essential data from this blog.
    Informatica training institute in Chennai|Best Informatica Training Institute In Chennai|Informatica training in chennai

  11. There are lots of information about latest technology and how to get trained in them, like Best Hadoop Training In Chennai in Chennai have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get trained in future technologies Hadoop Training in Chennai By the way you are running a great blog. Thanks for sharing this blogs..

  12. I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    SalesForce Training in Chennai

  13. Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    Unix Training In Chennai

  14. This information is impressive..I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic
    Android Training In Chennai In Chennai

  15. SAP Training in Chennai
    This post is really nice and informative. The explanation given is really comprehensive and informative..

  16. Oracle Training in chennai
    Thanks for sharing such a great information..Its really nice and informative..

  17. Selenium Training in Chennai
    Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..

  18. Data warehousing Training in Chennai
    I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly..

  19. Whatever we gathered information from the blogs, we should implement that in practically then only we can understand that exact thing clearly, but it’s no need to do it, because you have explained the concepts very well. It was crystal clear, keep sharing..
    Websphere Training in Chennai

  20. Oracle DBA Training in Chennai
    Thanks for sharing this informative blog. I did Oracle DBA Certification in Greens Technology at Adyar. This is really useful for me to make a bright career..

  21. This is really an awesome article. Thank you for sharing this.It is worth reading for everyone. Visit us:
    Oracle Training in Chennai

  22. very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.
    Oracle DBA Training in Chennai

  23. great article!!!!!This is very importent information for us.I like all content and information.I have read it.You know more about this please visit again.
    Oracle RAC Training in Chennai

  24. Wonderful tips, very helpful well explained. Your post is definitely incredible. I will refer this to my friend.
    SalesForce Training in Chennai

  25. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
    Java Training in Chennai

  26. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
    PHP Training in Chennai

  27. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.Nice article i was really impressed by seeing this article, it was very interesting and it is very useful for me..
    Android Training in Chennai

  28. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
    SAP Training in Chennai

  29. Excellent information with unique content and it is very useful to know about the information based on blogs.
    Hadoop Training in Chennai


Please enter relevant question and information.