ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
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. <
Ad

More Related Content

Viewers also liked (14)

life stile of watever
life stile of wateverlife stile of watever
life stile of watever
thefunny
?
??? ????
??? ??????? ????
??? ????
dafna simana
?
§á§â§Ö§Ù§Ö§ß§ä§Ñ§è§Ú§ñ Microsoft Office Power Point
§á§â§Ö§Ù§Ö§ß§ä§Ñ§è§Ú§ñ Microsoft Office Power Point§á§â§Ö§Ù§Ö§ß§ä§Ñ§è§Ú§ñ Microsoft Office Power Point
§á§â§Ö§Ù§Ö§ß§ä§Ñ§è§Ú§ñ Microsoft Office Power Point
Orionnn
?
Altering reality exploring the concept 2
Altering reality exploring the concept 2Altering reality exploring the concept 2
Altering reality exploring the concept 2
camilla randall
?
???? ??? ????????????
???? ??? ???????????? ???? ??? ????????????
???? ??? ????????????
dafna simana
?
yadasimcom???? ??? ?????yadasim
yadasimcom???? ??? ?????yadasimyadasimcom???? ??? ?????yadasim
yadasimcom???? ??? ?????yadasim
dafna simana
?
Presenting Social Media Strategy to FRG
Presenting Social Media Strategy to FRGPresenting Social Media Strategy to FRG
Presenting Social Media Strategy to FRG
Ronietee
?
?????? ?????? ???????
?????? ?????? ????????????? ?????? ???????
?????? ?????? ???????
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 Fingertips
Ronietee
?
MMM Services Application - Intro
MMM Services Application  - IntroMMM Services Application  - Intro
MMM Services Application - Intro
Ronietee
?
Urban Homesteading Cooking Classes
Urban Homesteading Cooking ClassesUrban Homesteading Cooking Classes
Urban Homesteading Cooking Classes
Jamie Milks
?
???? ?? ?????, (????? ?????)
???? ?? ?????, (????? ?????)???? ?? ?????, (????? ?????)
???? ?? ?????, (????? ?????)
dafna simana
?
????? ?? ????
????? ?? ????????? ?? ????
????? ?? ????
dafna simana
?
Samvit Insights Profile
Samvit Insights ProfileSamvit Insights Profile
Samvit Insights Profile
arijitchanda
?
life stile of watever
life stile of wateverlife stile of watever
life stile of watever
thefunny
?
§á§â§Ö§Ù§Ö§ß§ä§Ñ§è§Ú§ñ Microsoft Office Power Point
§á§â§Ö§Ù§Ö§ß§ä§Ñ§è§Ú§ñ Microsoft Office Power Point§á§â§Ö§Ù§Ö§ß§ä§Ñ§è§Ú§ñ Microsoft Office Power Point
§á§â§Ö§Ù§Ö§ß§ä§Ñ§è§Ú§ñ Microsoft Office Power Point
Orionnn
?
Altering reality exploring the concept 2
Altering reality exploring the concept 2Altering reality exploring the concept 2
Altering reality exploring the concept 2
camilla randall
?
???? ??? ????????????
???? ??? ???????????? ???? ??? ????????????
???? ??? ????????????
dafna simana
?
yadasimcom???? ??? ?????yadasim
yadasimcom???? ??? ?????yadasimyadasimcom???? ??? ?????yadasim
yadasimcom???? ??? ?????yadasim
dafna simana
?
Presenting Social Media Strategy to FRG
Presenting Social Media Strategy to FRGPresenting Social Media Strategy to FRG
Presenting Social Media Strategy to FRG
Ronietee
?
?????? ?????? ???????
?????? ?????? ????????????? ?????? ???????
?????? ?????? ???????
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 Fingertips
Ronietee
?
MMM Services Application - Intro
MMM Services Application  - IntroMMM Services Application  - Intro
MMM Services Application - Intro
Ronietee
?
Urban Homesteading Cooking Classes
Urban Homesteading Cooking ClassesUrban Homesteading Cooking Classes
Urban Homesteading Cooking Classes
Jamie Milks
?
???? ?? ?????, (????? ?????)
???? ?? ?????, (????? ?????)???? ?? ?????, (????? ?????)
???? ?? ?????, (????? ?????)
dafna simana
?
Samvit Insights Profile
Samvit Insights ProfileSamvit Insights Profile
Samvit Insights Profile
arijitchanda
?

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. <