SlideShare a Scribd company logo
1 of 21
ClusteringJBoss AS 7
Página 1 de 2

En este artículo vamos a mostrar cómo configurar en pocas palabras JBoss AS 7 para
clustsering. A continuación, vamos a desplegar una muestra de aplicaciones Java EE 6 en la parte
superior de la misma.
Usuarios de JBoss anteriores utilizados para iniciar una configuración de servidor en clúster
alimentando el c-alllos parámetros a la shell de arranque del servidor de aplicaciones.
El AS 7 es muy diferente de otras versiones del servidor, ya que no contiene varios directorios de
configuración del servidor (todo, por defecto, minimal..). Es sólo contiene un conjunto de archivos
de configuración de cada uno incluyendo un conjunto diferente de módulos de servidor.
La función de archivo de configuración de cluster son standalone-ha.xml y standalone-fullha.xml (este último incluido el apoyo Corba). Así que vamos a empezar una configuración de clúster
de demostración compuesto por dos nodos en la misma máquina.
Así descomprimir dos como 7 Distribución en el camino de su elección, por ejemplo:
C:  jboss-as-7.1.1.Final.NodoA
C:  jboss-as-7.1.1.Final.NodoB
Para iniciar los nodos del clúster que debe proporcionar un nombre de nodo único y, ya está
ejecutando varios servidores en la misma máquina especificar un port offset modo que usted no
tiene conflictos de puertos entre los servidores de puerto.
Así que vamos a poner en marcha NodoA con:
standalone -c standalone-ha.xml -Djboss.node.name=nodoA
y el nodo B con:
standalone -c standalone-ha.xml -Djboss.socket.binding.port-offset=100 Djboss.node.name=nodoB
Fine. Pedido la página de bienvenida para ver que todo funciona correctamente:
http://localhost:8080 (nodeA) y http://localhost:8180 (nodoB)

Configuración del servidor Web Apache para llegar a JBoss AS
7 clúster
Hay más de una opción disponible para conectar un servidor Web en frente de JBoss AS 7
clúster. Se puede elegir el viejomod_jk que ofrece una visión estática del JBoss7 en clúster o, como
sugerencia, configurar mod_cluster que proporciona ventajas adicionales, tales como:
Configuración dinámica de los trabajadores httpd
Cálculo del factor de equilibrio de carga del lado del servidor
Granuralidadfinapara el control de ciclo de vida de las aplicaciones Web
Bibliotecas Java Mod_cluster están incorporados en JBoss AS 7 de distribución por lo que no tiene
que interrumpir la comunicación en el servidor. Por otra parte, es necesario añadir a su servidor
Apache las bibliotecas nativas necesarias para llamadas de proxy a JBoss AS. Descargue la última
mod_cluster binarios en:
http://www.jboss.org/mod_cluster/downloads/1-2-0-Final
Los módulos anteriores pueden encontrarse en la distribución mod_cluster bajo httpd / ruta de
módulos. Hay que colocarlos en la carpeta de módulos de Apache.
Luego editamos httpd.conf. Hay que añadir los módulos:
LoadModule slotmem_module modules/mod_slotmem.so
LoadModule manager_module modules/mod_manager.so
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule advertise_module modules/mod_advertise.so
Además, tenga en cuenta que debemos comentar:
# LoadModulemódulosproxy_balancer_module / mod_proxy_balancer.so
Éste entra en conflicto con módulo de clúster. Y luego tenemos que hacer httpd escuchar
megafonía para poder hacer la prueba. Debido a que instalamos httpd en 192.168.1.0 anfitrión se
utilizará el siguiente puerto disponible:
Escuchar 192.168.1.0:6666
<VirtualHost 192.168.1.0:6666>
<Directory />
Orden negar, permitir
Denegar de todos
Dejar de 192.168.1.
</ Directory>
KeepAliveTimeout 60
MaxKeepAliveRequests 0
ManagerBalancerNamemyCluster
AdvertiseFrequency 5
</ VirtualHost>
Ahora compruebe que la conexión JBoss Apache funciona correctamente
tecleando: http://192.168.1.0:6666
ClusteringJBoss AS 7 - Creación de una
aplicación en clúster en JBoss AS 7
Página 2 de 2
Ahora vamos a implementar una variante de nuestra aplicación web Java EE 6 , que se compone de
los siguientes componentes:

Componentes de aplicación
Un bean con estado de EJB que se utiliza para almacenar una memoria caché de datos, mediante
la exposición de una interfaz local
Un JSF bean gestionado que actúa como una capa entre el EJB y la interfaz gráfica de usuario
Una vista JSF que se utiliza para recopilar datos
Vamos a empezar con la codificación de la clase JSF Managed haba:
01.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">import java.io.Serializable;</span>java.io.Serializableimportación;<
/span>
02.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">import java.util.ArrayList;</span>java.util.ArrayListimportación;</s
pan>
03.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">import java.util.List;</span>importarjava.util.List;</span>
04.
05.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">importjavax.enterprise.context.SessionScoped;</span>importarjavax.e
nterprise.context.SessionScoped;</span>
06.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">import javax.inject.Inject;</span>importarjavax.inject.Inject;</span
>
07.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">import javax.inject.Named;</span>importarjavax.inject.Named;</span>
08.
09.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">import com.sample.ejb.StatefulData;</span>com.sample.ejb.StatefulDat
aimportación;</span>
10.
11.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">@SessionScoped</span> @ SessionScoped</span>
12.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">@Named(value="manager")</span> @ Named (value
= "manager")</span>
13.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public class PropertyManager implementsSerializable
{</span>PropertyManagerclasepúblicaimplementaSerializable {</span>
14.
15.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">@Inject</span> @ Inyectar</span>
16.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">StatefulDataejb;</span>StatefulDataejb;</span>
17.
18.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">ArrayListcacheList = newArrayList
();</span>ArrayListcacheList = new ArrayList ();</span>
19.
20.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">private String key;</span> clave private String;</span>
21.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">private String value;</span> Valor de la
cadenaprivada;</span>
22.
23.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public String getKey() {</span>public String getKey ()
{</span>
24.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">return key;</span> clave de retorno;</span>
25.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
26.
27.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public void setKey(String key)
{</span> public void setKey (String key) {</span>
28.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">this.key = key;</span> this.key key =;</span>
29.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
30.
31.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public String getValue() {</span>getValue public String
() {</span>
32.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">return value;</span> valor de retorno;</span>
33.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
34.
35.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public void setValue(String value)
{</span>setValue public void (String value) {</span>
36.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">this.value = value;</span> this.value = valor;</span>
37.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
38.
39.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public void save() {</span>public void save () {</span>
40.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">ejb.put(key, value);</span>ejb.put (clave, valor);</span>
41.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
42.
43.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public void clear() {</span>public void clear () {</span>
44.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">ejb.delete();</span>ejb.delete ();</span>
45.
46.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
47.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public List getCacheList()
{</span>getCacheListListapública () {</span>
48.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">returnejb.getCache();</span>volverejb.getCache ();</span>
49.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
50.
51.
52.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
Y esta es la clase Local Stateful EJB que está anotado como @ @ Stateful clúster @ SessionScoped
01.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">package com.sample.ejb;</span>paquetecom.sample.ejb;</span>
02.
03.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">import java.util.ArrayList;</span>java.util.ArrayListimportación;</s
pan>
04.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">import java.util.List;</span>importarjava.util.List;</span>
05.
06.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">import javax.annotation.PostConstruct;</span>importarjavax.annotatio
n.PostConstruct;</span>
07.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">import javax.ejb.LocalBean;</span>importarjavax.ejb.LocalBean;</span
>
08.
09.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">import javax.ejb.Stateful;</span>javax.ejb.Statefulimportación;</spa
n>
10.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">importjavax.enterprise.context.SessionScoped;</span>importarjavax.e
nterprise.context.SessionScoped;</span>
11.
12.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">importorg.jboss.ejb3.annotation.Clustered;</span>importar
org.jboss.ejb3.annotation.Clustered;</span>
13.
14.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">import com.sample.model.Property;</span>importarcom.sample.model.Pro
perty;</span>
15.
16.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">@Stateful</span> @ Stateful</span>
17.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">@Clustered</span> @ Clúster</span>
18.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">@SessionScoped</span> @ SessionScoped</span>
19.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">@LocalBean</span> @ LocalBean</span>
20.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public class LocalStatefulDataimplements StatefulData
{</span> public class LocalStatefulDataimplementaStatefulData {</span>
21.
22.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">private List<Property> cache;</span> cache
<Property>Listaprivado;</span>
23.
24.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">@Override</span> @ Override</span>
25.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">@PostConstruct</span> @ PostConstruct</span>
26.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public void initCache(){</span>initCache public void ()
{</span>
27.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">this.cache = queryCache();</span> this.cacheQueryCache =
();</span>
28.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">if (cache ==null) cache
= new ArrayList<Property>();</span> if (caché == null) cache
= new ArrayList<Property> ();</span>
29.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
30.
31.
32.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">@Override</span> @ Override</span>
33.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public void delete(){</span> delete public void ()
{</span>
34.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">this.cache.clear();</span> this.cache.clear ();</span>
35.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
36.
37.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">@Override</span> @ Override</span>
38.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public void put(String key,String value){</span>
put public void (String key, String value) {</span>
39.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">Property p =new Property();</span>Propiedad p = new inmueble
();</span>
40.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">p.setKey(key);</span>p.setKey (clave);</span>
41.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">p.setValue(value);</span>p.setValue (valor);</span>
42.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">this.cache.add(p);</span> this.cache.add (p);</span>
43.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
44.
45.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">@Override</span> @ Override</span>
46.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public List<Property>getCache()
{</span>Listapública<Property>GetCache () {</span>
47.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">return cache;</span>volvercaché;</span>
48.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
49.
50.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">@Override</span> @ Override</span>
51.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">public List<Property>queryCache(){</span>Listapública<Property>Query
Cache () {</span>
52.
53.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">return cache;</span>volvercaché;</span>
54.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
55.
56.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
Aviso ImportanteLa versión actual de JBoss Herramientas (3.3) no se incluye de forma
predeterminada las bibliotecas donde se contiene la anotación @ clúster. Hasta que este problema
se resuelve, usted tiene que incluir el jboss-ejb3-ext-api-2.0.0.jarmanualmente como se muestra
en la siguiente imagen:
En aras de la exhaustividad se incluye también la interfaz Stateful SB:
01.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">package com.sample.ejb;</span>paquetecom.sample.ejb;</span>
02.
03.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">import java.util.List;</span>importarjava.util.List;</span>
04.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">import com.sample.model.Property;</span>importarcom.sample.model.Pro
perty;</span>
05.
06.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public interface StatefulData
{</span>interfazpúblicaStatefulData {</span>
07.
08.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">public abstract void delete();</span> public abstract void delete
();</span>
09.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public abstract void put(String key, String
value);</span> public abstract void put (String key, String value);</span>
10.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">public abstract List<Property>getCache();</span> public abstract List
a<Property>GetCache ();</span>
11.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">public abstract List<Property>queryCache();</span> public abstract Li
sta<Property>QueryCache ();</span>
12.
13.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
Entonces, esta es la clase de modelo que consiste en una simple POJO:
01.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">package com.sample.model;</span>com.sample.modelpaquete;</span>
02.
03.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">import java.io.Serializable;</span>java.io.Serializableimportación;<
/span>
04.
05.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align:
left">public class Property implementsSerializable{</span>Propiedadclasepú
blicaimplementaSerializable {</span>
06.
07.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">private String key;</span> clave private String;</span>
08.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">private String value;</span> Valor de la
cadenaprivada;</span>
09.
10.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public String getKey() {</span>public String getKey ()
{</span>
11.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">return key;</span> clave de retorno;</span>
12.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
13.
14.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public void setKey(String key)
{</span> public void setKey (String key) {</span>
15.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">this.key = key;</span> this.key key =;</span>
16.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
17.
18.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public String getValue() {</span>getValue public String
() {</span>
19.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">return value;</span> valor de retorno;</span>
20.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
21.
22.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">public void setValue(String value)
{</span>setValue public void (String value) {</span>
23.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">this.value = value;</span> this.value = valor;</span>
24.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
25.
26.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof
f()"><span class="google-src-text notranslate" style="direction: ltr;
text-align: left">}</span> }</span>
Última parte de la aplicación es la página JSF home.xhtml que se unchanghed de ninguna
aplicación Java EE en clúster:
01.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"</span><DOCTYPE HTML PUBLIC "- / / W3C / / DTD XHTML 1.0
Transitional / / EN"</span>
02.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left">"http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional.dtd"></span> "Http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional.dtd"></span>
03.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><span class="google-src-text notranslate" style="direction: ltr; textalign:
left"><htmlxmlns="http://www.w3.org/1999/xhtml"</span><HTML xmlns = "http:
//www.w3.org/1999/xhtml"</span>
04.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left">xmlns:ui="http://java.sun.com/jsf/facelets"</span>xmlns: ui
= "http://java.sun.com/jsf/facelets"</span>
05.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left">xmlns:h="http://java.sun.com/jsf/html"</span>xmlns: h =
"http://java.sun.com/jsf/html"</span>
06.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left">xmlns:f="http://java.sun.com/jsf/core"</span>xmlns: f =
"http://java.sun.com/jsf/core"</span>
07.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left">xmlns:c="http://java.sun.com/jsp/jstl/core"></span>xmlns: c
= "http://java.sun.com/jsp/jstl/core"></span>
08.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"><h:head></span><h:head></span>
09.
10.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"></h:head></span></ H: head></span>
11.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"><h:body></span><h:body></span>
12.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"><h2>Cluster demo on JBoss 7</h2></span><h2>demostración
Cluster en JBoss 7 </ h2></span>
13.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><span class="google-src-text notranslate" style="direction: ltr; textalign:
left"><h:form id="jsfexample"></span><h:form id="jsfexample"></span>
14.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign:
left"><h:panelGridcolumns="2" styleClass="default"></span><h:panelGrid col
umns="2" styleClass="default"></span>
15.
16.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:outputText value="Enter
key:" /></span><h:outputText Value="Enter key:" /></span>
17.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign:
left"><h:inputText value="#{manager.key}" /></span><h:inputText value="#{ma
nager.key}" /></span>
18.
19.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:outputText value="Enter
value:" /></span><h:outputText Value="Enter value:" /></span>
20.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign:
left"><h:inputText value="#{manager.value}" /></span><h:inputText value="#{
manager.value}"/></span>
21.
22.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign:
left"><h:commandButton actionListener="#{manager.save}"</span><H: commandB
uttonactionListener = "# {manager.save}"</span>
23.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">styleClass="buttons" value="Save key/value"
/></span>styleClass = value "botones" = "Guardar clave / valor" /></span>
24.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign:
left"><h:commandButton actionListener="#{manager.clear}"</span><H: command
ButtonactionListener = "# {manager.clear}"</span>
25.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">styleClass="buttons" value="Clear cache" /></span>styleClass
= value "botones" = "Borrarcaché" /></span>
26.
27.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:messages /></span><h:messages /></span>
28.
29.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"></h:panelGrid></span></ H: panelGrid></span>
30.
31.
32.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign:
left"><h:dataTablevalue="#{manager.cacheList}" var="item"</span><H: valor
dataTable = var = "item" "# {manager.cacheList}"</span>
33.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">styleClass="table" headerClass="tableheader"</span>styleClass = "mesa" headerClass = "table-header"</span>
34.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">rowClasses="table-odd-row,table-even-row"></span>rowClasses
= "table-imparfila, tabla de equilibriofila"></span>
35.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:column></span><h:column></span>
36.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign:
left"><f:facet name="header">Key</f:facet></span><f:facet name="header">
clave </ f:faceta></span>
37.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign:
left"><h:outputText value="#{item.key}" /></span><h:outputText value="#{ite
m.key}" /></span>
38.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"></h:column></span></ H: column></span>
39.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:column></span><h:column></span>
40.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; text-
align:
left"><f:facet name="header">Value</f:facet></span><f:facet name="header">
Valor </ f:faceta></span>
41.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign:
left"><h:outputText value="#{item.value}" /></span><h:outputText value="#{i
tem.value}"/></span>
42.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"></h:column></span></ H: column></span>
43.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"></h:dataTable></span></ H: dataTable></span>
44.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"></h:form></span></ H: form></span>
45.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"></h:body></span></ H: body></span>
46.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff
()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"></html></span></ Html></span>
Eso es todo. Recuerde que para agregar un archivo beans.xml vacío en la carpeta WEB-INF para
que las dependencias de soldadura se activan de forma automática por AS 7.
He aquí cómo el proyecto debería quedar así:
Ahora abra su navegador y probar la aplicación Web, señalando al puerto mod_cluster que hemos
configurado antes:
http://192.168.1.0:6666 / as7clustersample/home.xhtml

Nota importante acerca de conmutación por error: JSF / CDI de conmutación por error sigue sin
funcionar correctamente en un clúster.
Si intenta acceder a la sesión replicado en el segundo nodo muestra la siguiente advertencia en los
registros:
WARN [org.jboss.as.clustering.web.infinispan] (http - 127.0.2.1-8080-1)
JBAS010322: Problema para acceder a sesiones [9gzXvHZaf01gCVbeao-9-PL5]:
JBAS010334: No se pudo almacenar atributos de sesión para la sesión:
9gzXvHZaf01gCVbeao -9-PL5
Verifique el tema AS7-3746 se fija antes de comprometerse en la producción con una aplicación en
clúster. <

More Related Content

Viewers also liked

life stile of watever
life stile of wateverlife stile of watever
life stile of wateverthefunny
 
презентация Microsoft Office Power Point
презентация Microsoft Office Power Pointпрезентация Microsoft Office Power Point
презентация Microsoft Office Power PointOrionnn
 
Altering reality exploring the concept 2
Altering reality exploring the concept 2Altering reality exploring the concept 2
Altering reality exploring the concept 2camilla randall
 
היום יום הולדתךרוגעית
היום יום הולדתךרוגעית היום יום הולדתךרוגעית
היום יום הולדתךרוגעית dafna simana
 
yadasimcomמפגש בני דודיםyadasim
yadasimcomמפגש בני דודיםyadasimyadasimcomמפגש בני דודיםyadasim
yadasimcomמפגש בני דודיםyadasimdafna simana
 
Presenting Social Media Strategy to FRG
Presenting Social Media Strategy to FRGPresenting Social Media Strategy to FRG
Presenting Social Media Strategy to FRGRonietee
 
קיימות חברתית סביבתית
קיימות חברתית סביבתיתקיימות חברתית סביבתית
קיימות חברתית סביבתיתdafna simana
 
MMM Services Application - Service Requests at your Fingertips
MMM Services Application -  Service Requests at your FingertipsMMM Services Application -  Service Requests at your Fingertips
MMM Services Application - Service Requests at your FingertipsRonietee
 
MMM Services Application - Intro
MMM Services Application  - IntroMMM Services Application  - Intro
MMM Services Application - IntroRonietee
 
Urban Homesteading Cooking Classes
Urban Homesteading Cooking ClassesUrban Homesteading Cooking Classes
Urban Homesteading Cooking ClassesJamie Milks
 
שאלה לי אליכם, (ותענו בכנות)
שאלה לי אליכם, (ותענו בכנות)שאלה לי אליכם, (ותענו בכנות)
שאלה לי אליכם, (ותענו בכנות)dafna simana
 
חידון על עצמי
חידון על עצמיחידון על עצמי
חידון על עצמיdafna simana
 
Samvit Insights Profile
Samvit Insights ProfileSamvit Insights Profile
Samvit Insights Profilearijitchanda
 

Viewers also liked (14)

life stile of watever
life stile of wateverlife stile of watever
life stile of watever
 
שנה חדשה
שנה חדשהשנה חדשה
שנה חדשה
 
презентация Microsoft Office Power Point
презентация Microsoft Office Power Pointпрезентация Microsoft Office Power Point
презентация Microsoft Office Power Point
 
Altering reality exploring the concept 2
Altering reality exploring the concept 2Altering reality exploring the concept 2
Altering reality exploring the concept 2
 
היום יום הולדתךרוגעית
היום יום הולדתךרוגעית היום יום הולדתךרוגעית
היום יום הולדתךרוגעית
 
yadasimcomמפגש בני דודיםyadasim
yadasimcomמפגש בני דודיםyadasimyadasimcomמפגש בני דודיםyadasim
yadasimcomמפגש בני דודיםyadasim
 
Presenting Social Media Strategy to FRG
Presenting Social Media Strategy to FRGPresenting Social Media Strategy to FRG
Presenting Social Media Strategy to FRG
 
קיימות חברתית סביבתית
קיימות חברתית סביבתיתקיימות חברתית סביבתית
קיימות חברתית סביבתית
 
MMM Services Application - Service Requests at your Fingertips
MMM Services Application -  Service Requests at your FingertipsMMM Services Application -  Service Requests at your Fingertips
MMM Services Application - Service Requests at your Fingertips
 
MMM Services Application - Intro
MMM Services Application  - IntroMMM Services Application  - Intro
MMM Services Application - Intro
 
Urban Homesteading Cooking Classes
Urban Homesteading Cooking ClassesUrban Homesteading Cooking Classes
Urban Homesteading Cooking Classes
 
שאלה לי אליכם, (ותענו בכנות)
שאלה לי אליכם, (ותענו בכנות)שאלה לי אליכם, (ותענו בכנות)
שאלה לי אליכם, (ותענו בכנות)
 
חידון על עצמי
חידון על עצמיחידון על עצמי
חידון על עצמי
 
Samvit Insights Profile
Samvit Insights ProfileSamvit Insights Profile
Samvit Insights Profile
 

Clustering j boss7

  • 1. ClusteringJBoss AS 7 Página 1 de 2 En este artículo vamos a mostrar cómo configurar en pocas palabras JBoss AS 7 para clustsering. A continuación, vamos a desplegar una muestra de aplicaciones Java EE 6 en la parte superior de la misma. Usuarios de JBoss anteriores utilizados para iniciar una configuración de servidor en clúster alimentando el c-alllos parámetros a la shell de arranque del servidor de aplicaciones. El AS 7 es muy diferente de otras versiones del servidor, ya que no contiene varios directorios de configuración del servidor (todo, por defecto, minimal..). Es sólo contiene un conjunto de archivos de configuración de cada uno incluyendo un conjunto diferente de módulos de servidor. La función de archivo de configuración de cluster son standalone-ha.xml y standalone-fullha.xml (este último incluido el apoyo Corba). Así que vamos a empezar una configuración de clúster de demostración compuesto por dos nodos en la misma máquina. Así descomprimir dos como 7 Distribución en el camino de su elección, por ejemplo: C: jboss-as-7.1.1.Final.NodoA C: jboss-as-7.1.1.Final.NodoB Para iniciar los nodos del clúster que debe proporcionar un nombre de nodo único y, ya está ejecutando varios servidores en la misma máquina especificar un port offset modo que usted no tiene conflictos de puertos entre los servidores de puerto. Así que vamos a poner en marcha NodoA con: standalone -c standalone-ha.xml -Djboss.node.name=nodoA y el nodo B con: standalone -c standalone-ha.xml -Djboss.socket.binding.port-offset=100 Djboss.node.name=nodoB Fine. Pedido la página de bienvenida para ver que todo funciona correctamente: http://localhost:8080 (nodeA) y http://localhost:8180 (nodoB) Configuración del servidor Web Apache para llegar a JBoss AS 7 clúster Hay más de una opción disponible para conectar un servidor Web en frente de JBoss AS 7 clúster. Se puede elegir el viejomod_jk que ofrece una visión estática del JBoss7 en clúster o, como sugerencia, configurar mod_cluster que proporciona ventajas adicionales, tales como: Configuración dinámica de los trabajadores httpd Cálculo del factor de equilibrio de carga del lado del servidor Granuralidadfinapara el control de ciclo de vida de las aplicaciones Web Bibliotecas Java Mod_cluster están incorporados en JBoss AS 7 de distribución por lo que no tiene que interrumpir la comunicación en el servidor. Por otra parte, es necesario añadir a su servidor Apache las bibliotecas nativas necesarias para llamadas de proxy a JBoss AS. Descargue la última
  • 2. mod_cluster binarios en: http://www.jboss.org/mod_cluster/downloads/1-2-0-Final Los módulos anteriores pueden encontrarse en la distribución mod_cluster bajo httpd / ruta de módulos. Hay que colocarlos en la carpeta de módulos de Apache. Luego editamos httpd.conf. Hay que añadir los módulos: LoadModule slotmem_module modules/mod_slotmem.so LoadModule manager_module modules/mod_manager.so LoadModule proxy_cluster_module modules/mod_proxy_cluster.so LoadModule advertise_module modules/mod_advertise.so Además, tenga en cuenta que debemos comentar: # LoadModulemódulosproxy_balancer_module / mod_proxy_balancer.so Éste entra en conflicto con módulo de clúster. Y luego tenemos que hacer httpd escuchar megafonía para poder hacer la prueba. Debido a que instalamos httpd en 192.168.1.0 anfitrión se utilizará el siguiente puerto disponible: Escuchar 192.168.1.0:6666 <VirtualHost 192.168.1.0:6666> <Directory /> Orden negar, permitir Denegar de todos Dejar de 192.168.1. </ Directory> KeepAliveTimeout 60 MaxKeepAliveRequests 0 ManagerBalancerNamemyCluster AdvertiseFrequency 5 </ VirtualHost> Ahora compruebe que la conexión JBoss Apache funciona correctamente tecleando: http://192.168.1.0:6666
  • 3. ClusteringJBoss AS 7 - Creación de una aplicación en clúster en JBoss AS 7 Página 2 de 2 Ahora vamos a implementar una variante de nuestra aplicación web Java EE 6 , que se compone de los siguientes componentes: Componentes de aplicación Un bean con estado de EJB que se utiliza para almacenar una memoria caché de datos, mediante la exposición de una interfaz local Un JSF bean gestionado que actúa como una capa entre el EJB y la interfaz gráfica de usuario Una vista JSF que se utiliza para recopilar datos Vamos a empezar con la codificación de la clase JSF Managed haba: 01.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">import java.io.Serializable;</span>java.io.Serializableimportación;< /span> 02.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">import java.util.ArrayList;</span>java.util.ArrayListimportación;</s pan> 03.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">import java.util.List;</span>importarjava.util.List;</span> 04. 05.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">importjavax.enterprise.context.SessionScoped;</span>importarjavax.e nterprise.context.SessionScoped;</span> 06.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">import javax.inject.Inject;</span>importarjavax.inject.Inject;</span >
  • 4. 07.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">import javax.inject.Named;</span>importarjavax.inject.Named;</span> 08. 09.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">import com.sample.ejb.StatefulData;</span>com.sample.ejb.StatefulDat aimportación;</span> 10. 11.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">@SessionScoped</span> @ SessionScoped</span> 12.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">@Named(value="manager")</span> @ Named (value = "manager")</span> 13.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public class PropertyManager implementsSerializable {</span>PropertyManagerclasepúblicaimplementaSerializable {</span> 14. 15.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">@Inject</span> @ Inyectar</span> 16.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">StatefulDataejb;</span>StatefulDataejb;</span> 17. 18.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">ArrayListcacheList = newArrayList ();</span>ArrayListcacheList = new ArrayList ();</span> 19. 20.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">private String key;</span> clave private String;</span>
  • 5. 21.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">private String value;</span> Valor de la cadenaprivada;</span> 22. 23.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public String getKey() {</span>public String getKey () {</span> 24.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">return key;</span> clave de retorno;</span> 25.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 26. 27.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public void setKey(String key) {</span> public void setKey (String key) {</span> 28.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">this.key = key;</span> this.key key =;</span> 29.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 30. 31.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public String getValue() {</span>getValue public String () {</span> 32.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">return value;</span> valor de retorno;</span> 33.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 34.
  • 6. 35.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public void setValue(String value) {</span>setValue public void (String value) {</span> 36.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">this.value = value;</span> this.value = valor;</span> 37.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 38. 39.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public void save() {</span>public void save () {</span> 40.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">ejb.put(key, value);</span>ejb.put (clave, valor);</span> 41.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 42. 43.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public void clear() {</span>public void clear () {</span> 44.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">ejb.delete();</span>ejb.delete ();</span> 45. 46.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 47.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public List getCacheList() {</span>getCacheListListapública () {</span> 48.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">returnejb.getCache();</span>volverejb.getCache ();</span>
  • 7. 49.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 50. 51. 52.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> Y esta es la clase Local Stateful EJB que está anotado como @ @ Stateful clúster @ SessionScoped 01.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">package com.sample.ejb;</span>paquetecom.sample.ejb;</span> 02. 03.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">import java.util.ArrayList;</span>java.util.ArrayListimportación;</s pan> 04.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">import java.util.List;</span>importarjava.util.List;</span> 05. 06.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">import javax.annotation.PostConstruct;</span>importarjavax.annotatio n.PostConstruct;</span> 07.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">import javax.ejb.LocalBean;</span>importarjavax.ejb.LocalBean;</span > 08. 09.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr;
  • 8. text-align: left">import javax.ejb.Stateful;</span>javax.ejb.Statefulimportación;</spa n> 10.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">importjavax.enterprise.context.SessionScoped;</span>importarjavax.e nterprise.context.SessionScoped;</span> 11. 12.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">importorg.jboss.ejb3.annotation.Clustered;</span>importar org.jboss.ejb3.annotation.Clustered;</span> 13. 14.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">import com.sample.model.Property;</span>importarcom.sample.model.Pro perty;</span> 15. 16.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">@Stateful</span> @ Stateful</span> 17.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">@Clustered</span> @ Clúster</span> 18.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">@SessionScoped</span> @ SessionScoped</span> 19.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">@LocalBean</span> @ LocalBean</span> 20.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public class LocalStatefulDataimplements StatefulData {</span> public class LocalStatefulDataimplementaStatefulData {</span> 21.
  • 9. 22.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">private List<Property> cache;</span> cache <Property>Listaprivado;</span> 23. 24.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">@Override</span> @ Override</span> 25.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">@PostConstruct</span> @ PostConstruct</span> 26.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public void initCache(){</span>initCache public void () {</span> 27.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">this.cache = queryCache();</span> this.cacheQueryCache = ();</span> 28.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">if (cache ==null) cache = new ArrayList<Property>();</span> if (caché == null) cache = new ArrayList<Property> ();</span> 29.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 30. 31. 32.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">@Override</span> @ Override</span> 33.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public void delete(){</span> delete public void () {</span>
  • 10. 34.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">this.cache.clear();</span> this.cache.clear ();</span> 35.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 36. 37.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">@Override</span> @ Override</span> 38.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public void put(String key,String value){</span> put public void (String key, String value) {</span> 39.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">Property p =new Property();</span>Propiedad p = new inmueble ();</span> 40.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">p.setKey(key);</span>p.setKey (clave);</span> 41.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">p.setValue(value);</span>p.setValue (valor);</span> 42.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">this.cache.add(p);</span> this.cache.add (p);</span> 43.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 44. 45.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">@Override</span> @ Override</span> 46.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public List<Property>getCache() {</span>Listapública<Property>GetCache () {</span>
  • 11. 47.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">return cache;</span>volvercaché;</span> 48.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 49. 50.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">@Override</span> @ Override</span> 51.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public List<Property>queryCache(){</span>Listapública<Property>Query Cache () {</span> 52. 53.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">return cache;</span>volvercaché;</span> 54.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 55. 56.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> Aviso ImportanteLa versión actual de JBoss Herramientas (3.3) no se incluye de forma predeterminada las bibliotecas donde se contiene la anotación @ clúster. Hasta que este problema se resuelve, usted tiene que incluir el jboss-ejb3-ext-api-2.0.0.jarmanualmente como se muestra en la siguiente imagen:
  • 12. En aras de la exhaustividad se incluye también la interfaz Stateful SB: 01.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">package com.sample.ejb;</span>paquetecom.sample.ejb;</span> 02. 03.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">import java.util.List;</span>importarjava.util.List;</span> 04.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">import com.sample.model.Property;</span>importarcom.sample.model.Pro perty;</span> 05. 06.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public interface StatefulData {</span>interfazpúblicaStatefulData {</span> 07. 08.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public abstract void delete();</span> public abstract void delete ();</span> 09.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public abstract void put(String key, String value);</span> public abstract void put (String key, String value);</span>
  • 13. 10.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public abstract List<Property>getCache();</span> public abstract List a<Property>GetCache ();</span> 11.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public abstract List<Property>queryCache();</span> public abstract Li sta<Property>QueryCache ();</span> 12. 13.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> Entonces, esta es la clase de modelo que consiste en una simple POJO: 01.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">package com.sample.model;</span>com.sample.modelpaquete;</span> 02. 03.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">import java.io.Serializable;</span>java.io.Serializableimportación;< /span> 04. 05.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public class Property implementsSerializable{</span>Propiedadclasepú blicaimplementaSerializable {</span> 06. 07.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">private String key;</span> clave private String;</span> 08.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr;
  • 14. text-align: left">private String value;</span> Valor de la cadenaprivada;</span> 09. 10.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public String getKey() {</span>public String getKey () {</span> 11.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">return key;</span> clave de retorno;</span> 12.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 13. 14.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public void setKey(String key) {</span> public void setKey (String key) {</span> 15.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">this.key = key;</span> this.key key =;</span> 16.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 17. 18.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public String getValue() {</span>getValue public String () {</span> 19.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">return value;</span> valor de retorno;</span> 20.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 21.
  • 15. 22.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">public void setValue(String value) {</span>setValue public void (String value) {</span> 23.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">this.value = value;</span> this.value = valor;</span> 24.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> 25. 26.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipof f()"><span class="google-src-text notranslate" style="direction: ltr; text-align: left">}</span> }</span> Última parte de la aplicación es la página JSF home.xhtml que se unchanghed de ninguna aplicación Java EE en clúster: 01.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"</span><DOCTYPE HTML PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / / EN"</span> 02.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left">"http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional.dtd"></span> "Http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional.dtd"></span> 03.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"><htmlxmlns="http://www.w3.org/1999/xhtml"</span><HTML xmlns = "http: //www.w3.org/1999/xhtml"</span> 04.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left">xmlns:ui="http://java.sun.com/jsf/facelets"</span>xmlns: ui = "http://java.sun.com/jsf/facelets"</span> 05.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left">xmlns:h="http://java.sun.com/jsf/html"</span>xmlns: h = "http://java.sun.com/jsf/html"</span>
  • 16. 06.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left">xmlns:f="http://java.sun.com/jsf/core"</span>xmlns: f = "http://java.sun.com/jsf/core"</span> 07.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left">xmlns:c="http://java.sun.com/jsp/jstl/core"></span>xmlns: c = "http://java.sun.com/jsp/jstl/core"></span> 08.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"><h:head></span><h:head></span> 09. 10.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"></h:head></span></ H: head></span> 11.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"><h:body></span><h:body></span> 12.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"><h2>Cluster demo on JBoss 7</h2></span><h2>demostración Cluster en JBoss 7 </ h2></span> 13.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"><h:form id="jsfexample"></span><h:form id="jsfexample"></span> 14.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:panelGridcolumns="2" styleClass="default"></span><h:panelGrid col umns="2" styleClass="default"></span> 15. 16.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:outputText value="Enter key:" /></span><h:outputText Value="Enter key:" /></span> 17.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign:
  • 17. left"><h:inputText value="#{manager.key}" /></span><h:inputText value="#{ma nager.key}" /></span> 18. 19.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:outputText value="Enter value:" /></span><h:outputText Value="Enter value:" /></span> 20.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:inputText value="#{manager.value}" /></span><h:inputText value="#{ manager.value}"/></span> 21. 22.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:commandButton actionListener="#{manager.save}"</span><H: commandB uttonactionListener = "# {manager.save}"</span> 23.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">styleClass="buttons" value="Save key/value" /></span>styleClass = value "botones" = "Guardar clave / valor" /></span> 24.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:commandButton actionListener="#{manager.clear}"</span><H: command ButtonactionListener = "# {manager.clear}"</span> 25.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">styleClass="buttons" value="Clear cache" /></span>styleClass = value "botones" = "Borrarcaché" /></span> 26. 27.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:messages /></span><h:messages /></span> 28.
  • 18. 29.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"></h:panelGrid></span></ H: panelGrid></span> 30. 31. 32.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:dataTablevalue="#{manager.cacheList}" var="item"</span><H: valor dataTable = var = "item" "# {manager.cacheList}"</span> 33.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">styleClass="table" headerClass="tableheader"</span>styleClass = "mesa" headerClass = "table-header"</span> 34.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left">rowClasses="table-odd-row,table-even-row"></span>rowClasses = "table-imparfila, tabla de equilibriofila"></span> 35.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:column></span><h:column></span> 36.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><f:facet name="header">Key</f:facet></span><f:facet name="header"> clave </ f:faceta></span> 37.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:outputText value="#{item.key}" /></span><h:outputText value="#{ite m.key}" /></span> 38.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"></h:column></span></ H: column></span> 39.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:column></span><h:column></span> 40.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; text-
  • 19. align: left"><f:facet name="header">Value</f:facet></span><f:facet name="header"> Valor </ f:faceta></span> 41.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"><h:outputText value="#{item.value}" /></span><h:outputText value="#{i tem.value}"/></span> 42.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"></h:column></span></ H: column></span> 43.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><spanclass="google-src-text notranslate" style="direction: ltr; textalign: left"></h:dataTable></span></ H: dataTable></span> 44.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"></h:form></span></ H: form></span> 45.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"></h:body></span></ H: body></span> 46.<span class="notranslate" onmouseover="_tipon(this)" onmouseout="_tipoff ()"><span class="google-src-text notranslate" style="direction: ltr; textalign: left"></html></span></ Html></span> Eso es todo. Recuerde que para agregar un archivo beans.xml vacío en la carpeta WEB-INF para que las dependencias de soldadura se activan de forma automática por AS 7. He aquí cómo el proyecto debería quedar así:
  • 20. Ahora abra su navegador y probar la aplicación Web, señalando al puerto mod_cluster que hemos configurado antes: http://192.168.1.0:6666 / as7clustersample/home.xhtml Nota importante acerca de conmutación por error: JSF / CDI de conmutación por error sigue sin funcionar correctamente en un clúster. Si intenta acceder a la sesión replicado en el segundo nodo muestra la siguiente advertencia en los registros: WARN [org.jboss.as.clustering.web.infinispan] (http - 127.0.2.1-8080-1)
  • 21. JBAS010322: Problema para acceder a sesiones [9gzXvHZaf01gCVbeao-9-PL5]: JBAS010334: No se pudo almacenar atributos de sesión para la sesión: 9gzXvHZaf01gCVbeao -9-PL5 Verifique el tema AS7-3746 se fija antes de comprometerse en la producción con una aplicación en clúster. <