Refresh Your Java - Before Java Interview
We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....
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.
This Portal is intended to put all Java/J2ee related topics at one single place for quick referance, not only Technical , but also the Project Management Related thing such as Development Process methodoogies build process, unit testing etc.,
This Portal has More than 500 Java Interview Questions (also could be Considered as Quick Notes) very neatly separated topic by topic with simple diagrams which makes you easily understandable. Importantly these are from our Realtime expericance.