Java Reference
In-Depth Information
Introducing Session Beans
Session Beans encapsulate business logic for enterprise applications. It is a good
idea to use session beans when developing enterprise applications, since we as
application developers can focus on developing business logic, and not worry
worry about other enterprise application requirements such as scalability, security,
transactions, so on.
Even though we as application developers don't directly implement
common enterprise application requirements such as transactions and
security, we can configure these services via annotations.
There are two types of session beans stateless session beans and stateful session
beans . The difference between the two of them is that stateful session beans maintain
conversational state with their client between method invocations, whereas stateless
session beans do not.
Creating a session bean in NetBeans
Session Beans can be created in three types of NetBeans projects, Enterprise
Application , EJB Module , and Web Application . EJB Module projects can contain
only EJBs, whereas Enterprise Application projects can contain EJBs along with their
clients, which can be web applications or "standalone" Java applications. The ability
to add EJBs to web applications is a new feature introduced in Java EE 6. Having this
ability allows us to simplify packaging and deployment of web applications using
EJBs. We can now package the web application code and the EJB code in a single
WAR file, whereas with previous versions of Java EE and J2EE, we had to create an
EAR (Enterprise Application) file.
When deploying enterprise applications to the GlassFish application server included
with NetBeans, it is possible to deploy standalone clients as part of the application
to the application server. These standalone clients are then available via Java Web
Start ( http://java.sun.com/products/javawebstart/ ); this feature also allows us
to easily access EJBs from the client code by using the annotations. True standalone
clients executing outside the application server require JNDI lookups to obtain a
reference to the EJB.
To create an Enterprise Application project, go to File | New Project , select the
Enterprise category, then Enterprise Application :
 
Search WWH ::




Custom Search