Java Reference
In-Depth Information
Note
Please notice that the @Resource annotation bears a lookup attribute, which
is not included in the default JDK implementation of the
@javax.annotation.Resource annotation. In order to solve this issue and
avoid a compilation problem, you need to copy the JAR file jboss-
annotations-api_1.X_spec-1.X.X.Final.jar (contained in
JBOSS_HOME/modules/javax/annotation/api/main ) into JAVA_HOME/
jre/lib/endorsed of your JDK distribution. As an alternative, you can pass -
Djava.endorsed.dirs to the JVM parameters, indicating the folder where the
JBoss API is located.
Subsequently, when the EJB is instantiated (see the method start , which is an-
notated as @PostConstruct ), org.infinispan.Cache is created using
CacheContainer as a factory. This cache will be used to store our highly available
set of data.
The operations performed against the distributed cache are quite intuitive: the put
method is used to store instances of the Seat object in the cache and the corres-
ponding get method is used to retrieve elements from it, just what you would do
from an ordinary hashtable.
As far as application deployment is concerned, you need to state a dependency to
the Infinispan API explicitly, which is not included as an implicit dependency in the
AS 7 class loading policy. This is most easily done by adding the following line to
your application's META-INF/MANIFEST.MF :
Dependencies: org.infinispan export
Coding the cluster-aware remote client
The remote EJB client will not need any particular change in order to be able to
achieve high availability. We have added a pressAKey method between each ticket
transaction so that you will be able to shut down the application server that is pinned
to our EJB client, and thus test failover on the other server node:
Search WWH ::




Custom Search