Java Reference
In-Depth Information
link. The byte stream can then be deserialized, converting the stream into a rep-
lica of the original object.
Additionally, in an HTTP servlet that implements
javax.servlet.http.HttpSession , you need to use the setAttribute
method to change the attributes in a session object. If you set attributes in a session
object with setAttribute , by default the object and its attributes are replicated us-
ing the Infinispan API. Every time a change is made to an object that is in the ses-
sion, setAttribute should be called to update that object across the cluster.
Likewise, you need to use removeAttribute to remove an attribute from a session
object.
Achieving HA in JSF applications
In the applications included in this topic, we have used JSF and CDI API to manage
the web session. In this case, we transparently replicate the other server nodes to
the beans, which are marked as @SessionScoped .
Note
Clustering JSF-based applications requires special attention in case you are
dealing with both HTTP and EJB sessions created by SFSB. In the earlier
servlet-centric frameworks, the usual approach was to store references of State-
ful Session Beans in javax.servlet.http.HttpSession . When dealing
with high-level JSF and CDI Beans, it is vital to provide a @SessionScoped con-
troller to your application, which gets injected in the SFSB reference, otherwise
you will end up creating a new Stateful Session Beans at each request.
The following is an example of how to adapt your Ticket CDI application (described
in Chapter 4 , Learning Context Dependency Injection ) to a clustered environment. At
first, as we said, we need to include the distributable stanza in your web.xml file to
trigger clustering modules:
Search WWH ::




Custom Search