Loading
EJB 3.1

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  What is new in EJB 3.1 ?


Ans)

Some of the new Features in Ejb 3.1 are below.

i) EJB Interfaces are Optional

you do not need any interfaces for Session Beans, just like JPA Entities and Message
Driven Beans. All you have to do is annotate a POJO with the @Stateless or @Stateful
to get a fully functional EJB. Take a look at the example below.

@Stateless

public class PlaceBidBean {
@PersistenceContext
 private EntityManager entityManager;
 public void placeBid (Bid bid) {
 entityManager.persist(bid);
 }
}

Expose Session Bean as Web service :

@Stateless @WebService
public class PlaceBidBean {

 @PersistenceContext
  private EntityManager entityManager;
  @WebMethod public void placeBid (Bid bid) {
  entityManager.persist(bid);
  }
}

Allows Singleton Beans :

The following bean load data in init() method and saves the data when destroyed

@Singleton
public class YourTestBean {

 @PersistenceContext
 private EntityManager entityManager;
 private Rate rate;
 @PostConstruct
 private void init() {
 rate = entityManager.find(Rate.class, 1);
 }
 @PreDestroy
 private void destroy() {
 entityManager.merge(rate);
 }
 public void setRate(Rate rate) {
 this.rate = rate;
 }
 public Rate getRate() {
 return rate;
 }
}


iii)
Support for direct use of EJBs in the servlet container, including simplified packaging
options
. The current thought is to allow EJBs in the WEB-INF/classes directory while
allowing ejb-jar.xml to reside in the WEB-INF directory, just like the web.xml file.
In a similar vein, you would be able to place an EJB jar into the WEB-INF/lib directory.

iv) Support for stateful web services via Stateful Session Bean web service endpoints.



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

EJB 3.1


EJB 3.1

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free