<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">

<channel>
<title>Narciso Cerezo: Java</title>
<link>http://narcisocerezo.zoomblog.com/</link>
<description>Blog personal de Narciso Cerezo.
Relexiones sobre tecnolog&#237;a y el dif&#237;cil cami</description>
<dc:language>es</dc:language>
<dc:date>2007-04-19T12:56:00+01:00</dc:date>
<lastBuildDate>Sat, 05 Jul 2008 10:33:46 GMT</lastBuildDate>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
<image>
<title>ZoomBlog</title>
<url>http://narcisocerezo.zoomblog.com/photo.jpg</url><link>http://www.zoomblog.com/</link>
</image>

<item>
 <title>Sneak preview: desarrollo de aplicaciones m&#243;viles con BaseMovil</title>
<link>http://narcisocerezo.zoomblog.com/archivo/2007/04/19/sneak-preview-desarrollo-de-aplicacion.html</link>
 <guid isPermaLink="true">http://narcisocerezo.zoomblog.com/archivo/2007/04/19/sneak-preview-desarrollo-de-aplicacion.html</guid>
 <description>
 <![CDATA[
Este seguramente ser&#225; el primero de una serie en la que quiero ir profundizando en c&#243;mo se pueden hacer aplicaciones m&#243;viles, realmente r&#225;pido, con BaseMovil.<br />Todav&#237;a no est&#225; abierto, de ah&#237; lo de "sneak preview", pero lo estar&#225; dentro de poco. De hecho habr&#225; dos fases: una primera para los "betatesters" que podr&#225;n empezar a trastear y hacer sus aplicaciones, y una segunda en la que se abrir&#225; a cualquiera que quiera hacer aplicaciones con nuestros sistema e infraestructura.<br />Hoy voy a hablar simplemente de la creaci&#243;n de la interfaz de usuario.<br />El desarrollo es puramente conceptual, desapegado de la implementaci&#243;n final de la que se encarga el generador de vistas. De esta forma el c&#243;digo que hay que hacer est&#225; exclusivamente en el controlador y el modelo, ya que las vistas son s&#243;lo una definici&#243;n v&#237;a XML.<br /><br />El caso quiz&#225;s m&#225;s simple es un men&#250;, implementado como una lista de selecci&#243;n, y al que se le pueden poner iconos a la izquierda de cada opci&#243;n.<br />Cada opci&#243;n del men&#250; lleva asociado un c&#243;digo num&#233;rico que es el que permite al controlador saber que opci&#243;n ha seleccionado el usuario.<br />Para crear un men&#250; basta con definir la vista de esta forma:<br /><br /> 
<div style="text-align: left; background-color: rgb(240, 240, 240);"><span style="font-weight: bold;">&lt;</span><span style="color: rgb(0, 0, 102); font-weight: bold;">menu</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">id</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"100"</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">name</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"mainMenu"</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">title</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"mainMenu.Title" </span><span style="font-weight: bold;">&gt;</span><br style="font-weight: bold;" /><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: rgb(0, 0, 102); font-weight: bold;">menuItem</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">title</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"mainMenu.Customers" </span><span style="font-weight: bold;"><span style="color: rgb(51, 51, 255); font-weight: bold;">action</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"100"</span><span style="font-weight: bold;">/&gt;</span><br style="font-weight: bold;" /><span style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: rgb(0, 0, 102); font-weight: bold;">menuItem</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">title</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"mainMenu.Options" </span><span style="font-weight: bold;"><span style="color: rgb(51, 51, 255); font-weight: bold;">action</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"101"</span><span style="font-weight: bold;">/&gt;</span><br style="font-weight: bold;" /><span style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: rgb(0, 0, 102); font-weight: bold;">menuItem</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">title</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"mainMenu.Exit" </span><span style="font-weight: bold;"><span style="color: rgb(51, 51, 255); font-weight: bold;">action</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"102"</span><span style="font-weight: bold;">/&gt;</span><br style="font-weight: bold;" /><span style="font-weight: bold;"><span style="font-weight: bold;"><span style="font-weight: bold;">&lt;/</span><span style="color: rgb(0, 0, 102); font-weight: bold;">menu</span><span style="font-weight: bold;">&gt;</span><br /></span></span></span></span></span></span></span></div><br />Para mostrar el men&#250; necesitar&#237;amos hacer esto desde el controlador:<br /><br /> 
<div style="text-align: left; background-color: rgb(240, 240, 240);"><span style="color: rgb(0, 0, 102); font-weight: bold;">final</span> MenuView view = ViewFactory.getMenu( <span style="color: rgb(0, 153, 0);">"mainMenu"</span> );<br />view.show();<br /></div><br />Y nos mostrar&#237;a un men&#250; de selecci&#243;n simple, con tres opciones.<br />Los campos title pueden ser un texto concreto, pero en este caso son una referencia a un recurso, de forma que el texto concreto depender&#225; del idioma seleccionado.<br /><br />Otro caso t&#237;pico es querer hacer un listado de una consulta (del motor de datos hablar&#233; en el siguiente post de la serie). Digamos que queremos listar los clientes cuyo nombre contiene "bar".<br />Para definir el listado que mostrar&#225; el resultado s&#243;lo tenemos que definir la vista mediante el siguiente fragmento de XML (ya haremos un editor gr&#225;fico para los m&#225;s vagos):<br /><br /> 
<div style="text-align: left; background-color: rgb(240, 240, 240);"><span style="font-weight: bold;">&lt;</span><span style="color: rgb(0, 0, 102); font-weight: bold;">listBrowser</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">id</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"110"</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">name</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"customerList"</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">title</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"customerList.Title" </span><span style="color: rgb(51, 51, 255); font-weight: bold;">pageSize</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"20"</span><span style="font-weight: bold;">&gt;</span><br style="font-weight: bold;" /><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: rgb(0, 0, 102); font-weight: bold;">field</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">name</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"cust_name" </span><span style="font-weight: bold;">/&gt;</span><br style="font-weight: bold;" /><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: rgb(0, 0, 102); font-weight: bold;">field</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">name</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"phone"</span><span style="font-weight: bold;"> /&gt;</span><br style="font-weight: bold;" /><span style="font-weight: bold;">&lt;/</span><span style="color: rgb(0, 0, 102); font-weight: bold;">listBrowser</span><span style="font-weight: bold;">&gt;</span><br /></div><br />Y para mostrarlo har&#237;a falta un pedazo de c&#243;digo Java similar a esto:<br /><br /> 
<div style="text-align: left; background-color: rgb(240, 240, 240);"><span style="color: rgb(0, 0, 102); font-weight: bold;">final</span> RowSet result = CustomerModel.findCustomersByName( <span style="color: rgb(0, 153, 0); font-weight: bold;">"bar"</span> );<br /><span style="color: rgb(0, 0, 102); font-weight: bold;">final</span> ListBrowserView view = ViewFactory.getListBrowser( <span style="color: rgb(0, 153, 0); font-weight: bold;">"customerList"</span> );<br />view.bind( result );<br />view.show();<br /></div><br />Con eso ya nos mostrar&#237;a una pantalla de listado con los campos especificados, con paginaci&#243;n cada 20 elementos.<br />Si decidimos mostrar adem&#225;s del nombre y el tel&#233;fono la direcci&#243;n ser&#237;a tan sencillo como variar la definici&#243;n por esto:<br /><br /> 
<div style="text-align: left; background-color: rgb(240, 240, 240);"><span style="font-weight: bold;">&lt;</span><span style="color: rgb(0, 0, 102); font-weight: bold;">listBrowser</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">id</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"110"</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">name</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"customerList"</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">title</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"customerList.Title" </span><span style="color: rgb(51, 51, 255); font-weight: bold;">pageSize</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"20"</span><span style="font-weight: bold;">&gt;</span><br style="font-weight: bold;" /><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: rgb(0, 0, 102); font-weight: bold;">field</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">name</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"cust_name" </span><span style="font-weight: bold;">/&gt;</span><br style="font-weight: bold;" /><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: rgb(0, 0, 102); font-weight: bold;">field</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">name</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"address"</span><span style="font-weight: bold;"> /&gt;</span><br style="font-weight: bold;" /><span style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: rgb(0, 0, 102); font-weight: bold;">field</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">name</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"phone"</span><span style="font-weight: bold;"> /&gt;</span><br style="font-weight: bold;" /><span style="font-weight: bold;">&lt;/</span><span style="color: rgb(0, 0, 102); font-weight: bold;">listBrowser</span><span style="font-weight: bold;">&gt;</span><br /></span></div><br />Y aunque los listados est&#225;n muy bien como ejemplo de "data binding" sencillo, tambi&#233;n se puede hacer un data binding m&#225;s complejo con los formularios.<br />Una vez que hemos seleccionado el cliente queremos poder editar algunos datos de su ficha, y para eso nada mejor que un formulario de datos:<br /><br /> 
<div style="text-align: left; background-color: rgb(240, 240, 240);"><span style="font-weight: bold;">&lt;</span><span style="color: rgb(0, 0, 102); font-weight: bold;">form</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">id</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"120"</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">name</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"customerEditor"</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">title</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"customerEditor.Title"</span><span style="color: rgb(51, 51, 255); font-weight: bold;"><span style="color: rgb(0, 153, 0); font-weight: bold;"><span style="font-weight: bold; color: rgb(0, 0, 0);">&gt;</span><br style="font-weight: bold;" /><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">&lt;</span></span><span style="color: rgb(0, 0, 102); font-weight: bold;">text</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">name</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"name" <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  </span><span style="font-weight: bold;"><span style="color: rgb(51, 51, 255); font-weight: bold;">label</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"customer.CommercialName"</span><br /><span style="color: rgb(0, 153, 0); font-weight: bold;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  </span><span style="font-weight: bold;"><span style="color: rgb(51, 51, 255); font-weight: bold;">bind</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"cust_name"</span><br /><span style="color: rgb(0, 153, 0); font-weight: bold;">&nbsp;&nbsp;&nbsp; </span><span style="font-weight: bold; color: rgb(0, 0, 0);">/&gt;</span><br style="font-weight: bold;" /><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">&lt;</span></span><span style="color: rgb(0, 0, 102); font-weight: bold;">text</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">name</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"fiscalName" <br /> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  </span><span style="font-weight: bold;"><span style="color: rgb(51, 51, 255); font-weight: bold;">label</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"customer.FiscalName"</span><br /><span style="color: rgb(0, 153, 0); font-weight: bold;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  </span><span style="font-weight: bold;"><span style="color: rgb(51, 51, 255); font-weight: bold;">bind</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"company_name"</span><br /><span style="color: rgb(0, 153, 0); font-weight: bold;"><span style="color: rgb(0, 153, 0); font-weight: bold;">&nbsp;&nbsp;&nbsp; </span><span style="font-weight: bold; color: rgb(0, 0, 0);">/&gt;</span><br style="font-weight: bold;" /><span style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">&lt;</span></span><span style="color: rgb(0, 0, 102); font-weight: bold;">integer</span><span style="font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-weight: bold;">name</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"code" <br /> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  </span><span style="font-weight: bold;"><span style="color: rgb(51, 51, 255); font-weight: bold;">label</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"customer.CustomerCode"</span><br /><span style="color: rgb(0, 153, 0); font-weight: bold;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  </span><span style="font-weight: bold;"><span style="color: rgb(51, 51, 255); font-weight: bold;">bind</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"custom_id"</span><br /><span style="color: rgb(0, 153, 0); font-weight: bold;"><span style="color: rgb(0, 153, 0); font-weight: bold;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  </span><span style="font-weight: bold;"><span style="color: rgb(51, 51, 255); font-weight: bold;">readOnly</span><span style="font-weight: bold;">=</span><span style="color: rgb(0, 153, 0); font-weight: bold;">"true"</span><br /><span style="color: rgb(0, 153, 0); font-weight: bold;">&nbsp;&nbsp;&nbsp; </span><span style="font-weight: bold; color: rgb(0, 0, 0);">/&gt;</span><br style="font-weight: bold;" /><span style="font-weight: bold;"><span style="font-weight: bold;"><span style="font-weight: bold; color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 102); font-weight: bold;">form</span><span style="font-weight: bold; color: rgb(0, 0, 0);">&gt;</span><br /></span></span></span></span></span></span></span></span></span></span></span></span></span></span></div><br />Para mostrar el formulario, podr&#237;amos hacer algo similar a esto:<br /><br /> 
<div style="text-align: left; background-color: rgb(240, 240, 240);"><span style="color: rgb(0, 0, 102); font-weight: bold;"><span style="color: rgb(0, 0, 102); font-weight: bold;">final</span> </span><span style="color: rgb(0, 0, 0);">ListBrowserView listView = ViewFactory.getListBrowser(</span><span style="color: rgb(0, 0, 102); font-weight: bold;"> <span style="color: rgb(0, 153, 0); font-weight: bold;">"customerList"</span> </span><span style="color: rgb(0, 0, 0);">);</span><span style="color: rgb(0, 0, 102); font-weight: bold;"><br /><span style="color: rgb(0, 0, 102); font-weight: bold;">final</span> </span><span style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 0);">DataFormView form = ViewFactory.getDataForm(</span></span><span style="color: rgb(0, 0, 102); font-weight: bold;"> <span style="color: rgb(0, 153, 0); font-weight: bold;">"customerSelector"</span> </span><span style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 0);">);</span></span><span style="color: rgb(0, 0, 102); font-weight: bold;"><br /></span><span style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 0);">form.bind( listView.getSelected() );</span><br style="color: rgb(0, 0, 0);" /><span style="color: rgb(0, 0, 0);"> form.show();</span></span><span style="color: rgb(0, 0, 102); font-weight: bold;"><br /></span></div><br />Eso nos mostrar&#237;a un formulario con una casilla de texto editable para el nombre comercial, otra para el nombre fiscal, y una no editable para el c&#243;digo de cliente. El formulario tiene autom&#225;ticmente tambi&#233;n una acci&#243;n de aceptar y otra de cancelar, y si pulsamos en aceptar actualiza la fila de datos con los contenidos del formulario y los graba de nuevo en la tabla correspondiente.<br /><br />&#191;Sencillo, no?<br /><br />En pr&#243;ximos art&#237;culos exploraremos un poco m&#225;s las posibilidades, s&#243;lo estamos ara&#241;ando la superficie, pero como comienzo creo que est&#225; bien.<br />La enorme ventaja de esta forma de crear las pantallas, adem&#225;s de la rapidez, es que es algo completamente conceptual y que nos despega completamente de la implementaci&#243;n final de las pantallas y sus complejidades. Entre ellas, el discernir entre diferentes dispositivos para hacer la presentaci&#243;n m&#225;s adecuada.<br />Y adem&#225;s brinda opciones adicionales, tales como que podemos hacer que cada cliente final de la aplicaci&#243;n pueda definir que campos quiere ver en cada pantalla, ya que la definici&#243;n de las vistas es algo din&#225;mico y que puede descargarse remotamente.<br /><br /><br />&#191;Qu&#233; te parece? &#191;Alguna sugerencia? &#191;Te gustar&#237;a hacer de beta tester para luego comercializar tus propias aplicaciones?<br />
 ]]>
</description>
 <dc:date>2007-04-19T12:56:00+01:00</dc:date>
 <dc:creator>Narciso Cerezo</dc:creator>
</item>

<item>
 <title>El pr&#243;ximo post ser&#225; de tecnolog&#237;a</title>
<link>http://narcisocerezo.zoomblog.com/archivo/2007/03/01/el-proximo-post-sera-de-tecnologia.html</link>
 <guid isPermaLink="true">http://narcisocerezo.zoomblog.com/archivo/2007/03/01/el-proximo-post-sera-de-tecnologia.html</guid>
 <description>
 <![CDATA[
Bueno, o por lo menos uno de los pr&#243;ximos. Hace poco que he descubiero una herramienta open source (con dual licensing) que es muy buena. La estamos probando y parece claro que vamos a seguir en esa l&#237;nea para la interfaz web de BaseMovil. As&#237; que en uno de los pr&#243;ximos posts hablar&#233; de nuevo de tecnolog&#237;a pura y dura :-)<br /><br />
 ]]>
</description>
 <dc:date>2007-03-01T00:08:00+01:00</dc:date>
 <dc:creator>Narciso Cerezo</dc:creator>
</item>

<item>
 <title>Java sobre ruedas</title>
<link>http://narcisocerezo.zoomblog.com/archivo/2005/08/09/java-sobre-ruedas.html</link>
 <guid isPermaLink="true">http://narcisocerezo.zoomblog.com/archivo/2005/08/09/java-sobre-ruedas.html</guid>
 <description>
 <![CDATA[
<div style="clear: both;" />Hace ya unos a&#241;os que vi en un programa de televisi&#243;n sobre coches que cierto fabricante estaba ya haciendo pruebas para poner sistemas basados en MS Windows CE (ahora PocketPC) dentro de sus coches. Y con dentro quiero decir controlando la electr&#243;nica del coche, desde temas como puede ser la inyecci&#243;n electr&#243;nica o la alarma hasta cosas m&#225;s de entretenimiento como el <a href="http://es.wikipedia.org/wiki/GPS">GPS</a> o DVD. Este "prodigio" ser&#237;a capaz de hacer cosas como por ejemplo detectar componentes que pudieran estar a punto de fallar, de controlar cuando debemos llevar el coche a revisi&#243;n, y lo que es mejor, concertar autom&#225;ticamente una cita con el taller para ello. A&#250;n hay m&#225;s, tambi&#233;n ser&#237;a capaz de autoactualizarse sobre la marcha, con algo similar al Windows Update pero espec&#237;fico para esto. Para ello utilizar&#237;a el tel&#233;fono m&#243;vil integrado.<br />Aquello no lleg&#243; a salir (usaba Windows CE).<br />Pero ahora hay algo similar que va a salir ya a la calle, de momento sobre los <a href="http://www.bmw.es">BMW</a> serie 5, 6 y 7, y que funciona con <a href="http://www.java.com">Java.</a> Aunque no controla nada de electr&#243;nica del propio coche (mejor) y se dedica exclusivamente al tema de entretenimiento y comunicaci&#243;n. En los coches con navegador y pantalla a color vendr&#225; este sistema, que permite controlar el navegador, la radio, el tel&#233;fono m&#243;vil, la climatizaci&#243;n, la televisi&#243;n, el dvd, el <a href="http://es.wikipedia.org/wiki/GPS">GPS</a>, etc.<br />De momento funciona con Personal Java, que est&#225; siendo abandonado en favor de  <a href="http://www.technorati.com/tag/J2ME">J2ME</a>, pero ya est&#225;n realizando la adaptaci&#243;n para que funcione con <a href="http://www.technorati.com/tag/J2ME">J2ME</a> <a href="http://es.wikipedia.org/wiki/Configuracion_de_Dispositivos_Conectados">CDC</a> (CDC es una versi&#243;n de <a href="http://www.technorati.com/tag/J2ME">J2ME</a> para dispositivos con m&#225;s capacidad que los tel&#233;fonos m&#243;viles, que funcionan sobre CLDC).<br />Esto abre un mundo de posibilidades muy grande de cara a los desarrolladores de aplicaciones m&#243;viles, un campo en auge y con gran futuro y con el que tengo mucho que ver en estos &#250;ltimos tiempos.<br />El sistema est&#225; pensado para montarlo en cualquier veh&#237;culo, no solo en BMW, y cuando empiecen a extenderse (cada vez son m&#225;s los coches con navegador gps) ser&#225;n muchas las posibilidades, no solo de aplicaciones de entretenimiento, sino tabmi&#233;n de negocio.<br />M&#225;s informaci&#243;n:<br />
<ul><br />
<li><a href="http://java.sun.com/developer/technicalArticles/J2ME/TLA.html">The Network on Wheels</a></li><br />
<li><a href="http://www.java.com">Java</a></li><br /></ul>
<div style="clear: both; padding-bottom: 0.25em;" />
 ]]>
</description>
 <dc:date>2005-08-09T14:18:00+01:00</dc:date>
 <dc:creator>Narciso Cerezo</dc:creator>
</item>

<item>
 <title>Hibernate y JBoss</title>
<link>http://narcisocerezo.zoomblog.com/archivo/2004/08/13/hibernate-y-Jboss.html</link>
 <guid isPermaLink="true">http://narcisocerezo.zoomblog.com/archivo/2004/08/13/hibernate-y-Jboss.html</guid>
 <description>
 <![CDATA[
<div style="clear: both;" />Lo prometido es deuda, as&#237; que hoy voy a explicar c&#243;mo he integrado <a href="http://www.hibernate.org">Hibernate</a> y <a href="http://www.jboss.org">JBoss</a>.<br />Lo primero que hay que tener en cuenta son las versiones, esto aplica a JBoss 3.2.x (en concreto estoy trabajando actualmente con la 3.2.5) y a Hibernate 2.1.6. La versi&#243;n 2.1.4 de Hibernate ten&#237;a un fallo que imped&#237;a su uso con JBoss as&#237; que es imporante utilizar la 2.1.6 que ahora es la &#250;ltima disponible.<br />Al grano.<br />Con Hibernate creamos los denominados POJO (Plain Old Java Objects) o Java Beans, e Hibernate se encarga de manejar la persistencia de dichos objetos. Hibernate nos permite una flexibilidad increiblemente mayor que los Entity Beans a la hora de dise&#241;ar la estructura de clases, y eso significa que podemos hacer dise&#241;os de una granularidad muy fina, usar la herencia adecuadamente y crear componentes (otros POJOs) que act&#250;en como campos de nuestras entidades.<br />Para hacer que Hibernate funcione con JBoss hemos de crear un archivo de servicio dentro de nuestra aplicaci&#243;n, es decir un archivo .SAR, pero como queremos poder llamar a nuestras clases desde el resto de la aplicaci&#243;n, en dicho .SAR s&#243;lo ir&#225; el archivo de servicio y los archivos descriptores de nuestras entidades (los .hbm.xml). Y algo m&#225;s... tambi&#233;n hemos de incluir el archivo de servicio que crear&#225; la fuente de datos (DataSource) uitilizado por Hibernate.<br />Yo utilizo XDoclet y Ant para la automatizaci&#243;n de todo este proceso, aunque XDoclet introduce algunas limitaciones sigue siendo lo suficientemente interesante.<br />Por otro lado, en nuestro archivo de aplicaci&#243;n (.EAR) tenemos que hacer referencia a los diferentes servicios en el orden adecuado, as&#237; como incluir todas las librer&#237;as necesarias: las que necesita Hibernate, una con las clases que representan nuestras entidades y el resto que necesite nuestra aplicaci&#243;n.<br />En definitiva, nuestra aplicaci&#243;n debe tener la siguiente estructura:<br /><pre><div class="MyCode">aplicacion.EAR<br />    |<br />    |- hibernate.SAR<br />    |      |<br />    |      |- <a href="#descriptores">descriptores</a><br />    |      |- META-INF/<br />    |             |<br />    |             |- <a href="#datasource">datasource.xml</a><br />    |             |- <a href="#sar-service">jboss-service.xml</a><br />    |- lib/<br />    |     |- dependencias de Hibernate<br />    |     |- <a href="#model">model.jar</a><br />    |     |- dem&#225;s librer&#237;as que necesite la aplicaci&#243;n<br />    |<br />    |- META-INF/<br />    |      |<br />    |      |- <a href="#application">application.xml</a><br />    |      |- <a href="#jboss-app">jboss-app.xml</a><br /></div></pre><br />D&#243;nde:
<ul><br />
<li><a name="descriptores"><b>descriptores</b></a> es la jerarqu&#237;a de directorios paralela a nuestra jerearqu&#237;a de clases persistentes con los ficheros .hbm.xml correspondientes</li><br />
<li><a name="datasource"><b>datasource.xml</b></a> es el descriptor de nuestro origen de datos (m&#225;s informaci&#243;n en la documentaci&#243;n de JBoss)</li><br />
<li><a name="sar-service"><b>jboss-service.xml</b></a> es el descriptor del servicio Hibernate. Yo lo genero autom&#225;ticamente con Ant y XDoclet, es lo m&#225;s c&#243;modo y seguro para no equivocarse. En cualquier caso os doy un <a href="#service-sample">ejemplo</a></li><br />
<li><a name="model"><b>model.jar</b></a> es nuestro modelo, las clases persistentes que manejar&#225; Hibernate empaquetadas en un jar.</li><br />
<li><a name="application"><b>application.xml</b></a> es el descriptor de aplicaci&#243;n J2EE (m&#225;s informaci&#243;n en la documentaci&#243;n de Java J2EE). Aqu&#237; lo importante es hacer referencia a todas las librer&#237;as y servicios de nuestra aplicaci&#243;n, as&#237; que tambi&#233;n os pongo un <a href="#app-sample">ejemplo</a>.</li><br />
<li><a name="jboss-app"><b>jboss-app.xml</b></a> es el descriptor de aplicaci&#243;n espec&#237;fico de JBoss, en el se hace referencia al servicio de Hibernate y a otros que podamos tener en nuestra aplicaci&#243;n (m&#225;s informaci&#243;n en la documentaci&#243;n de JBoss). Tambi&#233;n os doy otro <a href="#jboss-app-sample">ejemplo</a></li><br /></ul><br />Ejemplos:<br /><b><a name="service-sample">1. Archivo de servicio para hibernate.SAR</a></b><br /><br /><pre><div class="MyCode"><?xml version="1.0" encoding="UTF-8"?><br /><!DOCTYPE server><br /><!-- Generated file - Do not edit! --><br /><br /><server><br />   <mbean <br />      code="net.sf.hibernate.jmx.HibernateService"<br />      name="jboss.jca:service=Model"<br />   ><br />      <depends>jboss.jca:service=RARDeployer</depends><br />      <attribute name="MapResources"><br />         com/sample/app/model/Role.hbm.xml,<br />         com/sample/app/model/common/Telephone.hbm.xml,<br />         (other descriptors)<br />      </attribute><br />      <attribute<br />         name="JndiName"<br />      >java:/hibernate/DefaultSessionFactory<br />      </attribute><br />      <attribute<br />         name="Datasource">java:/myDS</attribute><br />      <attribute<br />         name="Dialect">net.sf.hibernate.dialect.MyDialect<br />      </attribute><br />      <attribute<br />         name="ShowSql">false</attribute><br />      <attribute<br />         name="UserTransactionName">UserTransaction<br />      </attribute><br />      <attribute<br />         name="TransactionStrategy"<br />         >net.sf.hibernate.transaction.JTATransactionFactory<br />      </attribute><br />      <attribute<br />         name="TransactionManagerLookupStrategy"<br />         ><br />      net.sf.hibernate.transaction.JBossTransactionManagerLookup<br />      </attribute><br />   </mbean><br /></server><br /></div></pre><br /><br /><b><a name="app-sample">2. Archivo de aplicaci&#243;n</a></b><br /><br /><pre><div class="MyCode"><?xml version="1.0" encoding="ISO-8859-1"?><br /><!DOCTYPE application <br />PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN'<br />'http://java.sun.com/dtd/application_1_3.dtd'><br /><application><br />    <display-name>Mi Aplicaci&#243;n</display-name><br /><br />    <!-- ===================================<br />        jdbc driver<br />    ======================================= --><br />    <module><br />        <java>lib/my-jdbc-driver.jar</java><br />    </module><br /><br />    <!-- ===================================<br />        Model classes<br />    ======================================= --><br />    <module><br />        <java>lib/model.jar</java><br />    </module><br /><br />    <!-- ===================================<br />        Hibernate classes<br />    ======================================= --><br />    <module><br />        <java>lib/c3p0-0.8.4.5.jar</java><br />    </module><br />    <module><br />        <java>lib/cglib-full-2.0.2.jar</java><br />    </module><br />    <module><br />        <java>lib/commons-collections-2.1.1.jar</java><br />    </module><br />    <module><br />        <java>lib/commons-lang-1.0.1.jar</java><br />    </module><br />    <module><br />        <java>lib/concurrent-1.3.3.jar</java><br />    </module><br />    <module><br />        <java>lib/dom4j-1.4.jar</java><br />    </module><br />    <module><br />        <java>lib/ehcache-0.9.jar</java><br />    </module><br />    <module><br />        <java>lib/hibernate2.jar</java><br />    </module><br />    <module><br />        <java>lib/jaas.jar</java><br />    </module><br />    <module><br />        <java>lib/jcs-1.0-dev.jar</java><br />    </module><br />    <module><br />        <java>lib/odmg-3.0.jar</java><br />    </module><br />    <module><br />        <java>lib/oscache-2.0.jar</java><br />    </module><br />    <module><br />        <java>lib/swarmcache-1.0rc2.jar</java><br />    </module><br /><br />    <!-- ================================<br />        EJBs<br />    ===================================== --><br />    <module><br />        <ejb>ejbs/01-model.jar</ejb><br />    </module><br /><br />    <!-- ================================<br />        Web Application<br />    ===================================== --><br />    <module><br />      <web><br />        <web-uri>my.war</web-uri><br />        <context-root>/my</context-root><br />      </web><br />    </module><br /></application><br /></div></pre><br /><b><a name="jboss-app-sample">3. Archivo de aplicaci&#243;n de JBoss</a></b><br /><br /><pre><div class="MyCode"><jboss-app><br /><br />    <module><br />        <service>model.sar</service><br />    </module><br /><br /></jboss-app><br /></div></pre><br /><br />Y con esto terminamos por hoy. Con estas instrucciones no deber&#237;as tener problemas para empezar r&#225;pidamente con Hibernate y JBoss, sobretodo si utilizais Ant y XDoclet, lo cual os aconsejo.<br />
<div style="clear: both; padding-bottom: 0.25em;" />
 ]]>
</description>
 <dc:date>2004-08-13T08:34:00+01:00</dc:date>
 <dc:creator>Narciso Cerezo</dc:creator>
</item>

<item>
 <title>Consideraciones de dise&#241;o con JUnit</title>
<link>http://narcisocerezo.zoomblog.com/archivo/2004/07/29/consideraciones-de-diseno-con-Junit.html</link>
 <guid isPermaLink="true">http://narcisocerezo.zoomblog.com/archivo/2004/07/29/consideraciones-de-diseno-con-Junit.html</guid>
 <description>
 <![CDATA[
<div style="clear: both;" />Hace tiempo que no escribo en el blog, pero es que mi actual proyecto consume todo mi tiempo. No obstante, merece la pena, porque es el m&#225;s importante que he emprendido profesionalmente hablando.<br /> Pero vamos al grano...<br /> Aunque todav&#237;a no he terminado de entrar en la din&#225;mica del desarrollo guiado por pruebas, al estilo de XP, hace ya tiempo que estoy "infectado por los tests". No hay duda de que el tiempo que "pierdes" escribiendo los test con <a href="http://www.junit.org">JUnit</a> es un tiempo bien empleado, puesto que luego puedes tener la tranquilidad de que si los test funcionan es m&#225;s que probable que todo funcione. De hecho es la &#250;nica manera de poder hacer test de regresi&#243;n sin apenas esfuerzo y estar totalmente seguro de que no has introducido un bug, ni siquiera uno inducido en un m&#243;dulo que no has tocado.<br /> Sin embargo, hay algunos tipos de componente sobre los que es m&#225;s complicado hacer pruebas con JUnit, sin ir m&#225;s lejos los EJB (sean del tipo que sean). En general todo lo que se ejecuta sobre un contenedor es complicado de probar puesto que no es sencillo emular en nuestros juegos de pruebas las situaciones reales a las que se enfrenta el c&#243;digo en el contenedor.<br /> Actualmente estoy desarrollando una aplicacion J2EE, preparando el camino para que todo pueda funcionar con WebServices, que sea muy r&#225;pida, estable y segura (como todos ;-) ).<br /> Como servidor de aplicaciones estoy utilizando <a href="http://www.jboss.org">JBoss</a>, aunque cuando el tiempo me deje y est&#233; m&#225;s maduro probar&#233; <a href="http://geronimo.apache.org">Geronimo</a>. <br /> En el dilema que me plante&#233; incialmente sobre que utilizar de J2EE estaban los Entity Beans CMP e <a href="http://www.hibernate.org">Hibernate</a>. Al final ha ganado Hibernate por ser m&#225;s f&#225;cil de probar con JUnit, m&#225;s f&#225;cil de generar y distribuir, y mucho m&#225;s cercano al verdadero desarrollo orientado a objetos. Podr&#237;a utilizar Entity Beans BMP que a su vez utilizaran Hibernate, pero me parece rizar el rizo e introducir complejidad innecesaria.<br /> Sin embargo, si he decidido utilizar Stateless Session Beans, pues permiten distribuir la carga entre varios servidores de aplicaciones facilmente, pero sobre todo porque me permiten dejar el trabajo transaccional al contenedor y estar seguro de que se hace bien.<br /> En este punto es donde de nuevo entra JUnit. Probar EJB, incluso Session Beans, es complicado. As&#237; que al final, usar JUnit ha inducido una decisi&#243;n de dise&#241;o importante, que puede implicar un peque&#241;o coste adicional en tiempo de ejecuci&#243;n, pero cuyas ventajas creo que son superiores. Lo que estoy haciendo es que los Session Beans sean meros proxies de POJOs (que llamar&#233; Business Objects) que son los que realmente tienen la l&#243;gica de negocio. Los BOs utilizan sessiones de Hibernate para realizar su trabajo, pero no realizan ning&#250;n tipo de asunci&#243;n con respecto a las transacciones. De esta forma es sencillo realizar pruebas sobre los BOs fuera del contenedor, dejando que sean las clases de prueba las que manejen las transacciones de forma simple, y estar razonablemente seguros de que todo funcionar&#225; correctamente sobre el contenedor.<br /> &#191;Te parece una buena soluci&#243;n? &#191;Crees que hay una mejor?<br /> <br /> En el pr&#243;ximo post detallar&#233; el proceso de trabajo con Hibernate sobre JBoss, ya que a pesar del art&#237;culo al respecto que hay en la web de Hibernate, la realidad es algo diferente y adem&#225;s creo que ser&#237;a muy conveniente detallar la integraci&#243;n del proceso con Ant, cosa que est&#225; explicada en varios sitios pero parcialmente en todos ellos.<br /> 
<div style="clear: both; padding-bottom: 0.25em;" />
 ]]>
</description>
 <dc:date>2004-07-29T08:04:00+01:00</dc:date>
 <dc:creator>Narciso Cerezo</dc:creator>
</item>

</channel>
</rss>

