<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2038455272007745877</id><updated>2026-04-05T03:29:37.207-03:00</updated><category term="Patrones"/><category term="Patrones de Comportamiento"/><category term="Patrones Estructurales"/><category term="Java Cache"/><category term="Patrones Creacionales"/><category term="Adapter"/><category term="Decorator"/><category term="Spring"/><category term="API Reflection"/><category term="Abstract Factory"/><category term="Base de Datos"/><category term="Bridge"/><category term="Builder"/><category term="Cassandra"/><category term="Chain of Responsibility"/><category term="Command"/><category term="Composite"/><category term="EhCache"/><category term="Facade"/><category term="Factory Method"/><category term="Flyweight"/><category term="Hibernate"/><category term="Infinispan"/><category term="Interpreter"/><category term="Introduccion a Hibernate"/><category term="Introduccion a Patrones"/><category term="Introducción a Cache"/><category term="Introducción a Spring"/><category term="Iterator"/><category term="JBoss Cache"/><category term="Log4J"/><category term="Mediator"/><category term="Memento"/><category term="Objetos"/><category term="Observer"/><category term="POO"/><category term="Programación orientada a objetos con Java"/><category term="Prototype"/><category term="Proxy"/><category term="Singleton"/><category term="Spring Core"/><category term="State"/><category term="Strategy"/><category term="Template Method"/><category term="Visitor"/><category term="Wrapper"/><category term="¿Cual es el mejor Java Cache?"/><title type='text'>Mi granito de java</title><subtitle type='html'>Java, Patrones de Diseño, SQL, Frameworks, etc...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>38</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-2512346546505821849</id><published>2012-09-12T08:37:00.000-03:00</published><updated>2012-09-12T08:43:15.787-03:00</updated><title type='text'>Página en G+</title><content type='html'>He realiado una página en Google Plus sobre &quot;Mi granito de Java&quot;. Mi intención es que este Blog sea para educación y la página en G+ para compartir novedades, eventos y humor del mundo IT.&lt;br /&gt;
&lt;br /&gt;
Aquellos que quieran seguirla este es el link: &lt;a href=&quot;https://plus.google.com/u/0/b/101928657082381280272/101928657082381280272&quot;&gt;https://plus.google.com/u/0/b/101928657082381280272/101928657082381280272&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/2512346546505821849/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/2512346546505821849' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/2512346546505821849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/2512346546505821849'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2012/09/pagina-en-g.html' title='Página en G+'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-4188816217619410174</id><published>2012-09-07T09:23:00.000-03:00</published><updated>2012-09-12T08:41:26.358-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="API Reflection"/><title type='text'>Api Reflection</title><content type='html'>&lt;span style=&quot;font-size: large;&quot;&gt;Api Reflection&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Java posee un API muy poderosa que no se encuentra en la gran mayoría de los lenguajes. Se trata del API Reflection, que permite comunicarse casi directamente con la máquina virtual de java.&lt;br /&gt;
Dicho de otra forma, permite inspeccionar y manipular clases y objetos sin conocer a priori con que objetos estamos trabajando.&amp;nbsp;Este API es utilizada por la gran mayoría de los frameworks como por ejemplo Hibernate o Spring.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;La clase Class.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Todos los objetos en java heredan de java.lang.Object y por ello estan dotados del método &lt;b&gt;public final Class getClass()&lt;/b&gt;. Este método nos devuelve un&amp;nbsp;objeto java.lang.Class, que va a ser nuestro punto de entrada al API Reflection.&amp;nbsp;En nuestro caso vamos a usar una clase sencilla como ejemplo. La clase Persona, que tiene 4 atributos con sus getters y setters:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVZkTq_jzM4Gbsnh3vBCrGraffgOJh3xbgi-eR4pymQmpZvoK6lqnVJ2FVpbwGzkjzeX75V8JSHb7vb0Yt5VFX1RgINBYtMMHnPShjfR4H6UtRjhOTW9aPKTD_yTQPSR1phZfsseRtViM/s1600/0+persona.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVZkTq_jzM4Gbsnh3vBCrGraffgOJh3xbgi-eR4pymQmpZvoK6lqnVJ2FVpbwGzkjzeX75V8JSHb7vb0Yt5VFX1RgINBYtMMHnPShjfR4H6UtRjhOTW9aPKTD_yTQPSR1phZfsseRtViM/s1600/0+persona.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Hay diversas formas de obtener el objeto Class. Las más comunes son:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9H7BU4xGdAvGXH6c3_4I9lsBXuvwSCILqcCX6k7gSzxSubvLC2YPOO-WUImTjdChiu_ti3qqkc7aiPYwQjaQM63aUopMmkC9J2xlX-YiQY_rxfkrFSXHocTux1rIf0AKa3vGiIMqc3wE/s1600/class.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9H7BU4xGdAvGXH6c3_4I9lsBXuvwSCILqcCX6k7gSzxSubvLC2YPOO-WUImTjdChiu_ti3qqkc7aiPYwQjaQM63aUopMmkC9J2xlX-YiQY_rxfkrFSXHocTux1rIf0AKa3vGiIMqc3wE/s1600/class.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
En el primer caso la obtengo de una clase en particular. Si estoy parado en dicha clase también es posible hacer&amp;nbsp;this.getClass(). En el segundo caso obtengo Class a partir de un objeto.&amp;nbsp;Y en el tercer caso obtengo Class a partir del nombre de la clase.&lt;br /&gt;
&lt;br /&gt;
Una vez obtenida la clase es posible acceder a un montón de métodos muy útiles. Los principales son:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;i&gt;Field getField(String name)&lt;/i&gt;: devuelve un campo público de la clase, a&amp;nbsp;partir de su nombre. Si la clase no contiene ningún campo con ese nombre, se&amp;nbsp;comprueban sus superclases recursivamente, y en caso de no encontrar finalmente el&amp;nbsp;campo, se lanzará la excepcion java.lang.NoSuchFieldException.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Field[] getFields()&lt;/i&gt;: devuelve un array con todos los campos públicos de&amp;nbsp;la clase, y de sus superclases.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Method[] getMethods()&lt;/i&gt;: devuelve un array con todos los métodos&amp;nbsp;públicos de la clase, y de sus superclases. También existe el método getMethod que se le puede pedir un método en particular.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Class[] getInterfaces()&lt;/i&gt;: devuelve un array con todos los interfaces que&amp;nbsp;implementa la clase.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Constructor[] getConstructors()&lt;/i&gt;:&amp;nbsp;devuelve un array con todos los constructores&amp;nbsp;públicos.&lt;/li&gt;
&lt;li&gt;También es posible crear un objeto de una clase en particular en tiempo de ejecución gracias al método:&lt;i&gt; public T newInstance()&lt;/i&gt;.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZF3Psh3ZZwtV6mXFg96N-UWRBSkQrWvZtRetWiRQYgXdHXyxHCr04JSyF-jhnclx1EZLyUToVAjKcCvboHa2W-t7_Q6vJAkjVaGNCe08IC2LR1Vbh8YEXjtQMXHPN_BOKwd9j3eVdeLM/s1600/objeto2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZF3Psh3ZZwtV6mXFg96N-UWRBSkQrWvZtRetWiRQYgXdHXyxHCr04JSyF-jhnclx1EZLyUToVAjKcCvboHa2W-t7_Q6vJAkjVaGNCe08IC2LR1Vbh8YEXjtQMXHPN_BOKwd9j3eVdeLM/s1600/objeto2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span style=&quot;text-align: left;&quot;&gt;&lt;i&gt;Nos devuelve un Object que luego podemos castear a la clase correspondiente.&lt;/i&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Hay varios métodos más que se pueden utilizar. La lista completa esta acá:&amp;nbsp;&lt;a href=&quot;http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html&quot;&gt;http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Si observamos la lista veremos que varios se repiten pero con la palabra &lt;i&gt;Declared &lt;/i&gt;en la firma. Por ejemplo, tenemos &lt;i&gt;getMethods &lt;/i&gt;y &lt;i&gt;getDeclaredMethods&lt;/i&gt;. La diferencia radica en que el primero obtiene los métodos públicos de la clase y los heredados y el segundo los métodos públicos y privados pero no los heredados.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;java.lang.reflect.Field&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Field es una clase que representa un atributo de una clase en al API reflection. Tiene muchos metodos interesantes como por ejemplo:&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;i&gt;public String getName()&lt;/i&gt;: es el nombre del atributo.&lt;br /&gt;
&lt;i&gt;public Class getType()&lt;/i&gt;: devuelve la clase del atributo.&lt;br /&gt;
&lt;i&gt;public int&amp;nbsp;getModifiers()&lt;/i&gt;: devuelve los modificadores de un campo representados por un entero que se corresponde con las constantes definidas en la clase&amp;nbsp;java.lang.reflect.Modifier.&lt;br /&gt;
&lt;i&gt;public Object get(Object obj)&lt;/i&gt;: devuelve el valor del atributo.&lt;br /&gt;
&lt;i&gt;public void set(Object obj, Object value)&lt;/i&gt;: setea un valor al atributo.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJJRKvfsDlkjz7A5Raxh9YMgZG9uxlQ0vvZ7dILkIAc7i8ukbRmup0fWXZ3Mka-YW6xkhXfB4nXNewFiH3FBySpQoab9ej2qlcEONFWZz2Ks6_BIkCiRl2mEOWjM9s2CTkTT2JFSntn04/s1600/3+Field.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJJRKvfsDlkjz7A5Raxh9YMgZG9uxlQ0vvZ7dILkIAc7i8ukbRmup0fWXZ3Mka-YW6xkhXfB4nXNewFiH3FBySpQoab9ej2qlcEONFWZz2Ks6_BIkCiRl2mEOWjM9s2CTkTT2JFSntn04/s1600/3+Field.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;java.lang.reflect.Method.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Como se habrán imaginado Method tes una clase que representa un método. También tiene varios métodos muy útiles, como por ejemplo:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;public String getName()&lt;/i&gt;: nombre del método.&lt;br /&gt;
&lt;i&gt;public Class[] getParameterTypes()&lt;/i&gt;: array con las clases de los parámetros del método.&lt;br /&gt;
&lt;i&gt;public Class[] getExceptionTypes()&lt;/i&gt;: &amp;nbsp;array con las clases de las excepciones.&lt;br /&gt;
&lt;i&gt;public Class getReturnType()&lt;/i&gt;: devuelve la clase del valor que devuelve el método.&lt;br /&gt;
&lt;i&gt;public Object invoke(Object obj, Object... args)&lt;/i&gt;: ejecuta el método sobre un objeto, pasándole los parámetros como segundo argumento si es que los necesita. Veremos un ejemplo sobre su uso al final de este post.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Veremos que diferencia hay entre los metodos getMethods() y getDeclaredMethods().&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0EDXzfGwUPxDwTs4uJwgU89HBQbNx63hgF75ndZ7KGMlcHS_mYcIlihImTTthFppPJAYtJ8hVEXhk7FSSSEBJKPqxW3r8yFr_N-aogi3zSt0eWYcNYqAx4CQ5TV_mCZ3UqJHnBS7WYuY/s1600/4+metodos.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0EDXzfGwUPxDwTs4uJwgU89HBQbNx63hgF75ndZ7KGMlcHS_mYcIlihImTTthFppPJAYtJ8hVEXhk7FSSSEBJKPqxW3r8yFr_N-aogi3zSt0eWYcNYqAx4CQ5TV_mCZ3UqJHnBS7WYuY/s1600/4+metodos.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwvL0Pjro2-ftrNfoEXV1DIT9ymlhtgGqSJ3T1gr46oR1YvSa2dmRaBl826pX2znjowWXd-5E40qX9nav7tQBDId7pz_YSL-TzoqnIbGNLP9JYvxeG7hxwgXMjVa-rFPiajQB7LP7-3HU/s1600/5+metodos.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwvL0Pjro2-ftrNfoEXV1DIT9ymlhtgGqSJ3T1gr46oR1YvSa2dmRaBl826pX2znjowWXd-5E40qX9nav7tQBDId7pz_YSL-TzoqnIbGNLP9JYvxeG7hxwgXMjVa-rFPiajQB7LP7-3HU/s1600/5+metodos.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Como se puede observar&amp;nbsp;getDeclaredMethods() puede ser más util en la mayoría de los casos.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Un ejemplo integrador.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Les voy a mostrar un ejemplo que tuve que hacer para el trabajo. Si bien no es exactamente el mismo, es bastante similar. Resulta que nuestra aplicación enviar por web service ciertos datos para que otra aplicación lo pueda mostrar por una página web. Básicamente envía objetos simples con atributos que sean primitivos o Strings con sus getters y setters.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Esta otra aplicación es un semi enlatado que necesita los datos &quot;escapeados&quot;. Esto quiere decir, sin acentos ni caracteres raros, sino con el escape de html.&lt;/div&gt;
&lt;div&gt;
Nos avisaron de esto muy poco tiempo antes de entregar el producto como no podía ser de otra manera. Por suerte existe una clase en el apache commons lang que nos ayudó mucho ya que tiene un método que convierte un String normal en uno escapeado:&amp;nbsp;StringEscapeUtils.escapeHtml(String s).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
El problema es que teniamos que recorrer cada uno de nuestros objetos y escapear cuando sean Strings. Y la realidad es que los seteabamos por toda nuestra aplicación y no lo podiamos hacer en la misma clase (que &amp;nbsp;igual era muy molesto) debido a que también guardabamos el valor en nuestra base de datos y allí no tenía que estar escapeado.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Por ello decidimos utilizar reflaction para que le podamos enviar cualquier objeto y por reflection cambie todos sus strings por strings escapeados:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw7pBXcP7djFHS05NYOZxz9Z-bSv04wxvbWM9sksmZU1NkdcYVhG5CfJRQKl3T8cbrmCtToBNv5-9w2tuBxCFL6LaEvtG80iEwQ0mFR3qujXCyv5It6V4rPMVsKaBOO8lmFLx3DGFX-78/s1600/final+escap.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw7pBXcP7djFHS05NYOZxz9Z-bSv04wxvbWM9sksmZU1NkdcYVhG5CfJRQKl3T8cbrmCtToBNv5-9w2tuBxCFL6LaEvtG80iEwQ0mFR3qujXCyv5It6V4rPMVsKaBOO8lmFLx3DGFX-78/s1600/final+escap.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;Y su uso sería el siguiente:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzYIkgELKJuy9iogGpXYnvy1OEiji_vqO39nMjESrzc4HlniXwDaWIm1p_-6zOfZofjhaqHN82TLJ1Fv0pM8y0Mgr1tjeCU5FLw5un5M6gKDjoHN0nVlwF1McLK3M_g9D1-vldUINWO4U/s1600/final+main.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzYIkgELKJuy9iogGpXYnvy1OEiji_vqO39nMjESrzc4HlniXwDaWIm1p_-6zOfZofjhaqHN82TLJ1Fv0pM8y0Mgr1tjeCU5FLw5un5M6gKDjoHN0nVlwF1McLK3M_g9D1-vldUINWO4U/s1600/final+main.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Conclusión.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Este API es muy poderosa y permite realizar muchas cosas que en otro lenguaje sería casi imposible. Pero uno debe evitar a toda costa abusar de la misma. Las personas que hace poco la conocen quieren utilizarla en todos lados y realmente puede hacer mucho lío en el código y en su lectura.&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/4188816217619410174/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/4188816217619410174' title='6 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/4188816217619410174'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/4188816217619410174'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2012/09/api-reflection.html' title='Api Reflection'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVZkTq_jzM4Gbsnh3vBCrGraffgOJh3xbgi-eR4pymQmpZvoK6lqnVJ2FVpbwGzkjzeX75V8JSHb7vb0Yt5VFX1RgINBYtMMHnPShjfR4H6UtRjhOTW9aPKTD_yTQPSR1phZfsseRtViM/s72-c/0+persona.jpg" height="72" width="72"/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-2951158940239061873</id><published>2011-08-14T01:44:00.000-03:00</published><updated>2011-08-14T01:44:43.928-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Hibernate"/><category scheme="http://www.blogger.com/atom/ns#" term="Introduccion a Hibernate"/><title type='text'>Introducción a Hibernate</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;En este post voy a hacer una introducción a Hibernate. Tan sólo un Hola Mundo para que se entiendan los conceptos principales. Luego más adelante haré otras entradas para profundizar un poco más sobre este framework. &lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Hibernate.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
“Hibernate es una herramienta de Mapeo objeto-relacional (ORM) para la  plataforma Java (y disponible también para .Net con el nombre de  NHibernate) que facilita el mapeo de atributos entre una base de datos  relacional tradicional y el modelo de objetos de una aplicación,  mediante archivos declarativos (XML) o anotaciones en los beans de las  entidades que permiten establecer estas relaciones. Hibernate es  software libre, distribuido bajo los términos de la licencia GNU LGPL. “  - Wikipedia.&lt;br /&gt;
&lt;br /&gt;
Hibernate es un framework que agiliza la relación  entre la aplicación y la base de datos. De todos los frameworks ORM que  he utilizado, sin dudas es el más completo.&lt;br /&gt;
Para aprender Hibernte es  necesario tener los conocimientos mínimos de SQL y Java. Conocer JDBC  es recomendable.  Se puede bajar (en principio con bajar Hibernate Core  alcanza) de &lt;a href=&quot;http://www.hibernate.org/&quot;&gt;www.hibernate.org&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH7XT1_T0bLDMqtF20igxylEYCFGV3baBob3E9o9Dc2hY2e-mNd5PpNwos2b4I_znX_eCZtHwH_ynp2VNRgTKZP8PT6D4O8rDDih2e3x9u5RLJgnNd6KZZoxFG8z25h_yFguMmRGVqcU4/s1600/org.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;155&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH7XT1_T0bLDMqtF20igxylEYCFGV3baBob3E9o9Dc2hY2e-mNd5PpNwos2b4I_znX_eCZtHwH_ynp2VNRgTKZP8PT6D4O8rDDih2e3x9u5RLJgnNd6KZZoxFG8z25h_yFguMmRGVqcU4/s640/org.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;¿Por que usar un framework ORM?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Cuando uno desarrolla una aplicación se dará cuenta que en la gran mayoría de los casos todo termina siendo un conjunto de ABMs (alta, baja, modificación de datos) para luego poder consultarlos. Para ello se utiliza una base de datos, donde existirán muchas tareas repetidas: por cada objeto que quiero persistir debo crear una clase que me permita insertalo, eliminarlo, modificarlo y consultarlo. Salvo aquellas consultas fuera de lo común, el resto es siempre lo mismo. Aquí es donde entra a jugar un rol importante un ORM: con solo configurarlo ya tiene todas esas tareas repetitivas realizadas y el desarrollador solo tendrá que preocuparse por aquellas consultas fuera de lo normal.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;¿Como funciona Hibernate?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Básicamente el desarrollador deberá configurar en un archivo XML o mediante annotations donde corresponde un atributo de una clase, con una columna de una tabla. Es una tarea relativamente sencilla donde existen herramientas que lo hacen por nosotros. En principio voy a realizar los ejemplos con archivos xml y luego, en otro post, los haré mediante annotations.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Configuración.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Vamos a hacer un paso a paso para dejar todo listo. Primero vamos a colocar los jars en el proyecto. Aqui van los de hibernate (que vienen en la carpeta lib de la distribución), más el del driver correspondiente a la base de datos que esten utilizando. Yo voy a utilizar DB2. A continuació voy a colocar los jars necesarios. He colocado los de Hibernate + DB2 + MySQL por si alguno la usa.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqFjDTpdmyo5i7h598MI2Uf1jgcq-itCjw5CukySPfZtgD9-ce674nRYIE3QpHCeiQ7YXEKhJV3Ss4oEHubsuAqrnV6Rr-hTym0UHKuhFkk4BE2ED8e1Nq5ocAGUUTRoKlOCF50FCD0zo/s1600/jars.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqFjDTpdmyo5i7h598MI2Uf1jgcq-itCjw5CukySPfZtgD9-ce674nRYIE3QpHCeiQ7YXEKhJV3Ss4oEHubsuAqrnV6Rr-hTym0UHKuhFkk4BE2ED8e1Nq5ocAGUUTRoKlOCF50FCD0zo/s1600/jars.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Luego vamos a crear una sencilla tabla en la base de datos:&lt;br /&gt;
Para MySQL:&lt;br /&gt;
&lt;div style=&quot;background-color: #93c47d;&quot;&gt;&lt;i&gt;CREATE TABLE `autos` (&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #93c47d;&quot;&gt;&lt;i&gt;`IDAUTO` int(10) unsigned NOT NULL auto_increment,&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #93c47d;&quot;&gt;&lt;i&gt;`MARCA` varchar(255) NOT NULL default &#39;&#39;,&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #93c47d;&quot;&gt;&lt;i&gt;`MODELO` varchar(255) NOT NULL default &#39;&#39;,&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #93c47d;&quot;&gt;&lt;i&gt;PRIMARY KEY  (`IDAUTO`)&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #93c47d;&quot;&gt;&lt;i&gt;) &lt;/i&gt;&lt;/div&gt;&lt;br /&gt;
Para DB2:&lt;br /&gt;
&lt;div style=&quot;background-color: #93c47d;&quot;&gt;&lt;i&gt;CREATE TABLE hib.AUTOS (&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #93c47d;&quot;&gt;&lt;i&gt;IDAUTO BIGINT NOT NULL,&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #93c47d;&quot;&gt;&lt;i&gt;MARCA VARCHAR(255),&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #93c47d;&quot;&gt;&lt;i&gt;MODELO VARCHAR(255)&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #93c47d;&quot;&gt;&lt;i&gt;);&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #93c47d;&quot;&gt;&lt;i&gt;CREATE UNIQUE INDEX SQL1108120858221120 ON hib.AUTOS (IDAUTO ASC);&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #93c47d;&quot;&gt;&lt;i&gt;ALTER TABLE hib.AUTOS ADD CONSTRAINT SQL1108128085281980 PRIMARY KEY (IDAUTO);&lt;/i&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
El siguiente paso es configurar un SessionManager que me permite obtener sesiones y transacciones para trabajar con la base de datos. En este caso haremos uno sencillo, que no sirve para trabajar en producción, pero que nos permite realizar nuestros ejemplos.&lt;br /&gt;
Aca les dejo la clase, comentada para que se entienda de donde salen todos los datos.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #f6b26b;&quot;&gt;package configuracion;&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;import java.util.Properties;&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;import org.hibernate.HibernateException;&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;import org.hibernate.MappingException;&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;import org.hibernate.Session;&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;import org.hibernate.cfg.Configuration;&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #f6b26b;&quot;&gt;public abstract class SessionManager {&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static Session getSession() throws HibernateException&lt;/span&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Instancia un objeto del tipo Configuration&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Configuration config = new Configuration();&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Registra las clases a mapear en la configuracion&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; registerMappers(config);&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Establece las propiedades de configuracion&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; config.setProperties(getHibernateProperties() );&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Retorna una sesion de trabajo&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return config.buildSessionFactory().openSession();&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private static Properties getHibernateProperties()&lt;/span&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Instancia un objeto del tipo Properties.&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Properties props = new Properties();&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Establece el driver de conexion dependiente del RDBMS.&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //para MySQL seria:&amp;nbsp; props.put(&quot;hibernate.connection.driver_class&quot;, &quot;com.mysql.jdbc.Driver&quot;);&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; props.put(&quot;hibernate.connection.driver_class&quot;, &quot;com.ibm.db2.jcc.DB2Driver&quot;);&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Establece la url de conexion, donde al final va el nombre de la BD&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //para MySQL&amp;nbsp; props.put(&quot;hibernate.connection.url&quot;, &quot;jdbc:mysql://localhost/testHibernate&quot;);&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; props.put(&quot;hibernate.connection.url&quot;, &quot;jdbc:db2://localhost:50000/sample&quot;);&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Establece el usuario.&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; props.put(&quot;hibernate.connection.username&quot;, &quot;db2admin&quot;);&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Establece la clave.&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; props.put(&quot;hibernate.connection.password&quot;, &quot;db2admin&quot;);&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Establece el dialecto a utilizar. Es necesario determinarlo ya que la implementación &lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // de SQL puede variar con cada motor de base de datos.&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Para MySQL sería: props.put(&quot;hibernate.dialect&quot;, &quot;org.hibernate.dialect.MySQLDialect&quot;);&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; props.put(&quot;hibernate.dialect&quot;, &quot;org.hibernate.dialect.DB2Dialect&quot;);&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Retorna las propiedades&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return props;&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Cada clase mapeada deberá aparecer aca.&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private static void registerMappers(Configuration config) throws MappingException&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; config.addResource(&quot;negocio/Auto.hbm.xml&quot;);&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #f6b26b;&quot; /&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Como verán, he configurado el SessionManager de manera programática. Obviamente lo ideal para un proyecto laboral es hacerlo con archivos de configuracion. Aca hay un ejemplo: &lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html&quot;&gt;http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Hasta aquí hemos terminado de confgurar Hibernate. Ahora podemos comenzar a utilizarlo. Para ello, haremos la clase Auto y su correspondiente archivo xml&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRT7zBtpAQiJv0iGy0no54j6RUw40B1IeO2UiiTgTjnbALGlBtE7E5r9bMEKile2JZFjXYmrERS_Hlm6Uxt5mI8_nYEN8QaJ2EkS8L8XJYy3Zqr7pXfLtJdR04ImfGzgz_bXOelqRN46A/s1600/auto.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRT7zBtpAQiJv0iGy0no54j6RUw40B1IeO2UiiTgTjnbALGlBtE7E5r9bMEKile2JZFjXYmrERS_Hlm6Uxt5mI8_nYEN8QaJ2EkS8L8XJYy3Zqr7pXfLtJdR04ImfGzgz_bXOelqRN46A/s1600/auto.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Y, ahora veremos el archivo auto.hbm.xml. La extensión hbm.xml es por conveción. Este archivo representa la forma de relacionar una clase con una tabla. Existirá un hbm.xml por cada clase que desee mapear. Por lo general, se acostumbra dejar el archivo xml en el mismo paquete de la clase mapeada.&lt;br /&gt;
&lt;div style=&quot;color: #c27ba0;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;&lt;/span&gt;&lt;br style=&quot;color: #c27ba0;&quot; /&gt;&lt;span style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;!DOCTYPE hibernate-mapping PUBLIC &quot;-//Hibernate/Hibernate Mapping DTD//EN&quot; &quot;http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd&quot;&amp;gt;&lt;/span&gt;&lt;br style=&quot;color: #c27ba0;&quot; /&gt;&lt;span style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;hibernate-mapping&amp;gt;&lt;/span&gt;&lt;br style=&quot;color: #c27ba0;&quot; /&gt;&lt;span style=&quot;color: #c27ba0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;class&amp;nbsp; name=&quot;negocio.Auto&quot; table=&quot;autos&quot;&amp;gt;&lt;/span&gt;&lt;br style=&quot;color: #c27ba0;&quot; /&gt;&lt;span style=&quot;color: #c27ba0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;id name=&quot;id&quot; column=&quot;idauto&quot;&amp;gt;&lt;/span&gt;&lt;br style=&quot;color: #c27ba0;&quot; /&gt;&lt;span style=&quot;color: #c27ba0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;generator class=&quot;increment&quot; /&amp;gt;&lt;/span&gt;&lt;br style=&quot;color: #c27ba0;&quot; /&gt;&lt;span style=&quot;color: #c27ba0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/id&amp;gt;&lt;/span&gt;&lt;br style=&quot;color: #c27ba0;&quot; /&gt;&lt;span style=&quot;color: #c27ba0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;marca&quot; /&amp;gt;&lt;/span&gt;&lt;br style=&quot;color: #c27ba0;&quot; /&gt;&lt;span style=&quot;color: #c27ba0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;modelo&quot; /&amp;gt;&lt;/span&gt;&lt;br style=&quot;color: #c27ba0;&quot; /&gt;&lt;span style=&quot;color: #c27ba0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/class&amp;gt;&lt;/span&gt;&lt;br style=&quot;color: #c27ba0;&quot; /&gt;&lt;span style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;/hibernate-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Listo, ya tenemos todo para realizar las primeras pruebas. Pero antes voy a explicar que es cada cosa en el xml:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt; &lt;b&gt;hibernate-mapping&lt;/b&gt; es la raíz del documento y, por ende, todos los tags quedan contenidos dentro de este tag.&lt;/li&gt;
&lt;li&gt;El tag &lt;b&gt;class &lt;/b&gt;es general: nombra la clase y la tabla.&lt;/li&gt;
&lt;li&gt;El tag &lt;b&gt;id &lt;/b&gt;representa el atributo que se relaciona con la clave primaria. Su atributo &lt;b&gt;name &lt;/b&gt;hace referencia a como se llama el id en la clase (en nuestro caso da la casualidad que se llama id) y el atributo &lt;b&gt;column &lt;/b&gt;representa la columna en la base de datos.&lt;/li&gt;
&lt;li&gt;El tag &lt;b&gt;property &lt;/b&gt;es utilizado para los atributos que no son clave primaria. Sus atributos más importantes son &lt;b&gt;name &lt;/b&gt;y &lt;b&gt;column&lt;/b&gt;. Si el nombre del atributo coincide con la columna, no es necesario especificar a ambos. Con especificar &lt;b&gt;name &lt;/b&gt;es suficiente.&lt;/li&gt;
&lt;li&gt;El tag &lt;b&gt;generator &lt;/b&gt;esta contenido dentro de &lt;b&gt;id &lt;/b&gt;y representa la forma de generar la clase primaria al insertar un nuevo registro. Puede tomar diversos valores pero los más comunes son:&lt;/li&gt;
&lt;/ol&gt;&lt;ul&gt;&lt;li&gt;increment: para las claves autoincrementales.&lt;/li&gt;
&lt;li&gt;sequence: para los secuenciadores.&lt;/li&gt;
&lt;li&gt;assign: para los casos donde la BD no generá la clave primaria, sino que el objeto es quién la determina.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;A probar!&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixECD7g489P_AnZNRecf-3DdGrrmlIQcsGoF1CwChQiEjYA8xpoRNFGb4NtmCEqX0gxbOd6g1Mrw-YlC_r0B_HgF1PuXh-JbIXJtvkMg_hAwCz4bSevoMQC7jq400vEeQsJc-bBRzXjzQ/s1600/main.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixECD7g489P_AnZNRecf-3DdGrrmlIQcsGoF1CwChQiEjYA8xpoRNFGb4NtmCEqX0gxbOd6g1Mrw-YlC_r0B_HgF1PuXh-JbIXJtvkMg_hAwCz4bSevoMQC7jq400vEeQsJc-bBRzXjzQ/s1600/main.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Hemos insertado un auto. Tan sencillo como eso, ejecutar el método save.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2yLxslXIN7vaOBE5cAh-kTGqp7abBeFRRWCYhksxuLJFkOe5ns7YA6ohkuXOLvJV7I5JrZ4TiXwtNV8eZHHePQaoR8wjZBZizNtd6hPv2ngj56ZRC0lDqxZJ8TINC3w4fv5GhpcRPTSw/s1600/tablaInsercion.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2yLxslXIN7vaOBE5cAh-kTGqp7abBeFRRWCYhksxuLJFkOe5ns7YA6ohkuXOLvJV7I5JrZ4TiXwtNV8eZHHePQaoR8wjZBZizNtd6hPv2ngj56ZRC0lDqxZJ8TINC3w4fv5GhpcRPTSw/s1600/tablaInsercion.png&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;/div&gt;Vamos a actualizarlo: ahora lo convertiremos en C4:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZA1XC-wbHriEun0R76InxFE3B4SAuCNMW9U6o-i7ZutT0PweqfRPCQxi7z9jNJ16et1WftJqZiE1Rzcvqpo-JfzzSqMZwUylIqYSF1Kloqw_5Q48zM3fAPx-oocfzmkiC_XZV1fwHblM/s1600/update.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZA1XC-wbHriEun0R76InxFE3B4SAuCNMW9U6o-i7ZutT0PweqfRPCQxi7z9jNJ16et1WftJqZiE1Rzcvqpo-JfzzSqMZwUylIqYSF1Kloqw_5Q48zM3fAPx-oocfzmkiC_XZV1fwHblM/s1600/update.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqnEYrxu0XKfuv8BJr-oy8_1IvHZ1Fn_RBj7JAGl7hzEAm8yFhqv1qFf2ivhBINIwQjVHIx7aKBuzM1_Iyk3X4V179q-21mUhCSG74JtP7MpQUAJ6fZlGs3ZiMPy8SpxQb3JOhQ0a4V9U/s1600/updateBD.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqnEYrxu0XKfuv8BJr-oy8_1IvHZ1Fn_RBj7JAGl7hzEAm8yFhqv1qFf2ivhBINIwQjVHIx7aKBuzM1_Iyk3X4V179q-21mUhCSG74JtP7MpQUAJ6fZlGs3ZiMPy8SpxQb3JOhQ0a4V9U/s1600/updateBD.png&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;Y, por último, eliminaremos el registro:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8dZ7Qzr_z3tCkc3QEnVyRvn8iWFbwA7lYmJ9EcEgxYZ789CWS_HA0ssYJ7dqfDhN0MzftYU-m4NR3A1BW_XHMW0Uj1PhEuWn1CNXHjL4fv7eB_zw6Y0Xa0oLOF136hQoqTU8bLPmw5Ww/s1600/delete.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8dZ7Qzr_z3tCkc3QEnVyRvn8iWFbwA7lYmJ9EcEgxYZ789CWS_HA0ssYJ7dqfDhN0MzftYU-m4NR3A1BW_XHMW0Uj1PhEuWn1CNXHjL4fv7eB_zw6Y0Xa0oLOF136hQoqTU8bLPmw5Ww/s1600/delete.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Algunas últimas aclaraciones:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;No he hecho consultas mediante Hibernate porque habría que profundizar un poco más y prefiero dejarlo para más adelante.&lt;/li&gt;
&lt;li&gt;Para actualizar un registro es necesario colocarle el id a la clase. En este caso era un Long, por lo que tuve que hacer setId(1L).&lt;/li&gt;
&lt;li&gt;Hibernate elimina por id de manera automática. Por ello, con solo colocarle el id al objeto auto es suficiente. Para eliminaciones más complejas hay que tirar un poco más de código.&lt;/li&gt;
&lt;/ul&gt;&lt;i&gt;Bien, hasta aquí llego nuestro pequeño ejemplo. Cuando tenga un poco más de tiempo voy a profundizar sobre este framework.&lt;/i&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/2951158940239061873/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/2951158940239061873' title='10 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/2951158940239061873'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/2951158940239061873'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/08/introduccion-hibernate.html' title='Introducción a Hibernate'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH7XT1_T0bLDMqtF20igxylEYCFGV3baBob3E9o9Dc2hY2e-mNd5PpNwos2b4I_znX_eCZtHwH_ynp2VNRgTKZP8PT6D4O8rDDih2e3x9u5RLJgnNd6KZZoxFG8z25h_yFguMmRGVqcU4/s72-c/org.png" height="72" width="72"/><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-5330601996861793967</id><published>2011-07-26T13:51:00.002-03:00</published><updated>2012-06-13T08:47:48.966-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Log4J"/><title type='text'>Log4j</title><content type='html'>La experiencia indica que el logging forma parte importante del desarrollo de una aplicación. Sobretodo porque nos permite conocer el estado de los objetos en un momento determinado.&lt;br /&gt;
&lt;br /&gt;
Log4j es un framework de Java que se utiliza como herramienta de logging. Muchas veces utilizamos el limitado pero efectivo System.out.printl() para realizar salidas por consola o hacer seguimiento de un error. Si bien a veces con esto alcanza, la realidad es que su alcance es limitado. Hay diversas situaciones en las cuales encuestaríamos algo más completo. Se me ocurre, por ejemplo:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Quiero guardar un archivo con las salidas de la consola.&lt;/li&gt;
&lt;li&gt;Quiero ver los mensajes con un formato determinado.&lt;/li&gt;
&lt;li&gt;¿Que pasa en los casos donde ocurre un error en producción que no se replica en desarrollo? Llenamos de log nuestro código para poder seguirlo! Y cuando lo encontramos, tenemos que volver a sacar todas las líneas que hemos puesto por las distintas clases! Sin contar la cantidad de veces que debo realizar el deploy en producción. Por otro lado, si lleno el código de log, se llena la consola sin sentido, pero sería bueno guardar esas líneas de log por las dudas...entonces ¿No sería bueno tener diversos niveles de log y que se ejecuten las lineas de log que yo quiero con solo modificar el nivel en un archivo de configuración? Estos y otros problemas los puede arreglar Log4j. &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;/ul&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Características de Log4j.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Es simple de usar y entender. Fue hecho en Java; es open source y fue desarrollada en Java por la Apache Software Foundation que permite a los desarrolladores de software elegir la salida y el nivel de granularidad de los mensajes o “logs” (logging) en tiempo de ejecución y no en tiempo de compilación como es comúnmente realizado. Como si fuera poco, es más rápdio que realizar un System.out.print() y le ocupa al sistema menor cantidad de recursos. &lt;br /&gt;
La configuración de salida y granularidad de los mensajes es realizada mediante un archivo de configuración externo. Adenás de Java, Log4J ha sido implementado en otros lenguajes como: C, C++, C#, Perl, Python, Ruby y Eiffel. &lt;br /&gt;
La página oficial de Log4J es&lt;a href=&quot;http://logging.apache.org/log4j/&quot;&gt; http://logging.apache.org/log4j/&lt;/a&gt; y desde allí debemos bajar los  jars necesarios para trabajar en nuestro programa. &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2FRUm3AALsOFT0XNWnDVsuew9IxSJcDG4co6btw1SRA4z41Id7kDLbIdh5RCcZdvqXnBZWhxlGVS5uZ8u6Zmjopi3g58FVkPPW1ip16hMemqcqpgY6nmEJ5gvKBuo5vaaA4taevWxw6Y/s1600/page.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2FRUm3AALsOFT0XNWnDVsuew9IxSJcDG4co6btw1SRA4z41Id7kDLbIdh5RCcZdvqXnBZWhxlGVS5uZ8u6Zmjopi3g58FVkPPW1ip16hMemqcqpgY6nmEJ5gvKBuo5vaaA4taevWxw6Y/s1600/page.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Configuración y uso&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
Podriamos dividir en dos partes a Log4j. La primer parte consiste en configurarlo. Esto se hace una sola vez y nunca más. En el 99% de los casos no lo tendremos que hacer nosotros, pero es bueno saber como se configura por si alguna vez caemos dentro de ese 1%. La configuración por lo general reside en un archivo de propiedades llamado log4j.properties. Pero debemos tener en cuenta que se puede hacer mediante un achivo xml o programáticamente. Esta última opción no es recomendable ya que se debe tocar código y compilar de nuevo cada vez que se quiere cambiar el nivel del logging.&lt;br /&gt;
La segunda parte consiste en saber usarlo. Es la parte más sencilla y con sólo aprender 2 o 3 tips y ya estamos listos.&lt;br /&gt;
Primero veremos como se configura y al final de este post veremos como se usa. Si sólo necesitan usarlo pueden ir directamente al final donde se muestran unos ejemplos de uso.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Niveles de prioridad.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Log4j tiene tres components principales para configurar: loggers, appenders y layouts (que los veremos más adelante). Estos tres funcionan juntos para loggear de acuerdo al tipo de mensaje y formato. Cuando escribamos un mensaje para que vaya al log debemos especificar su nivel de prioridad. Por defecto Log4J tiene 6 niveles de prioridad para los mensajes (trace, debug, info, warn, error, fatal). Además existen otros dos niveles extras (all y off).&lt;br /&gt;
Niveles de prioridad (De mayor -poco detalle- a menor -mucho detalle-):&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;FATAL: se utiliza para mensajes críticos del sistema, generalmente después de guardar el mensaje el programa abortará. &lt;/li&gt;
&lt;li&gt;ERROR: se utiliza en mensajes de error de la aplicación que se desea guardar, estos eventos afectan al programa pero lo dejan seguir funcionando, como por ejemplo que algún parámetro de configuración no es correcto y se carga el parámetro por defecto. &lt;/li&gt;
&lt;li&gt;WARN: se utiliza para mensajes de alerta sobre eventos que se desea mantener constancia, pero que no afectan al correcto funcionamiento del programa. &lt;/li&gt;
&lt;li&gt;INFO: se utiliza para mensajes informativos sobre el avance de la aplicación. Estimo que deb ser el más utilizado de todos los niveles.&lt;/li&gt;
&lt;li&gt;DEBUG: se utiliza para escribir mensajes de depuración. Este nivel no debe estar activado cuando la aplicación se encuentre en producción. &lt;/li&gt;
&lt;li&gt;TRACE: se utiliza para mostrar mensajes con un mayor nivel de detalle que debug. &lt;/li&gt;
&lt;/ul&gt;
Extras: &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;ALL: este es el nivel de máximo detalle, habilita todos los logs (en general equivale a TRACE). &lt;/li&gt;
&lt;li&gt;OFF: este es el nivel de mínimo detalle, deshabilita todos los logs. &lt;/li&gt;
&lt;/ul&gt;
Por lo general, INFO y DEBUG son los utilizados.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Appenders.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
En Log4J los mensajes son enviados a una (o varias) salida de destino, lo que se denomina un appender.  Existen varios appenders y también podemos crear propios. Típicamente la salida de los mensajes es redirigida a un fichero de texto .log (FileAppender, RollingFileAppender), a un servidor remoto donde almacenar registros (SocketAppender), a una dirección de correo electrónico (SMTPAppender), e incluso en una base de datos (JDBCAppender). Casi nunca es utilizado en un entorno de producción la salida a la consola (ConsoleAppender) ya que perdería gran parte de la utilidad de Log4J.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTmkKfTwAZ3wvmObTwHEdUrA2nZRuzYSzNRHVvE6I67c9Yfcs8FzsWL3Vs9-9Pxi3Wid3V-26omDhsbw4NkpYKhQxbqulFzvMDL_bpMG5aIbCLh7MaEcc1yPP8gdINqvzHDgR4e-7B1Bk/s1600/console.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTmkKfTwAZ3wvmObTwHEdUrA2nZRuzYSzNRHVvE6I67c9Yfcs8FzsWL3Vs9-9Pxi3Wid3V-26omDhsbw4NkpYKhQxbqulFzvMDL_bpMG5aIbCLh7MaEcc1yPP8gdINqvzHDgR4e-7B1Bk/s1600/console.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;i&gt;&amp;nbsp;No se precupen si no entienden la configuración, de a poco vamos a ver cada punto.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
*Fe de erratas: donde dice &lt;b&gt;No mostrará mensajes por debajo del nivel INFO&lt;/b&gt; debería decir&amp;nbsp;&lt;b&gt;No mostrará mensajes por debajo del nivel DEBUG&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Los appenders se configuran en el archivo externo.Los appenders que vienen con Log4J se encuentran en el paquete org.apache.log4j. Estos son: &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;ConsoleAppender&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Este appender despliega el log en la consola; tiene las siguientes opciones:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Threshold=WARN: Este parámetro establece que el appender no despliega ningún mensaje con prioridad menor a la especificada aquí.&lt;/li&gt;
&lt;li&gt;ImmediateFlush=true: El valor por defecto es true, esto quiere decir que los mensajes de log no son almacenados en un buffer, sino que son enviados directamente al destino.&lt;/li&gt;
&lt;li&gt;Target=System.err: El valor por defecto es System.out. Establece la salida del sistema a ser utilizada. &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;b&gt;FileAppender&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Este appender redirecciona los mensajes de logs hacia un archivo.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Threshold=WARN: Este parámetro establece que el appender no despliega ningún mensaje con prioridad menor a la especificada aquí.&lt;/li&gt;
&lt;li&gt;ImmediateFlush=true: El valor por defecto es true, esto quiere decir que los mensajes de log no son almacenadosen un buffer, sino que son enviados directamente al destino.&lt;/li&gt;
&lt;li&gt;File=mylog.txt: Nombre del archivo donde se almacenará el log. Se puede utilizar el nombre de algún property (${nombre_de_la_propiedad}) para especificar el nombre o la ubicación del archivo.&lt;/li&gt;
&lt;li&gt;Append=false: El valor por defecto es true, para que los nuevos mensajes de logs se adicionen al archivo existente.&lt;/li&gt;
&lt;li&gt;Si se especifica false, cuando se inicie la aplicación el archivo de log se sobreescribirá.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVnlrm_WVNC30LLr3uEULI-Da6dAm3uXm1fzffCuLS_XzwpfKKmrhyVYfvwfmDYNWrY779hASGXp8txZLzi3dq19VeoIekQ2Wz-wbqmV6m3FEdlEiGdV5WVq5_Al7-ddSCu5Yben6VcJg/s1600/appender.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVnlrm_WVNC30LLr3uEULI-Da6dAm3uXm1fzffCuLS_XzwpfKKmrhyVYfvwfmDYNWrY779hASGXp8txZLzi3dq19VeoIekQ2Wz-wbqmV6m3FEdlEiGdV5WVq5_Al7-ddSCu5Yben6VcJg/s1600/appender.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;/ul&gt;
&lt;br /&gt;
&lt;b&gt;RollingFileAppender&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Este appender redirecciona los mensajes de logs hacia un archivo y permite definir politicas de rotación para que el archivo no crezca indefinidamente.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Threshold=WARN: Este parámetro establece que el appender no despliega ningún mensaje con prioridad menor a la especificada aquí.&lt;/li&gt;
&lt;li&gt;ImmediateFlush=true: El valor por defecto es true, esto quiere decir que los mensajes de log no son almacenados en un buffer, sino que son enviados directamente al destino.&lt;/li&gt;
&lt;li&gt;File=mylog.txt: Nombre del archivo donde se almacenará el log. Se puede utilizar el nombre de algún property (${nombre_de_la_propiedad}) para especificar el nombre o la ubicación del archivo.&lt;/li&gt;
&lt;li&gt;Append=false: El valor por defecto es true, para que los nuevos mensajes de logs se adicionen al archivo existente. Si se especifica false, cuando se inicie la aplicación el archivo de log se sobreescribirá.&lt;/li&gt;
&lt;li&gt;MaxFileSize=100KB: Los sufijos pueden ser KB, MB o GB. Rota el archivo de log cuando alcanza el tamaño especificado.&lt;/li&gt;
&lt;li&gt;MaxBackupIndex=2: Mantiene un máximo de 2 (por ejemplo) archivos de respaldo. Borra los archivos anteriores.Si se especifica 0 no se mantiene respaldos. &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;b&gt;DailyRollingFileAppender&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Este appender redirecciona los mensajes de logs hacia un archivo y permite definir politicas de rotación basados en fechas.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Threshold=WARN: Este parámetro establece que el appender no despliega ningún mensaje con prioridad menor a la especificada aquí.&lt;/li&gt;
&lt;li&gt;ImmediateFlush=true: El valor por defecto es true, esto quiere decir que los mensajes de log no son almacenados en un buffer, sino que son enviados directamente al destino.&lt;/li&gt;
&lt;li&gt;File=mylog.txt: Nombre del archivo donde se almacenará el log. Se puede utilizar el nombre de algún property (${nombre_del_property}) para especificar el nombre o la ubicación del archivo.&lt;/li&gt;
&lt;li&gt;Append=false: El valor por defecto es true, para que los nuevos mensajes de logs se adicionen al archivo existente.Si se especifica false, cuando se inicie la aplicación el archivo de log se sobreescribirá.&lt;/li&gt;
&lt;li&gt;DatePattern=&#39;.&#39;yyyy-ww: Rota el archivo cada semana Se puede especificar que la frecuencia de rotación sea mensual, semanal, diaria, 2 veces al día, cada hora o cada minuto. Este valor no solo especifica la frecuencia de rotación sino el sufijo del archivo de respaldo. Algunos ejemplos de frecuencia de rotación son:&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&#39;.&#39;yyyy-MM: Rota el archivo el primero de cada mes&lt;/li&gt;
&lt;li&gt;&#39;.&#39;yyyy-ww: Rota el archivo al inicio de cada semana&lt;/li&gt;
&lt;li&gt;&#39;.&#39;yyyy-MM-dd: Rota el archivo a la media noche todos los días&lt;/li&gt;
&lt;li&gt;&#39;.&#39;yyyy-MM-dd-a: Rota el archivo a la media noche y al media día, todos los días&lt;/li&gt;
&lt;li&gt;&#39;.&#39;yyyy-MM-dd-HH: Rota el archivo al inicio de cada hora&lt;/li&gt;
&lt;li&gt;&#39;.&#39;yyyy-MM-dd-HH-mm: Rota el archivo al inicio de cada minuto &lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;b&gt;SocketAppender&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Redirecciona los mensajes de logs hacia un servidor remoto de log.&lt;br /&gt;
&lt;br /&gt;
El mensaje de log se almacenará en el servidor remoto sin sufrir alteraciones en los datos (como fecha, tiempo desde que se inicio la aplicación, NDC), exactamente como si hubiese sido guardado localmente.&lt;br /&gt;
&lt;br /&gt;
El SocketAppender no utiliza Layout. Únicamente serializa el objeto LoggingEvent para enviarlo.&lt;br /&gt;
Utiliza TCP/IP, consecuentemente si el servidor es accesible el mensaje eventualemente arribará al servidor. Si el servidor remoto está abajo, la petición de log será simplemente rota. Cuando el servidor vuelva a estar disponible la transmisión se reasume transparentemente.Esta reconexión transparente es realizada por un connector thread que periodicamente revisa si existe conexión con el servidor.&lt;br /&gt;
&lt;br /&gt;
Los eventos de logging son automaticamente almacenados en memoria por la implementación nativa de TCP/IP. Esto quiere decir que si la conexión hacia el servidor de logs es lenta y la conexión con los clientes es rápida, los clientes no se ven afectados por la lentitud de la red.&lt;br /&gt;
&lt;br /&gt;
El SocketAppender tiene las siguientes propiedades:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Threshold=WARN: Este parámetro establece que el appender no despliega ningún mensaje con prioridad menor a la especificada aquí.&lt;/li&gt;
&lt;li&gt;ImmediateFlush=true: El valor por defecto es true, esto quiere decir que los mensajes de log no son almacenados en un buffer, sino que son enviados directamente al destino.&lt;/li&gt;
&lt;li&gt;port=6548: Especifica el puerto por el que se va a comunicar al servidor de logs.&lt;/li&gt;
&lt;li&gt;remoteHost=192.168.10.225: Especifica la máquina donde se encuentra el servidor de logs.&lt;/li&gt;
&lt;li&gt;reconnectionDelay=300: El valor por defecto es de 30000 milisegundos, que corresponden a 30 segundos. Es un valor entero que corresponde al número de milisegundos que va a esperar para volver a intentar conectarse con el servidor cuando se ha perdido comunicación con este. &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;b&gt;SMTPAppender&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Envia un mail con los mensajes de logs, típicamente se utiliza para los niveles ERROR y FATAL.&lt;br /&gt;
&lt;br /&gt;
El número de eventos de log enviados en el mail depende del valor de BufferSize. El SMTPAppender mantiene únicamente el último BifferSize en un buffer cíclico.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Threshold=WARN: Este parámetro establece que el appender no despliega ningún mensaje con prioridad menor a la especificada aquí.&lt;/li&gt;
&lt;li&gt;ImmediateFlush=true: El valor por defecto es true, esto quiere decir que los mensajes de log no son almacenados en un buffer, sino que son enviados directamente al destino.&lt;/li&gt;
&lt;li&gt;To=direccion1@dominio.com: Especifica la dirección de correo a donde se enviará el mail.&lt;/li&gt;
&lt;li&gt;From=direccion2@dominio.com: Especifica la dirección de correo desde donde se envia el mail.&lt;/li&gt;
&lt;li&gt;SMTPHost=&lt;a href=&quot;http://mail.dominio.com/&quot;&gt;mail.dominio.com&lt;/a&gt;: Especifica el servidor de SMTP que se va a utilizar para enviar el mail.&lt;/li&gt;
&lt;li&gt;Subject=Mensajes de Logs: Especifica el asunto del mail.&lt;/li&gt;
&lt;li&gt;LocationInfo=true: El valor por defecto es false. Envía información acerca de la ubicación donde se generó el evento de log.&lt;/li&gt;
&lt;li&gt;BufferSize=20: El valor por defecto es 512. Representa el número máximo de eventos de logs que serán recolectados antes de enviar el mail. &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;b&gt;JDBCAppender&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Este appender redirecciona los mensajes de log hacia una base de datos.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Threshold=WARN: Este parámetro establece que el appender no despliega ningún mensaje con prioridad menor a la especificada aquí.&lt;/li&gt;
&lt;li&gt;ImmediateFlush=true: El valor por defecto es true, esto quiere decir que los mensajes de log no son almacenados en un buffer, sino que son enviados directamente al destino.&lt;/li&gt;
&lt;li&gt;Driver=mm.mysql.Driver: Define el driver a ser utilizado, asegurese de tener la clase en el CLASSPATH.&lt;/li&gt;
&lt;li&gt;URL=jdbc:mysql://localhost/LOG4JDemo: Es la cadena de conexión que se utilizará.&lt;/li&gt;
&lt;li&gt;ser=default: El usuario de la base de datos.&lt;/li&gt;
&lt;li&gt;password=default: La clave para poder ingresar a la base de datos.&lt;/li&gt;
&lt;li&gt;sql=INSERT INTO TABLA (Message) VALUES (&#39;%d - %c - %p - %m&#39;): La instrucción SQL que se utiliza para grabar el mensaje en la base de datos. Si se desea se puede guardar cada valor en columnas separadas,por ejemplo: INSERT INTO JDBCTEST (Date, Logger, Priority, Message) VALUES (&#39;%d&#39;, &#39;%c&#39;, &#39;%p&#39;, &#39;%m&#39;). &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;b&gt;Otros appeders:&lt;/b&gt;&lt;br /&gt;
SyslogAppender: redirecciona los mensajes de logs sistemas operativos Unix. &lt;br /&gt;
&lt;br /&gt;
NTEventLogAppender: redirecciona los mensajes de logs hacia los logs del sistema de NT. &lt;br /&gt;
&lt;br /&gt;
JMSAppender: serializa los eventos y los transmite como un mensaje JMS tipo ObjectMessage. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Layouts&lt;/span&gt; &lt;br /&gt;
&lt;br /&gt;
Es el responsable de dar un formato de presentación a los mensajes. Permite presentar el mensaje con el formato necesario para almacenarlo simplemente en un archivo de texto .log (SimpleLayout y PatternLayout), en una tabla HTML (HTMLLayout), o en un archivo XML (XMLLayout).&lt;br /&gt;
Además podemos añadir información extra al mensaje, como la fecha en que se generó, la clase que lo generó, el nivel que posee, etc. Inclusive se pueden crear layouts propios. Basta con heredar de la clase org.apache.log4j.Layout.&lt;br /&gt;
Los layouts que vienen con el PI son: DateLayout, HTMLLayout, PatternLayout, SimpleLayout, XMLLayout.&lt;br /&gt;
SimpleLayout, como lo indica su nombre, es algo simple: nivel de prioridad, un &quot;-&quot; y el mensaje en cuestión. Por ejemplo: INFO - Hola Mundo!&lt;br /&gt;
&amp;nbsp;El más utilizado es PatternLayout ya que permite darnos la libertad de utilizar la creatividad para crear el formato de los mensajes. Para ello, debemos aprender algunos patrones:&lt;br /&gt;
&lt;ul style=&quot;color: #f9cb9c;&quot;&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %m: muestra el mensaje.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %p: muestra el nivel de prioridad.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %r: muestra los milisegundos desde que comenzo la aplicación hasta el evento que se logueó.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %t: muestra el nombre del thread que loguel el evento.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %x: muestra el NDC&amp;nbsp; del thread que loguel el evento.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %n: deja un renglón, con lo cual nos olvidamos de &quot;\n&quot; o &quot;\r\n&quot;.&lt;/li&gt;
&lt;li&gt;&amp;nbsp; &amp;nbsp; %c: categoría del evento que figura en la configuración. &lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %%: muestra un signo de porcentaje.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %d: muestra la fecha del vento, que se le puede dar un formato determinado, por ejemplo %d{HH:mm:ss,SSS} o %d{dd MMM yyyy HH:mm:ss,SSS}. &lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %C: muestra el nombre de la clase que logueo el evento.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %M: muestra el método de la clase que logueo el evento.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %L: muestra el número de línea donde se logueo el evento.&lt;/li&gt;
&lt;/ul&gt;
&lt;i&gt;Obviamente utilizar la fecha (el&amp;nbsp; %d) hace el logueo más pesado.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Opcionalmete, se puede especificar los márgenes de cada uno:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #f9cb9c;&quot;&gt;Se utiliza el signo menos (-), seguido de un entero para el margen izquierdo.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;color: #f9cb9c;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Se utiliza un entero para el margen derecho.&lt;/li&gt;
&lt;li style=&quot;color: #f9cb9c;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Se utiliza un punto (.) con un entero para el ancho mínimo.&lt;/li&gt;
&lt;/ul&gt;
Ejemplos:&lt;br /&gt;
&amp;nbsp; %20p: espacios que tenrá a la derecha el nivel de prioridad.&lt;br /&gt;
&amp;nbsp; %-20p: espacios que tenrá a la izquierda el nivel de prioridad.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwafrfxlf0PtyBS5oWj4wT561bhWrGmMqkEYv4UsIbicyjcYKOXTGr7Rb9ol3-WudwL5KAvoCNZvEp9mkxTU7vbKr-caey_GDgpHTKh1IqjH_jmVsai69lbbA2sePf5ZkV_gXgqJ0BJZs/s1600/layout.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwafrfxlf0PtyBS5oWj4wT561bhWrGmMqkEYv4UsIbicyjcYKOXTGr7Rb9ol3-WudwL5KAvoCNZvEp9mkxTU7vbKr-caey_GDgpHTKh1IqjH_jmVsai69lbbA2sePf5ZkV_gXgqJ0BJZs/s1600/layout.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Configuración del entorno.&lt;/span&gt; &lt;br /&gt;
&lt;br /&gt;
El entorno log4j es completamente configurable programaticamente. Sin embargo, es mucho más flexible configurar log4j usando archivos de configuración . Estos archivos pueden estar escritos en XML o en Java properties (formato key=value). &lt;br /&gt;
&lt;br /&gt;
Veamos un ejemplo, con un archivo properties donde se colocan dos appenders: uno para realizar una salida por consola y otro para que guarde un archivo. Por otro lado, cada appender tiene un nivel de prioridad distinto.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: #f9cb9c;&quot;&gt;
log4j.rootCategory= miArchivo, miConsola&lt;br /&gt;
# Indica alias para las salidas de log, podemos tener varias&lt;br /&gt;
&lt;br /&gt;
log4j.appender.miArchivo=org.apache.log4j.FileAppender&lt;br /&gt;
# Appender miArchivo (lugar donde se envian los mensajes) es un archivo&lt;br /&gt;
&lt;br /&gt;
log4j.appender.miArchivo.Threshold=INFO&lt;br /&gt;
# No mostrará mensajes por debajo del nivel INFO&lt;br /&gt;
&lt;br /&gt;
log4j.appender.miArchivo.ImmediateFlush=true&lt;br /&gt;
#&amp;nbsp; Se vuelca el mensaje inmediatamente en el appender&lt;br /&gt;
&lt;br /&gt;
log4j.appender.miArchivo.file=C:/Users/Admin/Documents/Java/logFile.log&lt;br /&gt;
#&amp;nbsp; Archivo (appender)&lt;br /&gt;
&lt;br /&gt;
log4j.appender.miArchivo.layout=org.apache.log4j.PatternLayout&lt;br /&gt;
#&amp;nbsp; Tipo de diseño de los mensajes&lt;br /&gt;
&lt;br /&gt;
log4j.appender.miArchivo.layout.ConversionPattern=%d %-5p %C.%M(%L)===&amp;gt; %m%n&lt;br /&gt;
# Diseño&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
log4j.appender.miArchivo.append=false&lt;br /&gt;
# No añade, borra el contenido anterior &lt;br /&gt;
&lt;br /&gt;
log4j.appender.miConsola=org.apache.log4j.ConsoleAppender&lt;br /&gt;
# Appender de miConsola&lt;br /&gt;
&lt;br /&gt;
log4j.appender.miConsola.Threshold=DEBUG&lt;br /&gt;
# No mostrará mensajes por debajo del nivel INFO&lt;br /&gt;
&lt;br /&gt;
log4j.appender.miConsola.layout=org.apache.log4j.PatternLayout&lt;br /&gt;
# miConsola utiliza PatternLayout&lt;br /&gt;
&lt;br /&gt;
log4j.appender.miConsola.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n&lt;br /&gt;
# Diseño&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiF-Ur_KvwsLPOYfWT1i0gfdqVrdasvxrBqZ2fxWmy9cCIaHrnLpwq_WKXpK8lTss-S1NVJuOAerczL39AMIzZv6XFIVxI7lyySnXVY2pQQ34iuUf3zojwKRqONQVculPbwuRUPOYtE6uA/s1600/main.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiF-Ur_KvwsLPOYfWT1i0gfdqVrdasvxrBqZ2fxWmy9cCIaHrnLpwq_WKXpK8lTss-S1NVJuOAerczL39AMIzZv6XFIVxI7lyySnXVY2pQQ34iuUf3zojwKRqONQVculPbwuRUPOYtE6uA/s1600/main.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Como se puede observar en el ejemplo, usarlo es muy sencillo, basta con decirle a Log4j que nuestra clase quiere guardar log mediante la sentencia Logger.getLogger(Clase.class) y listo. Con eso es suficiente para utilizarlo. Si prestan atención cuando se loguea un mensaje, se coloca el nivel de prioridad.&lt;br /&gt;
Veremos como quedó el archivo que grabó el log con un nivel de prioridad distinto al de la consola:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZtxFUh5nmTPwKp-9DdHOdRpwIk_569AoxI32gmYftddWl8JS4yau8CmBcggBdULaFFhRVtEug8SHmUutgJxyya-bsU2Qtb_uOT26sFVVGkRtVZgBR-EUtZmj9Fz2YCoq4qcdLBCN95uw/s1600/salida.png&quot; /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/5330601996861793967/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/5330601996861793967' title='13 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/5330601996861793967'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/5330601996861793967'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/07/log4j.html' title='Log4j'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2FRUm3AALsOFT0XNWnDVsuew9IxSJcDG4co6btw1SRA4z41Id7kDLbIdh5RCcZdvqXnBZWhxlGVS5uZ8u6Zmjopi3g58FVkPPW1ip16hMemqcqpgY6nmEJ5gvKBuo5vaaA4taevWxw6Y/s72-c/page.png" height="72" width="72"/><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-5255686128376166713</id><published>2011-07-14T00:47:00.003-03:00</published><updated>2011-07-16T15:09:49.912-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Spring"/><category scheme="http://www.blogger.com/atom/ns#" term="Spring Core"/><title type='text'>Spring Core</title><content type='html'>Continuando con el post anterior de introducción a Spring, que se puede ver en &lt;a href=&quot;http://migranitodejava.blogspot.com/2011/06/introduccion-spring.html&quot;&gt;http://migranitodejava.blogspot.com/2011/06/introduccion-spring.html&lt;/a&gt;, vamos a profundizar algunos temas.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Creando Beans.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
En Spring hay diversas formas de crear un bean. En el ejemplo de la introducción a Spring vimos una opción donde colocábamos la ruta del xml de configuración:&lt;br /&gt;
&lt;b&gt;ApplicationContext respuesta = &lt;br /&gt;
new FileSystemXmlApplicationContext(&quot;C:/Users/max/eclipse workspace/spring.xml&quot;);&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Esta forma de crear beans esta bien para un ejemplo o aplicaciones muy chicas, pero es poco práctico para el resto de los casos. Spring nos brinda formas alternativas a FileSystemXmlApplicationContext y las más utilizadas son:&lt;br /&gt;
&lt;u&gt;ClassPathXmlApplicationContext&lt;/u&gt;: busca el xml en el classpath, para mi gusto es la mejor opción.&lt;br /&gt;
&lt;u&gt;XmlWebApplicationContext&lt;/u&gt;: el xml se encuentra en un contexto de una aplicación web.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ciclo de vida de un bean.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
En Spring la vida de un objeto difiere de la forma tradicional: existen más oportunidades para aprovechar en la creación o destrucción de un bean. Las distintas etapas son:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Instanciación del bean.&lt;/li&gt;
&lt;li&gt;Inyección de propiedades.&lt;/li&gt;
&lt;li&gt;Nombre del bean: si el bean implementa &lt;i&gt;BeanNameAware&lt;/i&gt;, Spring le pasa el id en el método setBeanName(). De esta forma, sabe cual es su id según el xml de Spring.&lt;/li&gt;
&lt;li&gt;Contexto: si el bean implementa &lt;i&gt;ApplicationContextAware&lt;/i&gt;, Spring llama al método setApplicationContext() y le pasa el contexto como parámetro. &lt;/li&gt;
&lt;li&gt;Post proccessor: si hay un &lt;i&gt;BeanPostProccessor&lt;/i&gt;, Spring llama al método postProccessBeforeInitialization().&lt;/li&gt;
&lt;li&gt;Inicializar bean: si implementa &lt;i&gt;InitializingBean&lt;/i&gt;, se llama a afterPropertiesSet().&lt;/li&gt;
&lt;li&gt;Post proccessor  (de nuevo!): si hay un &lt;i&gt;BeanPostProccessor&lt;/i&gt;, Spring también llama al método postProccessAfterInitialization().&lt;/li&gt;
&lt;li&gt;El bean esta listo para ser utilizado!&lt;/li&gt;
&lt;li&gt;Destrucción del bean: si implmenta &lt;i&gt;DisposableBean &lt;/i&gt;se llama a destroy().&lt;/li&gt;
&lt;/ol&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKcNyx5tsC-bECG-MSkgTU664cQqziLzIPqOjL11udDMvxjmGgWcm4yATZlJx4_OCmsdkNYzidxAZHpZwvKG-vgDyZZWgpwTVSFxuDHgtmywD1Nv6_8Jp68gVxgyhHw4FZv4cyPPLXV1U/s1600/beanAware.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKcNyx5tsC-bECG-MSkgTU664cQqziLzIPqOjL11udDMvxjmGgWcm4yATZlJx4_OCmsdkNYzidxAZHpZwvKG-vgDyZZWgpwTVSFxuDHgtmywD1Nv6_8Jp68gVxgyhHw4FZv4cyPPLXV1U/s1600/beanAware.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Y agregamos lo siguiente al xml:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;persona&quot; class=&quot;ejemplo.Persona&quot; &amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;nombre&quot; value=&quot;Maxi&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHIRaOvzISRCa46KOm81a2oRIWV2NG_AkGz5rDMrJKFMDr1tJ1-BUWS5qit4vE5zVspTHE-xpwpO4wyL7Y8hCsit7OJvYbgBXSHP-8cj6voXFL9aO9kNmojOlx0CxZ5k6gpNdtAAxBrLc/s1600/mainBeanAware.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHIRaOvzISRCa46KOm81a2oRIWV2NG_AkGz5rDMrJKFMDr1tJ1-BUWS5qit4vE5zVspTHE-xpwpO4wyL7Y8hCsit7OJvYbgBXSHP-8cj6voXFL9aO9kNmojOlx0CxZ5k6gpNdtAAxBrLc/s1600/mainBeanAware.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Inyección por constructores.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Es posible instanciar objetos con un constructor distinto al vacío. Para ello existe un tag llamado &lt;b&gt;&amp;lt;constructor-arg&amp;gt;&lt;/b&gt; que posee dos atributos importantes: &lt;b&gt;ref &lt;/b&gt;y &lt;b&gt;value&lt;/b&gt;. Por ejemplo, si tenemos un constructor que recibe un int podriamos hacer lo siguiente:&lt;br /&gt;
&lt;b&gt;&amp;lt;constructor-arg value=”100” /&amp;gt; &lt;/b&gt;&lt;br /&gt;
Pero si se recibe un objeto compuesto se deberá usar el atributo ref que hace referencia a otro bean de Spring y se lo llama por su id:&lt;br /&gt;
&lt;b&gt;&amp;lt;constructor-arg ref=”persona” /&amp;gt; &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Veamos un ejemplo:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguIE7C0yPjP4VtXTUrdQFZHdVsdFj3tIQB7iDfg4v5lrBA7yj1yGPTcyPI7Kc0SI034D1J_Gug75eHg_Ns_Z7tCGddcmacGnZMCB8PEk5_gEdCzhjqnJX86IxodiHMZv8UtSVzv-H07uE/s1600/personaConstructor.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguIE7C0yPjP4VtXTUrdQFZHdVsdFj3tIQB7iDfg4v5lrBA7yj1yGPTcyPI7Kc0SI034D1J_Gug75eHg_Ns_Z7tCGddcmacGnZMCB8PEk5_gEdCzhjqnJX86IxodiHMZv8UtSVzv-H07uE/s1600/personaConstructor.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&amp;nbsp;Y el xml:&lt;br /&gt;
&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;persona&quot; class=&quot;ejemplo.Persona&quot; &amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg value=&quot;100&quot; /&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg value=&quot;Perez&quot; /&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;nombre&quot; value=&quot;Maxi&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJAnFVHdCchZb-SjYzM0_ZQ34k025EPkXzt6ic_Ztc1OBpaJXc56jjL7eOrirJ0rqnMlenXrRoYGa4rxdRxIMl9ldf_PEgainpdlwCzK-NDeeKJGJEo6TsMn_C-U14t5-FsjwdVov0D8c/s1600/mainConstructor.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJAnFVHdCchZb-SjYzM0_ZQ34k025EPkXzt6ic_Ztc1OBpaJXc56jjL7eOrirJ0rqnMlenXrRoYGa4rxdRxIMl9ldf_PEgainpdlwCzK-NDeeKJGJEo6TsMn_C-U14t5-FsjwdVov0D8c/s1600/mainConstructor.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Entonces …¿conviene inyectar por constructor o por setter?&lt;br /&gt;
&lt;br /&gt;
Es muy útil la inyección por constructor por varios motivos. Primero, a diferencia de la mayoría de frameworks que nos obligan a que casi todas nuestras clases sean pojos (y por lo tanto usen el constructor vacío), aquí esto no supone un problema y es Spring quien se adapta y nos da la libertad de trabajar como queremos. Por otro lado, obligamos a que, cuando se crea un objeto, se lo haga de la forma adecuada (con todas sus dependencias creadas si o si).&lt;br /&gt;
Por otro lado, inyectar por constructor puede hacer engorrosa la herencia y si el bean tiene muchas dependencias se vuelve cada vez más complicado.&lt;br /&gt;
Particularmente prefiero inyectar por setter, pero es bueno tener ambas posibilidades.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Inyectar beans exclusivos.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Hay situaciones donde un bean debería ser una dependencia de otro de manera exclusiva. El problema del archivo xml de Spring es que una vez declarado, el bean puede ser dependencia de cualquiera. Por ejemplo:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;liz&quot; class=&quot;ejemplo.Persona&quot; &amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg value=&quot;3&quot; /&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg value=&quot;Juarez&quot; /&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;nombre&quot; value=&quot;Liz&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;documento&quot; ref=&quot;documentoLiz&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;documentoLiz&quot; class=&quot;ejemplo.Documento&quot; &amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;tipo&quot; value=&quot;DNI&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;numero&quot; value=&quot;123456789&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Hasta aquí nada sobresaliente, simplemente hemos agregado a la clase Persona un objeto Documento y lo hemos vinculado para que funcionen en conjunto.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZdyNIpX1LjWmXrMa1O4EOOlNZgox5carr-n4pT-SOlgFx8KULDbqkiE92oBAMjnzWQjyQXnXJpjDvABtR3gFn82JDOeaz9vTl1yzG8ToiXfsLnJoKo0yozLbQi0kIhN3Zq7E50qQV_GA/s1600/documento.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZdyNIpX1LjWmXrMa1O4EOOlNZgox5carr-n4pT-SOlgFx8KULDbqkiE92oBAMjnzWQjyQXnXJpjDvABtR3gFn82JDOeaz9vTl1yzG8ToiXfsLnJoKo0yozLbQi0kIhN3Zq7E50qQV_GA/s1600/documento.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYshf6WIKplZHpvjoyexkM-7DU0HrJ-HnP6526QwJyBUZixJmri5zhesU8CaVwk9k2TZapncH5Z1GmXJgjwn4Rgi4TnU166QooQevWR4nVV1bnLTsHXlaedOg31HfhRPXyiQBMaQs_YSw/s1600/personaDocumento.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYshf6WIKplZHpvjoyexkM-7DU0HrJ-HnP6526QwJyBUZixJmri5zhesU8CaVwk9k2TZapncH5Z1GmXJgjwn4Rgi4TnU166QooQevWR4nVV1bnLTsHXlaedOg31HfhRPXyiQBMaQs_YSw/s1600/personaDocumento.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Pero hay un pequeño problema. ¿Que pasa si agregamos lo siguiente en el xml?&lt;br /&gt;
&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;leo&quot; class=&quot;ejemplo.Persona&quot; &amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg value=&quot;30&quot; /&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg value=&quot;Gonzalez&quot; /&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;nombre&quot; value=&quot;Leo&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;documento&quot; ref=&quot;documentoLiz&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;br /&gt;
Leo esta usando el documento de Liz!! Eso no es correcto y, por ello, Spring permite crear beans exclusivos de la siguiente manera:&lt;br /&gt;
&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;liz&quot; class=&quot;ejemplo.Persona&quot; &amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg value=&quot;3&quot; /&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg value=&quot;Juarez&quot; /&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;nombre&quot; value=&quot;Liz&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;documento&quot;&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;bean class=&quot;ejemplo.Documento&quot; &amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;property name=&quot;tipo&quot; value=&quot;DNI&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;property name=&quot;numero&quot; value=&quot;123456789&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/property&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;Observamos que Spring permite definir un bean dentro de una propiedad que no lleva el atributo &lt;b&gt;id&lt;/b&gt; y, por lo tanto, no es posible referenciarlo de ninguna manera.&lt;br /&gt;
Hay que tener mucho cuidado al crear objetos de este tipo ya que estaremos impidiendo la reutilización del código.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Scope de un bean.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Por defecto, todos los beans de Spring son Singletons. Si no se conoce dicho patrón se puede leer en &lt;a href=&quot;http://migranitodejava.blogspot.com/2011/05/singleton.html&quot;&gt;http://migranitodejava.blogspot.com/2011/05/singleton.html&lt;/a&gt;&lt;br /&gt;
Spring sólo crea una única instancia de cada objeto en su contenedor y luego la reutiliza. Todos sabemos que en ciertos casos esto no es conveniente, por lo que nos da la opción de cambiarlo. Para ello, en la etiqueta &lt;b&gt;bean &lt;/b&gt;hay un atributo llamado &lt;b&gt;scope &lt;/b&gt;que puede tomar los siguientes valores:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;b&gt;Singleton&lt;/b&gt;: es el valor default e implica una única instancia.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;prototype&lt;/b&gt;: se instancia todas las veces que sea necesario.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;request&lt;/b&gt;: válido en Spring MVC, donde es instanciado por cada petición HTTP.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;session&lt;/b&gt;: válido en Spring MVC, donde es instanciado por cada usuario.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;global-session&lt;/b&gt;: válido en Spring MVC, donde es instanciado en una session global HTTP.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;i&gt;Ojo si usan una versión anterior a Spring 2 que esto se trata de manera diferente.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Como  se habrán dado cuenta, este singleton de Spring tiene una  particularidad: no es realmente un Singleton. Es decir, Spring nos  asegura que nos devolverá una única instancia pero nada impide que haga  un&lt;span style=&quot;color: magenta;&quot;&gt; new Object().&lt;/span&gt;&lt;br /&gt;
Muchas veces nosotros necesitamos controlar el Singleton para evitar problemas. Para ello Spring nos brinda una solución:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwYimT4TfCW_XBwkR20ZjR3DDG8-qWItFFtBCIBMIKbCzhOp4KdUnjENi1YXSGsRzqVm4YnPU_ADqj3tZpENOkXBdWgBDA82rKA7Ta-T0quS2Z1T1zC7rZ_ZF433TiSi6Shmt7L6jqXvU/s1600/fechautils.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwYimT4TfCW_XBwkR20ZjR3DDG8-qWItFFtBCIBMIKbCzhOp4KdUnjENi1YXSGsRzqVm4YnPU_ADqj3tZpENOkXBdWgBDA82rKA7Ta-T0quS2Z1T1zC7rZ_ZF433TiSi6Shmt7L6jqXvU/s1600/fechautils.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&amp;nbsp;Y en el xml definimos cual es el método encargado de crear el bean:&lt;br /&gt;
&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;fechaUtils&quot; class=&quot;calendario.FechaUtils&quot;&lt;b&gt; factory-method=&quot;getInstance&quot;&lt;/b&gt;/&amp;gt;&lt;/div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpIlNIB6Oft_kJANdRwSHG7WUZQtOWHhTx4eeILPYDklFKpOjR1SGrrTADxzzLZdtOtuLsH-gligGGzWGpZGMO4tjsD3v-j0STYJeTZ74gMWiYHnJCUMPqYGpgXgbenTR7Nxf5VEK-pKg/s1600/fechaumsain.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpIlNIB6Oft_kJANdRwSHG7WUZQtOWHhTx4eeILPYDklFKpOjR1SGrrTADxzzLZdtOtuLsH-gligGGzWGpZGMO4tjsD3v-j0STYJeTZ74gMWiYHnJCUMPqYGpgXgbenTR7Nxf5VEK-pKg/s1600/fechaumsain.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
De esta forma, es posible adaptar a Spring para que instancie los objetos como nosotros le digamos. Este ya si es un Singleton propiamente dicho.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Autoconexión&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
Vimos que es posible conectar las propiedades mediante un constructor o los métodos setters. Hasta aquí se hizo de manera explícita en el archivo xml. Pero se puede hacer que Spring resuelva esto por nosotros mediante el atributo autowire de cada bean. Hay 4 tipos de autoconexión:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;u&gt;byName&lt;/u&gt;: es la más común, ya que conecta por ID (ver el ejemplo). Si no se encuentra un bean correspondiente la propiedad queda sin conectar.&lt;/li&gt;
&lt;li&gt;&lt;u&gt;byType&lt;/u&gt;: busca un único bean en el contenedor cuyo tipo sea correspondiente con la propiedad a conectar. Si no se encuentra no conecta, pero si encuentra más de una lanza una UnsatisfiedDependenciException.&lt;/li&gt;
&lt;li&gt;&lt;u&gt;constructor&lt;/u&gt;: busca uno o más beans del contenedor que correspondan con los parámetros del constructor del bean a conectar. Si no puede resolverlo lanza una UnsatisfiedDependenciException.&lt;/li&gt;
&lt;li&gt;&lt;u&gt;autodetect&lt;/u&gt;: intenta primero conectar por constructor y luego byType. &lt;/li&gt;
&lt;/ol&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSKbdVjpm-qL9EUaw-PH2Hwbm2jUC9tpyN54_X-4oi-nx7YWR1G1nSso94fS4Vlfob_MhYbK6WxOacpZdbQlacqqcYjv4quSZkgvYKwBAysX1MYmw6o2am4NSWurpAahF5wx9qaJbCrbk/s1600/domicilio.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSKbdVjpm-qL9EUaw-PH2Hwbm2jUC9tpyN54_X-4oi-nx7YWR1G1nSso94fS4Vlfob_MhYbK6WxOacpZdbQlacqqcYjv4quSZkgvYKwBAysX1MYmw6o2am4NSWurpAahF5wx9qaJbCrbk/s1600/domicilio.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Y en el xml:&lt;br /&gt;
&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;persona&quot; class=&quot;ejemplo.Persona&quot; scope=&quot;prototype&quot; &lt;b&gt;autowire=&quot;byName&quot;&lt;/b&gt;&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg value=&quot;100&quot; /&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg value=&quot;Perez&quot; /&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;nombre&quot; value=&quot;Maxi&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;domicilio&quot; class=&quot;ejemplo.Domicilio&quot; &amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;calle&quot; value=&quot;Av. Rivadavia&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;numero&quot; value=&quot;948&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;localidad&quot; value=&quot;Bs As&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqn-kvel9yKRajNjoxnEfHgFONn3w7dPVQZ-yzs9YsJp_H0tK6JGPEQ5t-M1NpsF8T9X9ozgcSYNB2n-g8g9d7SS4l2ExRzEGs3blkYzQOgqQr-Fkd0BOHVM-Minem6Aq9qU8R3TmfoXk/s1600/autowireMain.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqn-kvel9yKRajNjoxnEfHgFONn3w7dPVQZ-yzs9YsJp_H0tK6JGPEQ5t-M1NpsF8T9X9ozgcSYNB2n-g8g9d7SS4l2ExRzEGs3blkYzQOgqQr-Fkd0BOHVM-Minem6Aq9qU8R3TmfoXk/s1600/autowireMain.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Autoconexión por defecto.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Por defecto, los beans no se conectan. Pero esto se puede cambiar en la etiqueta beans:&lt;br /&gt;
&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;beans default-autowire=&quot;byName&quot;&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;...&lt;/div&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;/beans&amp;gt;&lt;/span&gt;&lt;br /&gt;
De esta forma, le estamos diciendo a Spring que conecte por byName por defecto, lo que se puede sobreescribir en cualquier etiqueta bean.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Colecciones&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
Voy a asumir que  ya todos conocen el concepto de List, Set, Map y las colecciones más  importantes de Java, como por ejemplo Properties. Así que iré  directamente a un ejemplo integrador donde se mostrará como configurar  Spring para cada tipo de colección. De todas maneras, es muy intuitivo  entenderlo.&lt;br /&gt;
&lt;br /&gt;
List, set y arrays funcionan de manera similar. Cuando son array o list simplemente debo confgurar el xml de la siguiente manera (si son sets, solo hay que cambiar &amp;lt;list&amp;gt; por &amp;lt;set&amp;gt;):&lt;br /&gt;
&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;persona&quot; class=&quot;ejemplo.Persona&quot; &amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;lt;property name=&quot;telefonos&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;list&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;ref=&quot;telefono1&quot;&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;ref=&quot;telefono2&quot;&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;ref=&quot;telefono3&quot;&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/list&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;lt;/property&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: white;&quot;&gt;Y un Map sería:&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;map&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;entry key=&quot;clave1&quot; value=&quot;valor1&quot;&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;entry key=&quot;clave2&quot; value=&quot;valor2&quot;&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/map&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;Tanto en la clave como en el valor es posible referenciar a otros beans en lugar de poner Strings. Para ello, en vez de key debemos colocar key-ref donde haremos referencia hacia el id de otro bean. Lo mismo ocurre en el valor: en vez de value debemos colocar value-ref. &lt;br /&gt;
&lt;br /&gt;
En cuanto a los properties (clase java.util.Properties) se hace de la siguiente manera:&lt;br /&gt;
&lt;div style=&quot;color: #f6b26b;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;props&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;prop key=&quot;clave1&quot; &amp;gt;valor1&amp;lt;/prop&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;prop key=&quot;clave2&quot;&amp;gt;valor2&amp;lt;/prop&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/props&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: magenta;&quot;&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Herencia entre beans.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Es posible utilizar herencia dentro de los beans declarados en el xml de Spring, lo cual nos puede permitir que nuestro archivo se reduzca en cuanto a la cantidad de líneas que tenemos que escribir. Para ello, el tag bean posee 2 atributos que, hasta ahora, no hemos utilizado. Estos son:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;parent: indica quien es el padre (como un extends).&lt;/li&gt;
&lt;li&gt;abstract: indica si es un bean abstracto que me sirve solo como modelo pero que nunca se va a instanciar. Toma valores true o false.&lt;/li&gt;
&lt;/ul&gt;Por ejemplo, supongamos que en una empresa los empleados tienen, en su gran mayoría, el mismo domicilio y telefono laboral. Solo cambiar su interno.&lt;br /&gt;
&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;empleado&quot; class=&quot;ejemplo.Empleado&quot; abstract=&quot;true&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;domicilioLaboral&quot; value=&quot;Av. Rivadavia 123&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;telefonoLaboral&quot; value=&quot;49876648&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;Luego, cada vez que quiera crear un empleado solo debo hacer lo siguiente:&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;juan&quot; parent=&quot;empleado&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;Si un empleado no tiene, por ejemplo, ese domicilio laboral, entonces se lo puede sobreescribir: &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;sergio&quot; parent=&quot;empleado&quot;&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;domicilioLaboral&quot; value=&quot;Av. Cordoba 233&quot;/&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;/bean&amp;gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: magenta;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: magenta;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVIAAADKCAIAAAB49V8iAAAQTklEQVR4nO2dMWKrOBBAdS7dw1fQCdLnCnKRU7hIpzpp6Z2GJk0ap96aLQBpBAJjx8Z8z3vVLgiQf3jMSCDJNACgDPPoCgDA2qA9gDou175+fzO7V7M7hMLOX//yanavZvfqqtHO6mB2b/7nilqeZfa69yM402O93FF722+uV6zPOWpvt1YleATXRfvqMKF9y5dbWb+HXrf21vrgCjbV3m7Ksa3VBx6FaZqmj94/n3b3anavZv/VNE3T/6+rvtyui6Xdrlb7WP7lM7+XxvpNR+N4kvKpRsyVH19X1Hz3at9/444+ZxnWamr7NLW3LjRNyfuBZm0K4ELT9HmC9XW31VpnjDEudAmEC7G8iymFk0/aPp8Ybp+vKtpD00f76mB2b3bfKvTrX6JOmUhhL7VPyoX9Wf0mtv98WmFj2E+1HRaWn432P582NjGybOXXv/TnnNo+R2t96/1g11izui/dH1F3W1t3g4vCt8XinsHZvBW5enBmdOkiaA8tQvvU6k6GzGgvfJNGNcOjBMPt9ftb9ryoDvPR/lz5wnXDXqQGsZJ5ypAOmdo+TXAx1or/7Ou7XPvW2/4UUvty+fxKxSbGuKYLnw7w9CTtixov037o27Xan+Nc+dL5Yz2Hz6ZGNgHyqD61fYzo0yuk25vSvlgf0EnSvlc6S9qFSG0kFEl+lmz/IcnPg+1sV/+Z8sPzp+dUF/a7wvX7W9wui01tn2SY2A90LGovE/srtW+a/MSF9kURtIcWGe1b+Qf9ZGKjzxLmg0+9X31EjYXHXW5ylzx/nlefb0sXy09eN8Vt9x57KIf9drE+U9uLxHd0nbwx8FtfD5OAlAbIo7wzxljnbCwSXHt8382X9sTTy6fGpX16aA8txSQfnhTe20PTNPIFnng/BwDPDB/nAqgD7QHUgfYA6kB7AHWgPYA60B5AHWgPoI4ta3+baTl+/ctNBuGnz+KcO/sx7B+m2ei+1Lu6nhdR+8qYD2M+rP/vwkNPznwY+32XasGd2bL2t+Emc2/Iz1qXD2W79mPYpd/Y34raV5dr3zTNyaH9v8n9tU+TcA2m8WjSt/RpJo8XMeZ/cgKMQ8hG1B7C1HQao2/1k/9y1/lvEycFzqbVumqaDbnP9FNtCO0vnU7D2482gBtb2ahlOHYbS4F9oH2bAvT1zA+pv21/Hhcy7dN1zTGv5/C3wsNZJ9pPTuPRpNEy+69RQl4csRfT/olpMBYM/s8G5A7rM0XST4biEIIocOV4+3aiDJFMxEtcOp2GFDg4kYSHk6jnx6iew2hf+0rU89jvPTlT9dXJknxvxaMhHPPkH+03x4ral6bxaDrty/G2PG1GaSaciek0yidJqYQcULh4JFLtbdJvdiTcUu0Hw+XjONxrxtWfnClFXRGlYyQXF1ymffK/P2erd/1t3SmvZ4XkW2Y97adm45lpe5d2/XzaPsmPoX52Oo0J7f8y6CjOoyOj9FjSh2gvS8eoK6N0rnS/Be1VsZ72xWk8mou1b5qwb/sCkttT02k0TZM1HPonQttNkM0aNB/tM72zSTDysL9E+8I0G/l8XLLL8NLpNLwVvoWjaW2MfjZd2F+ifbel/rapbX9yIoOQjYjsuoOuvj7Hn685rMma0b40jYdIzvN3dVPTcjTDh0jTNFPTaYxPNdXbd2Z6j8G0GcWeuG6+DBfG5c3cNBt9wBdlXWreXzidhuhXy5L8+KLOmMq52GMnWwT5IalRUHl/TL16omvQuGNq3k83IoJb2hkJq/GQJB/0kCdKsA3We4HHNB4AG+H5P9cBgAFoD6AOtAdQB9oDqAPtAdSB9gDqQHsAdaA9gDrQHkAdaA+gDrQHUAfaA6gD7QHUgfYA6kB7AHWgPYA60B5AHWgPoA60B1AH2gOoA+0B1IH2AOpAewB1oD2AOranfb+cRnEVncK694nBurpXIhaad2fXnItrVV2+8ku2oPUD2ezvzdb/k8sNLidbaBAS29O+ac4unjWzWuYfkYtVyiUolx91CeeXsrwho/V4m2bLvzdbDbS44TzX1vP5WW8xrEP46Ral7JbE+olrVKaFK7tdrfax/GDpy9kl60sLY79OrqI5quzUjSKWphwXGBzVhsS4FPbUWpkuZBqINS6X3N6xQvkSmnKpzHw13tJCnNv9vd6Otl4e8NF+ivWWvnyz+1a5X/8S9csETutVt8vR9ormC2MPj2pmtv98WrGa7fkFrZtG3o7yJgshiAJXrmOfrQOZJb3eClWCOxt1Ux3yPFZWpPbWZJqVnyab/L3F0H7xKppoP8WK2qdWd7/O/Kz2ws9UvmWp9vX7W/a8qA7nor0k02Z2wemlGiQf0mGj0oWChZoJT9LVR1Fd1nRK+y3+3roQ7JtiCjDN8jaLQh6y0PWl2g99vlb7S4kxJ4szo5v2wdpn0XX6Rj+r/YZ+7y20L9YTWtbTPq1yLZJ2IWrbCBdJfpac/yHJT1uGWcOIPI2Md6fUrPZ2WfSTEVgkvdIOmfTKE5zv+pLlZcI8kwenQ4IzJb239HtJ8u/LmtG+lX/QryY2+r3oe9sdfNcXKBrksfC4i07ukufPu/Tio6SM6Mia7JmyzsUerEF5kQ6nA/IuN3mEc6m5O5tUF5AVstnNnSf64kzp0nHjdn8vXXp35SFJPtyS57y5b/ECj/f2U6z3Au9V5vnwZ8o98E/EDT7XgQm2+bkOANwRtAdQB9oDqAPtAdSB9gDqQHsAdaA9gDr0av/rX+40aP+G1L4y5sOYD+v/u/DQkzMfxn7fpVrwj6NX+/vN1XFzal9drn3TNCeH9lDiObTvP8hPM3YUv9WP3wiOvu131dlpP8bn7+b2cFU/ycei0X7efrQB3NjKRi3DsdtYCuwD7dsUoB9Mkx9Sf9v+PC5k2qfrmmP+ketwagx4ep5D+6Zpo3cvapfA1+9vYiyAnN6jmYj2EwOBJ87fbrQvB//Tnf/MUJ9M4OBEEh5OYmD8x2jE2zDa174SQ9uO/d6TM1Vvb5bkeyseDeGYJ/9or44n0z775j/NtCUH9gVR/mLth2MKvtxggPDZQQcnZ0pRV0TpGMnTzoXaJ//7c7Z619/WneThwVVIrpnn0r4wwd6kh9dof0n586SoK6N0rnS/Be3hhjyz9t3gv0zLPOcXM3yMZvuR035MnP9y7b0VvoWjaW2MfjZd2F+ifbel/rapbX9yIoOQjYjsuoOuvj7Hn604PBXPon1IU3Tk8+fkvXdZ21vsSttH0360u0rnz6brjeOLZ5v3ol8tS/LjizpjKudij51sEeSHpEZB5f0x9eqJrkHjjql5P92ICK44zwU8M8+iPVzJxTNVwROA9gDqQHsAdaA9gDrQHkAdaA+gDrQHUAfaA6gD7QHUsZ72fA0GsBFWjfbXrGcEALdmVe3HSyYDwPqgPYA6Vu7Sa9c4Z+QHwCMh2gOoA+0B1EFPPoA6eG8PoA6+0gNQB9oDqAPtAdSB9gDqQHsAdaA9gDrQHkAdaA+gDrQHUAfaA6gD7QHUgfYA6kB7AHWgPYA60B5AHWgPoA60B1AH2gOoA+0B1IH2AOpAewB1oD2AOtAeQB1oD6AOtAdQx/a0r9/fzO7V7A6lBXR+/cur2b2a3aurRjurg9m9+Z/7V/GS64b9q9m9mv3XWrXx1nQ456yfL1z3pS9fhjg4Y8y58+cVyy6y2Xr+hbvXs/b2it9Se5tXaXvaN00rUlH7li9X1H6rhP09tC8uI1oLt9pFxZecqh4YuZRwVldZVq6Ett163oK71vOKhSTH9bm/9il6/3zanQh9/f+66svtuhje7Wq1j+VfPvN/w7H201lAPEn5VON6dolGF6Vj3iHOY99/z1+3OsTCy7RP0c/a9ESv02ZT3NjGy5D2lG+44MRphgUGR7Wnb8/ZHpf2iku7kN2mok6F29LbbOtm6zmm/Hd5YD0vD/iP0L5pujTY7lvlfv1L1C8TOOnROtMrGvYDXaei/Wj7z6cVlob9VNtBlo/p+q9/6Y+tDkLsLzdM2kfXFWl/9zQ5o/1U9JN/r9pbk90W5btW3Kbi5gghiAKDI8e3RbYkeXD93uBMVk1RT3ErBzeK3oUQtcl6DpnMSh5ZT3nUIh6qfWr9JrtmtBd+ZjYOjxIMt9fvb9nzojrMRPtYB6F6V4dhuB62QQbXFc+L4uHlC6fwEe+iUVSXD/4p7SPZYyI/1ZW3abpf02Gj0oWCTT1WY5P1LFD6uzy6nnP/msUfMHq6rad9UeNl2g+9ulb7Jfx82j7Jz9KEe2svSE/3ucbeWe1FjM3iw+imerD2G6rnPPLv8tB6XqR9sT7raZ9ufZG0C2HaxrNI8jPr/pDkpy3DrKFM2LfdDaLkhUl+/f6Wngvyd02S/V1ERjyTz6VDgjMlbdLdI1uDtbfLolO3JesEznL1qcZI6Wk1SPI3W88h5b/Lg+v5TyX5h9D3cg0T736j34u+t93B531sWeFxF53cJc+fd+nJIDxb25Go8jzDyF+4buogjL9rLu/Is/nsLprcldLPuFFmpFM9R9a52MM0KF9sX1jvXTpXlvO61BydTXqbYYDabj0X/l0eWc9/q0tvti8Nnp0r3jtBiWv+IR/w3l68GFvzqxXYGle+zAbJdZ/rjNjm5zoAcEfQHkAdaA+gDrQHUAfaA6gD7QHUgfYA6nge7X/9S+HL3PKEHC0PmJaj9pUxH8Z8WP/fhYeenPkw9vsu1foz/8o0GNDyPNoXP9Tf5oQcta8u175pmpPbqvYt/8o0GPAc2o++1ZfDZtz7eLqOyekxsm8KFz0yvP1oA7ixlY1ahmO3sRTYB9q3KUA/mCY/pP62/XlcyLRP1zXH8yNwR5z1c3PTS4zOAVfzHNo3zUy0720fjoedmB4jjh0Ylx8jBQ5OJOHhJAbGf4xGaA2jfe0rMRTr2O89OVP1d3mW5HsrHg3hePPkf6vTS6D9bVCgfWE8/9Qh+XC9Ra2Dk+ujcRZ1RZSOkTztXKh98r8/Z6t3/W3dSR4eXDUjw1XRfovTS8CtQPuJcfsXDNTtSVFXRulc6X7Lmtr/lc1MLwG34nm0Fz35Z2fv6ShNjyEKDMu3AXAwGF74Fo6mtTH62XRhf4n23Zb626a2/cmJDEI2IrLr3qGrb4vTS/Q5/t9/HTyP9lnHnn3/Ff12b/4nzYQrZ8UcTI8x6M8bToxR1D5l8jLJjy/qjKmciz12skWQH5IaBZX3x9SrJ7oGjTum5v1sI+LvbHB6ieDGrQq4kmfSHp6Yi2eSghnQHkAdaA+gDrQHUAfaA6gD7QHUgfYA6kB7AHWgPYA61tOer6wANsKq0Z4FkQC2wKraj8dsAcD6oD2AOlbu0msHWTKiAuCREO0B1IH2AOqgJx9AHby3B1AHX+kBqAPtAdSB9gDqQHsAdaA9gDrQHkAdaA+gDrQHUAfaA6gD7QHUgfYA6kB7AHWgPYA60B5AHWgPoA60B1AH2gOoA+0B1IH2AOpAewB1oD2AOtAeQB1oD6AOtAdQB9oDqCNpz6o1AErIoj1r1AFoINOeFWkBNID2AOoYdOkFZ4z19WPqAgCrQLQHUAfaA6iDnnwAdfDeHkAdfKUHoA60B1AH2gOo43/iMmJIbdDbiwAAAABJRU5ErkJggg==&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: magenta;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANsAAABBCAIAAADXHEYyAAAE4klEQVR4nO2cP566PBCHOVfu4RVyAnuvEAtPYWGXflsPYENt5SH4FUAyEyYhqODwvt/ns8UukAl/HicEZm26N2hvl+Zwag5XL6x8ueOpOZyaw8neJyvv1+Zwcc93Ov0gzssdpZ15h4c9DEcnH+AqONMMWGuNK2/cjlsb1y7sx9umaebiz9A6807Xkebdhvdrxsieh93ugs3ytZ3x51Nzfnwh0AJaZ8IF9rbWGNpqCX7W+HX6jQxGjjnv+Wf6BNCf9/FPeye5oV/VGxm2P/7x3ZhKkM+dIYgcKkGMMyy093FtCHK/NjQ4bUVXBc/GhfGQ+1DJTsYmLGua22v+uMR+s2Svsbdj5hRyUtKqT5zWx3ZxbUtSsGdGxhVD03m+ZuQwDppzf9Ze7hjOIHMrJon+tI5n2Z8Tk3JpabL8+WfIhfTn3M3AXJzuYQ8nc7y657D/RA5hZ9rbhXREj7eLkp0fyYg/kyOffybcS2SOq9hvjmgGTWDee7JBoszUjNaZuI2341pvG5aCQxfOEGu9XTk3R7iR8c4sntyCkUQdejG6tBUhXd7eLuyS3K8VV0iM/7CJAVGdUsImP+FwHjaTvUQj/ZkGGU5C5rjK/c7SOhPNILltmsRqjYxqxmaTrYUNRepvKgowI0XD6oxMr/q7RtYiG5lJZhkjs9kue985NZLlPPKxzBxXud8KvI1jLxt4NRgp9rsUZmQ8WWQUJpenvzEiozbLSR+M2nFJmmtzLDKSjLxj/P5xAdue58hKI+kSf445MndcxX4lmHlRlKBONyTLGiOHJWw6HBQf/iCjNg1QO+P5spFXH266kxFnXOjYCHV1w2MgclonMwn5jp7G5zMANjkQEeKw6c74cIqEIk3Ehemniw/B4nGN28eZjb2FiWDxuDL9ypD5S3ZCYqwNE5dkezKexwbGORtj0RbWxlvJ4l1Bjq8b+UkoAL73PPISP7VbP28DgPL2E3IAVgFGAl3ASKALGAl0ASOBLmAk0AWMBLpQaeSvK4IXVciW4S8Bf8mWlbzsxQ194VmBSiO77ocVwYUK2Uk9w/7YopKXvSoXF5TYxMiY83ZQESxfM/6Sl77n7VcY146bDGvEnDRUzlo7CdORF8z8vXMe8mbbxDy0diVvMX4nFWvm02TaZ7dhjtxTRbBcIVvIkeOJ7X+nG4k1ONTasDZeyLpXw9lcvnIlbzl+JiHmbl5+buR+KoKH1rRCtmhkTqBaA3gWqRtbWdFO3LFVK3nn4netZKnsrsymRu6oIniEfeI3M7K2Ppbu5tB85Ureufg7M3IPFcGZCtmu6+gU0luWHT43ks9P2f+4ZGCBwwdn7UreufjLRm16tzOycY7UXxGcrZDlK8NJTytkxxVy5WwY8ayPm1AhyESlelrDB8+1K3kz8dmOVc5svBWG/V+N2qDE55XYv6T26Y+cODd9+oOK4DK5Of7u+E8+IQf/U2Ak0AWMBLqAkUAXMBLoAkYCXcBIoAsYCXQBI4EuYCTQBYwEuoCRQBcwEugCRgJdwEigCxgJdAEjgS5gJNAFjAS6gJFAFzAS6AJGAl3ASKALGAl0wYwUv/UCgC1Jc+Sir0MF4OukRgrfvwbAhsBIoIvpzKb/rsDdfjEX2DnIkUAXMBLoAnNtoAs8jwS6wDsboAsYCXQBI4EuYCTQBYwEuvgHq5Jlvobur5AAAAAASUVORK5CYII=&quot; /&gt;&lt;/div&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVsAAAERCAIAAABabpOwAAAZIElEQVR4nO2dMW/jOBbHeR/g6vsigwGG38PlFAMs+AnSe7DVdCMXqaZcYBsHlyqqk+p21aRKrlCTYoNZOM1hgWlXV1DiIylSlh1HVpzfDwQSUxRFy3x/vkdJlPrf//7XAAA0TdM0CkUAAAeKAADCvopQX56rxVIt1mVi41NxtlSLpVosTdXbWK3V4rx43Oeg2xg87stSaNVijNHFcOG6K62LesfjlEYpta3+0qgAk/qRRrBXOw/w+x7xd3wqzg5y0Fn1B/8wWw/xHB+hWmcUwXJvjvCLHuW4daHdiS7N2F/I32sXyq097Hn1v1Q9u3KU/nOQg77q/iCK0I35jzd6sVSLpVrdN03TdB9NdW8WrXK3m6wiuPJnN+Hh+ic3r/2uknRVPYbK94/rtXyx1JdPcpJaTyduVS4/Q/Zce4N1v0C0lx0o7HBu95OttTfklEEPkA09TyCo39agtenqcLvYDUVhci0d31MTv297Jldrs1jqyyf70f2T6G9CyjirtQo7Ya7+XHnXSFN1rXWdxy986v0hj+8jVGu1ONcre4KeijN3soLfplz5iiAntFxttcxM/uON9n7FcpULRkaWH5T5xxvtfNrAx3kqzro6c/lDyC/hC3ZZll6B6Cfq/0J1oaVMabqtpVHBkOMOUWivl5QmGovi+utC225SGvvXHc7re7ZY0NJdx674/Hc/0L01Wjm92f6Wrqe+PI9+F1s+V3+uvK1Zn62Lx6b3++Zk6AT7Q4aeIkgEKMYzoAieKfrG1sR7eaR+ab8rVOthH2Fb+cRxy5Wv/V0jQ0dDdsnlj6IutPwSnpb3RXtsD5CuILv1SucKpnYsjW2Krwh+TVHFh1CE1b3kh4qQ6m/JesQB8dK6zNafLd847Qial25817DX3h/GBy+xIiQtfJwixGdzX0XYxrbyg2NL3O0aP6YItT+Xv43O4AIt7/9es1KEuOBkijB+RHkqzvqRxUD92fLZ/pxqfLTXKfWHDLEiyNnxogDvNFm99KKGQGufETWEQ/TgZPWW8rke2f3fFa4vz/0e44rl8rMEv7T8MO6najyP3SPZA9qcYFrYdan2g+cl+hXEM0w7+QgqiEUPHjVkFSHZ39L12GA+sOQhHyFbflARvGsNXb861f6Qoe8juPmVyDPvMovAA18XMunS6X1vhiY9eePXHzpm2zU4WT57XFF3c+kmSuPpIteeXH6W6GJfcgJIG+OC9fjiYBjDd5UURury9zBGQseMF5q4+uhKmrKLPWs3d1XotnnhF8i3M0vv93UnU1/eGBuyXXbTT7n+NrL/BDOUqfpT5aPpT2/3xGSkzXz9/cFVtp8ibN0FTo0jXV6kv03LrvcjeEI47BTBSZGeFX9pgoGX/jYjuIsZAAQUAQAEFAEABBQBAAQUAQAEFAEABBQBAIT5K8JhVlg5ykoYw4Q3ux6TuqiUulbqWhc/jt0WODLzV4TD8NIrYfSeW3l91EWFIsBUijC0QkZ3J7ksynLmPTOfXbuie8pFPmZWRsmvhJFaUWPoSyRv9w1vJvfvJ7cb3BMEbktyFa32KQNjetU03o3s4f3tKUpzLQN+eWf/V/qhaRr5mHIHkopQ6Otul7syzNTFj865uOs1dSbeD+zMlD7C0AoZnTGv7nsefvJZSRdHZFawGLFYQ35FjQFy9/xmfYTOQOz/w08Z+0/E+Vtl/YJxt6YHtl3eKbPp/t/4Vt17EiZWhEJfB/VYWXEfPaHxqkIRXjeTK0JmhYx7kx2l0yugpNY7yqyMkq5kYEWNMQQrYQwqQs44xj4P7z9FO/YJto3pxu1CV96TuQ9auTF/myLUD9pJSdsir6ryjhDjJJlaEXIrZGxZqSK1rE0bNTgHYXBllIwiPOcZm+Ax9ckUYaDCsKrKlKGD0GyMqrwncysUAfpMrQi5FTJ2VISmKVd23kHMPrcyStM02ZUw0itqZMishNE0jf9AcbeKodvpuYoQPq0crKU3xMboh9hBcG5//aC3+giRf9FsTBg1pBXBj5LgFTK9j5BakcXz9sMLjbkVVppYX5qmya2M0q8qN+m4ZaWW7EoY4cahhUuS+W4dVPnQFfGX0Glz9NjFDOqiUuEg764yKlUZU3WBw8Z4oUQwU5iOMuLyvSnQV3/Z5S1zxKgB9uFYb08Yx3zusYA9mfrqIytk7Mdx1jWBt8dbuUMJAMaAIgCAgCIAgIAiAICAIgCAgCIAgIAiAICAIgCAgCIAgIAiAICAIgCAgCIAgIAiAICAIgCAgCIAgIAiAICAIgCAgCIAgIAiAICAIgCAgCIAgIAiAICAIgCAMLki3H77yfL5atLjAsAIplWE71eff/p89b1pmub220/fbmWLE4rpleL2W9em9EbEC94QkyrC96vPYnu339z/t99+cvJgRWOyJo3g9tu82gPwgkyqCJ0ItA5Bqwjfrz6HJmfdBy+8+B7HGt+vPv+U8Cls7uer7932VmZy+a6a2Efw6v926ylC5rgAJ8MRFKGNFzp5CBwHv1zPp3B+hJ8d+xRWO2zO7TcJTHL5iQb4YUQQNQwdF+AkOIIitHY1QhF8GZBS/kDtBvLEvqljp4gbEJV0LszwcQFOgmNEDZ6z3jTZqMHy/eqzdSh+8of7gcH55RSBCQV4AxxvZtFjcGbx9tvnq57N5q8OPF8RYvmRqGHwqgTAKTD91UeZ7Rt59fF7VLTbvee9Sx2hTz82P73l27dwKoGoAU6Zqe9QkmAcawKYH9zFDAACigAAAooAAIIowp9//U0izTb965//+Nc//3H0Zpx8QhFIryOhCNMkFIH0OhKKME1CEUivI6EI0yQUgfQ6EoowTZqrItz+e6UWS7X45SKx9b9fzpZqsVSL5affe1t//0UtVl/+eGYDfn6vWj6Zj++/PqeqXz+pd1/q45/Sv/7+7csH+512b8/VR6XULufh5/cffr51v+bXd3ucw9uv77ymogjTpLkqwl9/W9tOKoJN//mUVIQDpN++fHAd8ddPgSX8/N78evwzc7Bvt0u62kEZL4z6dOXn/PpJfcz/lGPaiSJMk6ZSBBnz/7h6v1iqxVKt/vPX33/+1X389Pt/Pi3akb/dZBXBlT+7ug3q7CtC3ndwlaSrilLaZm6/vlMBrotbh+Ldl7obhFvVSI7JNvPjJ9NV40vM1cc288PPX8yYwVx8mfcfZBy+cJUnaoi+Xduei7//tPLn7+J95Y8XniIM1m9bFdv/7m4CinCUNKWP8PsvarF6v7LW+N8vZ84yA9u+WPmKINZ7sYosOecj9PL/uHq/WL7/93+l/iHXwybP0r6G+RkfwRqJLXxhfHvo68tvXz74quG2iiGFDnMuZX2Zi6tfpcGxcSbbI2UuTLf16qNynn8YNQzW/+dfVx9V/yz5tY1KKMJR0uSKIBH+H1fv248DiuCZrpS3aawi3P57FUjJ779s8xH89NuXD6OiBjGkRA2jLDAcRcf59s6nCH2N0J3ZUxGib+Q3b7D+P2+/vksoQlI7sikK1v5EEaZKUytC0sLHKUJs6vsqwq4pGPEmU4SBCtPpwnQmFIzGwbF2ak9WEbbUfxBF6LcTRZgmTa0InbUHUYBnwzbg96KGwNt/RtQgObGv0Uuhf3v79Z03SSZT6BcmGJafrwjh/PzP78dMInjtdJN5vcF8jCKIKkm0EkihDNrb6idqeNVpeh/B6kI0vedlfll5U4CLX760U5Je8O8K92cK/U1+/eHMolOZdPJdcaWifnzRnxGMyjsLifPtLm668eOF1OYbZJvzfnvUIJMdYdTgDqHUh4+f3MRhuj3hccMZTW8GUX0ybiohU3/QMGYWX2k6YtRAGkr7XiOcRzrE1UfuRzhKmvrq49IPHEi9lLvG8erSAe5QChOKME2a8x1KJJIkFGGahCKQXkdCEaZJrKEEAAKKAAACigAAAooAAAKKAADCW1eEp+Jsaapjt2ILdVEpda3UtS5+HLstcOK8dUW4N4v5K4KlLioUAV6aU1KEam3viTTVvWkfbbipw01qsVSr+6af2e7YNI83OqrE7ZKu/6k4s5ntP3LQNKW5lgG/vLP/K/3QNI18TLkDSUUo9HW3y10ZZuriR+dcyKamKY1SSulisJHwZjklRWgaO+Z3NtxGBPXluVqsO5t4Ks58o036CEFmufJEJFW/zdRn6+KxrV9fPg02MrDt8k6ZTff/xrdqU+b36soE9VhZcR89ofGqQhFgiJNUBDHgpunG8DA5gdhLEYL620ynAmH5DBvTjduFrsQ46wet3Ji/TRHqB+2kxB7ZeFWVd4QYsAenqAihhT8VZwMmuo8i7FI+R11UpgwdhGZjlJh0WyDcBUWAl+b0FcFGDaHFhkFEu+nxRi/Oi8ewEjutcHhFaJqN0Q+xg+Dc/vpBb/URIv+i2ZgwakgrQhc0bG8gvElOSxFKWW3F2nZHOIkYxPneJsl3mWc3xUo2peqXqKSbs+gdIk1dVCoc5N1VRqUqY6oucNgYL5QIZgrTUUZc3sTzipHUAAinpQiwhdIwpwiDoAgAIKAIACCgCAAgTKcI1xmmOToAjGFSRRiZCQDHAkUAAAFFAAABRQAAYWpFiO6ZQxEAZsURfITSiCSgCACz4giKUBcaRQCYJygCAAhHmVksTbeID4oAMCvwEQBAQBEAQOBaAwAI3I8AAAL3LAKAgCIAgMD6CAAgsIYSAAgoAgAIKAIACCgCAAgoAgAIKAIACCgCAAgoAgAIKAIACCgCAAgoAgAIKAIACCgCAAgoAgAIKAIACCgCAAgoAgAIKAIACCgCAAgoAgAIKAIACCgCAAhzVYT68lwtlmqxLhMbn4qzpVos1WJpqt7Gaq0W58XjM49faNVijNHFc6oqTfsi7DlSuy9qyuDjUJNdqQN+r0J7ldWF3uOc14U+aJPeJnNVhKaxtp1UBMu9SSrCAai97mnfbO82eW+xfZWk2l9GkjfyO9aBET8P/12g6Yxp2/OGmUoRZMx/vNGLpVos1eq+aZqm+2iqe7NoR/52k1UEV/7sJvy5+4qQ9x1cJemq4sYm+5aMn/6o2jSdQ6GLuivSbkmOpTbTGNOrpmlfi2n3KMyIQThT3m+qs/Z8+wPzK40c1FWfaknyLHnHkCpz58ffK87a3U1AEQ7ClD5CtVaLc72y1vhUnDnLDGy7XPmKINZbriJLzvkIvfzHG71Y6ssnqX/I9bBIzx45flrjsYVL4xfq99S60L5quK1iGOMc4Fx5/4B1obf7OLVk+4LQlKVv1dGe/e9VaBWoiX/q8ucn4xDsHGyhCAdhckWQCP/xRrcfBxTBM10pbxmrCPXleSAl1Xqbj+AzyqKayJLiGvqKkBiTw1Fxe//Ole/5AuFwnW5/u3c0ModVbVGEOq47FJfs+WnqhIvQJB2HPFFwB3sztSIkLXycIsSmvq8i7Eowgk2mCEMm5NWbKh/PC/gMtz806mCU7tn7vBQh0R7Yi6kVobP2IArwbNgG/F7UEHj7z4gaJCf2NXqE/mrY0aXXlSYYNZ+vCKG3H3jgGXLlBxzubPtbt97L8RXHj3Py3yvMCIVpSOCIGmbE9D6C1YVoes/LLFbeFOBiXbRTkl7w7wr3Zwr9TX794cyiU5k03nxaf06t7M8IRuWVhOQp79154qaUIn2HX+sR/TtfPowcwoE/HQTk5jva6o3R3T7p7xXtMHAe+tbPzOJ8OGLUAEPs2r9ftz0c4uoj9yMchKmvPi79wAF65K5xHKr8bDnAHUpwCOZ8hxIATA2KAAACigAAAooAAAKKAAACigAAAooAAMJbV4Sn4uyFFlk4IHVRKXWt1LUufhy7LXDivHVFeLllVw5OXVQoArw0p6QI3UMNsvhK8nkHd8dk7/kIU21dwaVff7tMi6m69Vq2PGdZmmsZ8Ms7+7/SD03TyMeUO5BUhEJfd7vclWGmLn50zsVd74kmbvaFNKekCE1jx/zOhtuIoL48956n8FdqaTI+Qubp7Ez9NlOfrYvHtv4tT1KFtl3eKbPp/t/4Vt171jBWhEJfB/VYWXEfPaHpPeqEIkCak1SE4LkJWWrNf6Sy9MrvrAjxcxn3Jnpqe+uDGxvTjduFrrz7+R+0cmP+NkWoH7STEntk41VV3hFiwB6coiIkFl/Mmug+irBL+Rx1UZkydBCajVFi0m2BcBcUAV6a01eE9rHLwGLDIMJbrKW3ppO/gkum/r0UoWk2Rj/EDoJz++sHvdVHiPyLZmPCqCGtCP56hwA9TksRSlltJVwlKZxEDOJ8b5Pk91ZwsZtS9QcLQLuHvrdNJTT2mmI4yLurjEpVxlRd4LAxXigRzBSmo4y4fG+lpNe9wDy8KKelCLCFWb9NBuYAigAAAooAAAKKAAACigAAAooAAAKKAAACigAAAooAAMLUisA9cwBz5gg+wj4v8AKASTiCIvTfOw4AMwFFAADhKDOLpWERH4BZgo8AAAKKAAAC1xoAQOB+BAAQuGcRAAQUAQAEFAEABBQBAAQUAQAEFAEABBQBAAQUAQCEuSpC97q0depmpuDFajHVOn7F2zQMHrd9PdyY90E+j7rQymLK4OPQk2Wu1AEfPyt0UJlrhzLGPO+tk/N5L9XBzltd6D3OSV3oF3hicK6K0DTWxpKKYEm+lHW+jH1D7G6knhEpI5Mb+RxJHRnxcwjvVPdrts+97tq2OXOQ87bHrf2H/L08plIEGfPt25bdgNl9NNW9cS9rtZusIrjyZzfh18+8GD7pO7hK0lX129m6J96rX9dlWI/3rtf8cbs3yurLp3GKIGOp1jJuyFDvmZOfKV5B00TdqzTSb+yLoTPDWrKHeceQKm2mLuquCXFnLnSQle67+fbn6k+OyTbTGNOrxv/CuijM8GDuFa39DxOdt93dhFeuCE3T+tV6Za3xqThzlpl527o1p856y1VkyTkfoZf/eKM9Aw7fFp9CXhvftrPdt1p7Nn9v4iigd1wvjmiFZosi5MZS/6evC719jPUeL/UFoSlLv3f23kYf97BCq0BN/C7rv3W+NGFViQHPU7px/ku+/n4760L7quG2yncc52AHNftfYorztnMwdCqKIJG2GN6AInimGxhqvJdHnF9fngdSUq0HfATXBk8F2jbEg3wc1ETH9aQkuXv6wDIYuY7XG0vDYSdtUW1viUaesKotPbv31HooLibbHeu+1YQbx0QN+fqTipDwicLvPs5+RAaC4pOct6Gzlmqoet50TI6pFSFp4eMUITa5fRVhDI83uosaAufipRXBQ8aWeF7AZ9iiws4ZjEL9VSqmUYTIg5hMEYYa3K8qirsmOW87KULiuAdiakUQq/CiAM+WbKDuRQ2BQT4japCc2NdIU67s1IZXcseoob48F8nwv1eW4Cf2OuWAQym7lCYVQmciVd/PDrZH3q+fEQrTkIFFUUPY/NBgsu1/viKE7Q88+SFKo4vYQZjivL3VqGFddpNtsSffZRYrbwpwsS7Cqb6gcH+m0N/k1x/OLPpD92Brezbs1xP7C4njyjyl+15D3koYHgQdL7upTM6oNU023m6jeWN0t48fqgwFLJ5AZWIYr7XJJrYTCX6jEu3P1Z9up2tjO7b7x/C/sB5rP30XZ4rz9mZnFgen9OBUmN86WS9kP4dinxP2uu9H8K7qTXGjDhybmRhg7hrHvNjvDqWXYc53KAHA1KAIACCgCAAgoAgAIKAIACCgCAAgoAgAIJyaIjwVZ4lbmNNrq1iOsMJKXVRKXSt1rYsfUx73ULzECiswE05NEZIPO8xzbZW6qF6pIlhmfhcg7McpKULveQf/qSRz2V95JbvSSXCH5RY1Kc21DPjlnf1f6YemaeRjyh1IKkKhr7td7sowUxc/OufibuCG18TD03NeKcQtGIC2zINTUoSmGfAROiGIH1LOrHTinr/ol+8T2HZ5p8ym+3/jW3XvmblYEQp9HdRjZcV99ITmsA8NHHulEBRhRrwZRUisv5DbJXxQclS4sTHduF3oynuQ9kF3PoJS2xShftBOSmxLjVdVeTcyxNjVR2gPdbyVQmBWoAiD6yyMfnq6LipThg5CszFKTLotEO7yEoqwH0dcKQRmxakpgnetYesaTS2plU68AnH53kokLRujH2IHwbn99YPe6iNE/kWzMWHU8MLTkEdaKcSPJmAGnJoiBPOL+vLJmz48Lx5lbWV/MdVopZNoWjFe4ySnCE1dVCoc5N1VRqUqY6oucNgYL5QIZgrTUUZc/oVWHjjKSiGlSZ9MOBanpwjwipjP21igBUUAAAFFAAABRQAAAUUAAAFFAAABRQAAAUUAAAFFAABhakXgHjWAOXMEH2F+bwADgJYjKEL/KToAmAkoAgAIR5lZLA2L5gDMEnwEABBQBAAQuNYAAAL3IwCAwD2LACCgCAAgoAgAIKAIACCgCAAgoAgAIKAIACCgCAAgoAgAIKAIACCgCAAgoAgAIKAIACCgCAAgoAgAIKAIACCgCAAgoAgAIKAIACCgCAAgoAgAIKAIACCgCAAgoAgAIKAIACDEisA7lwDeMgkfgfcyArxZEorAu5sB3iwoAgAIyZnF0iili/oIzQGAo4KPAAACigAAAtcaAEDgfgQAELhnEQAEFAEABBQBAAQUAQAEFAEABBQBAIT/AxT2oummPiJDAAAAAElFTkSuQmCC&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: magenta;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;Y el xml era así:&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;saludoImpl&quot; class=&quot;saludo.SaludoImpl&quot;&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;valor&quot; value=&quot;Hola mundo!&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;alumno&quot; class=&quot;saludo.Alumno&quot; &amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;saludo&quot; ref=&quot;saludoImpl&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;Ahora vamos a hacer un pequeño cambio en el xml y lo vamos a dejar así:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;saludoImpl&quot; class=&quot;saludo.SaludoImpl&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;valor&quot; value=&quot;Hola mundo!&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;replaced-method name=&quot;saluda&quot; replacer=&quot;saludoAlternativo&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: magenta;&quot;&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;saludoAlternativo&quot; class=&quot;saludo.SaludoAlternativo&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: #f6b26b;&quot;&gt;&lt;/div&gt;&lt;span style=&quot;color: white;&quot;&gt;Y realizamos la implementación SaludoAlternativo:&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2gl3t9eK28-a-iMvruWQsbHqvylYDjmotCIK2L8Wtq5d63QhLEg0-xFlxiphxa7ZA08WepSNthYQWXyU4635Pi9BHzsl6bPxxoRY8fnk00CdJXOdHu_p3SU4pKahmQgBGX3H1vEX2oHs/s1600/saludoAlter.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2gl3t9eK28-a-iMvruWQsbHqvylYDjmotCIK2L8Wtq5d63QhLEg0-xFlxiphxa7ZA08WepSNthYQWXyU4635Pi9BHzsl6bPxxoRY8fnk00CdJXOdHu_p3SU4pKahmQgBGX3H1vEX2oHs/s1600/saludoAlter.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;color: white;&quot;&gt;Como se imaginarán hemos cambiado el &quot;Hola mundo&quot; por algo más actual. =)&lt;/div&gt;&lt;div style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white;&quot;&gt;2) Sustitución por getter: permite que los métodos sean sustituidos en tiempo de ejecución con nuevas implementaciones. En realidad es un caso especial de la sustitución anterior. Se suele utilizar en casos de métodos abstractos, aunque no es obligatorio.&lt;/div&gt;&lt;div style=&quot;color: white;&quot;&gt;Vamos a porner un ejemplo sencillo. Imaginemos que una clase llamada &lt;b&gt;Reloj &lt;/b&gt;posee el siguiente método:&lt;/div&gt;&lt;div style=&quot;color: white;&quot;&gt;&lt;i&gt;public abstract Tiempo getTiempo();&lt;/i&gt;&lt;/div&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: white;&quot;&gt;En el xml se podría escribir:&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;bean id=&quot;reloj&quot; class=&quot;ejemplo.Reloj&quot;&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;lookup-method name=&quot;getTiempo&quot; bean=&quot;tiempoImpl&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #f6b26b;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;De esta forma se sustituye lo que devuelve el método por la implementación de tiempoImpl. En la practica la sustitución por método no se suele utilizar demasiado ya que no son demasiados los casos donde se puede aplicar (¿para que voy a hacer un método que despues lo voy a cambiar no?), pero es bueno saber que existe.&lt;/span&gt;&lt;br /&gt;
&lt;i&gt;&lt;br style=&quot;color: white;&quot; /&gt;&lt;span style=&quot;color: white;&quot;&gt;Estas son las características principales del Core de Spring. Cuando tenga tiempo y ganas escribiré un post sobre Spring AOP.&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;color: black;&quot;&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/5255686128376166713/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/5255686128376166713' title='5 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/5255686128376166713'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/5255686128376166713'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/07/spring-core.html' title='Spring Core'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKcNyx5tsC-bECG-MSkgTU664cQqziLzIPqOjL11udDMvxjmGgWcm4yATZlJx4_OCmsdkNYzidxAZHpZwvKG-vgDyZZWgpwTVSFxuDHgtmywD1Nv6_8Jp68gVxgyhHw4FZv4cyPPLXV1U/s72-c/beanAware.png" height="72" width="72"/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-1315997299507430147</id><published>2011-06-28T18:36:00.001-03:00</published><updated>2011-06-28T19:53:43.133-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Introducción a Spring"/><category scheme="http://www.blogger.com/atom/ns#" term="Spring"/><title type='text'>Introducción a Spring</title><content type='html'>&lt;i&gt;Primero voy a dar una introducción a Spring para quienes no conozcan el framework, donde veremos de que se trata, como configurarlo y un sencillo &quot;Hola Mundo&quot;. Luego escribiré un post sobre Spring Core que permitirá conocer el framework de manera más amplia.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Spring es un marco de trabajo cuya finalidad es facilitar el desarrollo de aplicaciones con Java. Fue creado por Rod Johnson y es de código abierto. &lt;br /&gt;
Sus características son: &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Simplicidad y acoplamiento débil: da la sensación que quién desarrollo Spring se imagino a Java de otra manera, más robusto y configurable, con más facilidadades y posibilidades para los desarrolladores. Esto se ve reflejado en este framework: busca ser simple y se basa en la inyección de dependencias para obtener un acoplamiento débil. Luego veremos estos dos conceptos.&lt;/li&gt;
&lt;li&gt;Es un contenedor: no es solo un framewrok más. Es un contenedor que gestiona el ciclo de vida de los objetos y como se relacionan entre ellos. Proporciona una gran infraestructura que permite que el desarrollador se dedique a la lógica de la aplicación.&lt;/li&gt;
&lt;li&gt;Ligero: es muy rápido en tiempo de procesamiento y no es intrusivo a la hora de desarrollar. Esto último es uno de sus puntos más fuertes.&lt;/li&gt;
&lt;li&gt;Orientado a aspectos: soporta la programación orientada a aspectos, lo que permite facilitar una capa de servicios que son ideales para este tipo de programación como auditoría, o gestión de transacciones.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Módulos de Spring&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Spring posee diversos módulos que se pueden agregar a las aplicaciones Java. Cada desarrollador agrega los módulos que necesite.&amp;nbsp; Spring Core es el núcleo de Spring, es el único módulo que tenemos que agregar para que Spring funcione. ya que contiene la DI (inyección de dependencias) y la configuración y uso de objetos Java. Muchas aplicaciones sólo necesitan de Spring Core sin necesidad de agregar módulos adicionales.&lt;br /&gt;
&lt;br /&gt;
Otros módulos conocidos son: AOP para trabajar con aspectos, DAO para trabajar con base de datos, MVC para la capa web, Portlet MVC para trabajar con portlets, JMS para mensajería y Security para el manejo de seguridad (el framewrok de seguridad era antes conocido como Acegi).&lt;br /&gt;
Como se puede observar Spring nos da muchas opciones para poder agregar a nuestro proyecto. Estos no son los únicos módulos que nos ofrece Spring, sólo son los más importantes.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Inyección&amp;nbsp; de dependencias (DI).&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Originalmente la inyección de dependencias se llamaba inversión de control, pero en el 2004 Martin Fowler llegó a la conclusión que realmente no se invertía el control, sino las dependencias.&lt;br /&gt;
La DI permite a un objeto que conozca sus dependencias mediante una interfaz y no por su implementación. De esta forma, la implementación puede variar sin que el objeto dependiente se de cuenta. La gran ventaja de la DI es el acoplamiento débil entre objetos.&lt;br /&gt;
Muy linda la teoría pero si uno se inicia en Spring por primera vez suena a conceptos muy abstractos.&amp;nbsp; Nada mejor que un ejemplo sencillo para aclarar los puntos. Veremos un pequeño ejemplo antes de introducirnos en Spring Core,&amp;nbsp; pero antes veremos como configurar Spring en una aplicación eclipse:&lt;br /&gt;
&lt;br /&gt;
1) Bajar Spring desde &lt;a href=&quot;http://www.springsource.org/download&quot;&gt;http://www.springsource.org/download&lt;/a&gt; y agregar las fuentes al proyecto.&lt;br /&gt;
2) Si la distribución de Spring no adjunta las librerías de apache commons también hay que bajarlas: &lt;a href=&quot;http://commons.apache.org/&quot;&gt;http://commons.apache.org/&lt;/a&gt;&lt;br /&gt;
Adjunto un pic con las librerias necesarias para empezar (ignoren el archivo spring.xml por ahora):&lt;br /&gt;
&lt;span id=&quot;goog_763177392&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_763177393&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh6weh3glJofRaDRSjiVXpf-NMAgybx4GQ5ljsbhFO-sa8JpWHIrYjlmZEylMexkYAa3lS2Ck3gpL_l1x2cpghWjkw-aZq0thYe7zsAsDzRUYMrJ9cxG4sUH-6g7WgFH-QdKiDfF3gb2c/s1600/librerias.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh6weh3glJofRaDRSjiVXpf-NMAgybx4GQ5ljsbhFO-sa8JpWHIrYjlmZEylMexkYAa3lS2Ck3gpL_l1x2cpghWjkw-aZq0thYe7zsAsDzRUYMrJ9cxG4sUH-6g7WgFH-QdKiDfF3gb2c/s1600/librerias.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
3) Dentro de las librerías habrán visto que hay un archivo llamado spring.xml (le pueden poner el nombre que quieran, es lo mismo).&lt;br /&gt;
Por ahora les recomiendo que hagan un archivo xml que tenga el siguiente contenido y lo agreguen al classpath. Luego les explicaré que significa cada cosa de dicho archivo.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: #c27ba0;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; color: #c27ba0; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;nbsp;&amp;nbsp; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;nbsp;&amp;nbsp; xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans &lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&quot;&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;bean id=&quot;saludoImpl&quot; class=&quot;saludo.SaludoImpl&quot;&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;valor&quot; value=&quot;Hola mundo!&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;bean id=&quot;alumno&quot; class=&quot;saludo.Alumno&quot; &amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;saludo&quot; ref=&quot;saludoImpl&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;/beans&amp;gt;&lt;/div&gt;&lt;br /&gt;
4) Por último, vamos a hacer una clase que nos permita levantar el archivo:&lt;br /&gt;
&lt;br /&gt;
import org.springframework.context.ApplicationContext;&lt;br /&gt;
import org.springframework.context.support.FileSystemXmlApplicationContext;&lt;br /&gt;
&lt;br /&gt;
public class ContextFactory {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; private static ApplicationContext respuesta;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public static ApplicationContext getInstance(){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (respuesta != null) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return respuesta;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; respuesta = new FileSystemXmlApplicationContext&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (&quot;C:/Users/max/eclipse workspace/spring.xml&quot;); // aca pongan la ruta donde pusieron el xml&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return respuesta;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
Listo, con esto tenemos todo para comenzar con nuestro ejemplo.&lt;br /&gt;
Crearemos una clase Alumno que tiene un atributo de la clase (intefaz) Saludo.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs8Tgm9L9mCVdp0GKb6WdHokKQdz_xy1aRVGBWDJF7YOl8-ib2jCEuoqKxH1AxsjeLuguRtye3CEJbLnE-MU1IcpksXciLgRTherQYFFtiTn8p0b8l3oUfZ9lZ3paFwy0nVVGvJJ8ShKg/s1600/alumno.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs8Tgm9L9mCVdp0GKb6WdHokKQdz_xy1aRVGBWDJF7YOl8-ib2jCEuoqKxH1AxsjeLuguRtye3CEJbLnE-MU1IcpksXciLgRTherQYFFtiTn8p0b8l3oUfZ9lZ3paFwy0nVVGvJJ8ShKg/s1600/alumno.png&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8EAgGo3o-Z2sraQt6dO7RMKRUe1r8Q7ITTx_SiRJXRWd-byPsqnr8Xj6DkK4VKPZJE5JpXXqqnxN__v9msTBUfDQvblp9vzmZ55MfrWrpftR8bGs06PNRQq3AhDJ_y58dUk9W-2TJ56I/s1600/saludo.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8EAgGo3o-Z2sraQt6dO7RMKRUe1r8Q7ITTx_SiRJXRWd-byPsqnr8Xj6DkK4VKPZJE5JpXXqqnxN__v9msTBUfDQvblp9vzmZ55MfrWrpftR8bGs06PNRQq3AhDJ_y58dUk9W-2TJ56I/s1600/saludo.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Aquí una posible implementación de la clase Saludo:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmQHKsTL7OCv33EDFNYtFq5ck_tsyQ4eN9EJ_cJTQQ_aIl7fTIkr1RMXc1kn1qDzU_reyewjp9Iayf4eexQuUI0f-mRQh06kDPrYkoMRXJieQhR6Ucv0stwmjA7WR2FRUiw00v6ydFv2o/s1600/impl.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmQHKsTL7OCv33EDFNYtFq5ck_tsyQ4eN9EJ_cJTQQ_aIl7fTIkr1RMXc1kn1qDzU_reyewjp9Iayf4eexQuUI0f-mRQh06kDPrYkoMRXJieQhR6Ucv0stwmjA7WR2FRUiw00v6ydFv2o/s1600/impl.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Veamos como se ejecuta esto:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjI7r4E_7JuNPO8HqpHLLBSCnm7s0JzLaZqcBqT4ITiNw-dUr6jCBeXlM4nI3PATztaQGuVyyvsPGKxw2Xsk8z82cnhanDIEt8LylM1E-rvJF6szrsB0LAPzDRK97VDIfzGMUm0yPAooGI/s1600/holamundo.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjI7r4E_7JuNPO8HqpHLLBSCnm7s0JzLaZqcBqT4ITiNw-dUr6jCBeXlM4nI3PATztaQGuVyyvsPGKxw2Xsk8z82cnhanDIEt8LylM1E-rvJF6szrsB0LAPzDRK97VDIfzGMUm0yPAooGI/s1600/holamundo.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;¿Que ha pasado aquí?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
A simple vista deduciremos lo siguiente: la clase Alumno posee un atributo que es una interfaz y no se entera como es la implementación de la misma.&lt;br /&gt;
Vamos a explicar el funcionamiento: todo se debe gracias al archivo de configuración xml. El tag&lt;b&gt; &amp;lt;beans&amp;gt;&lt;/b&gt; es el elemento raíz del xml y todo lo que se encuentre dentro de este elemento es configuración de Spring.&lt;br /&gt;
El elemento&lt;b&gt; &amp;lt;bean&amp;gt;&lt;/b&gt;&amp;nbsp; indica a Spring que se configurará un objeto para ser utilizado en el contenedor de Spring. &lt;b&gt;Id &lt;/b&gt;es un atributo obligatorio que debería identificar unívocamente al bean en cuestión.&lt;br /&gt;
En nuestro ejemplo vemos la siguiente configuración:&lt;br /&gt;
&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;bean id=&quot;saludoImpl&quot; class=&quot;saludo.SaludoImpl&quot;&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;property name=&quot;valor&quot; value=&quot;Hola mundo!&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;El atributo &lt;b&gt;class &lt;/b&gt;indica la clase a la cual pertenece el bean y cada bean puede tener subelementos &lt;b&gt;&amp;lt;property&amp;gt;&lt;/b&gt; que representan los atributos (en este caso me refiero a atributos de objetos y no de xml) del bean. El &lt;b&gt;name &lt;/b&gt;debe coincidir con el nombre de atributo que tenga en la clase y, en este ejemplo, &lt;b&gt;value &lt;/b&gt;sería el valor que toma. Veremos luego que hay varias opciones más.&lt;br /&gt;
Continuando con el xml vemos:&lt;br /&gt;
&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;bean id=&quot;alumno&quot; class=&quot;saludo.Alumno&quot; &amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;property name=&quot;saludo&quot; ref=&quot;saludoImpl&quot;/&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #c27ba0;&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;La novedad aca aplica a atributo &lt;b&gt;ref &lt;/b&gt;del elemento &lt;b&gt;property&lt;/b&gt;: esta indicando que este atributo es un objeto y, por lo tanto, es conveniente configurar dicho objeto de manera separa y se hace referencia al mismo mediante su &lt;b&gt;id&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;¿Y no es lo mismo hacerlo así?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCHCQ3Ui2NexYPsiTtZMnZvJa8ax-Hno1ORqNl7I4gpv1qjnkYuaFJVwVL1MTQZHduWIbG3lqHWGxL4ysVA1g7CbgSbArrjZkK3Z_yPT8MfOR1dGABWH6KjzLJMbxnfTlqAdhBrGj8MG8/s1600/trad.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCHCQ3Ui2NexYPsiTtZMnZvJa8ax-Hno1ORqNl7I4gpv1qjnkYuaFJVwVL1MTQZHduWIbG3lqHWGxL4ysVA1g7CbgSbArrjZkK3Z_yPT8MfOR1dGABWH6KjzLJMbxnfTlqAdhBrGj8MG8/s1600/trad.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Si y no a la vez: tradicionalmente cada objeto es responsable de obtener sus propias dependencias y esto lleva a un código muy acoplado. Cada objeto debe conocer como se construyen otros y si bien los patrones creacionales pueden ayudar con este tema, entonces hay que conocer que patrón se aplicó a cada objeto.&lt;br /&gt;
Cuando se aplica la DI se otorgan las dependencias a cada objeto, se obtiene un acoplamiento débil: si un obejto solo conoce sus dependencias mediante su interfaz, entonces puede variar su implementación sin que&amp;nbsp; el objeto dependiente sepa la diferencia. Por otro lado, el código es más limpio y ordenado.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Hasta aquí con esta breve introducción a Spring. Cuando escriba sobre Spring Core se verán estos temas con más profuncidad.&lt;/i&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/1315997299507430147/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/1315997299507430147' title='3 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/1315997299507430147'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/1315997299507430147'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/introduccion-spring.html' title='Introducción a Spring'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh6weh3glJofRaDRSjiVXpf-NMAgybx4GQ5ljsbhFO-sa8JpWHIrYjlmZEylMexkYAa3lS2Ck3gpL_l1x2cpghWjkw-aZq0thYe7zsAsDzRUYMrJ9cxG4sUH-6g7WgFH-QdKiDfF3gb2c/s72-c/librerias.png" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-3415756223973367576</id><published>2011-06-23T00:46:00.000-03:00</published><updated>2011-06-23T00:46:47.315-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Base de Datos"/><category scheme="http://www.blogger.com/atom/ns#" term="Cassandra"/><title type='text'>Cassandra</title><content type='html'>&lt;i&gt;Junto a Guillermo Kessler hemos hecho una investigación sobre una base de datos NO SQL llamada Cassandra. Primero veremos sus características principales y luego les mostraremos el código fuente utilizado.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Cassandra es una Base de Datos NO SQL. Posee una estructura par-valor para almacenar datos de manera escalable, consistente y distribuída. Fue creada para manejar grandes volúmenes de datos distribuidos en numerosos servidores estándar, ofreciendo alta disponibilidad.&lt;br /&gt;
La historia de Cassandra nace directamente de la experiencia que supuso Dynamo para Amazon. Facebook contrató a uno de sus autores y le encargó diseñar un nuevo sistema para sus datos. Este ingeniero desarrolló Cassandra y, en 2008, Facebook liberó su código.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Características&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Punto de falla: maneja grandes volúmenes de datos distribuidos en numerosos servidores estándar, ofreciendo alta disponibilidad sin ningún punto único de falla.&lt;/li&gt;
&lt;li&gt;Basada en clave-valor: tiene un almacén de valores de claves manejado con consistencia eventual (modelo de consistencia usado en programación paralela). Las claves mapean hacia múltiples valores que se agrupan en familias de columnas. Esas familias se definen cuando se crea una base Cassandra, pero luego se les puede agregar columnas a las diferentes familias. Las columnas se pueden agregar a claves específicas y así diferentes claves tendrán diferentes cantidades de columnas dentro de una misma familia. Los valores de una familia de columnas para cada clave se almacenan juntos, haciendo de Cassandra un híbrido entre una DBMS orientada a columnas y un almacén de datos orientado a filas. &lt;/li&gt;
&lt;li&gt;Soporte comercial: debido a que es un producto relativamente nuevo, recién acaba de aparecer una primer empresa ofreciendo soporte comercial para Cassandra. Se trata de Riptano (http://www.riptano.com/), que además está creando herramientas para usar sobre el core de Cassandra. El plan de Riptano consiste en usar a Cassandra como plataforma central e ir agregándole porciones propietarias que hagan a su versión comercial. Uno de sus primeros servicios podría ser el de migración para que usuarios de otras bases de datos puedan pasar su información a Cassandra.&lt;/li&gt;
&lt;li&gt;Releases: Apache se encarga de sacar un nuevo release cada tres o 4 meses. Hoy esta en su versión 0.6 y ya esta trabajando en su versión 0.7.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Clientes&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Un cliente es una API que nos  permite conectar y realizar operaciones contra Cassandra. Esta última  usa como cliente por defecto Thrift que es un cliente de bajo nivel. Al  ser un cliente de bajo nivel resulta más complejo y lento operar contra  esta base de datos.&lt;br /&gt;
Existen clientes de alto nivel para diferentes  lenguajes como Java, PHP, Perl, etc. Un cliente de alto nivel nos va a  permitir operar mas fácil y rápido contra la base de datos,  facilitandonos las cosas. En la documentación oficial de Cassandra se  recomienda el uso de estos clientes de alto nivel por encima de Thrift.&lt;br /&gt;
&lt;br /&gt;
Los clientes de alto nivel recomendados para Java en la última versión estable de Cassandra (0.6.7) son:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Hector: &lt;a href=&quot;http://github.com/rantav/hector&quot;&gt;http://github.com/rantav/hector&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Pelops: &lt;a href=&quot;http://code.google.com/p/pelops/&quot;&gt;http://code.google.com/p/pelops/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;HelenaORM: &lt;a href=&quot;http://github.com/marcust/HelenaORM&quot;&gt;http://github.com/marcust/HelenaORM&lt;/a&gt; (ORM layer built on Hector) &lt;/li&gt;
&lt;li&gt;OCM: &lt;a href=&quot;http://github.com/charliem/OCM&quot;&gt;http://github.com/charliem/OCM&lt;/a&gt; (higher level client built on Hector) &lt;/li&gt;
&lt;li&gt;Datanucleus-Cassandra plug-in: &lt;a href=&quot;http://github.com/PedroGomes/datanucleus-cassandra&quot;&gt;http://github.com/PedroGomes/datanucleus-cassandra&lt;/a&gt; (Persistence of objects through the JDO/JPA APIs under the Datanucleus platform). &lt;/li&gt;
&lt;li&gt;Jassandra: &lt;a href=&quot;http://code.google.com/p/jassandra/&quot;&gt;http://code.google.com/p/jassandra/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Kundera: &lt;a href=&quot;http://code.google.com/p/kundera/&quot;&gt;http://code.google.com/p/kundera/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;Lamentablemente la mayoría de estos clientes tiene documentación escasa y poco mantenimiento.&lt;br /&gt;
Dentro  de los nombrados en la lista, el más robusto es Hector. Si bien es  sencillo de usar comparado con Thift, su documentación no es del todo  completa y se debe tener cuidado que en cada versión de Cassandra se  usan librerias diferentes de Hector, por lo cual se debe tener la  versión correspondiente de Hector con la de Cassandra.&lt;br /&gt;
&lt;i&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ventajas&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Dispone de consistencia eventual, al igual que el sistema Dynamo de Amazon.&lt;/li&gt;
&lt;li&gt;Proporciona un modelo de datos basados en ColumnFamily, más rico que el tradicional modelo de clave/valor, al igual que el modelo BigTable de Google.&lt;/li&gt;
&lt;li&gt;Es altamente escalable y distribuida. Normalmente se ejecutan en clusters de servidores formados por ordenadores baratos, por lo que la expansión del sistema es realmente sencilla. &lt;/li&gt;
&lt;li&gt;Es rápida ya que elimina el cuello de botella que supone el tener que traducir las consultas a lenguaje SQL.&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Pruebas&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Hemos realizado dos tipos de pruebas: en modo local y en modo distribuído. En ambos casos se ha observado una gran velocidad en la lectura/escritura de datos. Un ejemplo claro, es que con una configuración local ha podido traer a memoria 50.000 objetos repetidos de un total de 800.000 en sólo 3.08 segundos. La configuración y el código de esta prueba se encuentra al final de este post.&lt;br /&gt;
No hemos observado problema con la integración de varios nodos para trabajar conjuntamente en red: hemos probado 3 máquinas trabajando juntas sin mayores problemas.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN1pBMEIMIo4i1Grur9tobM_Ctdu3WolUA60Zc3oqj9fV_X6SHnOz9QE0MzcMTRsAiHURjez-xKzgDam_xFllUIFIvn_QsUFzOZWJhyphenhyphena-kQ4_Sv1TaKbFov9UvX3npks40xSWpxArQnWo/s1600/image01.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;90&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN1pBMEIMIo4i1Grur9tobM_Ctdu3WolUA60Zc3oqj9fV_X6SHnOz9QE0MzcMTRsAiHURjez-xKzgDam_xFllUIFIvn_QsUFzOZWJhyphenhyphena-kQ4_Sv1TaKbFov9UvX3npks40xSWpxArQnWo/s640/image01.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Es obvio que la velocidad es el fuerte de Cassandra, es por eso que es utilizada por empresas que tienen que manejar un gran volumen de datos.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Conclusión&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Observando a las compañías que manejan un enorme volúmen de datos, tales como Google, Amazon o Facebook, nos damos cuenta que sus sistemas de datos no están basados en bases de datos tradicionales (relacionales). Google utiliza BigTable, Amazon usa Dynamo, y Facebook y Digg gestionan sus datos con Cassandra. Actualmente, Twitter1 también esta migrando sus datos a esta tecnología. &lt;br /&gt;
&lt;b&gt;¿Por qué las compañías más relevantes del mundo de la tecnología abandonan las bases de datos relacionales?&lt;/b&gt; Principalmente, porque son muy costosas y lentas cuando manejan tal cantidad de datos. Por ejemplo, Cassandra es capaz de escribir en disco 50GB de datos en tan sólo 0.12 milisegundos, 2500 veces más rápido que MySQL.&lt;br /&gt;
Entonces, ¿todas las compañias seguirán estos pasos en un futuro? No, estas bases de datos deben utilizarse en casos especiales, cuando la información debe ser accedida por millones de personas y la velocidad es un tema primordial.&lt;br /&gt;
Para una compañía que no posee estas características hay varios puntos a tener en cuenta: no soporta trasacciones ya que tiene un almacén de valores de claves manejado con consistencia eventual, lo que quiere decir que los datos “eventualmente” se van a ver, pero no siempre reflejan la realidad. Por otro lado, no se tiene todas las ventajas conocidas de las base de datos relacionales como DB2 u Oracle, que van desde el soporte técnico hasta la facilidad para obtener información mediante reportes. Por último, la documentación es escasa y pobre.&lt;br /&gt;
Dicho de otra manera, si no tenes una red social o algo que se le parezca ni se te ocurra complicarte sin sentido!!!!&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Detalle de las pruebas:&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #f3f3f3;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background-color: #f3f3f3;&quot;&gt;&lt;span id=&quot;internal-source-marker_0.13340555157210887&quot; style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Adjuntamos la configuración/código utilizado:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;storage-conf.xml&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #f3f3f3;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;lt;Keyspace Name=&quot;CDT&quot;&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;!-- Un Column Family podr&amp;amp;iacute;a asimilarse al concepto de Tabla --&amp;gt; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;ColumnFamily Name=&quot;Proyectos&quot; CompareWith=&quot;BytesType&quot;/&amp;gt; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;ColumnFamily Name=&quot;Desarrolladores&quot; CompareWith=&quot;BytesType&quot;/&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;lt;!-- Entradas en un blog, esta ser&amp;amp;aacute; una super columna.--&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;ColumnFamily CompareWith=&quot;TimeUUIDType&quot; ColumnType=&quot;Super&quot; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;CompareSubcolumnsWith=&quot;BytesType&quot; Name=&quot;Trabajan&quot;/&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;ReplicaPlacementStrategy&amp;gt;org.apache.cassandra.locator.RackUnawareStrategy&amp;lt;/ReplicaPlacementStrategy&amp;gt; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;!-- Number of replicas of the data --&amp;gt; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;ReplicationFactor&amp;gt;1&amp;lt;/ReplicationFactor&amp;gt; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;EndPointSnitch&amp;gt;org.apache.cassandra.locator.EndPointSnitch&amp;lt;/EndPointSnitch&amp;gt; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/Keyspace&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;lt;/Keyspaces&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;package&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; main;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; java.util.ArrayList;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; java.util.Date;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; java.util.HashMap;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; java.util.List;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; java.util.Map;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; java.io.UnsupportedEncodingException;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.thrift.transport.TTransport;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.thrift.transport.TSocket;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.thrift.protocol.TProtocol;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.thrift.protocol.TBinaryProtocol;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.thrift.TException;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.cassandra.thrift.Cassandra;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.cassandra.thrift.Column;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.cassandra.thrift.ColumnOrSuperColumn;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.cassandra.thrift.ColumnParent;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.cassandra.thrift.ColumnPath;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.cassandra.thrift.ConsistencyLevel;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.cassandra.thrift.InvalidRequestException;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.cassandra.thrift.Mutation;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.cassandra.thrift.NotFoundException;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.cassandra.thrift.SlicePredicate;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.cassandra.thrift.SliceRange;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.cassandra.thrift.SuperColumn;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.cassandra.thrift.TimedOutException;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.apache.cassandra.thrift.UnavailableException;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.safehaus.uuid.UUID;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; org.safehaus.uuid.UUIDGenerator;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; TestCassandra {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; String &lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;UTF8&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;UTF8&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; String &lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;KEYSPACE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;CDT&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; String &lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;PROYECTOS_FAMILY&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Proyectos&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; String &lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;DESA_FAMILY&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Desarrolladores&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; String &lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;TRABAJAN_FAMILY&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Trabajan&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; test(&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; cantidad, &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; abrirTr) &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; Exception {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; inicio, intermedio, fin = 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; TTransport tr = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; TSocket(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;localhost&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, 9160);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; TProtocol proto = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; TBinaryProtocol(tr);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Cassandra.Client client = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; Cassandra.Client(proto);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; (abrirTr) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Comienzo la insercion&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; inicio = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; Date().getTime();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; i = 0; i &amp;lt; cantidad; i++) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tr.open();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;inserting&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;(client, i);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tr.close();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Fin inserción&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; intermedio = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; Date().getTime();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Comienzo la lectura&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; i = 0; i &amp;lt; cantidad; i++) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tr.open();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;reading&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;(client, i);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tr.close();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; fin = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; Date().getTime();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tr.open();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; inicio = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; Date().getTime();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Comienzo la inserción&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; i = 0; i &amp;lt; cantidad; i++) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;inserting&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;(client, i);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tr.close();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Fin inserción&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; intermedio = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; Date().getTime();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Comienzo la lectura&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tr.open();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; i = 0; i &amp;lt; cantidad; i++) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;reading&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;(client, i);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Fin lectura&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tr.close();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; fin = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; Date().getTime();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;double&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; insercion = (&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;double&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;) (intermedio - inicio) / 1000;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;double&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; lectura = (&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;double&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;) (fin - intermedio) / 1000;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;double&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; total = insercion + lectura;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Entrada de datos: &quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; + insercion);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Lectura de datos: &quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; + lectura);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Total proceso: &quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; + total);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; inserting(Cassandra.Client client, &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; i)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; UnsupportedEncodingException, InvalidRequestException,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; UnavailableException, TimedOutException, TException {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String keyID = &lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;java&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; + i;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// INSERTAMOS DATOS.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; timestamp = System.&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;currentTimeMillis&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;Un&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;proyecto&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ColumnPath colPathName = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ColumnPath(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;PROYECTOS_FAMILY&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; colPathName.setColumn(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;NOMBRE&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.getBytes(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;UTF8&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; client.insert(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;KEYSPACE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, keyID, colPathName, &lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Proyecto&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.getBytes(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;UTF8&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; timestamp, ConsistencyLevel.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;ONE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ColumnPath colPath = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ColumnPath(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;PROYECTOS_FAMILY&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; colPath.setColumn(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;email&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.getBytes(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;UTF8&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; client.insert(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;KEYSPACE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, keyID, colPath, &lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;blablabla&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.getBytes(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;UTF8&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; timestamp, ConsistencyLevel.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;ONE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String llaveID = &lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Me gusta esto&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; + i;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ColumnPath colName = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ColumnPath(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;DESA_FAMILY&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; colName.setColumn(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;unaColumna&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.getBytes(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;UTF8&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; client.insert(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;KEYSPACE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, llaveID, colName, keyID.getBytes(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;UTF8&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; timestamp, ConsistencyLevel.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;ONE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;Column&amp;gt; entriesColumns = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ArrayList&amp;lt;Column&amp;gt;();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; entriesColumns.add(&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; Column(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;observaciones&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.getBytes(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;UTF8&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Hijos nuestros&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.getBytes(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;), timestamp));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; entriesColumns.add(&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; Column(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;pm&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.getBytes(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;UTF8&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;te vas a la B&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.getBytes(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;), timestamp));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; UUID uuid = UUIDGenerator.&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;getInstance&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;().generateTimeBasedUUID();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; SuperColumn superColumn = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; SuperColumn(uuid.toByteArray(),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; entriesColumns);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ColumnOrSuperColumn cosc = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ColumnOrSuperColumn();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cosc.setSuper_column(superColumn);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;Mutation&amp;gt; mutList = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ArrayList&amp;lt;Mutation&amp;gt;();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Mutation mut = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; Mutation();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mut.setColumn_or_supercolumn(cosc);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mutList.add(mut);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Map&amp;lt;String, List&amp;lt;Mutation&amp;gt;&amp;gt; mapCF = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; HashMap&amp;lt;String, List&amp;lt;Mutation&amp;gt;&amp;gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 1);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mapCF.put(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;TRABAJAN_FAMILY&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, mutList);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Map&amp;lt;String, Map&amp;lt;String, List&amp;lt;Mutation&amp;gt;&amp;gt;&amp;gt; muts = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; HashMap&amp;lt;String, Map&amp;lt;String, List&amp;lt;Mutation&amp;gt;&amp;gt;&amp;gt;();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; muts.put(llaveID, mapCF);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; client.batch_mutate(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;KEYSPACE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, muts, ConsistencyLevel.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;ONE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; reading(Cassandra.Client client, &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; i)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; InvalidRequestException, NotFoundException,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; UnavailableException, TimedOutException, TException,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; UnsupportedEncodingException {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String keyID = &lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;java&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; + i;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String llaveID = &lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Me gusta esto&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; + i;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ColumnPath colPathName = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ColumnPath(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;PROYECTOS_FAMILY&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; colPathName.setColumn(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;NOMBRE&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.getBytes(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;UTF8&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;Leemos&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;una&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;columna&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;clave&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, valor y &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;timestamp&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Column &lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;col&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; = client.get(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;KEYSPACE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, keyID, colPathName,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ConsistencyLevel.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;ONE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;).getColumn();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.println(&quot;--------- &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;Leemos&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;una&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;columna&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ------&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.println(new String(col.name, UTF8) + &quot;:&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// + new String(col.value, UTF8) + &quot;:&quot; + new Date(col.timestamp));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;Leemos&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;las&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;filas&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;completas&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; SlicePredicate predicate = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; SlicePredicate();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; SliceRange sliceRange = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; SliceRange();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sliceRange.setStart(&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;[0]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sliceRange.setFinish(&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;[0]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sliceRange.setCount(50000);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; predicate.setSlice_range(sliceRange);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.println(&quot;--------- &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;Leemos&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;todas&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;las&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;filas&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ------&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ColumnParent parent = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ColumnParent(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;PROYECTOS_FAMILY&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;ColumnOrSuperColumn&amp;gt; results = client.get_slice(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;KEYSPACE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, keyID,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; parent, predicate, ConsistencyLevel.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;ONE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// for (ColumnOrSuperColumn result : results) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// Column column = result.column;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.print(new String(column.name, UTF8) + &quot;:&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// + new String(column.value, UTF8) + &quot;:&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// + new Date(column.timestamp)+&quot; | &quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.println(&quot;----------------------------&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;Leemos&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;las&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;entradas&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;//&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; parent = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ColumnParent(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;TRABAJAN_FAMILY&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; results = client.get_slice(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;KEYSPACE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, llaveID, parent, predicate,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ConsistencyLevel.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;ONE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; (ColumnOrSuperColumn result : results) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; SuperColumn superColumn = result.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;super_column&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; UUID &lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;uuid&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; UUID(superColumn.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.println(uuid.toString() + &quot; [ &quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; (Column &lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;column&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; : superColumn.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;columns&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.print(new String(column.name, UTF8) + &quot;:&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// + new String(column.value, UTF8) + &quot;:&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// + new Date(column.timestamp)+&quot; | &quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.println(&quot; ] &quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; lecturaParticular(&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; i) &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; InvalidRequestException,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; NotFoundException, UnavailableException, TimedOutException,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; TException, UnsupportedEncodingException {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; a = 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; TTransport tr = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; TSocket(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;localhost&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, 9160);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; TProtocol proto = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; TBinaryProtocol(tr);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Cassandra.Client client = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; Cassandra.Client(proto);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tr.open();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; inicio = &lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String keyID = &lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;java&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; + i;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String llaveID = &lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Me gusta Cassandra&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; + i;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ColumnPath colPathName = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ColumnPath(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;PROYECTOS_FAMILY&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; colPathName.setColumn(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;NOMBRE&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.getBytes(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;UTF8&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;Leemos&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;una&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;columna&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;clave&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, valor y &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;timestamp&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Column &lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;col&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; = client.get(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;KEYSPACE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, keyID, colPathName,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ConsistencyLevel.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;ALL&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;).getColumn();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.println(&quot;--------- &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;Leemos&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;una&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;columna&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ------&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.println(new String(col.name, UTF8) + &quot;:&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// + new String(col.value, UTF8) + &quot;:&quot; + new Date(col.timestamp));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;Leemos&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;las&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;filas&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;completas&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; SlicePredicate predicate = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; SlicePredicate();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; SliceRange sliceRange = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; SliceRange();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sliceRange.setStart(&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;[0]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sliceRange.setFinish(&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;[0]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sliceRange.setCount(50000);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; predicate.setSlice_range(sliceRange);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.println(&quot;--------- &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;Leemos&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;todas&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;las&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;filas&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ------&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ColumnParent parent = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ColumnParent(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;PROYECTOS_FAMILY&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;ColumnOrSuperColumn&amp;gt; results = client.get_slice(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;KEYSPACE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, keyID,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; parent, predicate, ConsistencyLevel.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;ALL&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Total columnas: &quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; + results.size());&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; (ColumnOrSuperColumn result : results) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Column &lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;column&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; = result.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;column&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.print(new String(column.name, UTF8) + &quot;:&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// + new String(column.value, UTF8) + &quot;:&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// + new Date(column.timestamp)+&quot; | &quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.println(&quot;----------------------------&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;--------- ------&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; parent = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; ColumnParent(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;TRABAJAN_FAMILY&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; results = client.get_slice(&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;KEYSPACE&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, llaveID, parent, predicate,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ConsistencyLevel.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;ALL&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; a = results.size();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; (ColumnOrSuperColumn result : results) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; SuperColumn superColumn = result.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;super_column&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; UUID &lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;uuid&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; UUID(superColumn.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.println(uuid.toString() + &quot; [ &quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; (Column &lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;column&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; : superColumn.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;columns&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.print(new String(column.name, UTF8) + &quot;:&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// + new String(column.value, UTF8) + &quot;:&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// + new Date(column.timestamp)+&quot; | &quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// System.out.println(&quot; ] &quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tr.close();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; fin = &lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;double&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; total = (&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;double&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;) (fin - inicio) / 1000;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Total encontrados: &quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; + a);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Total proceso: &quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; + total);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; f() {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; Date().getTime();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #f3f3f3;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #f3f3f3;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
Ejemplo de codigo de Hector:&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span id=&quot;internal-source-marker_0.13340555157210887&quot; style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;nombre&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;del&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; cluster, &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;de&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;conexion&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;puede&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;ser&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;cualquiera&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;del&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;nodo&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Cluster cluster = HFactory.&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;getOrCreateCluster&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Test Cluster&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;192.168.254.66:9160&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;nombre&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;del&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;keyspace&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Keyspace keyspace = HFactory.&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;createKeyspace&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;CDT&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, cluster);&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Mutator mutator = HFactory.&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;createMutator&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;(keyspace);&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;inserta&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;datos&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mutator.insert(&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;jsmith&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Proyectos&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, HFactory.&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;createStringColumn&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;first&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;John&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;));&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mutator.insert(&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;pedroloco&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Proyectos&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, HFactory.&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;createStringColumn&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;first&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Pedro&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;));&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mutator.insert(&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;juanmiguel&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Proyectos&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, HFactory.&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;createStringColumn&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;first&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Juan&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;));&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;// &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;recupera&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;un&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;dato&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ColumnQuery&amp;lt;String, String&amp;gt; columnQuery = HFactory.&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;createStringColumnQuery&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;(keyspace);&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; columnQuery.setColumnFamily(&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Proyectos&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;).setKey(&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;jsmith&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;).setName(&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;first&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; QueryResult&amp;lt;HColumn&amp;lt;String, String&amp;gt;&amp;gt; result = columnQuery.execute();&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(result.get().getValue());&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;recupera&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;varios&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #3f7f5f; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;&quot;&gt;datos&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; MultigetSliceQuery&amp;lt;String, String&amp;gt; multigetSliceQuery = HFactory.&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;createMultigetSliceQuery&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;(keyspace, StringSerializer.&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;(), StringSerializer.&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;());&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; multigetSliceQuery.setColumnFamily(&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;Proyectos&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; multigetSliceQuery.setKeys(&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;java1&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;java100&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;java999&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; multigetSliceQuery.setRange(&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #2a00ff; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;, 3);&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; QueryResult&amp;lt;Rows&amp;lt;String, String&amp;gt;&amp;gt; result2 = multigetSliceQuery.execute();&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(result2.get().getCount());&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #7f0055; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt; (Row&amp;lt;String, String&amp;gt; r : result2.get()) {&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: #0000c0; font-family: Verdana; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;.println(r.getColumnSlice().getColumnByName(r.getColumnSlice().getColumns().get(0).getName()).getValue());&lt;/span&gt;&lt;br style=&quot;background-color: #f3f3f3;&quot; /&gt;&lt;i&gt;  Es mucho mas sencillo usar Hector como cliente que Thrift.&lt;/i&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/3415756223973367576/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/3415756223973367576' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/3415756223973367576'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/3415756223973367576'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/cassandra.html' title='Cassandra'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN1pBMEIMIo4i1Grur9tobM_Ctdu3WolUA60Zc3oqj9fV_X6SHnOz9QE0MzcMTRsAiHURjez-xKzgDam_xFllUIFIvn_QsUFzOZWJhyphenhyphena-kQ4_Sv1TaKbFov9UvX3npks40xSWpxArQnWo/s72-c/image01.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-7126589787327676683</id><published>2011-06-17T15:29:00.001-03:00</published><updated>2011-06-17T20:59:54.290-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Objetos"/><category scheme="http://www.blogger.com/atom/ns#" term="POO"/><category scheme="http://www.blogger.com/atom/ns#" term="Programación orientada a objetos con Java"/><title type='text'>Programación orientada a objetos con Java</title><content type='html'>La programación orientada a objetos o POO (OOP según sus siglas en inglés) es un paradigma de programación que usa objetos y sus interacciones, para diseñar aplicaciones y programas informáticos. Está basado en varias técnicas, incluyendo herencia, abstracción, polimorfismo y encapsulamiento. Su uso se popularizó a principios de la década de los años 1990. En la actualidad, existe variedad de lenguajes de programación que soportan la orientación a objetos. - Wikkipedia.&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
¿Que es un objeto?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Un objeto es una representación detallada, concreta y particular de un &quot;algo&quot;. Tal representación determina su identidad, su estado y su comportamiento particular en un momento dado.&lt;br /&gt;
Quizas decir que es una representación de un “algo” suene un tanto vaga, pero es exactamente eso: un objeto en el software puede representar a un objeto tangible como un “motor” o bien, puede representar a un objeto no tangible, como el objeto “estrategia”.&lt;br /&gt;
Un objeto es una pieza de software única que posee ciertas características (atributos) y un comportamiento previamente determinado (métodos que se definen en una clase).&lt;br /&gt;
A diferencia de otros lenguajes, un objeto siempre pertenece a una clase. No puede existir sintaxis “tirada” en cualquier lugar.&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img height=&quot;238&quot; src=&quot;https://lh5.googleusercontent.com/W8dmHZ6xD5pbNm8sww9iTEDsa8dLdv6LwathpGMSPt7CtetRTX82Eesib2BDgY3M-m1Hbmk7RDrI7fBmZIPsT3IITl-1yQrR1pkJdHZNhiXG9lS-QpA&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;¿Que es una clase?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Un clase es una plantilla que se utiliza para definir las características y habilidades de los objetos, lo que significa, que una clase es la definición de un objeto. Es un modelo abstracto, sin “vida”, ya que son sus instancias (objetos) las que tendrán valores en el futuro.&lt;br /&gt;
Desde un punto de vista más técnico, es el lugar donde se define los métodos y atributos que tendrán los objetos. Una clase es un contenedor de uno o más datos (variables o propiedades miembro) junto a las operaciones de manipulación de dichos datos (funciones/métodos).&lt;br /&gt;
Para aquellos que vienen de la programación estructurada es un conjunto de datos definidos por el programador, parecidos a las “estructuras de datos” de la programación estructurada, pero con la importante novedad de incluir también las herramientas necesarias para su manipulación.&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://lh3.googleusercontent.com/rdTQMT9cOR5fMNmNMgie_zh3pTMiRBDCDh8rSdtS3tNYvZd3lQ0ViGl7sAda5ZqzcA4_nYvmzCUkWLu3EWyP7NH0h92oWpvxj-vIxkRE18r47NsBNF4&quot; /&gt;&lt;/div&gt;&lt;br /&gt;
Cuando se crea una clase, por convención, suelen colocarse en la parte superior los atributos de la misma. Y en la parte inferior, sus métodos. Si esto no se cumple, funcionan igual, aunque esto podría afectar el entendimiento de la misma y, por ende, el mantenimiento del sistema.&lt;br /&gt;
Los nombres de las clases empiezan con mayúscula y si tuviesen palabras en el medio, también comenzarían con mayúscula: AutoDeCarrera.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Atributos&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Los atributos son las características del objeto. Toman valores durante la vida del mismo. Estos valores determinan el estado del objeto.&lt;br /&gt;
Cuando definimos un atributo se establece su nombre y su tipo. Los atributos suelen ser sustantivos. Marcan las propiedades del objeto.&lt;br /&gt;
Una persona puede tener varios atributos. Además de las variables (y clases) definidas por Java, es posible agregar atributos propios, por ejemplo documento que hace referencia a la clase Documento.&lt;br /&gt;
Los atributos se escriben con minúscula y si tuviesen palabras en el medio, éstas van con mayúscula: colorDeOjos.&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://lh6.googleusercontent.com/2E_FiDwIQuBbSSMxFPVaAMHGc-JPFvwZseKItpdBnEmiFYynjHADvass8DuB2QbViu-q-JNxfy0pKwtF42kInMFRb-lDSUEY8y5VCXEDNFOUX0qZPK0&quot; /&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Métodos&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Representan el comportamiento del objeto. Es decir, lo que el objeto puede hacer.&lt;br /&gt;
Los métodos se escriben con minúscula y si tuviesen palabras en el medio, éstas van con mayúscula: dameCantidad().&lt;br /&gt;
&lt;br /&gt;
Deben especificar lo que devuelven….y en caso que no devuelvan nada se utiliza la palabra reservada “void”.&lt;br /&gt;
&lt;img src=&quot;https://lh6.googleusercontent.com/4LPAibOusHC3J7J3LiVSYUW2PtNeKg6AAHFHw_4P0RAGCit-oZ4KftlnYUtyrbbkU25A2MJAI1swtsmour0dsf9JVFBOduZXChplAe4Zdw4hNWgf1q0&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Creando objetos.&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Un objeto es una instancia de una clase.&lt;/li&gt;
&lt;li&gt;Es la implementación con valores del modelo abstracto (clase).&lt;/li&gt;
&lt;li&gt;La sintaxis para crear un objeto es new Objeto(), donde la parte izquierda del igual representa la referencia del objeto.&lt;/li&gt;
&lt;/ul&gt;Por ejemplo, para crear un objeto de la clase Persona habría que colocarla siguiente sintaxis:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Persona p = new Persona();&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
El paradigma de objetos posee tres características fundamentales:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Encapsulamiento&lt;/li&gt;
&lt;li&gt;Herencia&lt;/li&gt;
&lt;li&gt;Polimorfismo&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
1) Encapsulamiento.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Consiste en ocultar los detalles de la implementación de un objeto, a la vez que se provee una interfaz pública por medio de sus métodos permitidos.&lt;/li&gt;
&lt;li&gt;Es la propiedad de los objetos de permitir el acceso a sus estados. Esto se logra a través de su interfaz pública o a través de relaciones preestablecidas con otros objetos. Lo que importa es el comportamiento del objeto y no como esta implementado ese comportamiento.&lt;/li&gt;
&lt;li&gt;Tiene una regla de oro: atributos en privado y métodos públicos.&lt;/li&gt;
&lt;/ul&gt;El modificador “private” hace que un atributo (o método) pueda ser accedido sólo dentro de la propia clase.&lt;br /&gt;
El modificador “public” hace que un atributo (o método) pueda ser accedido desde todos lados.&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://lh5.googleusercontent.com/6o67oHK3JmbC2meIA1lU2My5N2OaYUgO5JHFrsOfaiBvFZtG5Cmy-cLeBS33ERlTXdDSCqGs2YKe95HF1HJ5QFiLdM_DCBtGFTYWh91zD2MJ_2PB5uc&quot; /&gt;&lt;/div&gt;Aquí vemos como todos los atributos son privatizados y todos tienen métodos Get que sirve para pedir el valor del atributo en cuestión y un método Set que sirve para asignarle un valor determinado. Se debe prestar especial atención a aquellos atributos que son objetos, ya que reciben un objeto instanciado.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://lh5.googleusercontent.com/nB6tnhXwBp8fRP9FPv7f8LP-v3nMuxrk3rGnypM168fC0kUbZAJi3ZPVoyBoWHSz26xkvNp9WPwgX81ElS3cRxuGqGQFwD7dHdUgzPoCDXcOFD7Nh5Q&quot; /&gt;&lt;/div&gt;Los errores de codificación se subrayan en rojo y son debido a que los atributos fueron privatizados, por ende, no pueden ser accedidos por fuera de la clase.&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://lh6.googleusercontent.com/eOkX6_hoIx2J2tzymbklr-I6vBuEaXFZpaG3rf6k1hpR6TzwvFZVSWErgxc4Ei9gtXaiZdZW7oHY4_-wPR_BJJ5eJr9UJIkER-o5gR0-fu0v6m0GDGk&quot; /&gt;&lt;/div&gt;Esta sería la forma correcta.&lt;br /&gt;
&lt;br /&gt;
Ventajas del encapsulamiento.:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;La complejidad de la implementación queda escondida al resto de los objetos. Esto se ve reflejado en la vida real, yo quiero que mi auto funcione pero no quiero saber como esta hecho el motor.&lt;/li&gt;
&lt;li&gt;La implementación de un objeto puede variar sin que ello afecte a los objetos que interactúan con él. Esto se debe a que los objetos llaman a un método y no saben como es la implementación. De esta manera, si la implementación (que es algo interno de la clase) varía, el resto de los objetos no se ven afectados.&lt;/li&gt;
&lt;li&gt;Se protege al objeto de usos indebidos o inapropiados. Si los atributos son accedidos a través de métodos, es posible realizar ciertas validaciones, por ejemplo, el método setSueldo(-120) no debería asignar 120 al sueldo de la persona, ya que es un número negativo. El método setIVA(0.25) debería ser privado, asi ese atributo es de sólo lectura.&lt;/li&gt;
&lt;li&gt;Se centraliza la manipulación del dato. Supongamos que el método getDNI() debe ser modificado para que, además del DNI, nos anteponga el número de sucursal donde trabaja la persona. Sin los Get y Set hubiera sido bastante engorroso y hubiesemos tenido que recorrer todo el programa. Con los Get y Set es tan simple como modificar 1 sólo método.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
2) Herencia.&lt;br /&gt;
&lt;br /&gt;
Es la capacidad de un objeto para utilizar las estructuras y métodos existentes en sus antepasados. Los “hijos” pueden compartir (y extender) su comportamiento sin tener que reimplementarlo. Si bien se heredan los métodos de los antepasados, es posible redefinirlos si fuera necesario.&lt;br /&gt;
La idea es no repetir comportamientos que otros ya lo tienen implementados. La idea es que en la clase padre exista un comportamiento estándar y la clase hija pueda especializarse en otros aspectos.&lt;br /&gt;
&lt;br /&gt;
Hay dos tipos de herencia:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Simple&lt;/li&gt;
&lt;li&gt;Múltiple ( es cuando una clase tiene más de 1 padre, lo cual no esta permitido en Java)&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://lh5.googleusercontent.com/nfdg_ukdt7ZYe4qpPbAEGL6EYgN0r5wovn6ay_L-DWOmsxIAujUyU7lMyI9xhBbaT7DGJR7HfNOD0sB5bHfQVJnSlnnp4gqoG5-qcnldJhKTPGH2WR4&quot; /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;En Java, para heredar de una clase se utiliza la palabra clave “extends”. En nuestro ejemplo la definición de la clase Cliente es: public class Cliente extends Persona&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://lh5.googleusercontent.com/GO2kImqC-8M30NkpssNyogSbZMyBRMEnkNJKEAlBSI_R46_W2JeUJ7Rt8RatTIgQB3h-4ra1wXhLtEpAvYierCa7wdrR-OH7NkKkapWGmI_avxtrL6w&quot; /&gt;&lt;/div&gt;&lt;br /&gt;
Ventajas de la herencia.&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Aumenta la reutilización del código. Tal como se pudo apreciar en la presentación anterior.&lt;/li&gt;
&lt;li&gt;Favorece el Polimorfismo de los objetos. Esto se verá a continuación.&lt;/li&gt;
&lt;li&gt;Las clases pueden ser organizadas jerárquicamente. Un “hijo” es un “tipo de…” de una clase padre.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
3) Polimorfismo.&lt;br /&gt;
&lt;br /&gt;
Polimorfismo implica varias formas de responder el mismo mensaje. En programación orientada a objetos se denomina polimorfismo a la capacidad que tienen objetos de diferentes clases de responder al mismo mensaje.&lt;br /&gt;
Esto significa que puede haber muchos mensajes con el mismo nombre, en diferentes clases. Cada clase responde al mensaje con su código propio (o método).&lt;br /&gt;
Existen diferentes formas de apreciar el polimorfismo:&lt;br /&gt;
a) Sobre-carga de métodos&lt;br /&gt;
b) Sobre-escritura de métodos&lt;br /&gt;
c) Vinculación dinámica&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
a) Sobrecarga de métodos.&lt;br /&gt;
&lt;br /&gt;
La sobrecarga de métodos consiste en declarar métodos con el mismo nombre que serán diferenciados por los parámetros que reciben o que retornan.&lt;br /&gt;
Los parametros se diferencian por el tipo y la cantidad.&lt;br /&gt;
Por ejemplo, un mismo nombre de método puede recibir un String o un int o nada. Ahora veremos un ejemplo donde quedará más claro.&lt;br /&gt;
&lt;img src=&quot;https://lh5.googleusercontent.com/F2j7bMMAgJOOlvkr5AgZsbwM8l4Ry1EmFK1LnSzcNKzjs0IXFmD4tt3S91yZhiOlmzNqGtnZbZfIwsPv3GvXBrddcQwUbN_vMnUuki8vAae_nEPyNS4&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
En el ejemplo se puede observar que en caso de crear un una Persona, es posible asignarle un apellido, así como también es posible no pasarle parámetros y que tome un apellido por default.&lt;br /&gt;
La ventaja de esto es que no es necesario declarar una método con distinto nombre para métodos similares en los que únicamente cambia el tipo de parámetros que han de utilizar.&lt;br /&gt;
&lt;br /&gt;
b) Sobreescritura de métodos&lt;br /&gt;
&lt;br /&gt;
Una subclase sobreescribe un método de su superclase cuando define un método con las mismas características (nombre, número y tipo de argumentos) que el método de la superclase.&lt;br /&gt;
Las subclases emplean la sobreescritura de métodos la mayoría de las veces para agregar o modificar la funcionalidad del método heredado de la clase padre.&lt;br /&gt;
&lt;img src=&quot;https://lh6.googleusercontent.com/11ZJ3N4tFWGKPE1a-3urOzYGaaGimLGrGZn2SsLa6UiuaqNqoZwd9Uslfr8ft3ciupBKzGyNwy1wMCs5BuObOUPPTQ5DnCBVeJ7VAaQMZ9q_WqRqwlY&quot; /&gt;&lt;br /&gt;
En el ejemplo vemos que el nombre por default “Perez” no le sirve a la clase Cliente, la cual prefiere “Garcia”.&lt;img src=&quot;https://lh6.googleusercontent.com/nIncQko2BvNkTJbdSY9-OPR4fnEoXUwAtdpmoYwlSIJOwbs3jdEv06mKIzzC8HEP99IVihOZwzVow5q_2emGnsLRodHMCzuFEJnEx2XksuqGeFCB7VA&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Vemos en el ejemplo que Persona y Cliente tienen la opción de setear un apellido (1er caso) o tomar el que viene por default (2do y 3er caso). Esto se puede apreciar en la salida por consola.&lt;br /&gt;
&lt;br /&gt;
c) Vinculación dinámica.&lt;br /&gt;
&lt;br /&gt;
Una referencia a un objeto de una clase, puede pasar a referenciar a otro objeto de otra clase.&lt;br /&gt;
Esto es posible siempre y cuando esten en la misma línea de herencia.&lt;br /&gt;
En nuestro ejemplo, una persona Puede referencia a un Cliente, ya que ambos se encuentran en la misma línea de herencia.&lt;br /&gt;
&lt;img src=&quot;https://lh3.googleusercontent.com/gmTKJg6At1nrpR3e-fUV63kcvG2ytItRhfl5zlzeXtxhAtiEIFpcCy_CQ1VFocqukRWPg5CkB2WFlsV_niEAOtb7UQ2-Q7LYBLh2Vo0ljvhwrYWn1dA&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Si bien la clase instancia es Cliente, se puede observar que el numero de cliente no aparece. Si lo necesito debo “castear”. Luego veremos este concepto.&lt;br /&gt;
&lt;img src=&quot;https://lh6.googleusercontent.com/4-TASfrDzRvoPFShFq3_uImqDe4D6vMr1wbukYQCOdh8ZB_6KAX_59S6CYiEv3hJ9SLXuTAL5ktpkfHUqTPCjxF1oXy25-aoXkQYLuoWLshhHl87Fjs&quot; /&gt;&lt;br /&gt;
Respuesta correcta: Garcia.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Casteo.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Para que un objeto que fue referenciado por otro pueda recuperar sus métodos particulares es necesario “castear”.&lt;br /&gt;
El casteo sirve para cambiar de tipo. Es como que el objeto se “saca el disfraz”.&lt;img src=&quot;https://lh5.googleusercontent.com/B0xp6P6jaJdhcymdZ7SRFbEIU5GWq2tBpqwjGP2_OJN5Mr0w9UT_kJerdy2uHXaXFkKHJzwkr8iABHrEzV2eKL1qCsb5bDr3g_n4SDkAozENkorPTuM&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Hasta aquí la teoría de objetos, pero pronto crearé una nueva entrada con cosas básicas de Java como tipos de atributos/métodos, clases abstractas, paquetes, interfaces, etc. que van a complementar este post.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;nbsp;Para crear este post me he basado en unos manuales que he escrito junto a otros profesores cuando trabajaba en IBM. Ellos son:&lt;/i&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;i&gt;David Brunstein.&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Gabriel García.&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Sabrina Campa.&lt;/i&gt;&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/7126589787327676683/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/7126589787327676683' title='5 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/7126589787327676683'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/7126589787327676683'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/programacion-orientada-objetos-con-java.html' title='Programación orientada a objetos con Java'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh5.googleusercontent.com/W8dmHZ6xD5pbNm8sww9iTEDsa8dLdv6LwathpGMSPt7CtetRTX82Eesib2BDgY3M-m1Hbmk7RDrI7fBmZIPsT3IITl-1yQrR1pkJdHZNhiXG9lS-QpA=s72-c" height="72" width="72"/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-7673211614326318412</id><published>2011-06-16T21:31:00.003-03:00</published><updated>2011-06-24T17:20:20.645-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Cache"/><category scheme="http://www.blogger.com/atom/ns#" term="¿Cual es el mejor Java Cache?"/><title type='text'>¿Cual es el mejor Java Cache?</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Para hacerla corta...Infinispan. Para hacerla larga y ver que pruebas hicimos para sacar esa conclusión, leer lo que sigue a continuación.&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;Hemos realizado diverso tipos de pruebas con los caches más conocidos para que se tenga una mejor visión a la hora de seleccionar una alternativa.&lt;br /&gt;
&lt;br /&gt;
Algunas de las siguientes pruebas se realizaron con el framework &lt;a href=&quot;http://cachebenchfwk.sourceforge.net/&quot;&gt;CacheBenchFwk&lt;/a&gt;  en su version 1.0.0 y otras se hicieron con una aplicación desarrollada  especialmente para estas pruebas, para poder tener una vista mas  detallada sobre las ventajas de esta herramienta. &lt;br /&gt;
&lt;br /&gt;
Las pruebas con el CacheBenchFwk las hemos realizado con las siguientes herramientas: &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Infinispan 4.0.0 &lt;/li&gt;
&lt;li&gt;Jboss Cache 3.2.2GA &lt;/li&gt;
&lt;li&gt;EHCache 1.7.2 &lt;/li&gt;
&lt;/ul&gt;Y las pruebas desarrolladas por nosotros las hicimos con las siguientes librerías en su versión FINAL:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Infinispan 4.1.0 &lt;/li&gt;
&lt;li&gt;Jboss Cache 3.2.5GA &lt;/li&gt;
&lt;li&gt;EHCache 2.2.0 &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
Las pruebas fueron realizadas con las siguiente configuracion:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Linux Ubuntu 10.04 &lt;/li&gt;
&lt;li&gt;Total memoria RAM: 4 Gigas. &lt;/li&gt;
&lt;li&gt;Procesador: 4 procesadores Intel Atom 330 1.6 Ghz. &lt;/li&gt;
&lt;li&gt;JDK version &quot;1.6.0_20&quot; 64-Bit con los parametros -Xms1g -Xmx1g &lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://cachebenchfwk.sourceforge.net/&quot;&gt;CacheBenchFwk&lt;/a&gt; 1.0.0 &lt;/li&gt;
&lt;li&gt;Pruebas en modo standalone con 25 concurrencias usando Strings generados aleatoriamente tanto para valores como para las claves generando 1 kb de carga por cada entrada. &lt;/li&gt;
&lt;li&gt;Las pruebas no locales fueron hechas en una red local con 3 nodos de iguales características a las descriptas anteriormente.  &lt;/li&gt;
&lt;li&gt;Configuraciones de las distintas tecnologias estan por default.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Pruebas locales.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
En los siguientes graficos de performance se ven dos barras verticales para Infinispan como para JbossCache. Cada una se corresponde con un tipo de Isolation level Read Commited y Repeatable Read. &lt;br /&gt;
&lt;br /&gt;
1) Pruebas de Stress &lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;Carga de datos &lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrLHTmRQF6HhC1eJrf8PU2bUEwu1AqeqDu0LdNydXv_u8CZ8ECR17CdtOqO4OBZUVsZwpS1LuQSPsOGkPQmOOs923sy5IL9Ll8wNbZvGvnmYjsTrhA646ogZIIMX1ten8R09glODIoFow/s1600/stress1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrLHTmRQF6HhC1eJrf8PU2bUEwu1AqeqDu0LdNydXv_u8CZ8ECR17CdtOqO4OBZUVsZwpS1LuQSPsOGkPQmOOs923sy5IL9Ll8wNbZvGvnmYjsTrhA646ogZIIMX1ten8R09glODIoFow/s640/stress1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;Lectura de datos &lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-VRxvxCJ_bOWHVmcfYzuT74Qg7Ti7lkHXhBS9zpZUjGqybyoEXlfZTr1XoUqwDezboYktsmT4SnFe4BA2kRC2uVZWCgCCTqkQ50124NgARm1EllfMbGRBcUNi2MsCQ1-01psOxPj1OXg/s1600/lect1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-VRxvxCJ_bOWHVmcfYzuT74Qg7Ti7lkHXhBS9zpZUjGqybyoEXlfZTr1XoUqwDezboYktsmT4SnFe4BA2kRC2uVZWCgCCTqkQ50124NgARm1EllfMbGRBcUNi2MsCQ1-01psOxPj1OXg/s640/lect1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
2) Pruebas de escritura y lectura simples &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmLz_f6H7gfciGBnWh8WTT_EktjXaGhxhm0G6XOfu_R4p0-a-CQZtOVFE96-UTLgbaWxBw3aEWtQ4Lc7pYEK54FuZUz43CopuyDZymYgFgutWCfy9dZ7KjG8Z2OdQGWLZ_aOxm2rfxaKg/s1600/escritsimple.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmLz_f6H7gfciGBnWh8WTT_EktjXaGhxhm0G6XOfu_R4p0-a-CQZtOVFE96-UTLgbaWxBw3aEWtQ4Lc7pYEK54FuZUz43CopuyDZymYgFgutWCfy9dZ7KjG8Z2OdQGWLZ_aOxm2rfxaKg/s640/escritsimple.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgehFWK_cJk1E_y5aAs2IlFDmcN1Nfu_OJYCX_8hfMtEMgtJR0g5bV4ZxBPeuhP4SjZVv3LILNngaDi7ccKIR6neOk4b3KX2YUxGnWrvomEs5YVs15Ve65lgwAXzMzU-QzgHyXeXHvpIPU/s1600/lectsimple.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgehFWK_cJk1E_y5aAs2IlFDmcN1Nfu_OJYCX_8hfMtEMgtJR0g5bV4ZxBPeuhP4SjZVv3LILNngaDi7ccKIR6neOk4b3KX2YUxGnWrvomEs5YVs15Ve65lgwAXzMzU-QzgHyXeXHvpIPU/s640/lectsimple.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;i&gt;Los tiempos son tan bajos que Infinispan no aparece en la grafica. &lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Como se puede apreciar en los graficos anteriores Infinispan es superior a Jboss Cache y EHCache, obteniendo los tiempos mas bajos tanto en escritura como lectura de datos. &lt;br /&gt;
&lt;br /&gt;
En el caso de la pruebas de stress, estan fueron hechas con los distintos caches como si funcionaran unicamente en un servidor dedicado exclusivamente para cache. Si bien la tecnologia con la que se hicieron las pruebas no son las de un servidor, son aproximados los resultados. Las pruebas de stress demuestran que en el caso de que se quiera montar un servidor para uso exclusivo de cache Infinispan es una excelente opción, ya que en la pruebas se uso concurrencia simulando las distintas peticiones que se pueden realizar. Estas pruebas se realizaron como unico nodo, pero Infinispan se puede usar en modo cluster lo cual permitiria una mayor disponibilidad de datos y ser escalable, pudiendo elegir el modo en que se repliquen los datos(en cada nodo una copia o una parte de esta). &lt;br /&gt;
&lt;br /&gt;
Por otro lado las pruebas simples fueron hechas con una aplicación simple desarrollada por Guillermo y por mí para demostrar la performance de cada cache en un modo de uso local contra una aplicación. Las pruebas, como se ve en los graficos, volvieron a dar a Infinispan como el más rapido. Estos resultados por ejemplo nos sirven a la hora de decidir con que cache de segundo nivel poner a funcionar Hibernate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Pruebas no locales.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Dado que Infinispan fue un amplio ganador con respecto al resto, decidimos ampliar sus pruebas y realizar un testeo con varios nodos en red para ver si decrecía su rendimiento de alguna manera. Estas pruebas tuvieron las siguientes características: &lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Las pruebas se realizaron el con el cliente Hot Rod y en modo embebido, debido a que son las dos mejores maneras de usar Infinispan en un entorno con Java. &lt;/li&gt;
&lt;li&gt;Para funcionar en modo cluster Infinispan usa Jgroups con las configuraciones TCP como para UDP. &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Vamos a hacer una breve explicación de los dos modos:&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;1) Modo embebido.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
La configuración en este modo es secilla, puede ser declarativa o programatica. Con esto podemos levantar varios nodos, pero en cada uno de estos debemos poner nuestra aplicación con Infinispan embebido. Si bien la configuracion es sencilla esto tiene desventajas: &lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Alto consumo de recursos. &lt;/li&gt;
&lt;li&gt;Tiempo en inicializar Infinispan depende de la cantidad de datos que maneje el cache en ese momento. &lt;/li&gt;
&lt;li&gt;Bloqueo de acceso al resto de las instancias al agregar nuevos nodos, debido que estos son lentos en levantar. &lt;/li&gt;
&lt;li&gt;Para agregar un nuevo nodo debo deployar la aplicación en este. &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;2) Hot Rod Client&lt;/span&gt;&lt;br /&gt;
Esta manera de utilizar Infinispan resulta mas sencilla, rapido y performante que la embebida. Lo que se hizo fue levantar los nodos de la siguiente manera: &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;./startServer.sh -r hotrod -l 192.168.254.66 -c config.xml -p 11311 -o 192.168.254.66 -x 11311 &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Una vez con todos los nodos levantados, estos ya se estaban mandando mensajes entre sí. Luego levantamos la aplicación configurando la ip de un solo nodo y enseguida reconocio el resto y creo un pool de conexiones para cada uno. El codigo usado fue el siguiente: &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG8z8xE_5zL0Jw11j7BGXADkxmYxRkyx0sM5pUH0xn1e5JZtOA2ICAE8e_nUI2vmQ0Hvo3J0tMWMmlznYmvW6JeTKGNHPLQ1maIBpGUCQ0A3fDzGVBbElBm-Z1LgclvT06xnpQ7NGGhfM/s1600/codigo.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG8z8xE_5zL0Jw11j7BGXADkxmYxRkyx0sM5pUH0xn1e5JZtOA2ICAE8e_nUI2vmQ0Hvo3J0tMWMmlznYmvW6JeTKGNHPLQ1maIBpGUCQ0A3fDzGVBbElBm-Z1LgclvT06xnpQ7NGGhfM/s1600/codigo.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoBOyATYZVvb8SAhCaLFQn3bD9uVkF1X52DYWVrs3BieJ6NaOI7lnjEPGpJmP8hWfxoZdSwl5wGAUvTb4zwoOOPJwBaSY-IYzFBE_qUwrTwKvsdXGOyG2OOSxnX_N5HXdfPCLTmBgRY_8/s1600/properties.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoBOyATYZVvb8SAhCaLFQn3bD9uVkF1X52DYWVrs3BieJ6NaOI7lnjEPGpJmP8hWfxoZdSwl5wGAUvTb4zwoOOPJwBaSY-IYzFBE_qUwrTwKvsdXGOyG2OOSxnX_N5HXdfPCLTmBgRY_8/s1600/properties.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Las pruebas con este cliente fueron mas que satisfactorias, ya que el cliente detectaba cuando se agregaba un nodo o se bajaba uno del cluster. Esto no afectaba a su performance. Si bien este cliente hay algunas operaciones que no soporta como las queries sobre el cache su manejo del cluster compensa. &lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;¿Que aprendimos de las pruebas realizadas?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Al realizar las pruebas en modo embebido y con el cliente Hot Rod, se recomienda ampliamente el uso del cliente Hot Rod en un entorno Java, ya que este maneja de manera mas eficiente el cluster: &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Detecta automáticamente cambios en la topología del cluster. &lt;/li&gt;
&lt;li&gt;Al agregar nuevos nodos resulta es más rapido con el cliente Hot Rod que de manera embebida. &lt;/li&gt;
&lt;li&gt;Usa lo que se llama smart routing para mayor velocidad de respuesta. &lt;/li&gt;
&lt;li&gt;Se puede controlar el pool de conexiones con el cluster. &lt;/li&gt;
&lt;li&gt;Al levantar el cliente este empieza a detectar los posibles nodos del cluster en la red local.&lt;/li&gt;
&lt;li&gt;Muy configurable. &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Conclusión. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Infinispan es un producto opensource de JBoss y se ha nutrido de la experiencia de Jboss Cache (una librería). Es una solución que nos permite crear enormes estructuras de datos distribuidas y altamente concurrentes almacenadas en la memoria RAM de múltiples nodos de un cluster. &lt;br /&gt;
&lt;br /&gt;
Hemos podido observar que Infinispan es altamenta escalable, configurable y sencilla de utilizar. Asimismo, su rendimiento suele ser superior en casi todos los aspectos con respecto a sus competidores. &lt;br /&gt;
&lt;br /&gt;
Infinispan no presentó problemas para realizar pruebas en máquinas distribuídas y su velicidad se ha mantenido constante en las diversas pruebas. Es un producto áltamente recomendable.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Este post es una adaptación de un informe que hice junto a Guillermo Kessler&lt;/i&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/7673211614326318412/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/7673211614326318412' title='3 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/7673211614326318412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/7673211614326318412'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/cual-es-el-mejor-java-cache.html' title='¿Cual es el mejor Java Cache?'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrLHTmRQF6HhC1eJrf8PU2bUEwu1AqeqDu0LdNydXv_u8CZ8ECR17CdtOqO4OBZUVsZwpS1LuQSPsOGkPQmOOs923sy5IL9Ll8wNbZvGvnmYjsTrhA646ogZIIMX1ten8R09glODIoFow/s72-c/stress1.png" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-1969971963175303076</id><published>2011-06-16T00:18:00.003-03:00</published><updated>2011-06-22T17:49:17.085-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Infinispan"/><category scheme="http://www.blogger.com/atom/ns#" term="Java Cache"/><title type='text'>Infinispan</title><content type='html'>Infinispan es una plataforma open source de manejo de Cache. Es similar a otras herramientas conocidas en el mercado como EHCache, JBoss Cache o Coherence.&lt;br /&gt;
Cabe aclarar que siendo una herramienta de Jboss, no es una improvisación, sino que el proyecto creció nutriendose de la experienca de JBoss Cache. De todas maneras, son herramientas diferentes, sin relación alguna. La gran diferencia entre ambas es que Jboss Cache es una librería y infinispan es una plataforma mucho mas completa, con herramientas GUI y posibilidad de distribuirla en miles de servidores/nodos.&lt;br /&gt;
Se puede bajar de: &lt;a href=&quot;http://www.jboss.org/infinispan&quot;&gt;http://www.jboss.org/infinispan&lt;/a&gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Sus características son: &lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Memoria masiva y alta disponibilidad: si bien es posible utilizar infinispan de manera local, su fuerte es el trabajo distribuìdo. No sólo se limita a que cada servidor es una copia de otro (como Jboss Cache), también es posible realizar realizar una distribución de la información en los diferentes servidores. &lt;/li&gt;
&lt;li&gt;Escalabilidad: dado que es una plataforma distribuida es muy simple lograr que sea escalable. Se puede acoplar tantas instancias como se deseen y no existe impedimento hasta donde se quiera crecer con la capacidad del Cache. &lt;/li&gt;
&lt;li&gt;Datos distribuidos: su algoritmo de hashing permite que sus datos distribuidos se recuperen de manera veloz y sin generar tráfico en la red. &lt;/li&gt;
&lt;li&gt;Persistencia: posee varias formas para guardar los datos en el disco duro, que van desde JDBC hasta archivos planos. &lt;/li&gt;
&lt;li&gt;Lenguajes varios: no sólo es posible trabajar con Java, también es posible utilizar varios lenguajes más como PHP, Python, Ruby, C, etc. &lt;/li&gt;
&lt;li&gt;Administración: es simple de administrar y posee herramientas GUI para realizar estadísticas. &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Configuración del Cache.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Es posible realizar una configuración declarativa, basada en XML o bien a nivel programación. Por otro lado, se puede configurar como default o Global, siendo esta última un cache compartido entre varias instancias. &lt;br /&gt;
Si se tiene una configuración previa con otra herramienta de cache, existen scripts que automatizan la migración hacia infinispan desde: &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;EHCache 1.x &lt;/li&gt;
&lt;li&gt;JBoss Cache 3.x &lt;/li&gt;
&lt;li&gt;Coherence 3.x &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Tiene muchas facilidades para lockear objetos, sincronizar el cache, limpiarlo o hasta indexarlo de diversas formas. Es altamente configurable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ejemplo.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV4BmXOv1O88wcGadnp3ffIRHt7IdLq3TQL9Pg8cWzAy21r83_zKsGKb2Lic5Y0OzVhThVvfbYdSaUxwd6q3mUCbwXpMIz4j3Ev9Y5doyvpDJlRSkC5V4fqvEJ6ttiQbnLBWVILMPNujc/s1600/infnispan.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV4BmXOv1O88wcGadnp3ffIRHt7IdLq3TQL9Pg8cWzAy21r83_zKsGKb2Lic5Y0OzVhThVvfbYdSaUxwd6q3mUCbwXpMIz4j3Ev9Y5doyvpDJlRSkC5V4fqvEJ6ttiQbnLBWVILMPNujc/s1600/infnispan.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio_ERM2_C2Tn0zJTNUdtS-3zP0n_dpOkDqQHKt0msbvzXTynwK0FTvsxI72epmB0tyaBqM07IRVIFNNprhnNt8PVp396aJ586lRGhyphenhyphenQj3viMixu7jf8eLyFlGWTm9t_o-ktT3Ym68MM7o/s1600/infimetodfos.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio_ERM2_C2Tn0zJTNUdtS-3zP0n_dpOkDqQHKt0msbvzXTynwK0FTvsxI72epmB0tyaBqM07IRVIFNNprhnNt8PVp396aJ586lRGhyphenhyphenQj3viMixu7jf8eLyFlGWTm9t_o-ktT3Ym68MM7o/s1600/infimetodfos.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Cache Loaders &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Un Cache Loader es la conexión que se mantiene contra una herramienta de persistencia de datos. Dicho loader es el encargado de guardar los datos para su posterior persistencia y obtener los datos cuando estos no se encuentren en el cache. &lt;br /&gt;
Infinispan posee muchas formas de configuración de cache loaders, de hecho, se puede configurar más de uno al mismo tiempo para que trabajen en cadena. Asimismo, se puede configurar algunos items como Cache Passivation, Eviction, Pool de Conexiones, etc. &lt;br /&gt;
Se ofrecen diversos tipos de cache loaders como File System, JDBC (soporta JTA), Hibernate, Cloud cache loader, Remote cache loader y Cassandra cache loader. &lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
Módulos de servidor para Infinispan.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Apartir de la version 4.1 se agrego la posibilidad de usar Infinispan en el modo cliente-servidor, lo cual permite levantar unicamente servidores de Infinispan de manera muy rapida. Esto es por la creacion de distintos modulos de servidor y distintos clientes para estos, permitiendo usar un esquema de acceso como el siguiente (el gráfico lo saque de la página oficial): &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://community.jboss.org/servlet/JiveServlet/downloadImage/102-15557-12-3911/450-336/Screen+shot+2010-07-09+at+1.03.17+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://community.jboss.org/servlet/JiveServlet/downloadImage/102-15557-12-3911/450-336/Screen+shot+2010-07-09+at+1.03.17+PM.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
Tipos de servidor &lt;/span&gt;          &lt;style type=&quot;text/css&quot;&gt;
p { margin-bottom: 0.21cm; }h1 { margin-top: 0cm; margin-bottom: 0cm; }h1.western { font-family: &quot;Liberation Serif&quot;,serif; font-size: 12pt; font-weight: normal; }h1.cjk { font-family: &quot;DejaVu Sans&quot;; font-size: 12pt; font-weight: normal; }h1.ctl { font-family: &quot;DejaVu Sans&quot;; font-size: 12pt; font-weight: normal; }a:link {  }
&lt;/style&gt;&lt;br /&gt;
&lt;br /&gt;
Los tipos de servidores se diferencian en el protocolo de comunicación y como manejan las conexiones entrantes.&lt;br /&gt;
&lt;br /&gt;
REST:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Distribuído como un archivo WAR, que puede ser deployado en cualquier servlet container permitiendo el acceso a Infinispan vía &lt;a href=&quot;http://community.jboss.org/docs/DOC-14134&quot;&gt;RESTful interface&lt;/a&gt;. &lt;/li&gt;
&lt;li&gt;Para poder conectarse se puede usar cualquier cliente HTTP. &lt;/li&gt;
&lt;li&gt;Este módulo es recomendado para entornos donde el puerto HTTP es el único método de acceso permitido entre clientes y servidores. &lt;/li&gt;
&lt;li&gt;Los clientes de quieran equilibrar la carga o tolerancia a fallas (failover) entre los diferentes REST servers pueden usar culquier HTTP load balancer standard como &lt;a href=&quot;http://www.jboss.org/mod_cluster&quot;&gt;mod_cluster&lt;/a&gt;. &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Memcached:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Es una implementacion de &lt;a href=&quot;http://github.com/memcached/memcached/blob/master/doc/protocol.txt&quot;&gt;Memcached text protocol&lt;/a&gt; respaldado por Infinispan. &lt;/li&gt;
&lt;li&gt;Para conectarse se puede usar cualquiera de los &lt;a href=&quot;http://code.google.com/p/memcached/wiki/Clients&quot;&gt;Memcached client&lt;/a&gt;. &lt;/li&gt;
&lt;li&gt;A diferencia de los Memcached servers, los Memcached servers basados en Infinispan se los puede poner en cluster y por lo tanto distribuir o replicar informacion usando algoritmos hash. Entonces este modulo es interesante para usuarios que quieran proveer failover de la informacion en Memcaches servers. &lt;/li&gt;
&lt;li&gt;Algunos clientes soportan load balance y failover pasandoles una lista estatica de direcciones de servidores (perl&#39;s Cache::Memcached por ejemplo) pero para agregarle o sacarle algun servidor se tiene que hacer manualmente.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Hot Rod &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Hot Rod server es una implementacion de &lt;a href=&quot;http://community.jboss.org/docs/DOC-14421&quot;&gt;Hot Rod Protocol&lt;/a&gt; respaldado por Infinispan que permite a los clientes hacer dynamic load balancing, failover y smart routing. &lt;/li&gt;
&lt;li&gt;Las opciones de Java Hot Rod client son un poco limitadas debido a su implementacion. &lt;/li&gt;
&lt;li&gt; Es ideal para clientes que se ejecutan en java, ya que el cliente provee dynamic load balancing y failover. Esto significa que los Hot Rod clients puede detectar dinámicamente cambios en la topología de los Hot Rod servers mientras esten como cluster, entonces cuando nuevos nodos que se unen o se quitan, los clientes actualizan la vista de la topología de los Hot Rod servers. Y cuando los Hot Rod servers son configurados en modo distribución, los clientes pueden detectar donde reside una key en particular y pueden enrutar los pedidos de forma inteligente. &lt;/li&gt;
&lt;li&gt; Load balancing y failover es dinámicamente proporcionado por el cliente usando la información que le provee el server. &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
WebSocket &lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://community.jboss.org/docs/DOC-15184&quot;&gt;Infinispan WebSocket Server&lt;/a&gt; permite usar Infinispan sobre un &lt;a href=&quot;http://en.wikipedia.org/wiki/WebSockets&quot;&gt;Websocket&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Este modulo esta específicamente desarrollado para clientes Javascript. &lt;/li&gt;
&lt;li&gt;Este modulo es particularmente adecuado para desarrolladores que quieran acceder alas instancias de Infinispan desde código Javascript. &lt;/li&gt;
&lt;li&gt;Los websockets trabajan en el mismo puerto HTTP, se puede usar cualqueir HTTP load balancer. &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
h1 { margin-top: 0cm; margin-bottom: 0cm; }h1.western { font-family: &quot;Liberation Serif&quot;,serif; font-size: 12pt; font-weight: normal; }h1.cjk { font-family: &quot;DejaVu Sans&quot;; font-size: 12pt; font-weight: normal; }h1.ctl { font-family: &quot;DejaVu Sans&quot;; font-size: 12pt; font-weight: normal; }p { margin-bottom: 0.21cm; }
&lt;/style&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Modos de clusterización.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Infinispan puede ser configurado como local o cluster. Si es en modo cluster, el cache puede ser configurado para replicar los cambios en todos los nodos, para invalidar cambios en los nodos y finalmente ser usado en modo distribuído (los cambios de estado son replicados en un pequeño grupo de nodos suficientes como para ser tolerante a fallos pero no en muchos nodos para prevenir la escalabilidad). Estas configuraciones suelen ser muy sencillas. &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ6NuqpJdXkYqyqdp-8QUEgefix5FuNZeVkrR4bt3ZL2KBIN0A3Tcajgnb7GdsaMS_eBUe-XlQp8esx68F3tR6PMwDOSA23MWzjj2TEOw_qqIqRsL5UG4Qcb-TE-DKzSPkAjyTzj3xCwk/s1600/global.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ6NuqpJdXkYqyqdp-8QUEgefix5FuNZeVkrR4bt3ZL2KBIN0A3Tcajgnb7GdsaMS_eBUe-XlQp8esx68F3tR6PMwDOSA23MWzjj2TEOw_qqIqRsL5UG4Qcb-TE-DKzSPkAjyTzj3xCwk/s1600/global.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Los distintos modos de clusterización son:&lt;br /&gt;
&lt;br /&gt;
1) Modo Local&lt;br /&gt;
&lt;ul&gt;&lt;li&gt; Permite tener los datos en memoria como JBoss Cache y EHCache. Algunas de las caracteristicas que ofrece: &lt;/li&gt;
&lt;li&gt; Mantener los datos en memoria para después persistirlos, ejemplo: cache level-2 para Hibernate. &lt;/li&gt;
&lt;li&gt; Eliminar objetos para evitar quedarse sin memoria. &lt;/li&gt;
&lt;li&gt; Vencimiento de objetos en cache. &lt;/li&gt;
&lt;li&gt; Fue pensado para lograr un alto rendimiento en entornos multi-CPU/multi-core. &lt;/li&gt;
&lt;/ul&gt;2) Modo replicación &lt;br /&gt;
&lt;ul&gt;&lt;li&gt; Es un simple modo de clusterización donde cada instancia de cache descubre otras instacias de cache (en distintas JVM) dentro de la red local y formar un cluster. Las entradas que se agregan al cache en cualquiera de las instancias son replicadas a todas las instancias del cluster y pueden ser obtenidas localmente desde cualquier instancia. Este modo permite una manera rápida de compartir estados a través del cluster, pero este modo solo es performante en cluster pequeños (por debajo de los 10 servers), debido a la cantidad de replicaciones que debe hacer. &lt;/li&gt;
&lt;li&gt; Este modo puede ser sincrónico o asincrónico. El sincrónico bloquea la llamada (ejemplo: put()) hasta que se replica en todos los nodos. En cambio el asincrónico es mas rapido debido a que no hace falta que se replique inmediatamente en todos los nodos, por los tanto no produce bloqueos de ningun tipo. El asincrónico va a replicar en determinados intervalos de tiempo, cuando se llene la cola de elementos o una combinacion de estos. &lt;/li&gt;
&lt;/ul&gt;3) Modo invalidación &lt;br /&gt;
&lt;ul&gt;&lt;li&gt; Este modo no comparte información. Lo que hace es borrar información que puede ser vieja desde caches remotos. Usar este modo solo tiene sentido si se tiene respaldo de la información como una base de datos.&lt;/li&gt;
&lt;li&gt;Es usado para tener un acceso rapido a datos sin tener que acceder a la base cada vez que se soliciten estos. Se suele usar con cache loaders, puede ser sincrónico o asincrónico. &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
4) Modo distribuído &lt;br /&gt;
&lt;ul&gt;&lt;li&gt; Este es un modo poderoso que permite a Infinispan escalar linealmente a medida que se agregan mas servers al cluster. La distribucion hace el uso de un algoritmo hash consistente que determina donde deben ser almacenadas las entradas dentro del cluster. &lt;/li&gt;
&lt;li&gt; El numero de copias que mantiene en el cluster es un equilibrio entre la performance y la durabilidad de la información. &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
5) Hot Rod Client &lt;br /&gt;
&lt;br /&gt;
Hot Rod es un protocolo binario para la comunicación con el cluster. Este es sencillo de usar, pero posee ventajas y desventajas comparado con el resto de los clientes para los otros modulos. &lt;br /&gt;
&lt;br /&gt;
Ventajas: &lt;br /&gt;
&lt;ul&gt;&lt;li&gt; Sencillo uso a traves de su API. &lt;/li&gt;
&lt;li&gt; Configuración simple. &lt;/li&gt;
&lt;li&gt; Es inteligente. &lt;/li&gt;
&lt;li&gt; Para que funcione solo se debe conocer la ip y puerto de nodo. &lt;/li&gt;
&lt;li&gt; Maneja el pool de conexiones. &lt;/li&gt;
&lt;li&gt; Posee estrategias para el balance entre nodos. &lt;/li&gt;
&lt;li&gt; Detecta la topologia de la red y si esta fue modificada (cuando se agregan o quietan nodos). &lt;/li&gt;
&lt;li&gt; Detecta automaticamente todos los nodos del cluster solo configurandole con una ip de estos.&amp;nbsp;Conoce la distribución de las keys en los nodos lo cual baja la carga de trabajo de estos. &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Desventajas:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Solo soporta comunicación TCP. &lt;/li&gt;
&lt;li&gt; No soporta queries en el cache. &lt;/li&gt;
&lt;li&gt; No soporta las estadísticas.&lt;/li&gt;
&lt;/ul&gt;&lt;i&gt;Este post lo he adaptado de un informe que he realizado junto con Guillermo Kessler.&lt;/i&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/1969971963175303076/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/1969971963175303076' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/1969971963175303076'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/1969971963175303076'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/infinispan.html' title='Infinispan'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV4BmXOv1O88wcGadnp3ffIRHt7IdLq3TQL9Pg8cWzAy21r83_zKsGKb2Lic5Y0OzVhThVvfbYdSaUxwd6q3mUCbwXpMIz4j3Ev9Y5doyvpDJlRSkC5V4fqvEJ6ttiQbnLBWVILMPNujc/s72-c/infnispan.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-7924955290227780612</id><published>2011-06-15T11:54:00.000-03:00</published><updated>2011-06-15T11:54:46.371-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="EhCache"/><category scheme="http://www.blogger.com/atom/ns#" term="Java Cache"/><title type='text'>EhCache</title><content type='html'>EhCache es un cache open source, basado en standards, escalable, robusto, performante y basado en java. Es mantenido por Terracota, quien como un plus provee un servidor adicional para mejorar la performance del cache. Se puede bajar de &lt;a href=&quot;http://ehcache.org/&quot;&gt;http://ehcache.org&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Sus características principales son:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Rápido y simple de usar.&lt;/li&gt;
&lt;li&gt;Pequeño (menos de 700 kb) y con pocas dependencias.&lt;/li&gt;
&lt;li&gt;Escalable: permite, por un lado, escribir a disco y, por otro, trabajar con muchos caches en paralelo.&lt;/li&gt;
&lt;li&gt;Flexible: permite trabajar con Objects o Serializables y configurarlo mediante xml o programaticamente.&lt;/li&gt;
&lt;li&gt;Extensible: se pueden adicionar plug-ins, loaders, listeners, JMX y exceptions handlers. Trabaja con varias APIs como JTA o frameworks como Hibernate.&lt;/li&gt;
&lt;li&gt;Distribuído: posee muchas opciones de replicación de los datos.&lt;/li&gt;
&lt;li&gt;Cache Server: permite agregarle servidores standalone (o un war, en su defecto).&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Como funciona.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Es muy sencillo de utilizar. El API nos provee diversas formas de crear un cache y la más sencilla es simplemente pasando un parámetro String con el nombre del cache a un método (addCache) de la clase CacheManager.&lt;br /&gt;
&lt;img src=&quot;https://lh4.googleusercontent.com/3C7vUjwbE9sTtlsYQlvADpsyYCCBG9te3EVeG0haSIrSq9kezMD-tXZehGO2AIAxTlnVjo9By1fvzl0C79nPJ0GZCjIS48jp8OqKFzzF5AtvPJiVKtU&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Veremos los métodos de colocación/obtención de datos del cache. Como se observa hay que crear un nuevo objeto Element por cada entrada. Esto mucho no me gusta, pero la realidad es que lo hace de manera muy rápida.&lt;br /&gt;
&lt;br /&gt;
&lt;img src=&quot;https://lh5.googleusercontent.com/ebH_QZzP8hZxu9vrnfsuZxlsFsUVdogGLS1ddgDx-mund4kwPQzxLQMQ8zGc2Vq7u4PkWOAn6whxJ7XLAcFsLmmlDzGBnLKUwQ5x34HCMTBBN_tl6gQ&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Datos útiles.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Para enviar datos a disco el cache ofrece el método flush(). Para saber el estado general del cache nos ofrece varios métodos que nos dan diversa información. Los más usados son:&lt;br /&gt;
&lt;br /&gt;
&lt;img src=&quot;https://lh4.googleusercontent.com/sa_R_FrI_gDkaEly5VDcYgdlLeHJ09dsIguph_wbhpgXVaSibRtupjDmBxmUxW_mdoiQ-5-Yt3KLpDntrFp57HnG3FwYAYXqpH62SvUW7MzDeqyNkpg&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;¿Que más nos ofrece EhCache?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Se puede configurar de diversas maneras para su mejor performance. Un link interesante para ello se ofrece en la página oficial: &lt;a href=&quot;http://ehcache.org/documentation/offheap_store.html&quot;&gt;http://ehcache.org/documentation/offheap_store.html&lt;/a&gt;&lt;br /&gt;
También posee un API que nos permite buscar datos en el cache, lo cual puede resultarnos muy útil: &lt;a href=&quot;http://ehcache.org/documentation/search.html&quot;&gt;http://ehcache.org/documentation/search.html&lt;/a&gt;   verán que el API es muy parecido al Criteria de Hibernate.</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/7924955290227780612/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/7924955290227780612' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/7924955290227780612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/7924955290227780612'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/ehcache.html' title='EhCache'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh4.googleusercontent.com/3C7vUjwbE9sTtlsYQlvADpsyYCCBG9te3EVeG0haSIrSq9kezMD-tXZehGO2AIAxTlnVjo9By1fvzl0C79nPJ0GZCjIS48jp8OqKFzzF5AtvPJiVKtU=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-6768430096268425771</id><published>2011-06-14T11:15:00.000-03:00</published><updated>2011-06-14T11:15:50.942-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Cache"/><category scheme="http://www.blogger.com/atom/ns#" term="JBoss Cache"/><title type='text'>JBoss Cache</title><content type='html'>Es un cache transaccional, clusterizado y basado en una estructura de árbol. Obviamente también puede funcionar en modo “standalone“ y sin clusterizarlo.&lt;br /&gt;
&lt;br /&gt;
Lo podemos bajar de su page oficial: &lt;a href=&quot;http://www.jboss.org/jbosscache&quot;&gt;http://www.jboss.org/jbosscache&lt;/a&gt;  en la sección Downloads. Si leemos la documentación oficial veremos que hay una versión que especial para trabajar con clases POJOs y el cache viene prreparado para trabajar sus relaciones. No vamos a tener en cuenta esta particular versión.&lt;br /&gt;
&lt;br /&gt;
Sus ventajas más importantes son:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;API simple para trabajar el cache. &lt;/li&gt;
&lt;li&gt;Es eficiente y “thread-safe”. &lt;/li&gt;
&lt;li&gt;Posibilidad de replicar a algunos o todos los clusters.&lt;/li&gt;
&lt;li&gt;Persistencia a disco o remota.&lt;/li&gt;
&lt;li&gt;Garbage collector inteligente.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Como funciona.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Esta organizado como un árbol, con un único elemento raiz. Cada nodo del árbol que tiene un Map donde guarda objetos que hayan implementado la interface java.io.Serializable.&lt;br /&gt;
La forma más sencilla de comenzar a utilizarlo es mediante su interface Cache que se puede obtener mediante un CacheFactory que se basa en un xml u objeto java. Una vez que se tenga acceso al Cache, se puede navegar su estructura para guarda u obtener datos.&lt;br /&gt;
&lt;br /&gt;
Aqui un ejemplo de como he creado un cache:&lt;img src=&quot;https://lh3.googleusercontent.com/ScyoeYejVIDsj-BMu6bNpHu7zsOc5sp9iLKV_p6q4L5f8LRTSkmIG0GAIYbpddTits-OebjqdAwBP4d1wntI4jELBFp-sxMEnZPzY1qGCeznD15MJeI&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
El ejemplo sigue así: he colocado 2000 objetos del tipo String y luego los he obtenido. Si vemos la salida por consola observamos que se perdió más tiempo en colocarlo que en obtenerlos.&lt;img src=&quot;https://lh4.googleusercontent.com/kLq9zkL40EM87uyZzwGwpkk5FxZn2ANNKqXBFzgq6iwZkJNRY8khDM4RTEd8xsbnfEJ8WAfpguwhPpQhYYFHg42H465Lnv7TFcsuszMpHFnyFJ-42Y0&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Para colocar y obtener datos he utilizado 2 métodos:&lt;br /&gt;
&lt;img src=&quot;https://lh6.googleusercontent.com/2j_PJ5iFNb7uHbKEITbIafqZXNRFLyyC5HwYRv09RgK3_HrcPgSyMi0MN-ni90lUVDD0mOAoWsSdrsECz_hwJcq9_9GgoLAb24vyCYg4N0lBcqQ6EvY&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Los nombres de los nodos es arbritario y es recomendable verlo como un grupo lógico de datos. La clase Fully Qualified Name (Fqn) encapsula un patch a una ruta determinada del árbol.&lt;br /&gt;
La interface Cache también publica los métodos put/get/remove que reciben un Fqn como parámetro. Esto evita tener que trabajar con nodos:&lt;br /&gt;
&lt;br /&gt;
&lt;img src=&quot;https://lh3.googleusercontent.com/jt1rC5sTaajJDwHfbhvIdUKgwLbux_r6u2MEU5XKOUIP3PW35Ki-t6EV8Q8dhnHsPf-wJ7UvqymMcsCNsYZdcsWmLSz9Eden7vjjZG-b20Qq5fHM8_8&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Tipos de Cache&lt;/span&gt;&lt;br /&gt;
Se pueden setear diversos tipos de Cache:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;LOCAL: local, sin cluster.&lt;/li&gt;
&lt;li&gt;REPL_SYNC: replica de manera sincronizada con los otros cluster. Implica que los cambios son replicados y el cluster que disparó el cambio de datos se bloquea hasta tener el OK del resto.&lt;/li&gt;
&lt;li&gt;REPL_ASYNC: replica de manera asincrónica. Es decir, que el cluster que dispara el cambio no se bloquea, sique trabajando.&lt;/li&gt;
&lt;li&gt;INVALIDATION_SYNC: cuando un dato es actualizado en uno de los clusters, no lo replica, solo envía un mensaje al resto diciendo que sus datos son inválidos. Trabaja de manera sincronizada.&lt;/li&gt;
&lt;li&gt;INVALIDATION_ASYNC: ídem anterior, pero trabaja de manera asincrónica.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
En mi ejemplo, no he utilizado clusters por lo tanto lo seteo de manera local:&lt;br /&gt;
&lt;br /&gt;
&lt;img src=&quot;https://lh6.googleusercontent.com/oegTzqu3BZEA4NMi7jmbv5ViQvrOdbDXlvXRUwjF71u1h5DauEJrXM4ySQFAeAybGFb_LbnQoP3BGlXiTFvED752OSOMDwG0zkCFL0cnOlpzJbzUx0Q&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Cache Listerners&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Hay varios tipos de eventos que podemos “escuchar” si fuese necesario. Como son muchos, no voy a nombrar todos aquí. Les recomiendo que vean el siguiente link para ver todas las posibilidades que hay: &lt;a href=&quot;http://docs.jboss.org/jbosscache/3.2.1.GA/userguide_en/html_single/index.html#api.listener&quot;&gt;http://docs.jboss.org/jbosscache/3.2.1.GA/userguide_en/html_single/index.html#api.listener&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Los eventos más comunes para escuchar son:&lt;br /&gt;
@CacheStarted&lt;br /&gt;
@CacheStopped&lt;br /&gt;
@NodeCreated&lt;br /&gt;
@NodeModified&lt;br /&gt;
@NodeRemoved&lt;br /&gt;
@CacheBlocked&lt;br /&gt;
@CacheUnblocked&lt;br /&gt;
&lt;br /&gt;
Por suerte los nombres son muy descriptivos y no necesitan mayor explicación. Se utiliza de la siguiente manera:&lt;br /&gt;
&lt;img src=&quot;https://lh6.googleusercontent.com/6K7i0HSdiWgcDbGlR71qCBAVWRl0zF5xL0h9_s79LOUXIsvT04wk7dvypvmb_00f6M-0KhuE4Wa_VQ3khgndW5e3EgssiWMH6oR3QnYXbBiKT3rGncs&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;https://lh6.googleusercontent.com/DgjD2_3UUm_t3iOfAm3pxirREKuDClHN84mDhYniGqJB0emZN7w8nJ_ydSOGiAkGienS_m-y8Gt1GWyMMpAOCXLKsVmwtL2XbTisKCfs7OQacesk07o&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
¿Que más nos ofrece JBoss?&lt;br /&gt;
Si quieren seguir investigando hay muchos temas adicionales para ver como CacheLoaders, manejo de transacciones, politicas de Eviction, configuración por xml y estadísticas entre los temas mas importantes.</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/6768430096268425771/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/6768430096268425771' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/6768430096268425771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/6768430096268425771'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/jboss-cache.html' title='JBoss Cache'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh3.googleusercontent.com/ScyoeYejVIDsj-BMu6bNpHu7zsOc5sp9iLKV_p6q4L5f8LRTSkmIG0GAIYbpddTits-OebjqdAwBP4d1wntI4jELBFp-sxMEnZPzY1qGCeznD15MJeI=s72-c" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-6418746776118002302</id><published>2011-06-14T11:10:00.001-03:00</published><updated>2011-06-14T11:11:29.764-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Introducción a Cache"/><category scheme="http://www.blogger.com/atom/ns#" term="Java Cache"/><title type='text'>Java Cache</title><content type='html'>“En informática, una cache o caché (esta última única forma reconocida por la RAE Real Academia Española.) es un conjunto de datos duplicados de otros originales, con la propiedad de que los datos originales son costosos de acceder, normalmente en tiempo, respecto a la copia en el caché.” - Wikkipedia&lt;br /&gt;
&lt;br /&gt;
En el mundo Java existen una gran variedad de productos diseñados para almacenar en caché los objetos que suelen ser accedidos frecuentemente de manera que aumente de forma notable el rendimiento de aplicaciones e-bussines. Eliminando accesos innecesarios a la base de datos, se reduce el tráfico de red e incrementa la escalabilidad de las aplicaciones.&lt;br /&gt;
&lt;br /&gt;
Entre los productos más reconocidos podemos nombrar a JBoss Cache, EhCache y el nuevo producto de JBoss: Infinistpan. En los próximos post voy a dar una introducción de cada uno de ellos y luego los compararé para ver cual es el mejor de todos.</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/6418746776118002302/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/6418746776118002302' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/6418746776118002302'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/6418746776118002302'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/java-cache.html' title='Java Cache'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-6947052174882200708</id><published>2011-06-13T08:47:00.000-03:00</published><updated>2011-06-13T08:47:13.633-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Patrones"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones de Comportamiento"/><category scheme="http://www.blogger.com/atom/ns#" term="Visitor"/><title type='text'>Visitor</title><content type='html'>Busca separar un algoritmo de la estructura de un objeto. La operación se implementa de forma que no se modifique el código de las clases sobre las que opera.&lt;br /&gt;
Si un objeto es el responsable de mantener un cierto tipo de información, entonces es lógico asignarle también la responsabilidad de realizar todas las operaciones necesarias sobre esa información. La operación se define en cada una de las clases que representan los posibles tipos sobre los que se aplica dicha operación, y por medio del polimorfismo y la vinculación dinámica se elige en tiempo de ejecución qué versión de la operación se debe ejecutar. De esta forma se evita un análisis de casos sobre el tipo del parámetro.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Este patrón debe utilizarse cuando.&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Una estructura de objetos contiene muchas clases de objetos con distintas interfaces y se desea llevar a cabo operaciones sobre estos objetos que son distintas en cada clase concreta.&lt;/li&gt;
&lt;li&gt;Se quieren llevar a cabo muchas operaciones dispares sobre objetos de una estructura de objetos sin tener que incluir dichas operaciones en las clases.&lt;/li&gt;
&lt;li&gt;Las clases que definen la estructura de objetos no cambian, pero las operaciones que se llevan a cabo sobre ellas.&lt;/li&gt;
&lt;/ul&gt;Dado que este patrón separa un algoritmo de la estructura de un objeto,  es ampliamente utilizado en intérpretes, compiladores y procesadores de  lenguajes, en general.&lt;br /&gt;
Se debe utilizar este patrón si se quiere  realizar un cierto número de operaciones, que no están relacionadas  entre sí, sobre instancias de un conjunto de clases, y no se quiere  “contaminar” a dichas clases.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Diagrama UML&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img id=&quot;internal-source-marker_0.7163593192358332&quot; src=&quot;https://lh3.googleusercontent.com/_Xd3cyzJbgLtMIQZXf2jGTn67W6RUG8JukEHQkZw-JLTBrkwkdX8vLjoRXBot2L1ePqm-hTmp1n7iUd-S9neA0QKpGaUYfguFk_SdQQzh4y2xjnG_Q&quot; /&gt;&lt;/div&gt;&lt;br /&gt;
&lt;u&gt;Visitor&lt;/u&gt;: declara una operación de visita para cada uno de los elementos concretos de la estructura de objetos. Esto es, el método visit().&lt;br /&gt;
&lt;u&gt;VisitorConcreto &lt;/u&gt;: implementa cada una de las operaciones declaradas por Visitor. &lt;br /&gt;
&lt;u&gt;Element&lt;/u&gt;: define la operación que le permite aceptar la visita de un Visitor.&lt;br /&gt;
&lt;u&gt;ConcreteElement&lt;/u&gt;: implementa el método accept() que se limita a invocar su correspondiente método del Visitor.&lt;br /&gt;
&lt;u&gt;ObjectStructure&lt;/u&gt;: gestiona la estructura de objetos y puede ofrecer una interfaz de alto nivel para permitir a los Visitor visitar a sus elementos.&lt;br /&gt;
&lt;br /&gt;
El Element ejecuta el método de visitar y se pasa a sí mismo como parámetro.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ejemplo&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
En Argentina todos los productos pagan IVA. Algunos productos poseen una  tasa reducida. Utilizaremos el Visitor para solucionar este problema.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdCDmmw5Q4WaJvlHZjWIpDKiMrS_b1tJhq4DCWtgU3AgT1AP30_s3Z_cIupYQ9ZDewgVVk46Ncm7IKIEKNsMs8cETJlZDrjFS6pdCZHHlVTnkgKOZpcpOX3yTcVQS3RvhfO5ndFROszk4/s1600/visitable.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdCDmmw5Q4WaJvlHZjWIpDKiMrS_b1tJhq4DCWtgU3AgT1AP30_s3Z_cIupYQ9ZDewgVVk46Ncm7IKIEKNsMs8cETJlZDrjFS6pdCZHHlVTnkgKOZpcpOX3yTcVQS3RvhfO5ndFROszk4/s1600/visitable.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcVF10e7m-d0eaUAbAiciG1AZgwdXonMwlyGa7o3n08B407wRMEFwrML4U3-MUVGS3WSzlinsN-z8Z3DhxYV3sbcSYgTbNyVf69VUuXJaJrfXIXuPKynF4lvwvytAJforqD77PakXRRR4/s1600/pd.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcVF10e7m-d0eaUAbAiciG1AZgwdXonMwlyGa7o3n08B407wRMEFwrML4U3-MUVGS3WSzlinsN-z8Z3DhxYV3sbcSYgTbNyVf69VUuXJaJrfXIXuPKynF4lvwvytAJforqD77PakXRRR4/s1600/pd.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwhrq62PJqLSGoEAdeOPxMld5HLKfJv-OjceDX6GsjCWSVDsSjqceVa2nXSmlFcGthyphenhyphenu55BlZJf-lEKEPoEl0P6GnKWO8-SrG0W2nV0n3flV6EeYaseoyYIOBs8GDo7ztTP3KCnIve05A/s1600/pn.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwhrq62PJqLSGoEAdeOPxMld5HLKfJv-OjceDX6GsjCWSVDsSjqceVa2nXSmlFcGthyphenhyphenu55BlZJf-lEKEPoEl0P6GnKWO8-SrG0W2nV0n3flV6EeYaseoyYIOBs8GDo7ztTP3KCnIve05A/s1600/pn.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ7X6PsHwTofh-TojNRyxwVtnfyj1qv47yt1fH3Gd8UqE_WMBdKqAvdgn59YLHKYaaiAJifGs7HvlntiUboZnwZWXpui3yy5LCzy0a90_a2xutRTQIcvCXBc-dGNfRupibiiixNbgOyW0/s1600/visitor.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ7X6PsHwTofh-TojNRyxwVtnfyj1qv47yt1fH3Gd8UqE_WMBdKqAvdgn59YLHKYaaiAJifGs7HvlntiUboZnwZWXpui3yy5LCzy0a90_a2xutRTQIcvCXBc-dGNfRupibiiixNbgOyW0/s1600/visitor.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1K23as3F0RzshGWxwGdVlcxSU7mLP03JPIRuuODV3dpm5FM_kGQS4QsiMWaG68Y0Xfb8tiZnE2tqTsIUiiKdVBKHA2NjawWMQ2OHXEoKYdlxbTrmXCQwA8lBSJND7cbBef5Lb2inSj-k/s1600/iva.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1K23as3F0RzshGWxwGdVlcxSU7mLP03JPIRuuODV3dpm5FM_kGQS4QsiMWaG68Y0Xfb8tiZnE2tqTsIUiiKdVBKHA2NjawWMQ2OHXEoKYdlxbTrmXCQwA8lBSJND7cbBef5Lb2inSj-k/s1600/iva.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoHtXiFpZulB542zXKlfZMfjwfzGTqOt2hAgTEkyy2vat5wKYp_r7-gWZYQgqbsbit-Gq99c6eSzIfmw5IHiv-9u7tVfJd8mTw55pDA0pY7yw4J0RXEuiic0hGS0OTahwdw8lG0owc1Tc/s1600/mainv.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoHtXiFpZulB542zXKlfZMfjwfzGTqOt2hAgTEkyy2vat5wKYp_r7-gWZYQgqbsbit-Gq99c6eSzIfmw5IHiv-9u7tVfJd8mTw55pDA0pY7yw4J0RXEuiic0hGS0OTahwdw8lG0owc1Tc/s1600/mainv.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;font-size: large;&quot;&gt;Consecuencias&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Facilita la inclusión de nuevas operaciones.&lt;/li&gt;
&lt;li&gt;Agrupa las operaciones relacionadas entre sí.&lt;/li&gt;
&lt;li&gt;La inclusión de nuevos ElementsConcretos es una operación costosa.&lt;/li&gt;
&lt;li&gt;Posibilita visitar distintas jerarquías de objetos u objetos no relacionados por un padre común.&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/6947052174882200708/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/6947052174882200708' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/6947052174882200708'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/6947052174882200708'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/visitor.html' title='Visitor'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh3.googleusercontent.com/_Xd3cyzJbgLtMIQZXf2jGTn67W6RUG8JukEHQkZw-JLTBrkwkdX8vLjoRXBot2L1ePqm-hTmp1n7iUd-S9neA0QKpGaUYfguFk_SdQQzh4y2xjnG_Q=s72-c" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-9082312958229774289</id><published>2011-06-13T08:30:00.000-03:00</published><updated>2011-06-13T08:30:10.231-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Patrones"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones de Comportamiento"/><category scheme="http://www.blogger.com/atom/ns#" term="Template Method"/><title type='text'>Template Method</title><content type='html'>Define una estructura algorítmica cuya lógica quedará a cargo de las subclases. Para ello, escribe una clase abstracta que contiene parte de la lógica necesaria para realizar su finalidad. En ella se define una estructura de herencia que sirve de plantilla (&quot;Template&quot; significa plantilla) de los métodos en las subclases.&lt;br /&gt;
&lt;br /&gt;
Dicho de otra forma, define un esqueleto de un algoritmo, delegando algunos pasos a las subclases. Permite redefinir parte de dicho algoritmo sin cambiar su estructura.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Se debe utilizar este patrón cuando.&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Se quiera factorizar el comportamiento común de varias subclases. &lt;/li&gt;
&lt;li&gt;Se necesite implementar las partes fijas de un algoritmo una sola vez y dejar que las subclases implementen las partes variables.&lt;/li&gt;
&lt;li&gt;Se busque controlar las ampliaciones de las subclases, convirtiendo en métodos plantillas aquéllos métodos que pueden ser redefinidos.&lt;/li&gt;
&lt;/ul&gt;Este patrón se vuelve de especial utilidad cuando es necesario realizar  un algoritmo que sea común para muchas clases, pero con pequeñas  variaciones entre una y otras. En este caso, se deja en las subclases  cambiar una parte del algoritmo.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Diagrama UML&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://lh3.googleusercontent.com/0c-QKPKBVKwN-Dap3XYUW52cFbGKKsCNBKYAqOmoX270NuArLcJrMs4SG7B3MAzUsPQbdpcQM3SakEyG3NC1gjMFApyuK0lJR7Fpmjl4NR4-nI-W8w&quot; /&gt;&lt;/div&gt;&lt;u&gt;AbstractTemplate o AbstractClass&lt;/u&gt;: implementa un método plantilla que define el esqueleto de un algoritmo y define métodos abstractos que deben implementar las subclases concretas&lt;br /&gt;
&lt;u&gt;TemplateConcreto o ConcreteClass&lt;/u&gt;: implementa los métodos abstractos para realizar los pasos del algoritmo que son específicos de la subclase.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ejemplo&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Como ejemplo, imaginemos una empresa que posee  socios, clientes, empleados, etc. Cuando se les solicite que se  identifiquen, cada uno lo realizará de distinta manera: quizas un  empleado tiene un legajo, pero un cliente tiene un numero de cliente,  etc. &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgseBPXc_6xDf0xDbd3kEGyTqYMIuW6YFlAsd3XatYw9xrgcNFBrCWIHN-s81p2UemlQ1YAe73eNvMqMgs7oehEvMqvp0sMKnt1nrlDK2mL_lDuSikraWbyo8m-MIjueOt1JAIkbEAgeeo/s1600/persona.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgseBPXc_6xDf0xDbd3kEGyTqYMIuW6YFlAsd3XatYw9xrgcNFBrCWIHN-s81p2UemlQ1YAe73eNvMqMgs7oehEvMqvp0sMKnt1nrlDK2mL_lDuSikraWbyo8m-MIjueOt1JAIkbEAgeeo/s1600/persona.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqSezUEjgX5P2o9_FsWkJ5oPxBMevSxFDvDPup5zXassZoLBSEGYj7BI6Udzsasx_hCHz4nJkruLtp_rR4xnGW64MCE9ieY_P4pFB1vWEIt2caG7zD-cLtILGHylsXgQaL1HT-OLxjF10/s1600/cliente.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqSezUEjgX5P2o9_FsWkJ5oPxBMevSxFDvDPup5zXassZoLBSEGYj7BI6Udzsasx_hCHz4nJkruLtp_rR4xnGW64MCE9ieY_P4pFB1vWEIt2caG7zD-cLtILGHylsXgQaL1HT-OLxjF10/s1600/cliente.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRwSQsSWzlObsG6yx1nuXoH9ZXIGwgMT0sj13XhsTvnM-cMp2mZnr7A2xC-RBWnqxGllYpaM7y7diiMFuiKMRbJB8XAH0Sad8T-QcRlJjn27qzaSzI8PX8ppgTO1IAEN7rENJ-9wkv2kE/s1600/empleado.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRwSQsSWzlObsG6yx1nuXoH9ZXIGwgMT0sj13XhsTvnM-cMp2mZnr7A2xC-RBWnqxGllYpaM7y7diiMFuiKMRbJB8XAH0Sad8T-QcRlJjn27qzaSzI8PX8ppgTO1IAEN7rENJ-9wkv2kE/s1600/empleado.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMuhqZWGAtXll0GL5t3Ral49toICQiIgQVlZgzhHsETY-1Dm_L12IcQ5Y2LZhN1hxbPXcdmU7jkdf8webU3L9ARMbRsQCCT43G0eK9dKH_ibXtMuPHfk3wUZDBj_BxpQNN2Rv-yJz09Sc/s1600/socio.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMuhqZWGAtXll0GL5t3Ral49toICQiIgQVlZgzhHsETY-1Dm_L12IcQ5Y2LZhN1hxbPXcdmU7jkdf8webU3L9ARMbRsQCCT43G0eK9dKH_ibXtMuPHfk3wUZDBj_BxpQNN2Rv-yJz09Sc/s1600/socio.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-oB7gXXk6K0_PAiwDxe48-44oEDMMkn6oU9pl9aDimM6vS8W78IzXXtnCOG2Iu6PDGFxWzSl-x5tI708YErdEiRa7miqEH5okB4MJYSn8IYLutAb_IlSwZSGJ8OLYS7V6fsHR-tc3EXg/s1600/main.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-oB7gXXk6K0_PAiwDxe48-44oEDMMkn6oU9pl9aDimM6vS8W78IzXXtnCOG2Iu6PDGFxWzSl-x5tI708YErdEiRa7miqEH5okB4MJYSn8IYLutAb_IlSwZSGJ8OLYS7V6fsHR-tc3EXg/s1600/main.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Consecuencias&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Favorece la reutilización del código. &lt;/li&gt;
&lt;li&gt;Lleva a una estructura de control invertido: la superclase base invoca los métodos&lt;/li&gt;
&lt;li&gt;de las subclases.&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/9082312958229774289/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/9082312958229774289' title='3 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/9082312958229774289'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/9082312958229774289'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/template-method.html' title='Template Method'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh3.googleusercontent.com/0c-QKPKBVKwN-Dap3XYUW52cFbGKKsCNBKYAqOmoX270NuArLcJrMs4SG7B3MAzUsPQbdpcQM3SakEyG3NC1gjMFApyuK0lJR7Fpmjl4NR4-nI-W8w=s72-c" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-300900672770443016</id><published>2011-06-12T16:11:00.000-03:00</published><updated>2011-06-12T16:11:36.057-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Patrones"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones de Comportamiento"/><category scheme="http://www.blogger.com/atom/ns#" term="Strategy"/><title type='text'>Strategy</title><content type='html'>Encapsula algoritmos en clases, permitiendo que éstos sean re-utilizados e intercambiables. En base a un parámetro, que puede ser cualquier objeto, permite a una aplicación decidir en tiempo de ejecución el algoritmo que debe ejecutar.&lt;br /&gt;
La esencia de este patrón es encapsular algoritmos relacionados que son subclases de una superclase común, lo que permite la selección de un algoritmo que varia según el objeto y también le permite la variación en el tiempo. Esto se define en tiempo de ejecución. Este patrón busca desacoplar bifurcaciones inmensas con algoritmos dificultosos según el camino elegido.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Este patrón debe utilizarse cuando:&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Un programa tiene que proporcionar múltiples variantes de un algoritmo o comportamiento.&lt;/li&gt;
&lt;li&gt;Es posible encapsular las variantes de comportamiento en clases separadas que proporcionan un modo consistente de acceder a los comportamientos.&lt;/li&gt;
&lt;li&gt;Permite cambiar o agregar algoritmos, independientemente de la clase que lo utiliza.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Diagrama UML&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://lh5.googleusercontent.com/v-NVcoj0AatjiqadYCm92fQ1SXkwLHpxWPdI3qgf5d4sm1Gi-F3kyxVnkfpPoJz4ZZOGMkWic_3GUMaSN7GZ4DYWVn56Hbcldah4fLf8fJx69oY_jw&quot; /&gt;&lt;/div&gt;&lt;br /&gt;
&lt;u&gt;Strategy&lt;/u&gt;: declara una interfaz común a todos los algoritmos soportados.&lt;br /&gt;
&lt;u&gt;StrategyConcreto&lt;/u&gt;: implementa un algoritmo utilizando la interfaz Strategy. Es la representación de un algoritmo.&lt;br /&gt;
&lt;u&gt;Context&lt;/u&gt;: mantiene una referencia a Strategy y según las características del contexto, optará por una estrategia determinada..&lt;br /&gt;
&lt;u&gt;Context / Cliente&lt;/u&gt;: solicita un servicio a Strategy y este debe devolver el resultado de un StrategyConcreto.&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ejemplo&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Imaginemos una biblioteca de un instituto educativo que  presta libros a los alumnos y profesores. Imaginemos que los alumnos  pueden asociarse a la biblioteca pagando una mensualidad. Con lo cual un  libro puede ser prestado a Alumnos, Socios y Profesores.&lt;br /&gt;
Por  decisión de la administración, a los socios se les prestará el libro más  nuevo, luego aquel que se encuentre en buen estado y, por último, aquel  que estuviese en estado regular.&lt;br /&gt;
En cambio, si un Alumno pide un  libro, ocurre todo lo contrario. Por último, a los profesores intentarán otorgargarles libros buenos, luego los recién comprados y, por último, los regulares. Este caso es  ideal para el patrón Strategy, ya que dependiendo de un parámetro (el  tipo de persona a la que se le presta el libro) puede realizar una  búsqueda con distintos algoritmos.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgl10TMTcTK_JHc6JaVmBs3lehl1rqSPgjNtEmC4vQv_oYlk2C1Xb37cYBViMPz5PMkm7GP90sxpsBuFJC5dFlfwGcLkKEDg7FZrFGUePaXsvm0Or7f2ZhtAsyc-dvCoVJN4QfMHFI72rk/s1600/persona.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgl10TMTcTK_JHc6JaVmBs3lehl1rqSPgjNtEmC4vQv_oYlk2C1Xb37cYBViMPz5PMkm7GP90sxpsBuFJC5dFlfwGcLkKEDg7FZrFGUePaXsvm0Or7f2ZhtAsyc-dvCoVJN4QfMHFI72rk/s1600/persona.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNH5e6D70ry6800Mi8ndW1KHtb61R9a4So6xZpKhn5ava763wHqprWZC1c7WEMDQAAhiy5hYU3qNyj1_I6ARpGMVxSp5btVCyFEq4fy_AcF61nRuIRYXpIoL32-eLOhS8Tqtl5peXPKhM/s1600/alumno.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNH5e6D70ry6800Mi8ndW1KHtb61R9a4So6xZpKhn5ava763wHqprWZC1c7WEMDQAAhiy5hYU3qNyj1_I6ARpGMVxSp5btVCyFEq4fy_AcF61nRuIRYXpIoL32-eLOhS8Tqtl5peXPKhM/s1600/alumno.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtrV3zJ-ZqNr41YTU_IVMN6VFH0CgjY-QPgfxWt311b37A8lc1NUy5b6cM-ET_XAHKyyrhy-Fs1jOcg85cAlHyWWjI5AytrMz6OFDD-rRA2y7AWyrlfARQvC1vkS0FGK96PTv0EbvqGlQ/s1600/profe.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtrV3zJ-ZqNr41YTU_IVMN6VFH0CgjY-QPgfxWt311b37A8lc1NUy5b6cM-ET_XAHKyyrhy-Fs1jOcg85cAlHyWWjI5AytrMz6OFDD-rRA2y7AWyrlfARQvC1vkS0FGK96PTv0EbvqGlQ/s1600/profe.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6kA8OfOFaMTwBVj0KVpcjwOTARW5gbnrpukiAipWmLnzLKjjtUYDOw_8ckh08hkRywIo8NtzqLZNYSss2_H8t3lFLip1DtTbM_pRlkuYIQ_hSBiiaNC_aW8vyUbt_QA1C10UmsDAE6h8/s1600/socio.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6kA8OfOFaMTwBVj0KVpcjwOTARW5gbnrpukiAipWmLnzLKjjtUYDOw_8ckh08hkRywIo8NtzqLZNYSss2_H8t3lFLip1DtTbM_pRlkuYIQ_hSBiiaNC_aW8vyUbt_QA1C10UmsDAE6h8/s1600/socio.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&amp;nbsp; &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglrRCnwgxjI_m5LzdRPO044WBPdWeuHmwQeKsg-9o-vtGBmtGf-1hKphdAtqlOVheSfvg3uPzkwfhqww0vpJIoYLwUuXHRQIi1Q4_3wXXZC7FRlLZr1RS3P37zwXZN29WvynhjyciAAOI/s1600/Bibliotecas.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglrRCnwgxjI_m5LzdRPO044WBPdWeuHmwQeKsg-9o-vtGBmtGf-1hKphdAtqlOVheSfvg3uPzkwfhqww0vpJIoYLwUuXHRQIi1Q4_3wXXZC7FRlLZr1RS3P37zwXZN29WvynhjyciAAOI/s1600/Bibliotecas.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkuHyv7E4vyAuD7IY_t15Z51ROlGkYZPfos6pyH30PFucE-n__b1O9hkB6-AsivKYlEZszal5A8B3X9W2Ji1RamR6QU106UMTGjGNwOYe-ReHWywxyn9dMc9dEY5e1M-k5cc0cOXu3Efw/s1600/lstrategy.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkuHyv7E4vyAuD7IY_t15Z51ROlGkYZPfos6pyH30PFucE-n__b1O9hkB6-AsivKYlEZszal5A8B3X9W2Ji1RamR6QU106UMTGjGNwOYe-ReHWywxyn9dMc9dEY5e1M-k5cc0cOXu3Efw/s1600/lstrategy.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtx4z1T2IXkGjjf1a2Dq4rfECSiH85_368TjzHQFS0FJk78Q8XxmsZECWATZ2nEaccXjOFK__wED78ZbG0HcqlfkdBfhEkTOLc6ud4sAP-2NLcqk_oZs9R18e0vcKw-KNbg5zkY_WG5-s/s1600/bnr.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtx4z1T2IXkGjjf1a2Dq4rfECSiH85_368TjzHQFS0FJk78Q8XxmsZECWATZ2nEaccXjOFK__wED78ZbG0HcqlfkdBfhEkTOLc6ud4sAP-2NLcqk_oZs9R18e0vcKw-KNbg5zkY_WG5-s/s1600/bnr.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihU9ZKy7W4BavOUZjDdmtfNeANBH_cfak2MWhmA5D-TGkiw_o_9FRNN2mRtQmf7Yc_8B63Pr7R3fVfjzOEy6qPXAq4OLauCDjRXVybwLep-RW1KJUdBB-Vgl0nSVb2gumFc0YlomtRmcg/s1600/nbr.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihU9ZKy7W4BavOUZjDdmtfNeANBH_cfak2MWhmA5D-TGkiw_o_9FRNN2mRtQmf7Yc_8B63Pr7R3fVfjzOEy6qPXAq4OLauCDjRXVybwLep-RW1KJUdBB-Vgl0nSVb2gumFc0YlomtRmcg/s1600/nbr.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTkLjdF6vzFw-GexM8IyEmso0UxJV5PDcHhYeLJd_q_0sYZ1i-nqxzv9UkhT9bpRh0pEvWdTG0y2aleKSBVkj96jgjcgG1_Pa2bEzMPy15v8NWEBDf6bUyJg3e6gVhlp4T0VYIqlpqM8A/s1600/rbn.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTkLjdF6vzFw-GexM8IyEmso0UxJV5PDcHhYeLJd_q_0sYZ1i-nqxzv9UkhT9bpRh0pEvWdTG0y2aleKSBVkj96jgjcgG1_Pa2bEzMPy15v8NWEBDf6bUyJg3e6gVhlp4T0VYIqlpqM8A/s1600/rbn.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Seguramente las distintas estrategias concretas sean Singleton. &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgF1FeuKftid9zbxB8MeLmTUhSlCJ_C99bv5ueL0CLaTKk3UXSjBTBayBEc67caPmMXiiYx9Gj8EG3AXYN4PTu1dUs5ZJpdFpArRij2E9L5vHYJqWmHs_0OXjmM02DeN_MBBjx622nbNwU/s1600/finder.png&quot; /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnNd4MSnwtPQJIiQNE5JrUA-gP4ZlNiKwr10nvnc-IVuEljI3R6Ew6r1OioyANaHj6KKMnAQWdM7P1BYAm8Bf3nPAnLo7My1nt381roOqTb0EPsrl9sahtDiA6nsWMZZMksEtFJqIK6m4/s1600/main.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnNd4MSnwtPQJIiQNE5JrUA-gP4ZlNiKwr10nvnc-IVuEljI3R6Ew6r1OioyANaHj6KKMnAQWdM7P1BYAm8Bf3nPAnLo7My1nt381roOqTb0EPsrl9sahtDiA6nsWMZZMksEtFJqIK6m4/s1600/main.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Consecuencias&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Permite que los comportamientos de los Clientes sean determinados dinámicamente sobre un objeto base.&lt;/li&gt;
&lt;li&gt;Simplifica los Clientes: les reduce responsabilidad para seleccionar comportamientos o implementaciones de comportamientos alternativos. Esto simplifica el código de los objetos Cliente eliminando las expresiones if y switch. &lt;/li&gt;
&lt;li&gt;En algunos casos, esto puede incrementar también la velocidad de los objetos Cliente porque ellos no necesitan perder tiempo seleccionado un comportamiento.&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/300900672770443016/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/300900672770443016' title='13 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/300900672770443016'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/300900672770443016'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/strategy.html' title='Strategy'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh5.googleusercontent.com/v-NVcoj0AatjiqadYCm92fQ1SXkwLHpxWPdI3qgf5d4sm1Gi-F3kyxVnkfpPoJz4ZZOGMkWic_3GUMaSN7GZ4DYWVn56Hbcldah4fLf8fJx69oY_jw=s72-c" height="72" width="72"/><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-5327292382454124586</id><published>2011-06-11T12:29:00.000-03:00</published><updated>2011-06-11T12:29:14.683-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Observer"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones de Comportamiento"/><title type='text'>Observer</title><content type='html'>Este patrón de diseño permite reaccionar a ciertas clases llamadas observadores sobre un evento determinado.&lt;br /&gt;
Es usado en programación para monitorear el estado de un objeto en un programa. Está relacionado con el principio de invocación implícita. La motivación principal de este patrón es su utilización como un sistema de detección de eventos en tiempo de ejecución. Es una característica muy interesante en términos del desarrollo de aplicaciones en tiempo real.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Debe ser utilizado cuando:&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Un objeto necesita notificar a otros objetos cuando cambia su estado. La idea es encapsular estos aspectos en objetos diferentes permite variarlos y reutilizarlos independientemente.&lt;/li&gt;
&lt;li&gt;Cuando existe una relación de dependencia de uno a muchos que puede requerir que un objeto notifique a múltiples objetos que dependen de él cuando cambia su estado.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Este patrón tiene un uso muy concreto: varios objetos necesitan ser  notificados de un evento y cada uno de ellos deciden como reaccionar  cuando esta evento se produzca.&lt;br /&gt;
Un caso típico es la Bolsa de  Comercio, donde se trabaja con las acciones de las empresas. Imaginemos  que muchas empresas estan monitoreando las acciones una empresa X.  Posiblemente si estas acciones bajan, algunas personas esten interesadas  en vender acciones, otras en comprar, otras quizas no hagan nada y la  empresa X quizas tome alguna decisión por su cuenta. Todos reaccionan  distinto ante el mismo evento. Esta es la idea de este patrón y son  estos casos donde debe ser utilizado.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Diagrama UML&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img id=&quot;internal-source-marker_0.2800588684645351&quot; src=&quot;https://lh5.googleusercontent.com/rhCz8rvvliohkvWEs75W0JYz6PHhucjaAxrF8bHLhX4G9dx96zSDh9SSuzEU-t2EEWst-qoL_INklDR6raOk9YbpkhPdfXktlyYI1Rj79-E48s7YyA&quot; /&gt;&lt;/div&gt;&lt;br /&gt;
&lt;u&gt;Subject&lt;/u&gt;: conoce a sus observadores y ofrece la posibilidad de añadir y eliminar observadores. Posee un método llamado attach() y otro detach() que sirven  para agregar o remover observadores en tiempo de ejecución.&lt;br /&gt;
&lt;u&gt;Observer&lt;/u&gt;: define la interfaz que sirve para notificar a los observadores los cambios realizados en el Subject.&lt;br /&gt;
&lt;u&gt;SubjectConcreto&lt;/u&gt;: almacena el estado que es objeto de interés de los observadores y envía un mensaje a sus observadores cuando su estado cambia.&lt;br /&gt;
&lt;u&gt;ObserverConcreto&lt;/u&gt;: mantiene una referencia a un SubjectConcreto. Almacena el estado del Subject que le resulta de interés. Implementa la interfaz de  actualización de Observer para mantener la consistencia entre los dos estados.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;Ejemplo&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;Vamos a suponer un ejemplo de una Biblioteca, donde  cada vez que un lector devuelve un libro se ejecuta el método  devuelveLibro(Libro libro) de la clase Biblioteca.&lt;br /&gt;
Si el lector  devolvió el libro dañado entonces la aplicación avisa a ciertas clases  que están interesadas en conocer este evento:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7fkHfTlbBRfPzjqU22JW4KTorAL63bZl400hfFWQHs4PPaexxQy2Y0PuEaZjPGE9BIjCNV8YYnpwyfo4WbiEspwlGyMeYgisFZHg-wGTPH2o4eYQ0Kc7T6pO1cFyIAnOMFJrs5oAA-Hw/s1600/libro.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7fkHfTlbBRfPzjqU22JW4KTorAL63bZl400hfFWQHs4PPaexxQy2Y0PuEaZjPGE9BIjCNV8YYnpwyfo4WbiEspwlGyMeYgisFZHg-wGTPH2o4eYQ0Kc7T6pO1cFyIAnOMFJrs5oAA-Hw/s1600/libro.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Cada clase que quiera observar el cambio del estado en el libro deberá implementar la siguiente interface y darle lógica al método update:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpTigki3HeUjoRia1pZ0SlVIiyPf1um9EHQigAuGRh35S0iKswwgqMIBAQ3PTkEi6BDo6zTAKef36PxtPgH1hi2Vho9bVx8wmB4X20osLmaa6FJuvBxjHDs-AhefZFmq52OKwCaIH196w/s1600/ilibromal.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpTigki3HeUjoRia1pZ0SlVIiyPf1um9EHQigAuGRh35S0iKswwgqMIBAQ3PTkEi6BDo6zTAKef36PxtPgH1hi2Vho9bVx8wmB4X20osLmaa6FJuvBxjHDs-AhefZFmq52OKwCaIH196w/s1600/ilibromal.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_mDQSe_dl2twzHqXGyAoLnyd5l1YwACtCRi2IK2aOzfEogdCaDZ2hEI9MPTmlEk2Qcel-Iw8ze7ZQ48hlfroFlIEX7rvP7YUAsxEub_F7YnertD_dt-70jM-qBG-dBmIBLOEn-if_sFE/s1600/admi.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_mDQSe_dl2twzHqXGyAoLnyd5l1YwACtCRi2IK2aOzfEogdCaDZ2hEI9MPTmlEk2Qcel-Iw8ze7ZQ48hlfroFlIEX7rvP7YUAsxEub_F7YnertD_dt-70jM-qBG-dBmIBLOEn-if_sFE/s1600/admi.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8KtT7ZcOtyDGITIYXK3tOp9amvYIIZyzbmLLl6srfp-1Q3ZbtJ4gAOibF1GjnRLbDvWUjjHDvk2q9Yvh9m_wzPNGoU_FTuaoCcJYBMW-QmvW1WQy7R7tJ_nQeLBNtyzrSJ4ieJK5Ja1Q/s1600/compras.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8KtT7ZcOtyDGITIYXK3tOp9amvYIIZyzbmLLl6srfp-1Q3ZbtJ4gAOibF1GjnRLbDvWUjjHDvk2q9Yvh9m_wzPNGoU_FTuaoCcJYBMW-QmvW1WQy7R7tJ_nQeLBNtyzrSJ4ieJK5Ja1Q/s1600/compras.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHMNmRxcyrlR5BIgnAM-pfTZTk2wMqQmVnLOzvpBkKymP8jmnNmB9HScztacqlPIG-v6EGkko8DsBgy4lH1jYhM_d_9rgi2Z1Hl3aaxTZMl1iu0JVYxO7HtC_xX41wHcnTnHDaav-8Dj4/s1600/stock.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHMNmRxcyrlR5BIgnAM-pfTZTk2wMqQmVnLOzvpBkKymP8jmnNmB9HScztacqlPIG-v6EGkko8DsBgy4lH1jYhM_d_9rgi2Z1Hl3aaxTZMl1iu0JVYxO7HtC_xX41wHcnTnHDaav-8Dj4/s1600/stock.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Veamos el subject:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgS1D8KoXmoNb15gcngZp4r7pPOtvbDMJ6ORcdh7QAnkaT-w5YYn_allfPUBhVfl0JoVSHBjBlhERbCvFDAFXk4GLi_h8BvMnqatdKrvztNLFS2PWWSeWOSqEzDAuWOjTLBTp6Vc7-aC3c/s1600/subject.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgS1D8KoXmoNb15gcngZp4r7pPOtvbDMJ6ORcdh7QAnkaT-w5YYn_allfPUBhVfl0JoVSHBjBlhERbCvFDAFXk4GLi_h8BvMnqatdKrvztNLFS2PWWSeWOSqEzDAuWOjTLBTp6Vc7-aC3c/s1600/subject.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYGESWsj5Q214gk1OJ3RoSOWTppMWpEhYHAOok9dWebIT2oGwK-lKNxeX97wlyMqTCS48vnda0SnpVhpX0CNpCVBhsjS4HhVZx12_DzimFJIeMpCTEu-BL1G-dVyabGUWJgn8di9qjcuo/s1600/alarma.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYGESWsj5Q214gk1OJ3RoSOWTppMWpEhYHAOok9dWebIT2oGwK-lKNxeX97wlyMqTCS48vnda0SnpVhpX0CNpCVBhsjS4HhVZx12_DzimFJIeMpCTEu-BL1G-dVyabGUWJgn8di9qjcuo/s1600/alarma.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
La biblioteca es quién dispara el evento. Seguramente el estado de un libro no estará en formato String, pero no viene al caso.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3aL-9fdAp6EBqTm5LfZLvkLwd5Y-A5hxxbcfxUnISAGn7tWW7kTL_Cym2jXbnEexj_r-kj3juOWnq86bGPBD-DnGy0E0xPwa2BoRY-R956eouRJCyvEEoOhvM853d3W5RjtTqbNvnNX0/s1600/biblio.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3aL-9fdAp6EBqTm5LfZLvkLwd5Y-A5hxxbcfxUnISAGn7tWW7kTL_Cym2jXbnEexj_r-kj3juOWnq86bGPBD-DnGy0E0xPwa2BoRY-R956eouRJCyvEEoOhvM853d3W5RjtTqbNvnNX0/s1600/biblio.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Veamos como funciona:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiO1i_dBTegl2kZZajF3uXgj3jt5vPH8Vxel6UxMbRonZAIFuL6EuuQ_hWhqIJYE55dMvFP-lyMPvQfHhLdQMvFS_LIYJ2Fvw35hsbUXEQEYKp90LrxhWYv2uNFdwdLjFbPmBGJ1yrgn4s/s1600/main.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiO1i_dBTegl2kZZajF3uXgj3jt5vPH8Vxel6UxMbRonZAIFuL6EuuQ_hWhqIJYE55dMvFP-lyMPvQfHhLdQMvFS_LIYJ2Fvw35hsbUXEQEYKp90LrxhWYv2uNFdwdLjFbPmBGJ1yrgn4s/s1600/main.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Consecuencias&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Permite modificar las clases subjects y las observers independientemente. &lt;/li&gt;
&lt;li&gt;Permite añadir nuevos observadores en tiempo de ejecución, sin que esto afecte a ningún otro observador.&lt;/li&gt;
&lt;li&gt;Permite que dos capas de diferentes niveles de abstracción se puedan comunicar entre sí sin romper esa división. &lt;/li&gt;
&lt;li&gt;Permite comunicación broadcast, es decir, un objeto subject envía su notificación a todos los observers sin enviárselo a ningún observer en concreto (el mensaje no tiene un destinatario concreto). Todos los observers reciben el mensaje y deciden si hacerle caso ó ignorarlo.&lt;/li&gt;
&lt;li&gt;La comunicación entre los objetos subject y sus observadores es limitada: el evento siempre significa que se ha producido algún cambio en el estado del objeto y el mensaje no indica el destinatario. &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Temas a tener en cuenta.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Si los observadores pueden observar a varios objetos subject a la vez, es necesario ampliar el servicio update() para permitir conocer a un objeto observer dado cuál de los objetos subject que observa le ha enviado el mensaje de notificación.&lt;br /&gt;
Una forma de implementarlo es añadiendo un parámetro al servicio update() que sea el objeto subject que envía la notificación (el remitente). Y añadir una lista de objetos subject observados por el objeto observer en la clase Observer.&lt;br /&gt;
Si los objetos observers observan varios eventos de interés que pueden suceder con los objetos subjects, es necesario ampliar el servicio add() y el update() además de la implementación del mapeo subject-observers en la clase abstracta Subject. Una forma de implementarlo consiste en introducir un nuevo parámetro al servicio add() que indique el evento de interés del observer a añadir e introducirlo también como un nuevo parámetro en el servicio update() para que el subject que reciba el mensaje de notificación sepa qué evento ha ocurrido de los que observa.&lt;br /&gt;
&lt;br /&gt;
Cabe destacar que Java tiene una propuesta para el patrón observer:&lt;br /&gt;
Posee una Interfaz java.util.Observer: una clase puede implementar la interfaz Observer cuando dicha clase quiera ser informada de los cambios que se produzcan en los objetos observados. Tiene un servicio que es el siguiente: void update (Observable o, Object arg)&lt;br /&gt;
Este servicio es llamado cuando el objeto observado es modificado.&lt;br /&gt;
Además Java nos ofrece los siguientes servicios:&lt;br /&gt;
void addObserver (Observer o)&lt;br /&gt;
protected void clearChanged()&lt;br /&gt;
int countObservers()&lt;br /&gt;
void deleteObserver (Observer o)&lt;br /&gt;
void deleteObservers()&lt;br /&gt;
boolean hasChanged()&lt;br /&gt;
void notifyObservers()&lt;br /&gt;
void notifyObservers (Object arg)&lt;br /&gt;
protected void setChanged()&lt;br /&gt;
&lt;br /&gt;
Posee una clase llamada java.util.Observable: esta clase representa un objeto Subject.&lt;br /&gt;
Veamos el mismo ejemplo con el estandard de Java:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXlTWk59WuOx7sTxOXj_-bkSmhyphenhyphenoFVFhtkfLjpPuNRe04adsHeWno3otwTkNJ9N6GCymNNWctZmQ1gMQJPF_H5z6Z8rpW7pX8Wf5rgdlukK4IdpTCMoBvBlE0HnmWnbvCRVHkMr1vwMyU/s1600/adm.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXlTWk59WuOx7sTxOXj_-bkSmhyphenhyphenoFVFhtkfLjpPuNRe04adsHeWno3otwTkNJ9N6GCymNNWctZmQ1gMQJPF_H5z6Z8rpW7pX8Wf5rgdlukK4IdpTCMoBvBlE0HnmWnbvCRVHkMr1vwMyU/s1600/adm.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsX_hEywkewqOR_Q9ByOWMihN-TW6UPV2oXVmc74VYmobihH4inwgwIjWg0quqif0HAnOw9qTT3XFw6IXBjbvhsGPyGNXlRFBWqPCnWdHELdHWkSnPms2eu7s7wBMdFWZO9DjEghWSGTM/s1600/compras.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsX_hEywkewqOR_Q9ByOWMihN-TW6UPV2oXVmc74VYmobihH4inwgwIjWg0quqif0HAnOw9qTT3XFw6IXBjbvhsGPyGNXlRFBWqPCnWdHELdHWkSnPms2eu7s7wBMdFWZO9DjEghWSGTM/s1600/compras.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcR-MWwpq2tN3lMO6L0dDTri8_OhnmNbmKrRGtSw_HuXV_70pl_pfQKXHA3JaPDJRGHVhJAdQUzsZVAb4AZ_vzZzstPl-f66TRGOQjdDX2pAqPeF8K3lB9sWKfD_p5VKvoCZF68hxb8kQ/s1600/stock.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcR-MWwpq2tN3lMO6L0dDTri8_OhnmNbmKrRGtSw_HuXV_70pl_pfQKXHA3JaPDJRGHVhJAdQUzsZVAb4AZ_vzZzstPl-f66TRGOQjdDX2pAqPeF8K3lB9sWKfD_p5VKvoCZF68hxb8kQ/s1600/stock.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFW31_9meZ-ZhNjpqVESAWWx3znLa2EHclvUzpSGXn9S0LRDykp3lSVu-QxlaTeuy9s10X8lRiUdyoog0IE4dtArdgykY2IvoYGk2TL7hUERUYICnTyQuD7qZxLl-WkFblPDxiuzd4oDE/s1600/alarma.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFW31_9meZ-ZhNjpqVESAWWx3znLa2EHclvUzpSGXn9S0LRDykp3lSVu-QxlaTeuy9s10X8lRiUdyoog0IE4dtArdgykY2IvoYGk2TL7hUERUYICnTyQuD7qZxLl-WkFblPDxiuzd4oDE/s1600/alarma.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg27yBZ0aNJt3hSO2ijo7uPfChqRekRp6RtJyIZmBmch9u99fFWz9FuFV5cDHLVEEBSnde_sK4j9q3CMLSxOJXI0rbQy5uJ74LrLV8MB3UPR3f-5ckpY_ikbvYlp5edUhhezziTgplXHXo/s1600/biblio.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg27yBZ0aNJt3hSO2ijo7uPfChqRekRp6RtJyIZmBmch9u99fFWz9FuFV5cDHLVEEBSnde_sK4j9q3CMLSxOJXI0rbQy5uJ74LrLV8MB3UPR3f-5ckpY_ikbvYlp5edUhhezziTgplXHXo/s1600/biblio.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3WKp8rLGkwcNKYqdg2hE68h2qNvv-EDNDd_ZKP0AbRhGnghn7SecIDjUuo60dPTUTnFKm2JTTS_vp_Uq4hyuLTgA_DbkYF4kD1O5dTM5TEqOkMxLeiDLfuerKyxcE7o6_kkgngyVaeTI/s1600/main.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3WKp8rLGkwcNKYqdg2hE68h2qNvv-EDNDd_ZKP0AbRhGnghn7SecIDjUuo60dPTUTnFKm2JTTS_vp_Uq4hyuLTgA_DbkYF4kD1O5dTM5TEqOkMxLeiDLfuerKyxcE7o6_kkgngyVaeTI/s1600/main.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/5327292382454124586/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/5327292382454124586' title='14 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/5327292382454124586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/5327292382454124586'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/observer.html' title='Observer'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh5.googleusercontent.com/rhCz8rvvliohkvWEs75W0JYz6PHhucjaAxrF8bHLhX4G9dx96zSDh9SSuzEU-t2EEWst-qoL_INklDR6raOk9YbpkhPdfXktlyYI1Rj79-E48s7YyA=s72-c" height="72" width="72"/><thr:total>14</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-6297629112695626725</id><published>2011-06-10T15:01:00.001-03:00</published><updated>2011-09-21T11:00:10.411-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Patrones"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones de Comportamiento"/><category scheme="http://www.blogger.com/atom/ns#" term="State"/><title type='text'>State</title><content type='html'>Permite que un objeto modifique su comportamiento cada vez que cambie su estado interno. Busca que un objeto pueda reaccionar según su estado interno. Si bien muchas veces esto se puede solucionar con un boolean o utilizando constantes, esto suele terminar con una gran cantidad de if-else, código ilegible y dificultad en el mantenimiento. La intención del State es desacoplar el estado de la clase en cuestión.&lt;br /&gt;
&lt;br /&gt;
En determinadas ocasiones se requiere que un objeto tenga diferentes comportamientos según el estado en que se encuentra. Esto resulta complicado de manejar, sobretodo cuando se debe tener en cuenta el cambio de comportamientos y estados de dicho objeto, todos dentro del mismo bloque de código. El patrón State propone una solución a esta complicación, creando un objeto por cada estado posible.&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Este patrón debe ser utilizado cuando:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;El comportamiento de un objeto depende de un estado, y debe cambiar en tiempo de ejecución según el comportamiento del estado.&lt;/li&gt;
&lt;li&gt;Cuando las operaciones tienen largas sentencias con múltiples ramas que depende del estado del objeto.&lt;/li&gt;
&lt;/ul&gt;&amp;nbsp;Este patrón se utiliza cuando un determinado objeto tiene diferentes  estados y también distintas responsabilidades según el estado en que se  encuentre en determinado instante. También puede utilizarse para  simplificar casos en los que se tiene un complicado y extenso código de  decisión que depende del estado del objeto.&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Diagrama UML&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;&lt;img src=&quot;https://lh4.googleusercontent.com/EysIGvroQhDLTlv_EFSsI4pfsI9_HfK6mbgvA5eBL_WR1prxBF2oaLsdZJIZSij7xbEmy8JSXPUKNOLURhZPkAMYWpjVqqzxhZkhWzxdXwZbZ6VsvA&quot; /&gt;&lt;/div&gt;&lt;br /&gt;
&lt;u&gt;Context&lt;/u&gt;: mantiene una instancia con el estado actual&lt;br /&gt;
&lt;u&gt;State&lt;/u&gt;: define interfaz para el comportamiento asociado a un determinado estado del Contexto.&lt;br /&gt;
&lt;u&gt;StateConcreto&lt;/u&gt;: cada subclase implementa el comportamiento asociado con un estado del contexto.&lt;br /&gt;
&lt;br /&gt;
El Context delega el estado específico al objeto StateConcreto actual. Un objeto Context puede pasarse a sí mismo como parámetro hacia un objeto State. De esta manera la clase State puede acceder al contexto si fuese necesario. Context es la interfaz principal para el cliente. El cliente puede configurar un contexto con los objetos State. Una vez hecho esto estos clientes no tendrán que tratar con los objetos State directamente. Tanto el objeto Context como los objetos de StateConcreto pueden decidir el cambio de estado.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ejemplo&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Imaginemos que vamos a un  banco y cuando llegamos nos colocamos en la fila de mostrador: si la  misma esta abierta, seguiremos en la fila. En cambio, si esta cerrada  nos colocaremos en otra fila o tomaremos alguna decisión acorde. Por  otro lado, si vemos un cartel que dice &quot;enseguida vuelvo&quot; quizás tenemos  que contemplar el tiempo disponible que tenemos. Es decir, para  nosotros, el comportamiento de un banco cambia radicalmente según el  estado en el que se encuentre. Para estas ocasiones, es ideal el uso de  un patrón de estados.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0Vyli1cZZ3cJBockYR8I3H-nSmXVnKvrL522JbuxdQjY9aff9tmreKYJfpXEzUg78YZaSujCamZk4NX8IKMoxW_ElSP-SzM31CXLkR1k2csa0WmEtW6zjUNFfkaYGuB2qLqoUrKxMH5k/s1600/persona.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0Vyli1cZZ3cJBockYR8I3H-nSmXVnKvrL522JbuxdQjY9aff9tmreKYJfpXEzUg78YZaSujCamZk4NX8IKMoxW_ElSP-SzM31CXLkR1k2csa0WmEtW6zjUNFfkaYGuB2qLqoUrKxMH5k/s1600/persona.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNNxY3UHUs9zmzmPBN5PNmCGX-wLDorEDd2pzH7O99kMaGVvbQC9N4c8XNgrveR8DUtQBpZkWJaIA70TJshtATLQF00pq0cjZjGp8rzD-o5ih30ZXpW1ceRdZVh-5MNKb-HNmDxdPvC3E/s1600/banco.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNNxY3UHUs9zmzmPBN5PNmCGX-wLDorEDd2pzH7O99kMaGVvbQC9N4c8XNgrveR8DUtQBpZkWJaIA70TJshtATLQF00pq0cjZjGp8rzD-o5ih30ZXpW1ceRdZVh-5MNKb-HNmDxdPvC3E/s1600/banco.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;El banco publica un método llamado atende() pero en realidad la atención la realiza la ventanilla.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaMcRrGWbwVBZgrB_W6lihI2jYRr-20_qqlsRNQd5F1YcdwhZxx_2__vL-RlOuw5YVklryZ5fBOl9d6Xhw1Sv40Bo0N5pUu-vihrFXJY7t3cRGRRRY5yiUxzo_w7RH8P95oIQn2ijskMc/s1600/ventanilla.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaMcRrGWbwVBZgrB_W6lihI2jYRr-20_qqlsRNQd5F1YcdwhZxx_2__vL-RlOuw5YVklryZ5fBOl9d6Xhw1Sv40Bo0N5pUu-vihrFXJY7t3cRGRRRY5yiUxzo_w7RH8P95oIQn2ijskMc/s1600/ventanilla.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
La ventanilla cambia su comportamiento según el estado en que se encuentre. Por ejemplo, si esta cerrada, no hay atención directamente. Por eso mismo, delega el método de atención a su estado y es este mismo estado quién toma la decisión de atender o no.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJb8wUe5pKVPmvo-WtOvWXr0w4MvcJ6OM0hDdRjuj3MEEgzGAook6j4CuTdzR7G-L5cFcPcl16-I-vedj36DmvDyKmgNQZ_GMxa-C73tiqXdalmaWagl_mq_w9zqeGsen2h_lmKWyno2s/s1600/estadoventanilla.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJb8wUe5pKVPmvo-WtOvWXr0w4MvcJ6OM0hDdRjuj3MEEgzGAook6j4CuTdzR7G-L5cFcPcl16-I-vedj36DmvDyKmgNQZ_GMxa-C73tiqXdalmaWagl_mq_w9zqeGsen2h_lmKWyno2s/s1600/estadoventanilla.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGhImkHHhzCu4NR-CKPZsSgSRr4pU79hbUis49LdHnK5sIzFV1v0cMiSy1OSJpU121R_KsKAjkXNjohyphenhyphenfa9WIi9fc8EH1SnzrysKLUtanQjK1jZ38zheMn2BrPv64osL67FHBcehL-2so/s1600/abierta.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGhImkHHhzCu4NR-CKPZsSgSRr4pU79hbUis49LdHnK5sIzFV1v0cMiSy1OSJpU121R_KsKAjkXNjohyphenhyphenfa9WIi9fc8EH1SnzrysKLUtanQjK1jZ38zheMn2BrPv64osL67FHBcehL-2so/s1600/abierta.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDC87cQ4xFeNjTyaC5dc4HWShD86HO0asq7dZkCJl1yaRPismMqEW9rBFvVJqt7mDEQN0haAI8Rhqy5H6xwM-h7Oru6bXpWSezMdGeV0Xjdm-WhRlesCTTmQvEMhzxOG7HqC5VLmhSubs/s1600/suspendida.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDC87cQ4xFeNjTyaC5dc4HWShD86HO0asq7dZkCJl1yaRPismMqEW9rBFvVJqt7mDEQN0haAI8Rhqy5H6xwM-h7Oru6bXpWSezMdGeV0Xjdm-WhRlesCTTmQvEMhzxOG7HqC5VLmhSubs/s1600/suspendida.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEji1y9zbGJf4chQpW_83wW02Bya0q27XrSZP3yLD4-zENdn7jSl-eZZASYs1On4s-j6BQo3DqUx-wbsqZ2uPwd5Ngt7DEJTx9BEo_bRuVlmG2xW9IFWKvH6vpWWYZb0a7JWpASPkkHbCGQ/s1600/cerrada.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEji1y9zbGJf4chQpW_83wW02Bya0q27XrSZP3yLD4-zENdn7jSl-eZZASYs1On4s-j6BQo3DqUx-wbsqZ2uPwd5Ngt7DEJTx9BEo_bRuVlmG2xW9IFWKvH6vpWWYZb0a7JWpASPkkHbCGQ/s1600/cerrada.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBRMOuyqfkY2Y-xfbr4MReTRj3TS2vaEi0hBk_R8cLqnvFAGKJMI-hEYBrlPU-TvyuwX2lxgL8PZ5U5yndK9v12aANCb3-mYm15KjZu3_6zmsdQETThLllPTYJ5LOAy5qwA0_UVaX8WeE/s1600/main.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBRMOuyqfkY2Y-xfbr4MReTRj3TS2vaEi0hBk_R8cLqnvFAGKJMI-hEYBrlPU-TvyuwX2lxgL8PZ5U5yndK9v12aANCb3-mYm15KjZu3_6zmsdQETThLllPTYJ5LOAy5qwA0_UVaX8WeE/s1600/main.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Consecuencias&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Se localizan fácilmente las responsabilidades de los estados concretos, dado que se encuentran en las clases que corresponden a cada estado. Esto brinda una mayor claridad en el desarrollo y el mantenimiento posterior. Esta facilidad la brinda el hecho que los diferentes estados están representados por un único atributo (state) y no envueltos en diferentes variables y grandes condicionales.&lt;/li&gt;
&lt;li&gt;Hace los cambios de estado explícitos puesto que en otros tipos de implementación los estados se cambian modificando valores en variables, mientras que aquí al estar representado cada estado.&lt;/li&gt;
&lt;li&gt;Facilita la ampliación de estados mediante una simple herencia, sin afectar al Context.&lt;/li&gt;
&lt;li&gt;Permite a un objeto cambiar de estado en tiempo de ejecución.&lt;/li&gt;
&lt;li&gt;Los estados pueden reutilizarse: varios Context pueden utilizar los mismos estados.&lt;/li&gt;
&lt;li&gt;Se incrementa el número de subclases.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Temas a tener en cuenta&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
El patrón no indica exactamente dónde definir las transiciones de un estado a otro. Existen dos formas de solucionar esto: definiendo estas transiciones dentro de la clase contexto, la otra es definiendo estas transiciones en las subclaes de State. Es más conveniente utilizar la primer solución cuando el criterio a aplicar es fijo, es decir, no se modificará. En cambio la segunda resulta conveniente cuando este criterio es dinámico, el inconveniente aquí se presenta en la dependencia de código entre las subclases.&lt;br /&gt;
Por otro lado, los estados concretos suelen ser Singleton.</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/6297629112695626725/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/6297629112695626725' title='8 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/6297629112695626725'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/6297629112695626725'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/state.html' title='State'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh4.googleusercontent.com/EysIGvroQhDLTlv_EFSsI4pfsI9_HfK6mbgvA5eBL_WR1prxBF2oaLsdZJIZSij7xbEmy8JSXPUKNOLURhZPkAMYWpjVqqzxhZkhWzxdXwZbZ6VsvA=s72-c" height="72" width="72"/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-8292742367908903824</id><published>2011-06-10T12:01:00.000-03:00</published><updated>2011-06-10T12:01:27.934-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Memento"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones de Comportamiento"/><title type='text'>Memento</title><content type='html'>Este patrón de diseño permite capturar y exportar el estado interno de un objeto para que luego se pueda restaurar, sin romper la encapsulación.&lt;br /&gt;
Su finalidad es almacenar el estado de un objeto (o del sistema completo) en un momento dado, de manera que se pueda restaurar posteriormente si fuese necesario. Para ello se mantiene almacenado el estado del objeto para un instante de tiempo en una clase independiente de aquella a la que pertenece el objeto (pero sin romper la encapsulación), de forma que ese recuerdo permita que el objeto sea modificado y pueda volver a su estado anterior.&lt;br /&gt;
&lt;br /&gt;
Hoy en día, muchos aplicativos permiten el &quot;deshacer&quot; y &quot;rehacer&quot; de manera muy sencilla. Para ciertos aplicativos es casi una obligación tener estas funciones y sería impensado el hecho que no las posean. Sin embargo, cuando queremos llevar esto a código puede resultar complejo de implementar. Este patrón intenta mostrar una solución a este problema.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Se usa cuando:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Se necesite restaurar el sistema desde estados pasados. &lt;/li&gt;
&lt;li&gt;Se quiera facilitar el hacer y deshacer de determinadas operaciones, para lo que habrá que guardar los estados anteriores de los objetos sobre los que se opere (o bien recordar los cambios de forma incremental).&lt;/li&gt;
&lt;/ul&gt;Este patrón debe ser utilizado cuando se necesite salvar el estado de un  objeto y tener disponible los distintos estados históricos que se  necesiten. Por ello mismo, este patrón es muy intuitivo para darse  cuando debe ser utilizado.&lt;br /&gt;
Hoy en día una gran variedad de  aplicaciones poseen las opciones de &quot;deshacer&quot; y &quot;rehacer&quot;. Por ejemplo,  las herramientas de Microsoft Office como Word, Power Point, etc. Es  imposible pensar que ciertas herramientas no tengan esta opción, como el   Photoshop. También IDEs de programación como Eclipse utilizan una  opción de historial local. Una solución para este problema es el patrón  Memento. &lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Diagrama UML&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://lh4.googleusercontent.com/46luX0K0pXacXu0q4XyOOglFa5kv3KG2nCkhyiO3oVQ5cnHYdVgjkqZSPOCDb4BI6AsMR6RDsIhfqixMVgfZuS_w-SYDx5iRI64RPGo59CWxg_qaNQ&quot; /&gt;&lt;/div&gt;&lt;br /&gt;
&lt;u&gt;Caretaker&lt;/u&gt;: es responsable por mantener a salvo a Memento. No opera o examina su contenido.&lt;br /&gt;
&lt;u&gt;Memento&lt;/u&gt;: almacena el estado interno de un objeto Originator. El Memento puede&lt;br /&gt;
almacenar todo o parte del estado.&lt;br /&gt;
&lt;u&gt; Originator&lt;/u&gt;: crea un objeto Memento conteniendo una fotografía de su estado&lt;br /&gt;
interno.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ejemplo&lt;/span&gt; &lt;br /&gt;
&lt;br /&gt;
Vamos a realizar un ejemplo de este patrón donde se busque salvar  el nombre de una persona que puede variar a lo largo del tiempo.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkLwKiRY5DTnkyC6BBNRyKWrVzNZvR5gF6oxCxq1vvBQcCM-x8_r4BFjv5PPQxZWed3WSlygSINyUi_RQQS4s2Ho1PBMmcgojtw2fjyNcfrYnbLaEuVGqeQ3cBzernvRbxr-cwUmqbcXk/s1600/memento.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkLwKiRY5DTnkyC6BBNRyKWrVzNZvR5gF6oxCxq1vvBQcCM-x8_r4BFjv5PPQxZWed3WSlygSINyUi_RQQS4s2Ho1PBMmcgojtw2fjyNcfrYnbLaEuVGqeQ3cBzernvRbxr-cwUmqbcXk/s1600/memento.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4K5zRxz8TL8sveRzEIJMB4a5X_TZ3YGyl5tJm6BJeejMPBhJsDB13Ljra3Jgp1oaSBFUGuBeWO3WNYysosvZUwO53fjBi4fvwK0j2O8tAp0QaFNEnP72g-FFa9z3FaAcKoPQArz0P4Pw/s1600/persona.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4K5zRxz8TL8sveRzEIJMB4a5X_TZ3YGyl5tJm6BJeejMPBhJsDB13Ljra3Jgp1oaSBFUGuBeWO3WNYysosvZUwO53fjBi4fvwK0j2O8tAp0QaFNEnP72g-FFa9z3FaAcKoPQArz0P4Pw/s1600/persona.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4ii1CkG9qLsEXGrjgf-QDyO6Y9o_AiS7m6Garv0JjlseX5Wcm9FMwBVDITSVTT-yzKiAD4DIporMlUnh4OF9hRTpHw7o_R6O3e5okqJ3v9hlYoiYOUG3yjoLA5zIdgqA9obU2sYBJwUE/s1600/caret.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4ii1CkG9qLsEXGrjgf-QDyO6Y9o_AiS7m6Garv0JjlseX5Wcm9FMwBVDITSVTT-yzKiAD4DIporMlUnh4OF9hRTpHw7o_R6O3e5okqJ3v9hlYoiYOUG3yjoLA5zIdgqA9obU2sYBJwUE/s1600/caret.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDBhHPFiA_uAsCRN8VFqxU7aEKflz2FHhJdxf6_agxPHF-Mg33ZUFhu1nC6WgxywvjO2_KhIbS8OOf-lyEkaOmXsDSiuyRRynospAyg_HmYVgk96CaWoyxkdayr85GWRRUDah-k9-NRDs/s1600/main.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDBhHPFiA_uAsCRN8VFqxU7aEKflz2FHhJdxf6_agxPHF-Mg33ZUFhu1nC6WgxywvjO2_KhIbS8OOf-lyEkaOmXsDSiuyRRynospAyg_HmYVgk96CaWoyxkdayr85GWRRUDah-k9-NRDs/s1600/main.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Consecuencias&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;No es necesario exponer el estado interno como atributos de acceso público, preservando así la encapsulación.&lt;/li&gt;
&lt;li&gt;Si el originador tendría que de almacenar y mantener a salvo una o muchas copias de su estado interno, sus responsabilidades crecerían y sería inmanejable.&lt;/li&gt;
&lt;li&gt;El uso frecuente de Mementos para almacenar estados internos de gran tamaño, podría resultar costoso y perjudicar la performance del sistema.&lt;/li&gt;
&lt;li&gt;Caretaker no puede hacer predicciones de tiempo ni de espacio.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Temas a tener en cuenta.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Si bien la implementación de un Memento no suele variar demasiado, cuando la secuencia de creación y restauración de mementos es conocida, se puede adoptar una estrategia de cambio incremental: en cada nuevo memento sólo se almacena la parte del estado que ha cambiado en lugar del estado completo.&lt;br /&gt;
Esta estrategia se aplica cuando memento se utiliza para mantener una lista de deshacer/rehacer. &lt;br /&gt;
Otra opción utilizada es no depender de índices en la colecciones y utilizar ciertos métodos no indexados como el  .previus() que poseen algunas colecciones.</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/8292742367908903824/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/8292742367908903824' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/8292742367908903824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/8292742367908903824'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/memento.html' title='Memento'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh4.googleusercontent.com/46luX0K0pXacXu0q4XyOOglFa5kv3KG2nCkhyiO3oVQ5cnHYdVgjkqZSPOCDb4BI6AsMR6RDsIhfqixMVgfZuS_w-SYDx5iRI64RPGo59CWxg_qaNQ=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-3909273383459077344</id><published>2011-06-10T07:48:00.000-03:00</published><updated>2011-06-10T07:48:40.362-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Mediator"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones de Comportamiento"/><title type='text'>Mediator</title><content type='html'>Un Mediator es un patrón de diseño que define un objeto que hace de procesador central, coordinando las relaciones entre sus asociados o participantes. Permite la interacción de varios objetos, sin generar acoples fuertes en esas relaciones. Todos los objetos se comunican con un mediador y es éste quién realiza la comunicación con el resto.&lt;br /&gt;
&lt;br /&gt;
Cuando muchos objetos interactúan con otros objetos, se puede formar una estructura muy compleja, con muchas conexiones entre distintos objetos. En un caso extremo cada objeto puede conocer a todos los demás objetos. Para evitar esto, el patrón Mediator, encapsula el comportamiento de todo un conjunto de objetos en un solo objeto.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Usar el patrón Mediator cuando:&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Un conjunto grande de objetos se comunica de una forma bien definida, pero compleja.&lt;/li&gt;
&lt;li&gt;Reutilizar un objeto se hace difícil por que se relaciona con muchos objetos.&lt;/li&gt;
&lt;li&gt;Las clases son difíciles de reutilizar porque su función básica esta entrelazada con relaciones de dependencia.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Un ejemplo real que se puede comparar con este patrón es un  framework que se llama Struts. Struts posee un clase que hace de  Mediadora que se llama ActionServlet. Esta clase lee un archivo de  configuración (el struts-config.xml) para ayudarse con la mediación,  pero lo importante es que se encarga de comunicar el flujo de  información de todos los componentes web de una aplicación. Si no  utilizamos Struts, entonces cada página debe saber hacia donde debe  dirigir el flujo y el mantenimiento de dicha aplicación puede resultar  complicado, especialmente si la aplicación es muy grande.&lt;br /&gt;
En cambio,  si todas las páginas se comunican con un mediador, entonces la  aplicación es mucho más robusta: con cambiar un atributo del mediador  todo sigue funcionando igual.&lt;br /&gt;
Como conclusión podemos afirmar que  este patrón debe ser utilizado en casos donde convenga utilizar un  procesador central, en vez de que cada objeto tenga que conocer la  implementación de otro. Imaginemos un aeropuerto: que pasaría si no  tuviese una torre de control y todos los aviones que deban  aterrizar/despegar se tienen que poner todos de acuerdo para hacerlo.  Además cada avión debe conocer detalles de otros aviones (velocidad de  despegue, nafta que le queda a cada uno que quiera aterrizar, etc).&lt;br /&gt;
Para  evitar esto se utiliza un torre de control que sincroniza el  funcionamiento de un aeropuerto. Esta torre de control se puede ver como  un mediador entre aviones.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Diagrama UML&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://lh6.googleusercontent.com/ncM1VsUkV5iq1TOo0MtG3x5Z5Fcf5R3AmNayA8bHj3giiYnqoTGMKSv18A8cihfwhVm-jRf9EY5F3xL8OZEbIsTnCZNaSHHmZbDiX3NxT0ZJKpZmUTg&quot; /&gt;&lt;/div&gt;&lt;br /&gt;
&lt;u&gt;Mediator&lt;/u&gt;: define una interface para comunicarse con los objetos colegas.&lt;br /&gt;
&lt;u&gt;MediatorConcreto&lt;/u&gt;: implementa la interface y define como los colegas se comunican entre ellos. Además los conoce y mantiene, con lo cual hace de procesador central de todos ellos.&lt;br /&gt;
&lt;u&gt;Colleague&lt;/u&gt;: define el comportamiento que debe implementar cada colega para poder comunicarse el mediador de una manera estandarizada para todos.&lt;br /&gt;
&lt;u&gt;ColleagueConcreto&lt;/u&gt;: cada colega conoce su mediador, y lo usa para comunicarse con otros colegas.&lt;br /&gt;
Los colegas envían y reciben requerimientos de un objeto mediador. El mediador gestiona cada mensaje y se lo comunica a otro colega si fuese necesario.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ejemplo&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Nuestro ejemplo será un chat: donde habrá usuarios que se  comunicaran entre sí en un salón de chat.  Para ellos se define una  interface llamada IUsuarioChat que todos los objetos que quieran  participar de un chat deberán implementar. La clase Ususario representa un usuario que quiera chatear. &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYhyjgExPmqORI88nQXS6pJonLVwRLj1p8BtqlYEA1LP-BRc9-psObhrjV7IxgcfuKM92ctCWUKhpNwU4bYr22CaplkFlLwlbHzceVAFZPBKIrGCUZ5e_e4dgXzthoVmUngsDLA2FxmUk/s1600/iusuario.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYhyjgExPmqORI88nQXS6pJonLVwRLj1p8BtqlYEA1LP-BRc9-psObhrjV7IxgcfuKM92ctCWUKhpNwU4bYr22CaplkFlLwlbHzceVAFZPBKIrGCUZ5e_e4dgXzthoVmUngsDLA2FxmUk/s1600/iusuario.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHhABAbNU6VJ1bH7V7AzGdMEkP_MYCQ7tWlvTa-Us-nMUVueyBjEtxKtqnYl8aXcBFgKhzeELoJBGW7kZdlBWg-YMRO5zRuiMD1I2VjAQ8huhcsMwKirOlfTwKxC35-ZC-24kHRLHu5A8/s1600/user.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHhABAbNU6VJ1bH7V7AzGdMEkP_MYCQ7tWlvTa-Us-nMUVueyBjEtxKtqnYl8aXcBFgKhzeELoJBGW7kZdlBWg-YMRO5zRuiMD1I2VjAQ8huhcsMwKirOlfTwKxC35-ZC-24kHRLHu5A8/s1600/user.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAl6GunLhmukYxS01KIUNxZVHGlrLUybREOx_eotkBJc1RgU-9uNWHsNHGY7zrVqKiQfMzFHjxJKigVYwOH3amCih-8qi6GglTTkkwLVQJVwKLAvhe1lhyaXP0jEf4L6Xkl2t_YQEpWVY/s1600/isalon.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAl6GunLhmukYxS01KIUNxZVHGlrLUybREOx_eotkBJc1RgU-9uNWHsNHGY7zrVqKiQfMzFHjxJKigVYwOH3amCih-8qi6GglTTkkwLVQJVwKLAvhe1lhyaXP0jEf4L6Xkl2t_YQEpWVY/s1600/isalon.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5qssKH0X_1JZFSv5Ut1ZAd63pMNb1eFvUllO6Qih_qbO8woG-SWOqr_YJ5Wsk-GSIKhqS4rZoThw4x4GPAMQKpfJNdyaziAqCgE23WwI_me0H6ouxoi2laOLNWtxghiRI4x5AYFgrBg4/s1600/salon.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5qssKH0X_1JZFSv5Ut1ZAd63pMNb1eFvUllO6Qih_qbO8woG-SWOqr_YJ5Wsk-GSIKhqS4rZoThw4x4GPAMQKpfJNdyaziAqCgE23WwI_me0H6ouxoi2laOLNWtxghiRI4x5AYFgrBg4/s1600/salon.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Veamos como funciona:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUB4bU79z79TfsT1ng9Rt5ZwPZ-XZ3qpRcUXcJQh95ndouvLLO6u42r0pJTSNfen9V-b1B8xUbD-YUMlRotUqBgh9hmPpOzq2PfJqkgKvYaf7t0aP0Ikz9SEMfcNfC3WBULjh1jCpFUmw/s1600/main.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUB4bU79z79TfsT1ng9Rt5ZwPZ-XZ3qpRcUXcJQh95ndouvLLO6u42r0pJTSNfen9V-b1B8xUbD-YUMlRotUqBgh9hmPpOzq2PfJqkgKvYaf7t0aP0Ikz9SEMfcNfC3WBULjh1jCpFUmw/s1600/main.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Consecuencias&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Desacopla a los colegas: el patrón Mediator promueve bajar el acoplamiento entre colegas. Se puede variar y reusar colegas y mediadores independiéntemente.&lt;/li&gt;
&lt;li&gt;Simplifica la comunicación entre objetos: los objetos que se comunican de la forma &quot;muchos a muchos&quot; puede ser remplazada por una forma &quot;uno a muchos&quot; que es menos compleja y más elegante. Además esta forma de comunicación es más fácil de entender. Es decir, un objeto no necesita conocer a todos los objetos, tan sólo a un mediador.&lt;/li&gt;
&lt;li&gt;Clarifica como los objetos se relacionan en un sistema.&lt;/li&gt;
&lt;li&gt;Centraliza el control: el mediador es el que se encarga de comunicar a los colegas, este puede ser muy complejo, difícil de entender y modificar. Para que quién conoce el framework Struts, es muy similar al concepto del archivo struts-config.xml: centraliza el funcionamiento de la aplicación, aunque si llega a ser una aplicación muy compleja el archivo se vuelve un tanto complicado de entender y seguir.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Temas a tener en cuenta.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Sabemos que el patrón Mediator introduce un objeto para mediar la comunicación entre &quot;colegas&quot;. Algunas veces el objeto Mediador implementa operaciones simplemente para enviarlas o otros objetos; otras veces pasa una referencia a él mismo y por consiguiente utiliza la verdadera delegación.&lt;br /&gt;
Entre los colegas puede existir dos tipos de dependencias:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Un tipo de dependencia requiere un objeto para conseguir la aprobación de otros objetos antes de hacer tipos específicos de cambios de estado.&lt;/li&gt;
&lt;li&gt;El otro tipo de dependencia requiere un objeto para notificar a otros objetos después de que este ha hecho un tipo específico de cambios de estado.&lt;/li&gt;
&lt;/ol&gt;Ambos tipos de dependencias son manejadas de un modo similar. Las instancias de Colega1, Colega2, .... están asociadas con un objeto mediator. Cuando ellos quieren conseguir la aprobación anterior para un cambio de estado, llaman a un método del objeto Mediator. El método del objeto Mediator realiza cuidadoso el resto.&lt;br /&gt;
Pero hay que tener en cuenta lo siguiente con respecto al mediador: Poner toda la  dependencia de la lógica para un conjunto de objetos relacionados en un lugar puede hacer incomprensible la dependencia lógica fácilmente. Si la clase Mediator llega a ser demasiado grande, entonces dividirlo en piezas más pequeñas puede hacerlo más comprensible.</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/3909273383459077344/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/3909273383459077344' title='7 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/3909273383459077344'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/3909273383459077344'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/mediator.html' title='Mediator'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh6.googleusercontent.com/ncM1VsUkV5iq1TOo0MtG3x5Z5Fcf5R3AmNayA8bHj3giiYnqoTGMKSv18A8cihfwhVm-jRf9EY5F3xL8OZEbIsTnCZNaSHHmZbDiX3NxT0ZJKpZmUTg=s72-c" height="72" width="72"/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-1698546047326763550</id><published>2011-06-09T22:48:00.000-03:00</published><updated>2011-06-09T22:48:58.857-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Iterator"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones de Comportamiento"/><title type='text'>Iterator</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;Provee un mecanismo estándar para acceder secuencialmente a los elementos de una colección; define una interface que declara métodos para acceder secuencialmente a los objetos de una colección. Una clase accede a una colección a través de dicha interface.&lt;br /&gt;
&lt;br /&gt;
La motivación de este patrón reside en la gran diversidad de colecciones y algoritmos que existe hoy en día para recorrer una colección. Lo que se busca es acceder a los contenidos de los objetos incluidos sin exponer su estructura.&lt;br /&gt;
Podemos decir que este patrón nace para poder soportar diversas formas de recorrer  objetos y para ofrecer una interfaz uniforme para recorrer distintos tipos de estructuras de agregación.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Se utiliza cuando:&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Una clase necesita acceder al contenido de una colección sin llegar a ser dependiente de la clase que es utilizada para implementar la colección, es decir sin tener que exponer su representación interna.&lt;/li&gt;
&lt;li&gt;Una clase necesita un modo uniforme de acceder al contenido de varias colecciones.&lt;/li&gt;
&lt;li&gt;Cuando se necesita soportar múltiples recorridos de una colección.&lt;/li&gt;
&lt;/ul&gt;Este patrón debe ser utilizado cuando se requiera una forma estándar  de recorrer una colección, es decir, cuando no es necesario que un  cliente sepa la estructura interna de una clase. Un cliente no siempre  necesita saber si debe recorrer un List o un Set o un Queue y, menos que  menos, que clase concreta esta recorriendo.&lt;br /&gt;
El ejemplo más  importante de este patrón esta en el Java Framework Collection: las  colecciones en el paquete java.util siguen el patrón Iterator. La causa  de porque Java utiliza este patrón es muy simple. En la versión 1.6 Java  posee alrededor de 50 colecciones. Y cada una de ellas es un caso de  estudio: cada una funciona de manera distinta a la otra, con algoritmos  muy distintos, por ejemplo: hay trees, binary trees, arrays, ring  buffers, hashes, hash maps, array lists, sets, etc. Si nosotros como  clientes de Java tendríamos que aprender como se debe recorrer una  colección en Java, sería realmente muy molesto. Pero si todas las  colecciones se recorren de la misma forma estándar, y además, cada  colección sabe cual es la mejor manera de recorrerla, entonces sería un  gran avance que, de hecho, lo es.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Diagrama UML&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;img src=&quot;https://lh5.googleusercontent.com/m8zsq2NgkH3zuO0rMEoPRmk3YyVDOA0EHTr58G3J4gkAp3eQ-SVmNlVNsMz1P4QTr0drGJVbtao374Wp2vjNCJ0Y9H6mSMl2zU9BnCxnkOfOSG5Oyw&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Agregado/Aggregate&lt;/u&gt;: define una interfaz para crear un objeto iterator.&lt;br /&gt;
&lt;u&gt;Iterator&lt;/u&gt;: define la interfaz para acceder y recorrer los elementos de un agregado.&lt;br /&gt;
&lt;u&gt;IteradorConcreto&lt;/u&gt;: implementa la interfaz del iterador y guarda la posición actual del recorrido en cada momento.&lt;br /&gt;
&lt;u&gt;AgregadoConcreto&lt;/u&gt;: implementa la interfaz de creación de iteradores devolviendo una instancia del iterador concreto apropiado.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Cliente&lt;/u&gt;: solicita recorrer una colección y lo hace siguiendo los métodos otorgados por la interfaz Iterator.  &lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ejemplo&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Vamos a realizar un ejemplo muy sencillo: una división o  sucursal que contiene empleados. Para ello internamente implemento un  Array pero el cliente no tiene porque saberlo. &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjk5f85etCEwtFclXdJIXz73HAJBgIbQf_tKuOWAYowFe5bmtkRpMt-5oE1KKN-qmwCt02A4clAwn9DseJRATd-6npYiN3n6HfKcoN0FhigRsngGvlbo49RC3fznE82SL_RqwJKSl0-1uU/s1600/division.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjk5f85etCEwtFclXdJIXz73HAJBgIbQf_tKuOWAYowFe5bmtkRpMt-5oE1KKN-qmwCt02A4clAwn9DseJRATd-6npYiN3n6HfKcoN0FhigRsngGvlbo49RC3fznE82SL_RqwJKSl0-1uU/s1600/division.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_WkpwG08N7PH_KDrIfJhJTVG6MTX92PF-VqIyoAwgCF13mi0WhiCn3b06bhs-GKSKlIscJ75LgU7v_9LcYKvgJLkjbE_NvUG8zz8lpVSog7y1a8Ap9Zm4utaoeV3wG9kRUxTnxT7BcM0/s1600/empleado.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_WkpwG08N7PH_KDrIfJhJTVG6MTX92PF-VqIyoAwgCF13mi0WhiCn3b06bhs-GKSKlIscJ75LgU7v_9LcYKvgJLkjbE_NvUG8zz8lpVSog7y1a8Ap9Zm4utaoeV3wG9kRUxTnxT7BcM0/s1600/empleado.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;Y ahora crearemos un Iterator para recorrer los empleados de la división. El método iterator devuelve un objeto DivisionIterator. Veamos como funciona:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjScg3PTY4waXHv61hrzqnjKLH3rcVFMmGC-dl5PyQZyW32qBhiUyptek4hqZn6kjy7U10mtMmcLAoUydU93Dd_UcI8bU4udpwNGtGis7w5V3b_S49B5XeLa256v_wf517rTckDgXcDTRo/s1600/divit.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjScg3PTY4waXHv61hrzqnjKLH3rcVFMmGC-dl5PyQZyW32qBhiUyptek4hqZn6kjy7U10mtMmcLAoUydU93Dd_UcI8bU4udpwNGtGis7w5V3b_S49B5XeLa256v_wf517rTckDgXcDTRo/s1600/divit.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Si ha recorrido alguna colección mediante un objeto Iterator estará familiarizado con el siguiente código:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsdCYL8NaY35JBZeCNJLctDobrWNTCsReqC3ZS-dDLD08aZeQHBuSUnWMerlCcQRhQL5AY39xMzJGh7mJtZO4hH_muarlDjgStijeAbcTdjTJDR_CH01pgOkp2sj0Nw3G8I3iF7-CaJ_4/s1600/main.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsdCYL8NaY35JBZeCNJLctDobrWNTCsReqC3ZS-dDLD08aZeQHBuSUnWMerlCcQRhQL5AY39xMzJGh7mJtZO4hH_muarlDjgStijeAbcTdjTJDR_CH01pgOkp2sj0Nw3G8I3iF7-CaJ_4/s1600/main.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Consecuencias&lt;/span&gt; &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Es posible acceder a una colección de objetos sin conocer el código de los objetos.&lt;/li&gt;
&lt;li&gt;Utilizando varios objetos Iterator, es simple tener y manejar varios recorridos al mismo tiempo.&lt;/li&gt;
&lt;li&gt;Es posible para una clase Colecction proporcionar diferentes tipos de objetos Iterator que recorran la colección en diferentes modos. Por ejemplo, una clase Colecction que mantiene una asociación entre la clave de los objetos y el valor de los objetos podría tener diferentes métodos para crear Iterators que recorran sólo la clave de los objetos y crear Iterators que recorran sólo el valor de los objetos.&lt;/li&gt;
&lt;li&gt;Las clases Iterator simplifican el código de las colecciones, ya que el código de los recorridos se encuentra en los Iterators y no en las colecciones.&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/1698546047326763550/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/1698546047326763550' title='5 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/1698546047326763550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/1698546047326763550'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/iterator.html' title='Iterator'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh5.googleusercontent.com/m8zsq2NgkH3zuO0rMEoPRmk3YyVDOA0EHTr58G3J4gkAp3eQ-SVmNlVNsMz1P4QTr0drGJVbtao374Wp2vjNCJ0Y9H6mSMl2zU9BnCxnkOfOSG5Oyw=s72-c" height="72" width="72"/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-4334335334140659679</id><published>2011-06-09T14:40:00.000-03:00</published><updated>2011-06-09T14:40:27.718-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Interpreter"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones de Comportamiento"/><title type='text'>Interpreter</title><content type='html'>Este patrón busca representar un lenguaje mediante reglas gramáticas.  Para ello define estas reglas gramáticas y como interpretarlas. Utiliza una clase para representar una regla gramática.&lt;br /&gt;
Si un tipo particular de problema se presenta frecuentemente, puede ser provechoso expresar los diferentes casos del problema como sentencias de un lenguaje simple. Se puede, entonces, construir un intérprete que resuelva el problema interpretando dichas sentencias.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Cuando Utilizarlo.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Este patrón se debe utilizar cuando hay un lenguaje que interpretar y se puede interpretar sus palabras como árboles sintácticos abstractos. Para ello, la gramática debe ser simple.&lt;br /&gt;
Difícilmente el desarrollador utilice este patrón  en algún momento de su vida, lo que no quita que no sea un patrón  utilizado. La situación ideal que se debe considerar para aplicar este  patrón es que exista un lenguaje sencillo que pueda interpretarse con  palabras. El ejemplo más claro es JAVA: este lenguaje permite escribir  en archivos .java entendibles por humanos y luego este archivo es  compilado e interpretado para que pueda ejecutar sentencias entendibles  por una máquina.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Diagrama UML&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;img src=&quot;https://lh5.googleusercontent.com/DIXqZN-SX4-eHi5Xb3YDBkxVdLRBzYq3OH03hn9bA3b0patmRURUmhEMWoDNLXASE09cEzBEyql-AXMhKzHpDc6BCE5OxWIKF8oIcEcCod5Rz2Sd4ec&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;AbstractExpression&lt;/u&gt;: declara una interfaz para la ejecución de una operación.&lt;br /&gt;
&lt;u&gt;TerminalExpression&lt;/u&gt;: implementa una operación asociada con los símbolos terminales de la gramática&lt;br /&gt;
&lt;u&gt;NonterminalExpression&lt;/u&gt;: implementa una operación de interpretación asociada con los símbolos no terminales de la gramática.&lt;br /&gt;
&lt;u&gt;Context&lt;/u&gt;: contiene información global para el interprete.&lt;br /&gt;
&lt;u&gt;Client&lt;/u&gt;: construye un árbol sintáctico abstracto que representa una sentencia particular en el lenguaje que la gramática define. El cliente construye una expresión &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ejemplo&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Luego de leer el ejemplo, se entenderá  porque este patrón sólo funciona con lenguajes con reglas sencillas... de hecho este ejemplo no lo pensé yo, lo vi en una página hace muchos años y no recuerdo cual era para colocar la fuente...&lt;br /&gt;
Veamos un ejemplo donde se utiliza el interpreter para interpretar los  números romanos mediante ciertas reglas matemáticas y convertirlo en un  número de escala decimal.&lt;br /&gt;
&lt;br /&gt;
Primero creamos el contexto: esto es una clase donde tiene un input (un String ya que los numeros romanos son letras) y un output (un int ya que la respuesta será un número).&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi1K3QvJQJ0UsJxj1z-ev93-5pCxZrt7X18iX7CzY8VydbG32LWNn4o6R6GwzKALF_twCiX7d1dYEFIXiV23sMn8cC1d5XWDHIV8DVuT3PEPWw2k0L9Ze6q_91mr3qsf7ThEILZCYefqo/s1600/context.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi1K3QvJQJ0UsJxj1z-ev93-5pCxZrt7X18iX7CzY8VydbG32LWNn4o6R6GwzKALF_twCiX7d1dYEFIXiV23sMn8cC1d5XWDHIV8DVuT3PEPWw2k0L9Ze6q_91mr3qsf7ThEILZCYefqo/s1600/context.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Lo que sigue a continuación es puro algoritmo: si pensamos como funcionan los numeros romanos vamos a encontrar un patrón (pongo como ejemplo con escala de 10 pero es lo mismo para el resto de las escalas): de 1 a 3 es el mismo signo I (ocupa 1 espacio por vez), el 4 es una combinacion del 5 con el 1.... IV (ocupan dos lugares), el 5 es V (ocupa 1 lugar) y el próximo signo que hace combinación es el 9 (IX) que utiliza un signo de una escala mayor.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgefzw6XYUtBFcIBSApZnB7ib9_6rUVVYkDaYsE09Ya40O4wEInxxcckdSHiSIey885-GrX2I4Noz49ELMrCp56Ln4l2Hx949qqom9Mtgr0LeFLTybSeNr7kPQxX0n-dwVagwnnZTzNz24/s1600/exp.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgefzw6XYUtBFcIBSApZnB7ib9_6rUVVYkDaYsE09Ya40O4wEInxxcckdSHiSIey885-GrX2I4Noz49ELMrCp56Ln4l2Hx949qqom9Mtgr0LeFLTybSeNr7kPQxX0n-dwVagwnnZTzNz24/s1600/exp.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho5cdiRhAMCmJnQ-GNho_DwMf3FrBCAvLpC-dRERU6A0yGFNemu0SKLpNoZkAxEwR75qzaIkqv8HMOeJydolawgIcl9hVw9o6Fu9R4mQou2_Zm_ICTyO_JkWZxl_SrZ28EmDpQ3noLMMY/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho5cdiRhAMCmJnQ-GNho_DwMf3FrBCAvLpC-dRERU6A0yGFNemu0SKLpNoZkAxEwR75qzaIkqv8HMOeJydolawgIcl9hVw9o6Fu9R4mQou2_Zm_ICTyO_JkWZxl_SrZ28EmDpQ3noLMMY/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzMzMYO4dIQvdeTocXXfoF4odMGEx4nrm9e4-WfcvDZ3sj9s5J9SqbUwYBsewEctTypSHc4DPevKQD4vqmtMAWAenw860EaUrFrz-rezqZQpTkawtTBBh7VxPJqVOAb_Fwx1snCDDaDvg/s1600/10.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzMzMYO4dIQvdeTocXXfoF4odMGEx4nrm9e4-WfcvDZ3sj9s5J9SqbUwYBsewEctTypSHc4DPevKQD4vqmtMAWAenw860EaUrFrz-rezqZQpTkawtTBBh7VxPJqVOAb_Fwx1snCDDaDvg/s1600/10.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5g64yA6kkH2ctLBFmPSWFLGC6Yv0TNJQTcaTSpHJ99pjgU22yof-qpyZzcLX9Nz9JsVlBvNcN2NEh_kP6ZuprhsPKbrN9d_eWpJ_0uRw8xgzCy259LzQ9-35ueZOnQ7YmJgMkzUibX94/s1600/100.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5g64yA6kkH2ctLBFmPSWFLGC6Yv0TNJQTcaTSpHJ99pjgU22yof-qpyZzcLX9Nz9JsVlBvNcN2NEh_kP6ZuprhsPKbrN9d_eWpJ_0uRw8xgzCy259LzQ9-35ueZOnQ7YmJgMkzUibX94/s1600/100.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&amp;nbsp;Una vez que entendemos el algoritmo y logramos la interpretación correcta, agregar una nueva expresión es muy sencillo. Aca corte en 1000 porque ya se entiende la idea.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqHMjcdWmJCc8OBRjd2U3yOlBYPTxnsQko6eP-l0NjCi7llfTYzzTfB5LAZ13hLePD2vXEMEtMcZAsGA0CcTbuVXJ3RQn6u8Q_MOnwmjZczsF8tL3NYvbur4mQX_NdvFy51bzjA1e7sNc/s1600/1000.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqHMjcdWmJCc8OBRjd2U3yOlBYPTxnsQko6eP-l0NjCi7llfTYzzTfB5LAZ13hLePD2vXEMEtMcZAsGA0CcTbuVXJ3RQn6u8Q_MOnwmjZczsF8tL3NYvbur4mQX_NdvFy51bzjA1e7sNc/s1600/1000.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Veremos esto en práctica:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgajAeMnEg4af0ZiX_rnB-BicXwrzjnDDOEqRTuP31gBi4AGulfbAdNuC5Cr4sY1wvYXvuSq0mZNAWmcfZuchw8yZXpGa_2UlbfcalQqsyhP8PBcGuWc6vuL5SJiHh96m4cw39d_vECHK4/s1600/main.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgajAeMnEg4af0ZiX_rnB-BicXwrzjnDDOEqRTuP31gBi4AGulfbAdNuC5Cr4sY1wvYXvuSq0mZNAWmcfZuchw8yZXpGa_2UlbfcalQqsyhP8PBcGuWc6vuL5SJiHh96m4cw39d_vECHK4/s1600/main.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Consecuencias&lt;/span&gt;&lt;br /&gt;
Se puede destacar las siguientes ventajas:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Facilidad para cambiar la gramática, mediante herencia, dado que las diferentes reglas se representan con objetos.&lt;/li&gt;
&lt;li&gt;Facilidad para implementar la gramática, dado que las implementaciones de las clases nodo del árbol sintáctico son similares, pudiendo usarse para ello generadores automáticos de código.&lt;/li&gt;
&lt;li&gt;Facilidad para introducir nuevas formas de “interpretar” las expresiones en la gramática.&lt;/li&gt;
&lt;/ul&gt;Y las siguientes desventajas:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Limitación en el tipo de gramática: si no es simple, es casi imposible implementarlo.&lt;/li&gt;
&lt;li&gt;No es conveniente utilizarlo si la eficiencia es un punto clave.&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/4334335334140659679/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/4334335334140659679' title='3 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/4334335334140659679'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/4334335334140659679'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/interpreter.html' title='Interpreter'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh5.googleusercontent.com/DIXqZN-SX4-eHi5Xb3YDBkxVdLRBzYq3OH03hn9bA3b0patmRURUmhEMWoDNLXASE09cEzBEyql-AXMhKzHpDc6BCE5OxWIKF8oIcEcCod5Rz2Sd4ec=s72-c" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-4039554388739476548</id><published>2011-06-09T12:21:00.001-03:00</published><updated>2011-06-23T15:38:08.610-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Introduccion a Patrones"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones"/><title type='text'>Patrones de Diseño de GOF</title><content type='html'>Los patrones de diseño son una pieza fundamental en el desarrollo del software. En mi opinión un desarrollador senior debería conocerlos. No todos, pero si los más importantes. Al ser algo estándar, permiten hablar un lenguaje común entre un equipo de desarrollo; por ende, si un junior también los conoce puede ser muy beneficioso, ya que estaría hablando en el mismo lenguaje de una persona con más experiencia. Empecemos por explicar el concepto de un patrón:&lt;br /&gt;
&lt;br /&gt;
“Un patrón describe un problema el cual ocurre una y otra vez en nuestro ambiente, y además describen el núcleo de la solución a tal problema, en tal una manera que puedes usar esta solución millones de veces, sin hacer lo mismo dos veces.” [Alexander et al.].&lt;br /&gt;
Aunque Alexander se refería a patrones en ciudades y edificios, lo que dice también es válido para patrones de diseño orientados a objetos.&lt;br /&gt;
&lt;br /&gt;
Los patrones de diseño tratan los problemas del diseño de software que se repiten y que se presentan en situaciones particulares, con el fin de proponer soluciones a ellas. Son soluciones exitosas a problemas comunes.&lt;br /&gt;
&lt;br /&gt;
Estas soluciones han ido evolucionando a través del tiempo. Existen muchas formas de implementar patrones de diseño. Los detalles de las implementaciones se llaman estrategias.&lt;br /&gt;
En resumen, son soluciones simples y elegantes a problemas específicos del diseño de software orientado a objetos.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Un poco de Historia&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
En 1994 se publicó el libro &quot;Design Patterns: Elements of Reusable Object Oriented Software&quot; escrito por Erich Gamma, Richard Helm, Ralph Johnson y John Vlissides. Ellos recopilaron y documentaron 23 patrones de diseño aplicados usualmente por expertos diseñadores de software orientado a objetos. Ellos no fueron los únicos que inventaron los patrones, pero la idea de patrones de diseño comenzó a tomar fuerza luego de la publicación de dicho libro.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Que es gof.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Los  ahora famosos Gang of Four (GoF, que en español es la pandilla de los  cuatro) formada por Erich Gamma, Richard Helm, Ralph Johnson y John  Vlissides. Son los autores del famoso libro &quot;Design Patterns: Elements  of Reusable Object Oriented Software&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquí una breve reseña de los autores:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Erich  Gamma, informático suizo, es actualmente el director del centro  tecnológico OTI en Zúrich y lidera el desarrollo de la plataforma  Eclipse. Fue el creador de JUnit, junto a Kent Beck.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Richard  Helm trabaja actualmente con The Boston Consulting Group, donde se  desempeña como consultor de estrategias de IT aplicadas al mundo de los  negocios.&lt;br /&gt;
Su carrera abarca la investigación  de distintas tecnologías, desarrollo de productos, integración de  sistemas y consultoría de IT. Antes de incorporarse a BCG, Richard  trabajó en IBM: comenzó su carrera como científico investigador en &quot;IBM  Thomas J. Watson Research Center&quot; en Nueva York. Es una autoridad  internacional en arquitectura y diseño de software.&lt;br /&gt;
&lt;br /&gt;
Ralph  E. Johnson es profesor asociado en la Universidad de Illinois, en donde  tiene a su cargo el Departamento de Ciencias de la Computación.  Co-autor del famoso libro de Gof y pionero de la comunidad de Smalltalk,  lidera el UIUC patterns/Software Architecture Group. &lt;br /&gt;
&lt;br /&gt;
John  Vlissides (1961-2005) era ingeniero eléctrico y se desempeñaba como  consultor  de la Universidad de Standford.  Autor de muchos libros,  desde 1991 trabajó como investigador en el &quot;IBM T.J. Watson Research  Center&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Cuando utilizar los patrones de diseño.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Como analistas y programadores vamos desarrollando a diario nuestras habilidades para resolver problemas usuales que se presentan en el desarrollo del software. Por cada problema que se nos presenta pensamos distintas formas de resolverlo, incluyendo soluciones exitosas que ya hemos usado anteriormente en problemas similares. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Antes de comenzar nuestro diseño, deberíamos realizar un estudio meticuloso del problema en el que nos encontramos y explorarlo en busca de patrones que hayan sido utilizados previamente con éxito. Estos patrones nos ayudarán a que nuestro proyecto evolucione mucho más rápidamente.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Cuando no utilizarlos.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si hay una sensación que describa lo que puede sentir un desarrollador o diseñador después de conocer los patrones de diseño esa podría ser la euforia. Esta euforia viene producida por haber encontrado un mecanismo que convierte lo que era una labor artesana y tediosa, en un proceso sólido y basado en estándares, mundialmente conocido y con probado éxito.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Después de recién iniciarse en los patrones, probablemente el paso siguiente que tomará será emprender el rediseño de algunos proyectos aún vigentes y que intente aplicar todas las maravillosas técnicas que ha aprendido para que así estos proyectos se aprovechen de todos los beneficios inherentes al uso de patrones de diseño. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Esto termina en intentar que se aplique estos patrones en toda situación donde sea posible, aún en aquellas donde no deba aplicarse.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Donde utilizarlos.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
No es obligatorio utilizar los patrones siempre, sólo en el caso de tener el mismo problema o similar que soluciona el patrón, siempre teniendo en cuenta que en un caso particular puede no ser aplicable. Abusar o forzar el uso de los patrones es un error muy común.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Antes de abordar un proyecto con patrones se debe analizar minuciosamente qué patrones nos pueden ser útiles, cuáles son las relaciones entre los diferentes componentes de nuestro sistema, cómo podemos relacionar los patrones entre sí de modo que formen una estructura sólida, cuáles son los patrones que refleja nuestro dominio, etc. Esta tarea obviamente es mucho más compleja que el mero hecho de ponerse a codificar patrones &quot;porque sí&quot;.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Beneficios.&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Proporcionan elementos reusables en el diseño de sistemas software, lo que significa que es aplicable a diferentes problemas de diseño en distintas circunstancias. &lt;/li&gt;
&lt;li&gt;Efectividad comprobada en la resolución de problemas similares en ocasiones anteriores. &lt;/li&gt;
&lt;li&gt;Formalizan un vocabulario común entre diseñadores. &lt;/li&gt;
&lt;li&gt;Estandarizan el diseño, lo que beneficia notablemente a los desarrolladores. &lt;/li&gt;
&lt;li&gt;Facilitan el aprendizaje de las nuevas generaciones de diseñadores y desarrolladores utilizando conocimiento ya existente.&lt;/li&gt;
&lt;/ul&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Tipos de patrones.&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: white;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;Verán en casi todas las bibliogafrías que hay una clasificación de tipos de patrones. Los patrones tienen dos tipos de clasificaciones:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;1) Clasificación según su propósito&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;Creacionales: definen la mejor manera en que un objeto es instanciado. El objetivo de estos patrones es de abstraer el proceso de instanciación y ocultar los detalles de cómo los objetos son creados o inicializados.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;De Comportamiento: permiten definir la comunicación entre los objetos del sistema y el flujo de la información entre los mismos.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;Estructurales: permiten crear grupos de objetos para ayudarnos a realizar tareas complejas.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;2) Clasificación según alcance&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;De clase:  se basados en la herencia de clases.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;De objeto:  se basan en la utilización dinámica de objetos&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;table style=&quot;border-collapse: collapse; border: medium none; color: white;&quot;&gt;&lt;col width=&quot;79&quot;&gt;&lt;/col&gt;&lt;col width=&quot;71&quot;&gt;&lt;/col&gt;&lt;col width=&quot;163&quot;&gt;&lt;/col&gt;&lt;col width=&quot;94&quot;&gt;&lt;/col&gt;&lt;col width=&quot;184&quot;&gt;&lt;/col&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 0px;&quot;&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;br /&gt;
&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;br /&gt;
&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-top: 0pt; text-align: center;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;Propósito&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 0px;&quot;&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;De Creación&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;Estructural&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;De Comportamiento&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 0px;&quot;&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;Alcance&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;Clase&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Factory Method&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Adapter&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Interpreter&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 0px;&quot;&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Template Method&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 0px;&quot;&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;&quot;&gt;Objeto&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Abstract Factory&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Adapter&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Chain of Responsability&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 0px;&quot;&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Builder&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Bridge&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Command&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 0px;&quot;&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Prototype&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Composite&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Iterator&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 0px;&quot;&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Singleton&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Decorator&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Mediator&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 0px;&quot;&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Facade&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Memento&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 0px;&quot;&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Flyweight&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Observer&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 0px;&quot;&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Proxy&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;State&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 0px;&quot;&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Strategy&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 0px;&quot;&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 1px dotted rgb(170, 170, 170); padding: 0px 7px; vertical-align: top;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;Visitor&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: white; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Times New Roman; font-size: 12pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Por último...&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Cuando quise aprender a utilizar los patrones de diseño me encontré con una pobre documentación en la web: vagos ejemplos; lenguajes que no conocía, indioma inglés y casos mal explicados. Esto me llevo a escribir un manual de patrones de diseño que hoy en día se usa en un instituto educativo para dictar un curso sobre dichos patrones. Por esta razón, hoy he adaptado y modificado este libro para publicar dichos ejemplos en el blog.&lt;br /&gt;
Tengo que dejar algo bien en claro antes de abordar con&amp;nbsp; los patrones en sí. Daré ejemplos de cada uno de ellos, pero esto no quiere decir que es la única forma de hacerlo. Los patrones pueden adaptarse a nuestras necesidades: no lo tomen como algo rígido. Por ejemplo, si se necesita adaptar un poco un patrón para que me pueda ayudar en una solución, que así sea.</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/4039554388739476548/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/4039554388739476548' title='12 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/4039554388739476548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/4039554388739476548'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/05/patrones-de-diseno-de-gof.html' title='Patrones de Diseño de GOF'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-3143956295872157576</id><published>2011-06-07T19:55:00.002-03:00</published><updated>2011-06-09T23:04:42.317-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Command"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones de Comportamiento"/><title type='text'>Command</title><content type='html'>Encapsula un mensaje como un objeto. Especifica una forma simple de separar la ejecución de un comando, del entorno que generó dicho comando. Permite solicitar una operación a un objeto sin conocer el contenido ni el receptor real de la misma. Si bien estas definiciones parecen un tanto ambigüas, sería oportuno volver a leerlas luego de entender el ejemplo.&lt;br /&gt;
&lt;br /&gt;
Este patrón suele establecer en escenarios donde se necesite encapsular una petición dentro de un objeto, permitiendo parametrizar a los clientes con distintas peticiones, encolarlas, guardarlas en un registro de sucesos o implementar un mecanismo de deshacer/repetir.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Se debe usar cuando:&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Se necesiten colas o registros de mensajes.&lt;/li&gt;
&lt;li&gt;Se deba tener la posibilidad de deshacer las operaciones realizadas.  &lt;/li&gt;
&lt;li&gt;Se necesite uniformidad al invocar las acciones.&lt;/li&gt;
&lt;li&gt;Se quiera facilitar la parametrización de las acciones a realizar.&lt;/li&gt;
&lt;li&gt;Se quiera independizar el momento de petición del de ejecución.&lt;/li&gt;
&lt;li&gt;El parámetro de una orden puede ser otra orden a ejecutar. &lt;/li&gt;
&lt;li&gt;Se busque desarrollar sistemas utilizando órdenes de alto nivel que se construyen con operaciones sencillas (primitivas).&lt;/li&gt;
&lt;li&gt;Se necesite sencillez al extender el sistema con nuevas acciones.&lt;/li&gt;
&lt;/ul&gt;Lo que permite el patrón Command es desacoplar al objeto que invoca a  una operación de aquél que tiene el conocimiento necesario para  realizarla. Esto nos otorga muchísima flexibilidad: podemos hacer, por  ejemplo, que una aplicación ejecute tanto un elemento de menú como un  botón para hacer una determinada acción.  Además,  podemos cambiar  dinámicamente los objetos Command.  &lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Diagrama UML&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;img id=&quot;internal-source-marker_0.9968147360439709&quot; src=&quot;https://lh5.googleusercontent.com/OtjRGQJFs3QBzZezUyeLkahieSmS9dMHiCw_oJw5OfMzI3ylL3VOiYK3L39F8Qcr6gBLywbq4rCZIOJ3YrFca8S4NXHjHEFAzLxyxM_gsIctR8zbm9s&quot; /&gt;&lt;br /&gt;
&lt;u&gt;Command&lt;/u&gt;: declara una interfaz para ejecutar una operación.&lt;br /&gt;
&lt;u&gt;CommandConcreto&lt;/u&gt;: define un enlace entre un objeto “Receiver” y una acción. Implementa el método execute  invocando la(s) correspondiente(s) operación(es) del “Receiver”.&lt;br /&gt;
&lt;u&gt;Cliente&lt;/u&gt;: crea un objeto “CommandConcreto” y establece su receptor.&lt;br /&gt;
&lt;u&gt;Invoker&lt;/u&gt;: le pide a la orden que ejecute la petición.&lt;br /&gt;
&lt;u&gt;Receiver&lt;/u&gt;: sabe como llevar a cabo las operaciones asociadas a una petición. Cualquier clase puede hacer actuar como receptor.&lt;br /&gt;
&lt;br /&gt;
El cliente crea un objeto “CommandConcreto” y especifica su receptor. Un objeto “Invoker” almacena el objeto “CommandConcreto”. El invocador envía una petición llamando al método execute sobre la orden.&lt;br /&gt;
El objeto “CommandConcreto”, invoca operaciones de su receptor     para llevar a cabo la petición.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ejemplo&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC9GiN8OY7V-cpIE_tEdUJkY2l0C3hkkbxl_A0YpOpLjPqA49e_O1aijJYgdBfxDMYsx1A64M2yp9nSTGVJ3Uhwwd2iLz-0YgYHtm79LMPfVCE1yF2-uhcdO7_uMbfOwdRenXHcP9k0ZU/s1600/iserver.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Escenario:  una empresa maneja varios servidores y cada uno  de ellos deben correr diversos procesos, como apagarse, prenderse, etc.  Cada uno de estos procesos, a su vez, implican pequeños pasos como, por  ejemplo, realizar una conexión a dicho servidor, guardar los datos en un  log, etc.&lt;br /&gt;
Dado que cada servidor tiene su propia lógica para cada  operación, se decidió crear una interfaz llamada IServer que deben  implementar los servidores:&lt;br /&gt;
&lt;span id=&quot;goog_1368801188&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_1368801189&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC9GiN8OY7V-cpIE_tEdUJkY2l0C3hkkbxl_A0YpOpLjPqA49e_O1aijJYgdBfxDMYsx1A64M2yp9nSTGVJ3Uhwwd2iLz-0YgYHtm79LMPfVCE1yF2-uhcdO7_uMbfOwdRenXHcP9k0ZU/s1600/iserver.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC9GiN8OY7V-cpIE_tEdUJkY2l0C3hkkbxl_A0YpOpLjPqA49e_O1aijJYgdBfxDMYsx1A64M2yp9nSTGVJ3Uhwwd2iLz-0YgYHtm79LMPfVCE1yF2-uhcdO7_uMbfOwdRenXHcP9k0ZU/s1600/iserver.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVSVx3y7-ZQZ4ZNI4-mC5E3UF74pb7b690CyQ651kYO77-hItmGBrjjxwKLyj3Rv0vJIkK728BWjrVQcmFhuA0zae8i7WZtwAssX34NuR8EJFIQCLa5aezSf9TDksMQUaBEHC_MSkdRE0/s1600/argserver.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVSVx3y7-ZQZ4ZNI4-mC5E3UF74pb7b690CyQ651kYO77-hItmGBrjjxwKLyj3Rv0vJIkK728BWjrVQcmFhuA0zae8i7WZtwAssX34NuR8EJFIQCLa5aezSf9TDksMQUaBEHC_MSkdRE0/s1600/argserver.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggpxUBIBcrRLvuQnAiO74ccR_7awjZNOysWqB-6T1PuDx5-lG0j1KaRT8sH0zJs7DWqQ7jKJSkPjuXjBdR980BAjsLRpb5hOgG-UegjbHPHsH40ZAbJN2gMHYwttiD8CWtdN-sp0u_db0/s1600/brasilser.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggpxUBIBcrRLvuQnAiO74ccR_7awjZNOysWqB-6T1PuDx5-lG0j1KaRT8sH0zJs7DWqQ7jKJSkPjuXjBdR980BAjsLRpb5hOgG-UegjbHPHsH40ZAbJN2gMHYwttiD8CWtdN-sp0u_db0/s1600/brasilser.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtqR33SykvbsJEi39vAsJU7qpWgB7IaZnMo3JwYNQhjXTm7f3NXw4meC-l-cfsiaYTn1R1YKIyObP7EMh2qlOZu5TVdmnZ6QjXKM6gMBu85kSFWzB8qLYn5BnEv_TsaXX3U2SDVaha6BA/s1600/usa+server.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtqR33SykvbsJEi39vAsJU7qpWgB7IaZnMo3JwYNQhjXTm7f3NXw4meC-l-cfsiaYTn1R1YKIyObP7EMh2qlOZu5TVdmnZ6QjXKM6gMBu85kSFWzB8qLYn5BnEv_TsaXX3U2SDVaha6BA/s1600/usa+server.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Obviamente en un caso real los métodos tendrían el algoritmo necesario para realizar tales operaciones. Hemos simplificado estos algoritmos y en su lugar realizamos una salida por consola en cada método.&lt;br /&gt;
Hasta aquí nada nuevo, sólo clases que implementan una interfaz y le dan inteligencia al método. Comenzaremos con el Command:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrMrZmkVvu7OFNfCeQVySHl0nTR2NurqHBi3w_CmFRI_KXGd24nFfcc2pnUlrUooos2U2wZg2icN6g6h_ZlYGUi93_TOdYvmGocPvA3wcXWCZmzSMTvaXS405NIf5Nik8Rw0bKoaiN3OY/s1600/command.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrMrZmkVvu7OFNfCeQVySHl0nTR2NurqHBi3w_CmFRI_KXGd24nFfcc2pnUlrUooos2U2wZg2icN6g6h_ZlYGUi93_TOdYvmGocPvA3wcXWCZmzSMTvaXS405NIf5Nik8Rw0bKoaiN3OY/s1600/command.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxtiXoyVZja5gjk76HAcyjOPYhItUrAip_i74Muh_QsAkf9WxFiEWUsY6EC9HuOWl70gUjqaHyY_kcy7rnWVfPI0NpQ6s1PhRhVn2MVWjiDjvxMCK4UOZChzsQFjiKqx4aDix1rJLzToc/s1600/apagar.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxtiXoyVZja5gjk76HAcyjOPYhItUrAip_i74Muh_QsAkf9WxFiEWUsY6EC9HuOWl70gUjqaHyY_kcy7rnWVfPI0NpQ6s1PhRhVn2MVWjiDjvxMCK4UOZChzsQFjiKqx4aDix1rJLzToc/s1600/apagar.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkMK9YBRdF41ICrLjiXyuYEpP1TkUmg3fwJmdiU7BZa1dc69Wd05hUWiVAMMSUDHamVQbGh53b3-IpAMmj2Gdp28zSRNtUoS1Iz_Xst_0Z0q2QJVc_LaLvJeUAtUgfdGzCDXOAl03FuSI/s1600/prende.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkMK9YBRdF41ICrLjiXyuYEpP1TkUmg3fwJmdiU7BZa1dc69Wd05hUWiVAMMSUDHamVQbGh53b3-IpAMmj2Gdp28zSRNtUoS1Iz_Xst_0Z0q2QJVc_LaLvJeUAtUgfdGzCDXOAl03FuSI/s1600/prende.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3MGoPqJRgrYYBDczLLp6X4IqKZ8UHUREvHuMasCtvhzuHHQ_DFGWW4mYPozZv9UW0c-z7i_DMN0Eob5dltKRZUeMAKaudpFgf3YwQibBE81FaBiCWTsG382uzEFDwhFYxrok9hjspVKc/s1600/reset.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3MGoPqJRgrYYBDczLLp6X4IqKZ8UHUREvHuMasCtvhzuHHQ_DFGWW4mYPozZv9UW0c-z7i_DMN0Eob5dltKRZUeMAKaudpFgf3YwQibBE81FaBiCWTsG382uzEFDwhFYxrok9hjspVKc/s1600/reset.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHHXKDF8dY_gIniZpE014Jy2LbLeTm2lhOA1H623TfgRqipoaziJd5iPUc2VJunU-ps47vzCNYq4m8I2BarI-hj01Y1rbtOhO9KF-Kb3V1lDqBRE0qrBTMZNliQ2OfdGwFo2vuWPX1LG0/s1600/invoker.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;
&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Ahora realizaremos un invocador, es decir, una clase que simplemente llame al método execute:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHHXKDF8dY_gIniZpE014Jy2LbLeTm2lhOA1H623TfgRqipoaziJd5iPUc2VJunU-ps47vzCNYq4m8I2BarI-hj01Y1rbtOhO9KF-Kb3V1lDqBRE0qrBTMZNliQ2OfdGwFo2vuWPX1LG0/s1600/invoker.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHHXKDF8dY_gIniZpE014Jy2LbLeTm2lhOA1H623TfgRqipoaziJd5iPUc2VJunU-ps47vzCNYq4m8I2BarI-hj01Y1rbtOhO9KF-Kb3V1lDqBRE0qrBTMZNliQ2OfdGwFo2vuWPX1LG0/s1600/invoker.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
Veamos como funciona el ejemplo:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtS_cQezf2QcPBmoaPlLmPXY1AEWJD0X4Zw7MGDPzk0hXqK6PMC9br3wsjHHrmT_gcc5IONIEIXYD8_UIRRtFCoXQGz3BRRnJum2F3QVplPI1Sdz7vAhPl7vUuaVuI18sSp2u_NGcnBR8/s1600/main.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtS_cQezf2QcPBmoaPlLmPXY1AEWJD0X4Zw7MGDPzk0hXqK6PMC9br3wsjHHrmT_gcc5IONIEIXYD8_UIRRtFCoXQGz3BRRnJum2F3QVplPI1Sdz7vAhPl7vUuaVuI18sSp2u_NGcnBR8/s1600/main.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Consecuencias&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Command desacoplado: el objeto que invoca la operación de aquél que sabe como realizarla.&lt;/li&gt;
&lt;li&gt;Las órdenes son objetos manipulados y extendidos de forma natural.&lt;/li&gt;
&lt;li&gt;Se pueden ensamblar órdenes en una orden compuesta.&lt;/li&gt;
&lt;li&gt;Facilidad de adición de nuevos objetos Command. &lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/3143956295872157576/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/3143956295872157576' title='3 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/3143956295872157576'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/3143956295872157576'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/command.html' title='Command'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh5.googleusercontent.com/OtjRGQJFs3QBzZezUyeLkahieSmS9dMHiCw_oJw5OfMzI3ylL3VOiYK3L39F8Qcr6gBLywbq4rCZIOJ3YrFca8S4NXHjHEFAzLxyxM_gsIctR8zbm9s=s72-c" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2038455272007745877.post-8398346360142999774</id><published>2011-06-05T11:33:00.001-03:00</published><updated>2011-06-06T21:25:01.735-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Chain of Responsibility"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones"/><category scheme="http://www.blogger.com/atom/ns#" term="Patrones de Comportamiento"/><title type='text'>Chain of Responsibility</title><content type='html'>Permite establecer una cadena de objetos receptores a través de los cuales se pasa una petición formulada por un objeto emisor. La idea es que cualquiera de los receptores pueden responder a la petición en función de un criterio establecido. Encadena los objetos receptores y pasa la petición a través de la cadena hasta que es procesada por algún objeto. &lt;br /&gt;
Busca evitar un montón de  if – else largos y complejos en nuestro código, pero sobre todas las cosas busca evitar que el cliente necesite conocer toda nuestra estructura jeráquica y que rol cumple cada integrante de nuestra estructura.&lt;br /&gt;
En múltiples ocasiones, un cliente necesita que se realice una función, pero o no conoce al servidor concreto de esa función o es conveniente que no lo conozca para evitar un gran acoplamiento entre ambos.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Se utiliza cuando:&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Las peticiones emitidas por un objeto deben ser atendidas por distintos objetos receptores.&lt;/li&gt;
&lt;li&gt;No se sabe a priori cual es el objeto que me puede resolver el problema.&lt;/li&gt;
&lt;li&gt;Cuando un pedido debe ser manejado por varios objetos.&lt;/li&gt;
&lt;li&gt;El conjunto de objetos que pueden tratar una petición debería ser especificado dinámicamente.&lt;/li&gt;
&lt;/ul&gt;La motivación detrás de este patrón es crear un sistema que pueda servir  a diversas solicitudes de manera jerárquica.  En otras palabras, si un  objeto que es parte de un sistema no sabe cómo responder a una  solicitud, la pasa a lo largo del árbol de objetos. Como el nombre lo  implica, cada objeto de dicho árbol puede tomar la responsabilidad y  atender la solicitud.&lt;br /&gt;
Un ejemplo típico podría ser el lanzar un  trabajo de impresión. El cliente no sabe siquiera qué impresoras están  instaladas en el sistema, símplemente lanza el trabajo a la cadena de  objetos que representan a las impresoras. Cada uno de ellos lo deja  pasar, hasta que alguno, finalmente lo ejecuta.&lt;br /&gt;
Hay un desacoplamiento evidente entre el objeto que lanza el trabajo (el cliente) y el que lo realiza (impresora). &lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Diagrama UML&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;img src=&quot;https://lh6.googleusercontent.com/-3NnctckTzla7TA0IA8Be-AbBu0GJLNWMAyNV8DTowXkvpIxOtGh7vp2DXuYvgzVY0Xg1HE_e-R23dmur2jU0OADeQGrc48oI4xHxlCuJlFrfxvll1M&quot; /&gt;&lt;br /&gt;
&lt;u&gt;Handler&lt;/u&gt;:  define una interfaz para tratar las peticiones. Implementa el enlace al sucesor.&lt;br /&gt;
&lt;u&gt;HandlerConcreto&lt;/u&gt;: trata las peticiones de las que es responsable. Si puede manejar la petición, lo hace, en caso contrario la reenvía a su sucesor.&lt;br /&gt;
&lt;u&gt;Cliente&lt;/u&gt;: inicializa la petición. Conoce a un gestor que es el que lanza la petición a la cadena hasta que&lt;br /&gt;
alguien la recoge.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ejemplo&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Escenario: estamos realizando el software para un banco y uno  de los puntos más importantes es saber quién puede aprobar un crédito.  Por lo tanto el banco define las siguientes reglas de negocio:&lt;br /&gt;
&lt;br /&gt;
Si el monto no supera los $ 10.000 entonces el ejecutivo de cuenta pueda aprobar el préstamo.&lt;br /&gt;
Si  el monto esta entre los $10.000 y $50.000 entonces la persona indicada  para realizar la aprobación es el líder inmediato de dicho ejecutivo. &lt;br /&gt;
Si el monto se encuentra entre $ 50.000 y $100.000 entonces es el Gerente quién debe realizar dicha aprobación.&lt;br /&gt;
Por montos superiores a los $100.000 entonces la aprobación la realizará el Director.&lt;br /&gt;
&lt;br /&gt;
Para  este caso se ha decidido realizar un patrón Chain of Responsibility. Se  decide crear una interface llamada IAprobador que debe implementar toda  clase que pertenezca a nuestra cadena de responsabilidades.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUgdI4Ht_vKitjjTtl-UBlcix3_22rl3QmkdbnHemnHI5gBFhRnLEDJ5r7G9A1dHlxceLp5-EnrtHRofCjmA23tJQryqcfCoFpTvpQb4bKKLqWKda6NDiRuFlBQvPQyjnfnPyHZTnZFYw/s1600/iap.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUgdI4Ht_vKitjjTtl-UBlcix3_22rl3QmkdbnHemnHI5gBFhRnLEDJ5r7G9A1dHlxceLp5-EnrtHRofCjmA23tJQryqcfCoFpTvpQb4bKKLqWKda6NDiRuFlBQvPQyjnfnPyHZTnZFYw/s1600/iap.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhngAgGAq8Zc9tEvwk4DpeTqbFL_sH0OOmvTPZUWh2amWWtRHrSLELJtzwhKSfXh7O4iUDow9XKLlZOCky0ygiIdqbqoxti8sYozeYWefMIK7wB3JHY71nwsW3guVyvWlxeRrIOsAR2yss/s1600/ejecutivo.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhngAgGAq8Zc9tEvwk4DpeTqbFL_sH0OOmvTPZUWh2amWWtRHrSLELJtzwhKSfXh7O4iUDow9XKLlZOCky0ygiIdqbqoxti8sYozeYWefMIK7wB3JHY71nwsW3guVyvWlxeRrIOsAR2yss/s1600/ejecutivo.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAhgcZbiNCDgRmIvNF8L-pbYP_ADApcIR9tNpTAoVauQ7iVR6VUakmjLaynSt5qopyZ4SsAhnBGXUh9t0uRXnx4hO-wzAbE71OQUmcBMGUdrBoir1IoIt8_xzhH-TIfBx-rgu-lvtbfjI/s1600/lider.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAhgcZbiNCDgRmIvNF8L-pbYP_ADApcIR9tNpTAoVauQ7iVR6VUakmjLaynSt5qopyZ4SsAhnBGXUh9t0uRXnx4hO-wzAbE71OQUmcBMGUdrBoir1IoIt8_xzhH-TIfBx-rgu-lvtbfjI/s1600/lider.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh84vczZCTKcxPbiyHcmB4aWdfpTF6q3OgawRgj3vGSvXb8o3SQXGQYVE6TWcFbNzWBq4cw-zcxBRGqcgPq8YTaptFitzBsHq7B7rO3dNrRsxYQJGDoO91GiVjNmEeRY3LqAQLVBfYm5OA/s1600/gerente.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh84vczZCTKcxPbiyHcmB4aWdfpTF6q3OgawRgj3vGSvXb8o3SQXGQYVE6TWcFbNzWBq4cw-zcxBRGqcgPq8YTaptFitzBsHq7B7rO3dNrRsxYQJGDoO91GiVjNmEeRY3LqAQLVBfYm5OA/s1600/gerente.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA7LbfKPmDoNMcd97PEK3FAgScbHl_cIyNBeDlrtwmH-7Zy-6XA_2w1YxfYpCNnbRxnQXwsI-NMuO2Pur3e3YQYN8yasqG5KkRvfefcn9piUnG5C8buLvYc4XXvqq0HbT4rfZHCVzMl14/s1600/director.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA7LbfKPmDoNMcd97PEK3FAgScbHl_cIyNBeDlrtwmH-7Zy-6XA_2w1YxfYpCNnbRxnQXwsI-NMuO2Pur3e3YQYN8yasqG5KkRvfefcn9piUnG5C8buLvYc4XXvqq0HbT4rfZHCVzMl14/s1600/director.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;En nuestro caso será el banco quién organice la cadena, pero seguramente en la práctica utilizaremos un factory. Para el cliente el banco será suu punto de entrada.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiee8YCDAZYoJu3UCRldIPD0H0I0vkBkl5Jr9BYo5_Zf_uhnNzr51ZHgbAO5P82D6RpCvoQ2wCJMkIG3lpuH3w0ATNgaorFx1HtgNj-nfmuOoYQzRbEJLZJ243D2WCtyaE96xp1Kvaf3v4/s1600/bco.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiee8YCDAZYoJu3UCRldIPD0H0I0vkBkl5Jr9BYo5_Zf_uhnNzr51ZHgbAO5P82D6RpCvoQ2wCJMkIG3lpuH3w0ATNgaorFx1HtgNj-nfmuOoYQzRbEJLZJ243D2WCtyaE96xp1Kvaf3v4/s1600/bco.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Y, desde el punto de vista del cliente, verán que es muy sencillo:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwwNWBSufM6MJ2PtAu0LfoZtB97e72Evh4puBpXPh5QjUyUBsROHBlfLgBV-MqRd-_ZqUxU-QLhJPHOw9P-PDjAaYUgQuo0sl1_zQns0mALbO8i-OCnL-4GEL58QlQ_J2drwOl70hZYW8/s1600/main.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwwNWBSufM6MJ2PtAu0LfoZtB97e72Evh4puBpXPh5QjUyUBsROHBlfLgBV-MqRd-_ZqUxU-QLhJPHOw9P-PDjAaYUgQuo0sl1_zQns0mALbO8i-OCnL-4GEL58QlQ_J2drwOl70hZYW8/s1600/main.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Consecuencias&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Reduce el acoplamiento.&lt;/li&gt;
&lt;li&gt;Añade flexibilidad para asignar responsabilidades a objetos.&lt;/li&gt;
&lt;li&gt;No se garantiza la recepción.&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://migranitodejava.blogspot.com/feeds/8398346360142999774/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2038455272007745877/8398346360142999774' title='3 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/8398346360142999774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2038455272007745877/posts/default/8398346360142999774'/><link rel='alternate' type='text/html' href='http://migranitodejava.blogspot.com/2011/06/chain-of-responsibility.html' title='Chain of Responsibility'/><author><name>Max</name><uri>http://www.blogger.com/profile/06484998986695505357</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh6.googleusercontent.com/-3NnctckTzla7TA0IA8Be-AbBu0GJLNWMAyNV8DTowXkvpIxOtGh7vp2DXuYvgzVY0Xg1HE_e-R23dmur2jU0OADeQGrc48oI4xHxlCuJlFrfxvll1M=s72-c" height="72" width="72"/><thr:total>3</thr:total></entry></feed>