concept request in category ejb

appears as: requests, The request, request, request
EJB 3 in Action, Second Edition

This is an excerpt from Manning's book EJB 3 in Action, Second Edition.

Table 1.1. EJB services

Service

What it means for you

Registry, dependency injection, and lookup Helps locate and glue together components, ideally through simple configuration. Lets you change component wiring for testing.
Lifecycle management Lets you take appropriate actions when the lifecycle of a component changes, such as when it’s created and when it’s destroyed.
Thread safety EJB makes all components thread-safe and highly performant in ways that are completely invisible to you. This means that you can write your multithreaded server components as if you were developing a single-threaded desktop application. It doesn’t matter how complex the component is; EJB will make sure it’s thread-safe.
Transactions EJB automatically makes all of your components transactional, which means you don’t have to write any transaction code while using databases or messaging servers via JDBC, JPA, or Java Message Service (JMS).
Pooling EJB creates a pool of component instances that are shared by clients. At any point in time, each pooled instance can only be used by a single client. As soon as an instance is done servicing a client, it’s returned to the pool for reuse instead of being frivolously discarded for the garbage collector to reclaim.
You can also specify the size of the pool so that when the pool is full, any additional requests are automatically queued. This means that your system will never become unresponsive trying to handle a sudden burst of requests.
Similar to instance pooling, EJB also automatically pools threads across the container for better performance.
State management The EJB container manages the state transparently for stateful components instead of having you write verbose and error-prone code for state management. This means that you can maintain the state in instance variables as if you were developing a desktop application. EJB takes care of all the details of session/state maintenance behind the scenes.
Memory management EJB steps in to optimize memory by saving less frequently used stateful components into the hard disk to free up memory. This is called passivation. When memory becomes available again and a passivated component is needed, EJB puts the component back into memory. This is called activation.
Messaging EJB 3 allows you to write message processing components without having to deal with a lot of the mechanical details of the JMS API.
Security EJB allows you to easily secure your components through simple configuration.
Scheduling EJB lets you schedule any EJB method to be invoked automatically based on simple repeating timers or cron expressions.
Asynchronous processing You can configure any EJB method to be invoked asynchronously if needed.
Interceptors EJB 3 introduces AOP (aspect-oriented programming) in a lightweight, intuitive way using interceptors. This allows you to easily separate out crosscutting concerns such as logging and auditing, and to do so in a configurable way.
Web services EJB 3 can transparently turn business components into Simple Object Access Protocol (SOAP) or Representational State Transfer (REST) web services with minimal or no code changes.
Remoting In EJB 3, you can make components remotely accessible without writing any code. In addition, EJB 3 enables client code to access remote components as if they were local components using dependency injection (DI).
Testing You can easily unit- and integration-test any EJB component using embedded containers with frameworks like JUnit.

14.1. Limits of request–response

In the traditional HTTP model, the client browser opens a connection to an HTTP server and requests an operation to be performed, such as GET, POST, PUT, DELETE, and so on. The HTTP server performs the operation and returns a result, usually HTML content. The connection to the server may be kept open for additional requests so that if multiple resources from the server are being retrieved, each request doesn’t require an additional socket to open and close. If you look at the complexity of some of the current web pages, this makes sense—pages with lots of content, such as eBay.com, would be extremely slow if each image had to endure a full socket opening and closing. In each case, however, the client is the initiator—the client makes a request and the server responds. The server never pushes data back to the client without the client making a request.

The request–response model works perfectly for websites that produce content, such as newspapers, online encyclopedias, academic journals, file sharing, and so on. But the request–response model breaks down for uses on sites such as gaming, instant messaging, stock updates, and anything else where content/data needs to be pushed from the server to the client asynchronously. The request–response paradigm is a hindrance for these sites—the client must always make the initial request. There are different approaches you can take to get around this problem.