Java Reference
In-Depth Information
Introduction to Session Beans
Session beans encapsulate business logic for enterprise applications. It's a good
idea to use session beans when developing enterprise applications, since we as
application developers can focus on developing business logic, not having to
worry about other enterprise application requirements such as scalability, security,
transactions, so on and so forth.
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 and stateful . 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 two types of NetBeans projects: Enterprise
Application or EJB Module . EJB Module projects can contain only EJBs, whereas
Enterprise Application project can contain EJBs along with their clients, which can be
web applications or "standalone" Java applications.
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 more EJBs from the client code by using annotations, since with "true"
standalone clients executing outside the application server require JNDI lookups to
obtain a reference to the EJB.
As creating an Enterprise Application project results in a simpler programming
model, that is the type of project we will use for this example.
To create an Enterprise Application project, go to File | New Project , select the
Enterprise category, then Enterprise Application .
 
Search WWH ::




Custom Search