<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Our Geek Space &#187; java</title>
	<atom:link href="http://blog.moove-it.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.moove-it.com</link>
	<description>be free to express yourself...</description>
	<lastBuildDate>Thu, 26 Jan 2012 19:30:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Rules Engine &#8211; Java(Drools) &amp; Ruby(ruleby)</title>
		<link>http://blog.moove-it.com/rules-engine-java-drools-ruby-ruleby/</link>
		<comments>http://blog.moove-it.com/rules-engine-java-drools-ruby-ruleby/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 18:57:20 +0000</pubDate>
		<dc:creator>Martin Cabrera</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[moove-it]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[drools]]></category>
		<category><![CDATA[jboss]]></category>
		<category><![CDATA[ruleby]]></category>
		<category><![CDATA[rules]]></category>
		<category><![CDATA[rules engine]]></category>

		<guid isPermaLink="false">http://blog.moove-it.com/?p=549</guid>
		<description><![CDATA[Today we made one presentation with the whole team of moove-it about rules engine in Java and Ruby. We talk about Drools and ruleby. We share the presentation &#8230; Rules Engine &#8211; java(Drools) &#38; ruby(ruleby) View more presentations from martincabrera.]]></description>
			<content:encoded><![CDATA[<p>Today we made one presentation with the whole team of moove-it about rules engine in Java and Ruby.</p>
<p>We talk about Drools and ruleby.</p>
<table>
<tbody>
<tr>
<td><a href="http://blog.moove-it.com/wp-content/uploads/2010/12/drools.jpg" rel="lightbox[549]" title="drools"><img class="alignleft size-medium wp-image-553" title="drools" src="http://blog.moove-it.com/wp-content/uploads/2010/12/drools-300x169.jpg" alt="" width="300" height="169" /></a></td>
<td><a href="http://blog.moove-it.com/wp-content/uploads/2010/12/drools_2.jpg" rel="lightbox[549]" title="drools_2"><img class="alignleft size-medium wp-image-554" title="drools_2" src="http://blog.moove-it.com/wp-content/uploads/2010/12/drools_2-300x169.jpg" alt="" width="300" height="169" /></a></td>
</tr>
</tbody>
</table>
<p>We share the presentation &#8230;</p>
<div id="__ss_6022058" style="width: 425px;"><strong style="display: block; margin: 12px 0 4px;"><a title="Rules Engine - java(Drools) &amp; ruby(ruleby)" href="http://www.slideshare.net/martincabrera/rules-engine-java-rails">Rules Engine &#8211; java(Drools) &amp; ruby(ruleby)</a></strong><object id="__sse6022058" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=motorresdereglas-javarails-101203122600-phpapp01&amp;stripped_title=rules-engine-java-rails&amp;userName=martincabrera" /><param name="name" value="__sse6022058" /><param name="allowfullscreen" value="true" /><embed id="__sse6022058" type="application/x-shockwave-flash" width="425" height="355" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=motorresdereglas-javarails-101203122600-phpapp01&amp;stripped_title=rules-engine-java-rails&amp;userName=martincabrera" name="__sse6022058" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<div style="padding: 5px 0 12px;">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/martincabrera">martincabrera</a>.</div>
</div>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://blog.moove-it.com/rules-engine-java-drools-ruby-ruleby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auditing, History of database modifications with Hibernate &#8211; Envers Solution !</title>
		<link>http://blog.moove-it.com/auditing-history-of-database-modifications-with-hibernate-envers-solution/</link>
		<comments>http://blog.moove-it.com/auditing-history-of-database-modifications-with-hibernate-envers-solution/#comments</comments>
		<pubDate>Wed, 27 Oct 2010 14:16:22 +0000</pubDate>
		<dc:creator>Martin Cabrera</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[jee]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[auditing]]></category>
		<category><![CDATA[envers]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java ee]]></category>
		<category><![CDATA[java enterprise]]></category>

		<guid isPermaLink="false">http://blog.moove-it.com/?p=408</guid>
		<description><![CDATA[Envers is one of the Hibernate&#8217;s project sponsored by Redhat. Works with Hibernate and Hibernate Entity Manager. Aims to enable easy auditing of persistent classes. For each audited entity you must annotate your persistent clases with @Audited, a table will be created, which will hold the history of changes made to the entity. The idea is very similar [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.moove-it.com/wp-content/uploads/2010/10/hibernatelogo.png" rel="lightbox[408]" title="hibernate-logo"><img class="alignleft size-full wp-image-409" title="hibernate-logo" src="http://blog.moove-it.com/wp-content/uploads/2010/10/hibernatelogo.png" alt="hibernate-logo" width="312" height="92" /></a></p>
<p><strong>Envers</strong> is one of the <strong>Hibernate&#8217;s</strong> project sponsored by Redhat. Works with Hibernate and Hibernate Entity Manager.</p>
<p>Aims to enable easy auditing of persistent classes. For each audited entity you must annotate your persistent clases with @Audited, a table will be created,  which will hold the history of changes made to the entity.</p>
<p>The idea is very similar to CVS or Subersion. Each transaction with updates, deletes or inserts made in the database with hibernate generate a new revision number. One transaction is one revision.</p>
<p>Envers provide a simple way to retrive your data of a revision using: revision number, date, queries with min and max function between others.</p>
<p>You can use Envers wherever Hibernate works: standalone, inside JBoss AS, with JBoss Seam or Spring.</p>
<p>It&#8217;s very easy &#8230;</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">@Entity</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">@Audited</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">public class Usuario {</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public enum Rol{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>EMPRESA, ADMINISTRADOR,MESA_ENTRADA;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>private Long id;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>private String usuario;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>private String contrasenia;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>private Rol rol;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>@Id</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>@GeneratedValue</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public Long getId() {</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>return id;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public void setId(Long id) {</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>this.id = id;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 64px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<pre>@Entity @Audited
public class User {
<span style="white-space: pre;">	</span>private Long id;

        @Id @GeneratedValue
        public Long getId() { return id; }
        public void setId(Long id) { this.id = id; }

        // other fields and methods
        ...
}</pre>
<h3>Envers configuration</h3>
<p><span style="font-family: 'Lucida Grande', Geneva, Verdana, Arial, sans-serif; line-height: 18px; font-size: 12px; color: #333333;">When configuring your Hibernate (<code class="literal" style="font-size: 0,9em; font-family: verdana, helvetica, sans-serif; white-space: nowrap;">persistence.xml</code> if you are using JPA, <code class="literal" style="font-size: 0,9em; font-family: verdana, helvetica, sans-serif; white-space: nowrap;">hibernate.cfg.xml</code> or other if you are using Hibernate directly), add the following event listeners:</span></p>
<p><span style="font-family: 'Lucida Grande', Geneva, Verdana, Arial, sans-serif; line-height: 18px; font-size: 12px; color: #333333;"> </span></p>
<pre>&lt;persistence-unit ...&gt;
&lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
&lt;class&gt;...&lt;/class&gt;
&lt;properties&gt;
   &lt;property name="hibernate.dialect" ... /&gt;
   &lt;!-- other hibernate properties --&gt;

   &lt;property name="hibernate.ejb.event.post-insert"
             value="org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener" /&gt;
   &lt;property name="hibernate.ejb.event.post-update"
             value="org.hibernate.ejb.event.EJB3PostUpdateEventListener,org.hibernate.envers.event.AuditEventListener" /&gt;
   &lt;property name="hibernate.ejb.event.post-delete"
             value="org.hibernate.ejb.event.EJB3PostDeleteEventListener,org.hibernate.envers.event.AuditEventListener" /&gt;
   &lt;property name="hibernate.ejb.event.pre-collection-update"
             value="org.hibernate.envers.event.AuditEventListener" /&gt;
   &lt;property name="hibernate.ejb.event.pre-collection-remove"
             value="org.hibernate.envers.event.AuditEventListener" /&gt;
   &lt;property name="hibernate.ejb.event.post-collection-recreate"
             value="org.hibernate.envers.event.AuditEventListener" /&gt;
&lt;/properties&gt;
&lt;/persistence-unit&gt;</pre>
<p>Then, annotate your persistent class with @Audited (like the User example)</p>
<p>And that&#8217;s it!</p>
<h3>Queries</h3>
<p><strong>Find audited data</strong></p>
<p>You can access the audit (history) of an entity using the <a id="quickstart" style="text-decoration: none;"><code class="literal" style="font-size: 0,9em; font-family: verdana, helvetica, sans-serif; white-space: nowrap;">AuditReader</code></a> interface, which you can obtain when having an open EntityManager.</p>
<pre>AuditReader reader = AuditReaderFactory.get(entityManager); 
User oldUser = reader.find(User.class, userId, revision)</pre>
<p><strong>Search a revision number</strong></p>
<p>the whole documentation is in the Web site:  <a href="http://docs.jboss.org/envers/docs/index.html#queries">http://docs.jboss.org/envers/docs/index.html#queries</a></p>
<p>To ilustrate one example I show the way to search the max number revision of one Entity audited.</p>
<pre>Number revision = (Number) reader.createQuery().forRevisionsOfEntity(User.class, false, true)
.addProjection(AuditEntity.revisionNumber().max())
.add(AuditEntity.id().eq(userId))
.getSingleResult();</pre>
<p>We use Envers in a few projects. Works fine and very quickly, we recomended &#8230; no dubt !  Envers</p>
<p>Web site: <a href="http://www.jboss.org/envers">www.jboss.org/envers</a></p>
<p>Envers documentation: <a href="http://docs.jboss.org/envers/docs/index.html">http://docs.jboss.org/envers/docs/index.html</a></p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://blog.moove-it.com/auditing-history-of-database-modifications-with-hibernate-envers-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Steps to include lightweight cache in java applications &#8211; WhirlyCache</title>
		<link>http://blog.moove-it.com/steps-to-include-lightweight-cache-in-java-applications-whirlycache/</link>
		<comments>http://blog.moove-it.com/steps-to-include-lightweight-cache-in-java-applications-whirlycache/#comments</comments>
		<pubDate>Thu, 28 May 2009 21:34:12 +0000</pubDate>
		<dc:creator>Martin Cabrera</dc:creator>
				<category><![CDATA[jee]]></category>
		<category><![CDATA[whirlycache]]></category>
		<category><![CDATA[j2ee]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[java cache]]></category>
		<category><![CDATA[java enterprise]]></category>

		<guid isPermaLink="false">http://blog.moove-it.com/?p=188</guid>
		<description><![CDATA[Data caching is a very important consideration for JEE applications. A classic problem for any application is to detect and solve the recurrent calls for optimizing the applications. Some cases can be: database calls business logic calls remote method invocations Data caching limits the number of remote invocations in distributed applications and improves performance of [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom: 0cm;">Data caching is a very important consideration for JEE applications.</p>
<p>A classic problem for any application is to detect and solve the recurrent calls for optimizing the applications. Some cases can be:</p>
<ul>
<li>database calls</li>
<li>business logic calls</li>
<li>remote method invocations</li>
</ul>
<p>Data caching limits the number of remote invocations in distributed applications and improves performance of web applications by reducing the number of calls.</p>
<p>Several solutions exist to include a framework for implementing a cache.</p>
<ul>
<li><a href="http://www.opensymphony.com/oscache/" target="_blank">OsCache</a></li>
<li><a href="http://swarmcache.sourceforge.net/" target="_blank">SwarmCache</a></li>
<li><a href="http://www.jofti.com/" target="_blank">jofti</a></li>
<li><a href="http://labs.jboss.com/jbosscache/" target="_blank">jboss cache</a></li>
<li><a href="https://whirlycache.dev.java.net/" target="_blank">WhirlyCache</a></li>
<li><a href="http://ehcache.sourceforge.net/" target="_blank">EhCache</a></li>
<li><a href="http://cache4j.sourceforge.net/" target="_blank">Cache4J</a></li>
</ul>
<p>Check out this <a href="http://www.developer.com/img/2007/09/Table.htm" target="_blank">interesting comparative table.</a></p>
<h2>WhirlyCache (<a href="https://whirlycache.dev.java.net" target="_blank">https://whirlycache.dev.java.net</a>)</h2>
<p>I use whirlycache in two projects and works really good. I recommend it to incorporate in a simple lightweight Web application<br />
Whirlycache is a fast, configurable in-memory object cache for Java. It can be used, for example, to speed up a website or an application by caching objects that would otherwise have to be created by querying a database or by another expensive procedure. From the testing that we have done, it appears to be faster than any other Java cache that we have been able to inspect.</p>
<h2 style="margin-bottom: 0cm;">Steps to include WhirlyCache</h2>
<p><strong>(Step I)</strong> Donwload whirlycache and include it in your project -&gt; <a href="https://whirlycache.dev.java.net/files/documents/1995/34601/whirlycache-1.0.1.zip" target="_blank">https://whirlycache.dev.java.net/files/documents/1995/34601/whirlycache-1.0.1.zip</a></p>
<p><strong>(Step II)</strong> Create a cache instance</p>
<pre>CacheConfiguration cc = new CacheConfiguration();

cc.setName("KBCache");

cc.setBackend("com.whirlycott.cache.impl.ConcurrentHashMapImpl");

cc.setTunerSleepTime(60);

cc.setPolicy("com.whirlycott.cache.policy.LFUMaintenancePolicy");

cc.setMaxSize(10000);

Cache c = CacheManager.getInstance().createCache(cc);</pre>
<p><strong>(Step III)</strong> Use cache instance</p>
<p style="margin-bottom: 0cm;">
<pre>c.store(key, object);
c.remove(key);
c.retrieve(key);</pre>
<p style="margin-bottom: 0cm;">Example of java class (is a jboss seam entity class) &#8211; <span style="font-family: Monospace;"><span style="font-size: x-small;"><span style="color: #000000;"><span style="font-weight: normal;"><a href="http://blog.moove-it.com/wp-content/uploads/2009/05/stockcache.java">StockCache.java</a></span></span></span></span></p>
<p style="margin-bottom: 0cm;"><span style="font-family: Monospace;"><span style="font-size: x-small;"><span style="color: #000000;"><span style="font-weight: normal;"><br />
</span></span></span></span></p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://blog.moove-it.com/steps-to-include-lightweight-cache-in-java-applications-whirlycache/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

