Enterprise JavaBeans 3.1

EJB 3.1 and Web Services

  Support for web services in EJB 3.1 is based on the Java API for XML-based Web Services (JAX-WS) 2.1 specification, as well its predecessor, the Java API for XML-based RPC (JAX-RPC) 1.1. The name was changed primarily to avoid the common misconception that web services are only about RPC. Other specifications included in EJB […]

FirstEJB Example

  Description In this exercise, we’ll model an extremely simple business process: addition. The core logic is the same as one would write in a CS100-level undergraduate class, and we’ll create real EJBs from these small classes using a few annotations. In addition, this example shows how we may expose our EJBs through a variety […]

Stateless Session EJB: Encryption Example

  Description The stateless session bean is a fantastic implementation choice for business processes which require no server-side state to be retained in between client invocations. If all information needed to process a request can be found in the request itself, the SLSB may be used as a highly efficient endpoint. In this example we […]

Stateful Session EJB: FTP Client Example

  Description Often it’s necessary for the server to remember information about a specific client in between requests; this is modeled by components that have “conversational state.” For instance, the File Transfer Protocol is “stateful”—the server knows the current working directory used by each client, for example. In this example we’ll model an FTP client […]

Singleton Session EJB: RSS Cache Example

  Description Often we have a business process best modeled by a single instance instead of a backing pool (like SLSB) or cache (SFSB). New to EJB 3.1, the @Singleton EJB creates a sole backing instance to service all incoming requests. This has two important consequences. First, if this instance is eagerly brought into service […]

Message-Driven EJB: Status Update Listeners Example

  Description Session beans, as we’ve seen up to this point, are best suited for servicing client requests. Many enterprise systems, however, use a messaging layer to asynchronously pass requests from application to application. In Java, we use the Java Message Service abstraction to push/pull messages via Queues and Topics, and the integration of JMS […]

Java Persistence APIs: Employee Registry Example (Enterprise JavaBeans 3.1)

  Description Enterprise applications frequently need to deal with state which survives application restarts. We call this “persistent state,” and it’s typically modeled by a program called a relational database management system (RDBMS). Handling the transformation/ mapping between the row-based RDBMS and Java objects is a rote process for application developers, so we offload this […]

Security: Secured School Example (Enterprise JavaBeans 3.1)

  Description Multiuser applications, in order to be secure, must respect that there are differences in user types. For instance, perhaps a system administrator should be given access to alter records hidden to typical users. Coding security logic inside our applications, however, mixes concerns and makes code less maintainable. EJB therefore provides as a service […]

Transactions: Blackjack Game Example (Enterprise JavaBeans 3.1)

  Description All but the most simple of applications will have the requirement that a composite action, say, “Register a User,” succeeds or fails completely. In these cases, the single request is in fact a collection of many smaller pieces of work. If any of these smaller pieces fail halfway through the request, our application […]

Interceptors: TV Channel Service Example (Enterprise JavaBeans 3.1)

  Description As we’ve seen with security and transactions, often we have business logic that is not a part of our core concerns. Quite the opposite; applications are likely to have rules that need to be universal across modules or EJBs, and baking this logic into our implementation mixes concerns and makes for an unmaintainable […]