<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Science Locademy</title>
	<atom:link href="http://locademiaz.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://locademiaz.wordpress.com</link>
	<description>dancing posts</description>
	<lastBuildDate>Thu, 01 Sep 2011 19:50:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='locademiaz.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Science Locademy</title>
		<link>http://locademiaz.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://locademiaz.wordpress.com/osd.xml" title="Science Locademy" />
	<atom:link rel='hub' href='http://locademiaz.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Turn your Java apps Gnome-Shell friendly</title>
		<link>http://locademiaz.wordpress.com/2011/08/30/turn-your-java-apps-gnome-shell-friendly/</link>
		<comments>http://locademiaz.wordpress.com/2011/08/30/turn-your-java-apps-gnome-shell-friendly/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 14:15:42 +0000</pubDate>
		<dc:creator>diega</dc:creator>
				<category><![CDATA[gnome]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[upstream]]></category>
		<category><![CDATA[gnome-shell]]></category>
		<category><![CDATA[intelliJ]]></category>

		<guid isPermaLink="false">http://locademiaz.wordpress.com/?p=147</guid>
		<description><![CDATA[The Problem When you try to add a java application as favorite into the Gnome Shell&#8216;s lateral dock and run it you&#8217;ll end up having duplicated icons, one for the launcher and one for the running app. This happens b/c the shell uses an application based system for grouping tasks, so the idea is, if [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=147&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>The Problem</h3>
<p>When you try to add a java application as <em>favorite</em> into the <a title="Gnome Shell" href="https://live.gnome.org/GnomeShell" target="_blank">Gnome Shell</a>&#8216;s lateral dock and run it you&#8217;ll end up having duplicated icons, one for the launcher and one for the running app. This happens b/c the shell uses an application based system for grouping tasks, so the idea is, if you add an application as a favorite launcher and you start it you&#8217;ll end having that launcher icon highlighted. Internally the shell matches the running process with the Exec clause of the <a title=".desktop files specification" href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" target="_blank">.desktop file </a>.<br />
This works well except for applications running inside a VM or being interpreted b/c those will share the same running process. On that situation the shell inspects the WM_CLASS X Window property <a href="#footnote1"><sup>[1]</sup></a> and matches it with the full name of the desktop file. E.g. if your applications has the WM_CLASS set as &#8220;mySwingApp&#8221;, for this to successfully matched in the dock with its launcher, that launcher must be called mySwingApp.desktop located according <a href="http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html" title="XDG Base Directory Specification" target="_blank">XDG</a>.</p>
<p><strong>Note:</strong> for inspecting that value on any window you just need to run <code>xprop WM_CLASS</code> and click into the target window</p>
<h3>Why is this happening?</h3>
<p>Even if you are creating a swing application from scratch there is no easy way to tweak that X Window property using plain and portable APIs. Taking a look into openjdk sources, this is how them manages it</p>
<pre class="brush: java; light: true; toolbar: false;">
String mainClassName = null;

StackTraceElement trace[] = (new Throwable()).getStackTrace();
int bottom = trace.length - 1;
if (bottom &gt;= 0) {
    mainClassName = trace[bottom].getClassName();
}
if (mainClassName == null || mainClassName.equals(&quot;&quot;)) {
    mainClassName = &quot;AWT&quot;;
}
awtAppClassName = getCorrectXIDString(mainClassName);
</pre>
<p>As you may note what is used for this value is the name of the class running the Swing main loop.</p>
<h3>Da solution</h3>
<p>Digging around the web I founded a <a href="http://download.oracle.com/javase/6/docs/api/java/lang/instrument/package-summary.html" title="java.lang.instrument package javadoc" target="_blank">java agent</a> and a pretty similar <a href="http://blog.jteam.nl/2011/01/09/make-intellij-idea-behave-properly-in-linux-docks/" title="Make IntelliJ IDEA behave properly in Linux docks" target="_blank">explanation</a> on what&#8217;s going on.<br />
So what I did was to <a href="http://help.github.com/fork-a-repo/" title="Fork a repo" target="_blank">fork</a> <a href="https://github.com/jelmerk/window-matching-agent" title="jelmerk/window-matching-agent" target="_blank">that agent</a> and improve it a little bit. What I did was to move it into a <a href="http://maven.apache.org/" title="Apache Maven" target="_blank">maven</a> structure and remove its packaging as a fat-jar (I&#8217;m radically against fat-jars as you can see in <a href="http://www.vitavonni.de/blog/201108/2011081601-documenting-fat-jar-licenses.html" title="My comments in Documenting fat-jar licenses thread" target="_blank">my comments here</a>).</p>
<p>The forked project is located in my github here:<br />
<a href="https://github.com/diega/window-matching-agent" title="diega's Window matching agent" target="_blank">https://github.com/diega/window-matching-agent</a><br />
and please take a look to the README there
</p>
<h3>A practical example</h3>
<p>My first motivation on doing this was based on IntelliJ IDEA so I&#8217;ll paste here my environment.</p>
<ul>
<li>
<a href="https://github.com/downloads/diega/window-matching-agent/agent-1.0.jar" title="diega's Window Matching Agent v1.0">Download</a> the agent-1.0.jar and put it wherever you want (I put it into IntelliJ&#8217;s bin/ folder)
</li>
<li>
Edit the file <code>bin/idea.vmoptions</code> adding this line</p>
<p>
-javaagent:agent-1.0.jar=intellij-ultimate
</p>
</li>
<li>
Create the file <code>~/.local/share/applications/intellij-ultimate.desktop</code> with the following content</p>
<pre class="brush: plain; highlight: [7]; light: true; toolbar: false;">
[Desktop Entry]
Version=10.5.1
Name=IntelliJ IDEA Ultimate Edition
Comment=The Most Intelligent Java IDE
Categories=Applications;Development;
Encoding=UTF-8
Exec=env IDEA_CLASSPATH\=../lib/asm.jar /home/diego/bin/ideaIU-10.5/bin/idea.sh
GenericName=IntelliJ
Icon=/home/diego/bin/ideaIU-10.5/bin/idea128.png
MimeType=text/x-java
Terminal=false
Type=Application
URL=http://www.jetbrains.com/idea
</pre>
</li>
</ul>
<h4>Latest notes</h4>
<p>If you download the agent-1.0.jar into another location (or with another name) you must adjust the -javaagent: parameter.<br />
Of course, change the path in the Exec entry to point to your own executable.</p>
<p>
Hope this helps somebody, it took me a while to figure out the-right-things-to-do™ :)
</p>
<hr />
<span id="footnote1">[1]: <a title="Application Based GNOME 3" href="https://live.gnome.org/GnomeShell/ApplicationBased#The_WM_CLASS_X_Window_property" target="_blank">Application Based GNOME 3</a></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/locademiaz.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/locademiaz.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/locademiaz.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/locademiaz.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/locademiaz.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/locademiaz.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/locademiaz.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/locademiaz.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/locademiaz.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/locademiaz.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/locademiaz.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/locademiaz.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/locademiaz.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/locademiaz.wordpress.com/147/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=147&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://locademiaz.wordpress.com/2011/08/30/turn-your-java-apps-gnome-shell-friendly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>-34.608418 -58.373161</georss:point>
		<geo:lat>-34.608418</geo:lat>
		<geo:long>-58.373161</geo:long>
		<media:content url="http://1.gravatar.com/avatar/138ff7a37f402e8887945b9ce927ddea?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">diega</media:title>
		</media:content>
	</item>
		<item>
		<title>Drools persistence on top of HashMap</title>
		<link>http://locademiaz.wordpress.com/2011/02/07/drools-persistence-on-top-of-hashmap/</link>
		<comments>http://locademiaz.wordpress.com/2011/02/07/drools-persistence-on-top-of-hashmap/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 23:17:00 +0000</pubDate>
		<dc:creator>diega</dc:creator>
				<category><![CDATA[drools]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jboss]]></category>
		<category><![CDATA[jbpm]]></category>

		<guid isPermaLink="false">http://locademiaz.wordpress.com/?p=137</guid>
		<description><![CDATA[Introduction This post shows a reference implementation of drools persistence on top of a non transactional HashMap. This should serve as inspiration for more complex scenarios (like the Berkley DB one). This work was also developed under Intalio’s sponsorship. As the new abstraction is heavily inspired on JPA there are some mechanisms which should be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=137&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p style="text-align:justify;">
This post shows a reference implementation of drools persistence on top of a non transactional HashMap. This should serve as inspiration for more complex scenarios (like the Berkley DB one). This work was also developed under <a href="http://www.intalio.com">Intalio</a>’s sponsorship.
</p>
<p style="text-align:justify;">
As the new abstraction is heavily inspired on JPA there are some mechanisms which should be emulated in order to get the same behavior on both implementations.
</p>
<h3>Involved classes</h3>
<p style="text-align:justify;">
Starting from the abstraction described in my <a href="http://locademiaz.wordpress.com/2011/01/28/drools-abstract-persistence-layer/">previous post</a> this is the new hierarchy for persisting drools runtime into a HashMap.</p>
<div id="attachment_139" class="wp-caption aligncenter" style="width: 436px"><a href="http://locademiaz.files.wordpress.com/2011/02/droolspersistenceontopofhashmapimplementation.png"><img src="http://locademiaz.files.wordpress.com/2011/02/droolspersistenceontopofhashmapimplementation.png?w=426&#038;h=319" alt="Drools abstract storage persistence diagram" title="Drools abstract storage persistence diagram" width="426" height="319" class="size-full wp-image-139" /></a><p class="wp-caption-text">Drools abstract storage persistence diagram</p></div>
<p style="text-align:justify;">
I’ll try to explain the most relevant objects in the diagram relating them to JPA components.
</p>
<dl>
<dt>MapBasedPersistenceContext</dt>
<dd>behaves like the EntityManager, it stores all objects which are not yet commited. Finding objects is also resolved through this interface, for support this behavior it has to have access to the <em>KnowledgeSessionStorage</em>.
</dd>
<dt>KnowledgeSessionStorage</dt>
<dd>
represents the real persistent storage. This is the extension point for support any other non-JPA implementation. It provides saveOrUpdate and find methods and is the responsible to assign id’s to the entities.
</dd>
<dt>ManualTransactionManager</dt>
<dd>
as we cannot rely on JTA to manage our session Drools hooks explicit calls whenever things should be serialized. This component must access the <em>NonTransactionalPersistenceSession</em> to get the entities waiting for being persisted into the <em>KnowledgeSessionStorage</em>.
</dd>
</dl>
<h3>JBPM5</h3>
<p style="text-align:justify;">
The same concepts have been applied into JBPM5 codebase and we have there proper extensions for managing process semantics.
</p>
<p style="text-align:justify;">
You’ll find there:</p>
<ul>
<li>MapBasedProcessPersistenceContext</li>
<li>ProcessStorage</li>
<li>ManualProcessTransactionManager</li>
<li>etc</li>
</ul>
<h3>Usage</h3>
<p style="text-align:justify;">
You must setup the environment you gonna pass to the JPAKnowledgeService (still keeping the name for backward compatibility) setting the <em>TRANSACTION_MANAGER</em> and <em>PERSISTENCE_CONTEXT_MANAGER</em> keys. For this I have just created simple factories but you can build them the way you want.
</p>
<p style="text-align:justify;">
I suggest using KnowledgeSessionStorageEnvironmentBuilder or ProcessStorageEnvironmentBuilder. There doesn’t exist a default implementation of this storage, the one on top of HashMap is only used for testing porposes, so you have to pass to the builder your own implementation of the desired storage.
</p>
<h3>Testing further implementations</h3>
<p style="text-align:justify;">
To test this two implementations (and any new one which wants to respect the drools persistence semantic) together, I have created a simple set of abstract tests(*).<br />
For Drools Expert:<br />
<a href="https://github.com/droolsjbpm/droolsjbpm/blob/master/drools-persistence-jpa/src/test/java/org/drools/persistence/map/impl/MapPersistenceTest.java">https://github.com/droolsjbpm/droolsjbpm/[...]/MapPersistenceTest.java</a><br />
For JBPM5<br />
<a href="https://github.com/krisv/jbpm/blob/master/jbpm-persistence-jpa/src/test/java/org/jbpm/persistence/map/impl/MapPersistenceTest.java">https://github.com/krisv/jbpm/[...]/MapPersistenceTest.java</a><br />
In a future will be great to abstract the current tests on JPA to be able to run abstract of the lower persistence layer.
</p>
<h3>What’s next</h3>
<p style="text-align:justify;">
Clean up this interfaces a bit more and start working on a DB Berkley implementation
</p>
<p><sub>(*) tests names are not declarative enough, I’m holding a commit for this until coming repository split is done</sub></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/locademiaz.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/locademiaz.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/locademiaz.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/locademiaz.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/locademiaz.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/locademiaz.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/locademiaz.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/locademiaz.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/locademiaz.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/locademiaz.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/locademiaz.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/locademiaz.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/locademiaz.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/locademiaz.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=137&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://locademiaz.wordpress.com/2011/02/07/drools-persistence-on-top-of-hashmap/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<georss:point>-34.608418 -58.373161</georss:point>
		<geo:lat>-34.608418</geo:lat>
		<geo:long>-58.373161</geo:long>
		<media:content url="http://1.gravatar.com/avatar/138ff7a37f402e8887945b9ce927ddea?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">diega</media:title>
		</media:content>

		<media:content url="http://locademiaz.files.wordpress.com/2011/02/droolspersistenceontopofhashmapimplementation.png" medium="image">
			<media:title type="html">Drools abstract storage persistence diagram</media:title>
		</media:content>
	</item>
		<item>
		<title>Drools Abstract Persistence Layer</title>
		<link>http://locademiaz.wordpress.com/2011/01/28/drools-abstract-persistence-layer/</link>
		<comments>http://locademiaz.wordpress.com/2011/01/28/drools-abstract-persistence-layer/#comments</comments>
		<pubDate>Fri, 28 Jan 2011 13:28:58 +0000</pubDate>
		<dc:creator>diega</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://locademiaz.wordpress.com/?p=126</guid>
		<description><![CDATA[Introduction On the past two months, and under Intalio’s sponsorship, I’ve been working adding a new persistence layer into Drools. The main goal of this is to support Berlkey DB as persistent backend. Added abstractions are on that direction. The approach for this task was to work on top of the current drools-persistence-jpa module. Is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=126&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>
On the past two months, and under <a href="http://www.intalio.com">Intalio’s</a> sponsorship, I’ve been working adding a new persistence layer into Drools. The main goal of this is to support Berlkey DB as persistent backend. Added abstractions are on that direction.<br />
The approach for this task was to work on top of the current drools-persistence-jpa module. Is assumed this module is tested enough (through junit or merely day-to-day usage) and this is the one who defines the semantics which drools persistent applications should attach.
</p>
<h3>Little background on managing persistence</h3>
<p>
When you use the engine in a regular way, you obtain the ksession through the kbase and it doesn’t know anything about how to persist its state. To provide the ksession with persistence capabilities Drools makes use of the command pattern. That way, instead of creating it directly from the kbase you go through a factory which will return a decorator which will handle how and where the state is persisted. Being a decorator, at this point, will be totally transparent to the user whether or not the state is persisted.
</p>
<h3>Abstracting persistence</h3>
<p>
As the name dictates, drools-persistence-jpa module is heavily oriented to JPA usage. Then, what we have made here was to clean up the use of JPA interfaces and move them into this module.
</p>
<p>
The most used interface by JPA is the EntityManager, this one was abstracted by the PersistenceContext interface which now has specific methods for persisting SessionInfo’s and WorkItemInfo’s.<br />
Internally Drools uses different scopes for dealing with persistenceContext’s, one for the whole application and one for each command. This behaviour has also been abstracted into PersistenceContextManager.
</p>
<div id="attachment_127" class="wp-caption aligncenter" style="width: 436px"><a href="http://locademiaz.files.wordpress.com/2011/01/droolsabstractpersistencelayer.png"><img src="http://locademiaz.files.wordpress.com/2011/01/droolsabstractpersistencelayer.png?w=426&#038;h=319" alt="Persistence layer before refactor" title="Persistence Layer Before Refactor" width="426" height="319" class="size-full wp-image-127" /></a><p class="wp-caption-text">Persistence layer before refactor</p></div><br />
<div id="attachment_128" class="wp-caption aligncenter" style="width: 436px"><a href="http://locademiaz.files.wordpress.com/2011/01/droolsabstractpersistencelayer-1.png"><img src="http://locademiaz.files.wordpress.com/2011/01/droolsabstractpersistencelayer-1.png?w=426&#038;h=319" alt="Persistence layer after refactor" title="Persistence layer after refactor" width="426" height="319" class="size-full wp-image-128" /></a><p class="wp-caption-text">Persistence layer after refactor</p></div>
<h3>Backward compatibility</h3>
<p>
Other important aspect of this refactor is that maintains backward compatiblity. That means that, for the moment, you shouldn’t notice any difference if you already have your JPA application running. Current way to configure the ksession is still the same but we’ll add some new in the future, which, I wish, will end up being more polish and abstract.
</p>
<h3>JBPM5</h3>
<p>
This persistence refactor also applies for jbpm5 which now have a ProcessPersistenceContext and a ProcessPersistenceContextManager.
</p>
<h3>What’s next</h3>
<p>
In a comming post I’ll show a reference implementation on the top of a regular HashMap.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/locademiaz.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/locademiaz.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/locademiaz.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/locademiaz.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/locademiaz.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/locademiaz.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/locademiaz.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/locademiaz.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/locademiaz.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/locademiaz.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/locademiaz.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/locademiaz.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/locademiaz.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/locademiaz.wordpress.com/126/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=126&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://locademiaz.wordpress.com/2011/01/28/drools-abstract-persistence-layer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<georss:point>-34.608418 -58.373161</georss:point>
		<geo:lat>-34.608418</geo:lat>
		<geo:long>-58.373161</geo:long>
		<media:content url="http://1.gravatar.com/avatar/138ff7a37f402e8887945b9ce927ddea?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">diega</media:title>
		</media:content>

		<media:content url="http://locademiaz.files.wordpress.com/2011/01/droolsabstractpersistencelayer.png" medium="image">
			<media:title type="html">Persistence Layer Before Refactor</media:title>
		</media:content>

		<media:content url="http://locademiaz.files.wordpress.com/2011/01/droolsabstractpersistencelayer-1.png" medium="image">
			<media:title type="html">Persistence layer after refactor</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple Drools Rule Flow to BPMN2 migration tool</title>
		<link>http://locademiaz.wordpress.com/2010/12/28/simple-drools-rule-flow-to-bpmn2-migration-tool/</link>
		<comments>http://locademiaz.wordpress.com/2010/12/28/simple-drools-rule-flow-to-bpmn2-migration-tool/#comments</comments>
		<pubDate>Tue, 28 Dec 2010 03:16:56 +0000</pubDate>
		<dc:creator>diega</dc:creator>
				<category><![CDATA[drools]]></category>
		<category><![CDATA[flow]]></category>
		<category><![CDATA[jbpm]]></category>

		<guid isPermaLink="false">http://locademiaz.wordpress.com/?p=116</guid>
		<description><![CDATA[For ease the transition from Drools Flow files to the new BPMN2 standard drools gives you a nice but hidden feature, a XmlBPMNProcessDumper. This tiny piece takes a RuleFlowProcess instance and spits nice well formed BPMN2 files. So, for making your life just a little better, I&#8217;ve created a project on github exposing this internal [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=116&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">For ease the transition from Drools Flow files to the new BPMN2 standard drools gives you a nice but hidden feature, a XmlBPMNProcessDumper.<br />
This tiny piece takes a RuleFlowProcess instance and spits nice well formed BPMN2 files.<br />
So, for making your life just a little better, I&#8217;ve created a project on github exposing this internal piece with a nice interface. Take a look at the class RuleFlow2BPMN2Migrator in</p>
<p style="text-align:justify;"><a href="https://github.com/diega/rf-bpmn2-migrator">https://github.com/diega/rf-bpmn2-migrator<br />
</a><br />
Enjoy.</p>
<p style="text-align:justify;"><sub>Disclaimer: calling a 7-line class <em>a tool</em> isn&#8217;t fair enough, but you know&#8230;</sub></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/locademiaz.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/locademiaz.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/locademiaz.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/locademiaz.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/locademiaz.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/locademiaz.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/locademiaz.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/locademiaz.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/locademiaz.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/locademiaz.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/locademiaz.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/locademiaz.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/locademiaz.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/locademiaz.wordpress.com/116/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=116&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://locademiaz.wordpress.com/2010/12/28/simple-drools-rule-flow-to-bpmn2-migration-tool/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<georss:point>-34.608418 -58.373161</georss:point>
		<geo:lat>-34.608418</geo:lat>
		<geo:long>-58.373161</geo:long>
		<media:content url="http://1.gravatar.com/avatar/138ff7a37f402e8887945b9ce927ddea?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">diega</media:title>
		</media:content>
	</item>
		<item>
		<title>Are you ready for Drools 5.2 + jbpm5?</title>
		<link>http://locademiaz.wordpress.com/2010/12/16/are-you-ready-for-drools-5-2/</link>
		<comments>http://locademiaz.wordpress.com/2010/12/16/are-you-ready-for-drools-5-2/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 20:23:19 +0000</pubDate>
		<dc:creator>diega</dc:creator>
				<category><![CDATA[drools]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[jboss]]></category>

		<guid isPermaLink="false">http://locademiaz.wordpress.com/?p=107</guid>
		<description><![CDATA[Great things are happening into the core of Drools and it will impact into the whole community. This post is not about the great features we gonna have soon but about how to make the transition painless. From the developer point of view things are getting better and better. Git migration Maven 3 compliance Repository [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=107&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Great things are happening into the core of Drools and it will impact into the whole community.<br />
This post is not about the great features we gonna have soon but about how to make the transition painless.<br />
From the <strong>developer point of view</strong> things are getting better and better.</p>
<ul> Git <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Git-migration-plans-keep-it-as-similar-to-SVN-as-possible-td2091431.html">migration</a><br />
Maven 3 <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Build-upgraded-to-maven-3-on-trunk-td1965896.html">compliance</a><br />
Repository <a href="http://drools-java-rules-engine.46999.n3.nabble.com/classpath-files-within-drools-trunk-td785104.html">cleanup</a> (no more .classpath and .project files)<br />
Guvnor building coming less and less painful<br />
Huge internal refactors and optimizations</ul>
<p>The major of this tasks were leaded by <a href="http://twitter.com/geoffreydesmet">ge0ffrey</a> who has made our lives a lot better :)</p>
<p>As <strong>regular user</strong> of the framework when you finally decide to move from 5.1.1 to 5.2 you will find a big difference. Drools Flow is gone&#8230; but it has reborn as JBPM5!.<br />
So the concepts remains the same but you&#8217;ll need to adjust your dependencies and make a reorganization of your imports. This is the first step on breaking backward compatibility preparing us for the big crash arriving on 6.0 :)<br />
Basically u gonna need to add</p>
<pre class="brush: xml; light: true;">
&lt;depdency&gt;
  &lt;groupId&gt;org.jbpm&lt;/groupId&gt;
  &lt;artifactId&gt;jbpm-[flow | persistence-jpa | bpm2 | ...]&lt;/artifactId&gt;
  &lt;version&gt;${jbpm.version}&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<p>Doing so you should change a lot of your org.drools packages into org.jbpm.</p>
<p>w00t</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/locademiaz.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/locademiaz.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/locademiaz.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/locademiaz.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/locademiaz.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/locademiaz.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/locademiaz.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/locademiaz.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/locademiaz.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/locademiaz.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/locademiaz.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/locademiaz.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/locademiaz.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/locademiaz.wordpress.com/107/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=107&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://locademiaz.wordpress.com/2010/12/16/are-you-ready-for-drools-5-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>-34.608418 -58.373161</georss:point>
		<geo:lat>-34.608418</geo:lat>
		<geo:long>-58.373161</geo:long>
		<media:content url="http://1.gravatar.com/avatar/138ff7a37f402e8887945b9ce927ddea?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">diega</media:title>
		</media:content>
	</item>
		<item>
		<title>New Guvnor Feature &#8211; Rule Templates</title>
		<link>http://locademiaz.wordpress.com/2010/05/28/new-guvnor-feature-rules-templates/</link>
		<comments>http://locademiaz.wordpress.com/2010/05/28/new-guvnor-feature-rules-templates/#comments</comments>
		<pubDate>Fri, 28 May 2010 17:49:05 +0000</pubDate>
		<dc:creator>diega</dc:creator>
				<category><![CDATA[drools]]></category>
		<category><![CDATA[guvnor]]></category>
		<category><![CDATA[screencast]]></category>
		<category><![CDATA[cuarn]]></category>

		<guid isPermaLink="false">http://locademiaz.wordpress.com/?p=95</guid>
		<description><![CDATA[Here is a screencast showing guvnor rule template features As you can see here,  the Template Editor is an extension of the famous Rule Editor which now has a Template Data tab. On this tab you&#8217;ll find a grid having the template placeholders (a.k.a. &#8220;template keys&#8221;) as columns. So in your knowledge base you&#8217;ll finally [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=95&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is a screencast showing guvnor rule template features</p>
<div class='embed-vimeo' style='text-align:center;'><iframe src='http://player.vimeo.com/video/12112602' width='400' height='300' frameborder='0'></iframe></div>
<p>As you can see here,  the Template Editor is an extension of the famous Rule Editor which now has a Template Data tab. On this tab you&#8217;ll find a grid having the template placeholders (a.k.a. &#8220;template keys&#8221;) as columns. So in your knowledge base you&#8217;ll finally add the rules generated by the <strong>drools-template</strong> module, using the data into the grid and the parametrized rule that you&#8217;ve created in the editor.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/locademiaz.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/locademiaz.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/locademiaz.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/locademiaz.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/locademiaz.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/locademiaz.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/locademiaz.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/locademiaz.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/locademiaz.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/locademiaz.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/locademiaz.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/locademiaz.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/locademiaz.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/locademiaz.wordpress.com/95/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=95&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://locademiaz.wordpress.com/2010/05/28/new-guvnor-feature-rules-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>-34.608418 -58.373161</georss:point>
		<geo:lat>-34.608418</geo:lat>
		<geo:long>-58.373161</geo:long>
		<media:content url="http://1.gravatar.com/avatar/138ff7a37f402e8887945b9ce927ddea?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">diega</media:title>
		</media:content>
	</item>
		<item>
		<title>Drools Flow :: Work Items</title>
		<link>http://locademiaz.wordpress.com/2010/04/19/drools-flow-work-items/</link>
		<comments>http://locademiaz.wordpress.com/2010/04/19/drools-flow-work-items/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 15:09:24 +0000</pubDate>
		<dc:creator>diega</dc:creator>
				<category><![CDATA[drools]]></category>
		<category><![CDATA[jboss]]></category>
		<category><![CDATA[jbug]]></category>
		<category><![CDATA[work items]]></category>

		<guid isPermaLink="false">http://locademiaz.wordpress.com/?p=39</guid>
		<description><![CDATA[Introduction Working on improve our knowledge about the Drools platform and to give something back to the community. This time we&#8217;ll discuss a language extension called Work Items. The official documentation says: &#8220;[Drools Flow] offers constructs that are closely related to the problem the user is trying to solve&#8221;. In other words, creating your own [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=39&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p style="text-align:justify;">Working on improve our knowledge about the <a href="http://www.jboss.org/drools">Drools</a> platform and to give something back to the community. This time we&#8217;ll discuss a language extension called Work Items. The <a href="http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-flow/html/ch.Domain_Specific_Processes.html">official</a> documentation says: &#8220;[Drools Flow] offers constructs that are closely related to the problem the user is trying to solve&#8221;. In other words, creating your own WorkItems lets you extend the business modeling language to a domain oriented way.<br />
Creating a language for your process gives you an enormous flexibility in what you can express. The funny thing is that with this great power doesn&#8217;t come a great responsibility, meaning there is no more responsibility than needed to write any bored and unflexible process language.</p>
<p><span id="more-39"></span></p>
<h1>Creating Work Items</h1>
<p style="text-align:justify;">As I&#8217;m talking to business analysts that have everything organized, I can ask you to look at your white boards closely and think which nodes have actions that involve the process itself. What needs to be achieved in every node, not how it will be made. Once you have your palette in mind you can refer to <a href="http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-flow/html/ch.Domain_Specific_Processes.html#d0e1821">8.2. Example: Notifications</a> of the official documentation to learn how to integrate it with the Eclipse Flow Editor.<br />
If you are a sharp vi-editor pal and want to get your hands dirty writing BPMN2 xmls on your own, you have to know that Work Items in Drools Flow are represented with Task nodes and they use its taskName atributte to relate it with the WorkItemHandler (a.k.a &#8220;where action happens&#8221;).<br />
In this example you can see it</p>
<pre class="brush: xml; gutter: false;">&amp;lt;definition&amp;gt;
  ...
  &amp;lt;process&amp;gt;
    ...
    &amp;lt;task id=&amp;quot;_2&amp;quot; name=&amp;quot;SafePoint&amp;quot; tns:taskName=&amp;quot;SafePoint&amp;quot; /&amp;gt;
    ...
  &amp;lt;/process&amp;gt;
  ...
&amp;lt;/definition&amp;gt;</pre>
<p style="text-align:justify;">To get more information about Task nodes you can refer to the BPMN2 draft specification <a href="http://www.omg.org/cgi-bin/doc?dtc/09-08-14.pdf">here</a>, chapter 10.2.3<br />
It&#8217;s important to note that you only define what has to be done, not how. Keep reading if you are curious about that :)</p>
<h1>Writing WorkItemsHandlers</h1>
<p style="text-align:justify;">Running your own solution for a given Work Item is as easy as telling the KnowledgeSession which handler will react when the process reaches one of this nodes. This is done through the WorkItemManager obtained from the ksession.<br />
ksession.getWorkItemManager().registerWorkItemHandler(&#8220;MyVerySpecialWorkDomainAttached&#8221;, new MyVerySpecialWorkDomainAttachedHandler());<br />
MyVerySpecialWorkDomainAttachedHandler implements org.drools.runtime.process.WorkItemHandler which has two methods: executeWorkItem and abortWorkItem, pretty autodescriptive names.<br />
Now every time your session runs the process, it will execute your registered handler. Cool huh?<br />
Only one caveat! Remember to reregister the handlers if you load the session from a persistent storage, because this information doesn&#8217;t belong to the runtime of the session thus is not persisted</p>
<h1>Work Items behind the scenes</h1>
<p style="text-align:justify;">As the business analyst defines the semantics about Work Item, it is up to the developer to define how this will be implemented. Part of this decision involves dealing with the flow of the process, meaning if it should or should not be paused until the action finishes its execution. To inform the session that the Work Item has been completed, this has to be done through WorkItemManager, usually as follows:</p>
<p style="text-align:left;">• if you are inside WorkItemHandler, manager.completeWorkItem(workItem.getId());<br />
• if you are at StatefulKnowledgeSession level, ksession.getWorkItemManager().completeWorkItem(workItemId)</p>
<p style="text-align:justify;">As you notice here, you will need the id of the managed work item.<br />
To get the list of uncompleted work item ids, it&#8217;ll depend on a contract between your application and the implementation of the handler. There have been some <a href="http://n3.nabble.com/Resuming-the-Flow-SESSION-ID-PROCESS-INSTANCE-ID-WORKITEM-ID-td607507.html">discussions</a> recently in the <a href="https://lists.jboss.org/mailman/listinfo/rules-users">mailing list</a> about who should be responsible for getting the list. From the Drools point of view <a href="http://salaboy.wordpress.com">Salaboy</a> makes a good point and <a href="http://be.linkedin.com/in/krisverlaenen">Kris</a> gives a summary of the idea.<br />
The main idea is, if you have an specific node in your domain, you are the only one who knows what information is needed to achieve the task and who you should ask for this information. Furthermore, your long-running-remote-asynchronous task is going to need information collected along your process to complete it, all this information is part of the protocol between your application/process and the outside world to react when the process reaches its node. When these external part of your system completes, the execution will alert you about the completion and should be able to inject new information to the process. Again, it is up to you to push the results into the session and continue execution.<br />
This is the general way used for implementing Human Tasks but it is the subject of some next post.</p>
<h1>Work Items in action</h1>
<p style="text-align:justify;">As a teeny-weeny example of this concepts we have developed a web application that you can download from <a href="http://dl.dropbox.com/u/36600895/WorkItemsManagerApplication.tar.bz2">here</a> and simple run it with &#8216;mvn jetty:run&#8217;.</p>
<p style="text-align:justify;">Any feedback is absolutely welcome and rewarded with a glass of cold beer at a bar in my town (only applies for people with more than two degrees of separation from me :P)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/locademiaz.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/locademiaz.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/locademiaz.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/locademiaz.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/locademiaz.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/locademiaz.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/locademiaz.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/locademiaz.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/locademiaz.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/locademiaz.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/locademiaz.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/locademiaz.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/locademiaz.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/locademiaz.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=39&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://locademiaz.wordpress.com/2010/04/19/drools-flow-work-items/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>-34.608418 -58.373161</georss:point>
		<geo:lat>-34.608418</geo:lat>
		<geo:long>-58.373161</geo:long>
		<media:content url="http://1.gravatar.com/avatar/138ff7a37f402e8887945b9ce927ddea?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">diega</media:title>
		</media:content>
	</item>
		<item>
		<title>Jetty + DataSource + JTA</title>
		<link>http://locademiaz.wordpress.com/2010/04/18/jetty-datasource-jta/</link>
		<comments>http://locademiaz.wordpress.com/2010/04/18/jetty-datasource-jta/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 03:28:23 +0000</pubDate>
		<dc:creator>diega</dc:creator>
				<category><![CDATA[drools]]></category>
		<category><![CDATA[flow]]></category>
		<category><![CDATA[javaee]]></category>
		<category><![CDATA[jbug]]></category>
		<category><![CDATA[jetty]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[jta]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[mvn]]></category>
		<category><![CDATA[bitronix]]></category>
		<category><![CDATA[datasource]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[transaction manager]]></category>

		<guid isPermaLink="false">http://locademiaz.wordpress.com/?p=52</guid>
		<description><![CDATA[Working on my next post about Drools Flow Work Items I wanted to have a one click example. This example involves a web application so I started with Jetty which fits perfect for a mvn jetty:run example. In the standalone example we run our own JNDI directory provided by Bitronix. Jetty has JNDI directory embedded [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=52&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Working on my next post about Drools Flow Work Items I wanted to have a one click example. This example involves a web application so I started with <a href="http://jetty.codehaus.org/jetty/">Jetty</a> which fits perfect for a mvn jetty:run example. In the standalone example we run our own JNDI directory provided by Bitronix. Jetty has JNDI directory embedded so we have to register the datasource and the transaction manager. Doing this task for a totally jetty noob could be a little difficult and time consuming. So, hoping nobody has to spend too much time on this, I&#8217;ll try to summarize the steps I did to make this.<br />
<span id="more-52"></span></p>
<h3>Jetty configuration files</h3>
<p>There are two main configuration files: jetty.xml and jetty-env.xml. The first one is for configuring the whole server and the last for your specifc context (the webapp). To load the first one you have to configure the maven plugin to set the location.</p>
<pre class="brush: xml; gutter: false; toolbar: false;">
&lt;plugin&gt;
  &lt;groupId&gt;org.mortbay.jetty&lt;/groupId&gt;
  &lt;artifactId&gt;maven-jetty-plugin&lt;/artifactId&gt;
  &lt;configuration&gt;
    &lt;jettyConfig&gt;src/main/webapp/WEB-INF/jetty.xml&lt;/jettyConfig&gt;
  &lt;/configuration&gt;
  [...]
&lt;/plugin&gt;
</pre>
<p>The jetty-env.xml file will be auto loaded from your src/main/webapp/WEB-INF folder.</p>
<h3>Datasources and jetty-env.xml file</h3>
<p>Below, you can see how a WebAppContext is configured (pay attention to how readable this xml is). This is the way you expose objects in the JNDI directory: create a <em>Resource</em> into the jetty-env.xml file passing as first argument, the entry, in the directory and as second argument the object itself. In this example we are exposing a pooled datasource provided by H2, giving it a name that we&#8217;ll refer in persistence.xml as jta-data-source prefixed by java:comp/env/.</p>
<pre class="brush: xml; gutter: false;">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;!DOCTYPE Configure PUBLIC &quot;-//Mort Bay Consulting//DTD Configure//EN&quot; &quot;http://jetty.mortbay.org/configure.dtd&quot;&gt;
&lt;Configure class=&quot;org.mortbay.jetty.webapp.WebAppContext&quot;&gt;
    &lt;New id=&quot;DSTest&quot; class=&quot;org.mortbay.jetty.plus.naming.Resource&quot;&gt;
        &lt;Arg&gt;jdbc/testDS&lt;/Arg&gt;
        &lt;Arg&gt;
            &lt;New id=&quot;poolingDS&quot; class=&quot;bitronix.tm.resource.jdbc.PoolingDataSource&quot;&gt;
                &lt;Set name=&quot;uniqueName&quot;&gt;foobar&lt;/Set&gt;
                &lt;Set name=&quot;className&quot;&gt;org.h2.jdbcx.JdbcDataSource&lt;/Set&gt;
                &lt;Set name=&quot;allowLocalTransactions&quot;&gt;true&lt;/Set&gt;
                &lt;Get name=&quot;driverProperties&quot;&gt;
                    &lt;Put name=&quot;user&quot;&gt;sa&lt;/Put&gt;
                    &lt;Put name=&quot;password&quot;&gt;sasa&lt;/Put&gt;
                    &lt;Put name=&quot;URL&quot;&gt;jdbc:h2:/tmp/droolsflow.db&lt;/Put&gt;
                &lt;/Get&gt;
                &lt;Set name=&quot;maxPoolSize&quot;&gt;3&lt;/Set&gt;
                &lt;Call name=&quot;init&quot; /&gt;
            &lt;/New&gt;
        &lt;/Arg&gt;
    &lt;/New&gt;
&lt;/Configure&gt;
</pre>
<p>Finally you have to configure web.xml to expose the resource to your web application.</p>
<pre class="brush: xml; gutter: false; toolbar: false;">
&lt;web-app&gt;
...
    &lt;resource-ref&gt;
        &lt;description&gt;My DataSource Reference&lt;/description&gt;
        &lt;res-ref-name&gt;jdbc/testDS&lt;/res-ref-name&gt;
        &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
        &lt;res-auth&gt;Container&lt;/res-auth&gt;
    &lt;/resource-ref&gt;
&lt;/web-app&gt;
</pre>
<h3>Transaction Manager &amp; jetty.xml</h3>
<p>Now it&#8217;s time to configure the Transaction Manager, so we will use Bitronix which provides a maven+jetty plugin. To start using it, you have to add it as a dependency of the maven-jetty-plugin in the corresponding section as follows:</p>
<pre class="brush: xml; gutter: false;">
            &lt;plugin&gt;
                &lt;groupId&gt;org.mortbay.jetty&lt;/groupId&gt;
                &lt;artifactId&gt;maven-jetty-plugin&lt;/artifactId&gt;
                &lt;configuration&gt;
                    &lt;jettyConfig&gt;src/main/webapp/WEB-INF/jetty.xml&lt;/jettyConfig&gt;
                &lt;/configuration&gt;
                &lt;dependencies&gt;
                    &lt;dependency&gt;
                        &lt;groupId&gt;org.codehaus.btm&lt;/groupId&gt;
                        &lt;artifactId&gt;btm-jetty6-lifecycle&lt;/artifactId&gt;
                        &lt;version&gt;1.3.3&lt;/version&gt;
                    &lt;/dependency&gt;
                    &lt;dependency&gt;
                        &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
                        &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
                        &lt;version&gt;1.4.2&lt;/version&gt;
                    &lt;/dependency&gt;
                    &lt;dependency&gt;
                        &lt;groupId&gt;log4j&lt;/groupId&gt;
                        &lt;artifactId&gt;log4j&lt;/artifactId&gt;
                        &lt;version&gt;1.2.14&lt;/version&gt;
                    &lt;/dependency&gt;
                &lt;/dependencies&gt;
            &lt;/plugin&gt;
</pre>
<p>Next, you need to tell jetty to associate the Transaction Manager to start and shutdown the server life cycle. All this goes into jetty.xml:</p>
<pre class="brush: xml; gutter: false;">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;!DOCTYPE Configure PUBLIC &quot;-//Mort Bay Consulting//DTD Configure//EN&quot; &quot;http://jetty.mortbay.org/configure.dtd&quot;&gt;

&lt;Configure id=&quot;Server&quot; class=&quot;org.mortbay.jetty.Server&quot;&gt;
    &lt;Call name=&quot;getConfiguration&quot; class=&quot;bitronix.tm.TransactionManagerServices&quot;&gt;
        &lt;Set name=&quot;serverId&quot;&gt;jetty-btm-node0&lt;/Set&gt;
        &lt;Set name=&quot;logPart1Filename&quot;&gt;
            &lt;SystemProperty name=&quot;jetty.home&quot; default=&quot;.&quot; /&gt;
            btm1.tlog
        &lt;/Set&gt;
        &lt;Set name=&quot;logPart2Filename&quot;&gt;
            &lt;SystemProperty name=&quot;jetty.home&quot; default=&quot;.&quot; /&gt;
            btm2.tlog
        &lt;/Set&gt;
    &lt;/Call&gt;
    &lt;Call name=&quot;addLifeCycle&quot;&gt;
        &lt;Arg&gt;
            &lt;New class=&quot;bitronix.tm.integration.jetty6.BTMLifeCycle&quot; /&gt;
        &lt;/Arg&gt;
    &lt;/Call&gt;

    &lt;New class=&quot;org.mortbay.jetty.plus.naming.Transaction&quot;&gt;
        &lt;Arg&gt;
            &lt;Call name=&quot;getTransactionManager&quot; class=&quot;bitronix.tm.TransactionManagerServices&quot; /&gt;
        &lt;/Arg&gt;
    &lt;/New&gt;
&lt;/Configure&gt;
</pre>
<h2>Conclusion</h2>
<p>After this xml battle, you are able to run any JPA+JTA application inside your jetty environment with minimum effort, just mvn jetty:run. All this was especially applied to run a Drools Flow application with persistent StatefullKnowledgeSession, which, btw, runs like a charm :)</p>
<h2>Bonus stage</h2>
<h3>Remote debugging your mvn jetty:run with Eclipse</h3>
<p>If you want to debug any maven application (in particular jetty running inside maven), try to execute mvnDebug jetty:run, which starts port 8000 and waits until Eclipse connects to it. To create a remote application debug configuration, go to Run &gt; Debug Configurations &gt; Remote Java Application and set port 8000; in the source tab you can attach the sources where you want to put your breakpoints, and finally click the Debug button.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/locademiaz.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/locademiaz.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/locademiaz.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/locademiaz.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/locademiaz.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/locademiaz.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/locademiaz.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/locademiaz.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/locademiaz.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/locademiaz.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/locademiaz.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/locademiaz.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/locademiaz.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/locademiaz.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=52&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://locademiaz.wordpress.com/2010/04/18/jetty-datasource-jta/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<georss:point>-34.608418 -58.373161</georss:point>
		<geo:lat>-34.608418</geo:lat>
		<geo:long>-58.373161</geo:long>
		<media:content url="http://1.gravatar.com/avatar/138ff7a37f402e8887945b9ce927ddea?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">diega</media:title>
		</media:content>
	</item>
		<item>
		<title>Sobre la Programación Orientada a IDE©</title>
		<link>http://locademiaz.wordpress.com/2009/09/27/sobre-la-programacion-orientada-a-ide%c2%a9/</link>
		<comments>http://locademiaz.wordpress.com/2009/09/27/sobre-la-programacion-orientada-a-ide%c2%a9/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 13:02:00 +0000</pubDate>
		<dc:creator>diega</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[jboss developer studio]]></category>
		<category><![CDATA[jbug]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[mvn]]></category>

		<guid isPermaLink="false">http://locademiaz.wordpress.com/2009/09/27/sobre-la-programacion-orientada-a-ide%c2%a9</guid>
		<description><![CDATA[Hace algún tiempo que vengo luchando contra este concepto[*]. La idea viene de la falacia que todo hay que hacerlo desde dentro de la IDE. Así, la IDE es la que termina guiando nuestro desarrollo y volviéndolo uno con la decisiones unilaterales que han tomado sus desarrolladores.No estoy para nada en contra de las IDE, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=31&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hace algún tiempo que vengo luchando contra este concepto[*]. La idea viene de la falacia que todo hay que hacerlo desde dentro de la IDE. Así, la IDE es la que termina guiando nuestro desarrollo y volviéndolo uno con la decisiones unilaterales que han tomado sus desarrolladores.<br />No estoy para nada en contra de las IDE, solo de las IDE que te obligan a hacer las cosas de la manera que se les antoja. Ésta es una herramienta y no quiero que me obligue a nada, yo quiero usarla como se me antoje y mi profesionalismo me indique para <span style="font-style:italic;">expresar mi arte</span>.</p>
<p>Yendo al contexto Java, que es donde me siento <strike>cómodo</strike> seguro por el momento, me he encontrado con incontables casos donde a la pregunta de &#8220;cómo es su ciclo de deploy&#8221; la respuesta comienza con &#8220;exportamos el proyecto desde eclipse&#8221;&#8230;<br />Por qué esto está mal (sin orden particular)?<br />• Se depende de un humano para armar &#8216;entregables&#8217; (no hay integración continua)<br />• Atenta contra la posibilidad de incluir a un nuevo integrante al equipo que haga uso de otra herramienta<br />• Tenemos que manejar las dependencias desde el eclipse<br />Otros efectos colaterales:<br />• Tendencia a ensuciar los controladores de versiones con cosas propias de las IDE<br />• Tendencia a nunca entender lo que una IDE hace tan mágicamente (aunque esto es algo inherente a la estupidez en cualquier contexto)<br />Soluciones a esto:<br />• Uso de Maven</p>
<p>Por qué Maven?<br />Maven no es nada de otro planeta ni hace magias oscuras. Hace muy pocas cosas y las hace bien. Mediante el uso de Maven se obtienen algunos puntos muy positivos: controlar dependencias, manejar ciclos de deploy (incluyendo el empaquetado) y unificar (de manera IDE agnóstica) convenciones a la hora de trabajar. Ésto último tiene un punto a destacar alucinante, que venga alguien totalmente ajeno a nuestro desarrollo y no se sienta [tan] perdido frente a cientos de archivos de código; va a saber dónde estan los fuentes, dónde buscar tests, dónde mirar a grandes rasgos qué bibliotecas se usan y va a poder generar un entregable corriendo un solo comando.</p>
<p>Qué es lo peor que podés hacer?<br />Intentar ajustar maven a tu proyecto y no al revés. Maven es una herramienta para organizar, que si bien deja que modifiques sus convenciones al hacerlo estarías perdiendo muchas de las cosas que destaqué en la pregunta anterior. Cuando te convenzas que estas son las cosas que querés que tu proyecto cumpla, pagá el precio por haber comenzado por la senda del mal y purga tu alma moviendo archivos y repensando los paquetes que tiene tu sistema.</p>
<p>Qué es algo feo feo de ver?<br />A alguien usando JBoss Developer Studio para mostrar las maravillas de Seam (básicamente hot deploy) cuando realmente conciliar estas maravillas con las &#8216;buenas prácticas&#8217; antes mencionadas es imposible (y lo peor es que la mayoría de la gente valora más un entorno de desarrollo a-La PHP en lugar de un proyecto ordenado).</p>
<p>Quiénes son los más horrorizados con no comer/ver la tele/dormir con la IDE?<br />Los desarrolladores .Net . Ellos han comprado una serie de preceptos guiados por Visual Studio y sus wizards, que se les hace arcaico y elitista tratar de usar herramientas de línea de comando, el resto simplemente &#8220;la complican de gusto&#8221;.</p>
<p>Qué es lo que tendría que hacer un desarrollador nuevo cuando entra a un equipo?<br />• git clone  [o el scm que quieran]<br />• mvn eclipse:eclipse [o la ide que quieran]<br />• [abrir la ide y buscar las cosas como tu intuición te indica]<br />• mvn package<br />• [deploy]<br />• [probar la aplicación]</p>
<p>Qué alternativas similares hay?<br />Para Java ninguna[**] y no me parece mal. Creo que se puede confiar bastante en los desarrolladores de maven como para que guien este camino.<br />Hablar de ciclos de desarrollo en otros lenguajes no puedo, solo comentar que en C se adolece del mismo problema que generó Ant en su momento, Autoconf/Autotools son infinitamente poderosos, infinitamente complejos y no existe una manera estándar de hacer las cosas, realmente una pena; apenas crece un poquito un proyecto C meterse es una tarea heroica.</p>
<p>[*]: término que nunca antes había escuchado :)<br />[**]: ant+ivy me parece una aberración mutante</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/locademiaz.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/locademiaz.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/locademiaz.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/locademiaz.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/locademiaz.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/locademiaz.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/locademiaz.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/locademiaz.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/locademiaz.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/locademiaz.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/locademiaz.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/locademiaz.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/locademiaz.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/locademiaz.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=31&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://locademiaz.wordpress.com/2009/09/27/sobre-la-programacion-orientada-a-ide%c2%a9/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/138ff7a37f402e8887945b9ce927ddea?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">diega</media:title>
		</media:content>
	</item>
		<item>
		<title>Un poco de JAAS</title>
		<link>http://locademiaz.wordpress.com/2009/08/28/un-poco-de-jaas/</link>
		<comments>http://locademiaz.wordpress.com/2009/08/28/un-poco-de-jaas/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 11:14:00 +0000</pubDate>
		<dc:creator>diega</dc:creator>
				<category><![CDATA[autenticacion]]></category>
		<category><![CDATA[autorizacion]]></category>
		<category><![CDATA[jaas]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jbug]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[seguridad]]></category>

		<guid isPermaLink="false">http://locademiaz.wordpress.com/2009/08/28/un-poco-de-jaas</guid>
		<description><![CDATA[Un poco de JAAS Introducción: JAAS es una especifación Java con el fin de autenticar y autorizar intenciones de acceso a recursos. En en la práctica su uso más frecuente reside en la primera de estas dos intenciones. Esto, en mi opinión, se debe a que realmente la solución ofrecida para la autorización no es [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=30&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div class="note" id="Un poco de JAAS"><a name="un%20poco%20de%20jaas"></a><br />
<h1>Un poco de JAAS</h1>
<p><span style="font-size:large;">Introducción:</span><br /> <a style="color:#204A87;" href="#jaas">JAAS</a> es una especifación Java con el fin de autenticar y autorizar intenciones de acceso a recursos.<br /> En en la práctica su uso más frecuente reside en la primera de estas dos intenciones. Esto, en mi opinión, se debe a que realmente la solución ofrecida para la autorización no es demasiado agradable para el desarrollador.</p>
<p><span style="font-size:large;">Filosofía:</span><br /> JAAS está pensado para comportarse como una capa pluggeable que opera sobre <i>dominios</i> de autenticación. Su uso es totalmente transparente a través de la interfaz LoginContext que instancia todos los LoginModule del dominio especificado.<br /> La idea de JAAS es proveer mucha generalidad sobre lo que significa la autenticación ya que no todo se hace a través de un par nombre de usuario/contraseña. Para esto, un LoginModule tiene que ser capaz de pedir la información necesaria para autenticar. Siendo la invocación de los módulos a través del LoginContext, es a este a quien se le pasa una instancia que implementa la interfaz CallbackHandler. El contrato establecido podría ser &#8220;cuando me llames al login, yo te voy a pedir estos datos&#8221;. Haciendo nuevamente incapié en que esta información puede ser el nombre de usuario y la contraseña, la respuesta de un lector biométrico, la clave secreta que tiene una llave usb, etc., etc.<br />Durante el proceso de login (formalmente en el método LoginContext#commit), luego de una validación exitosa, se deja a disposición del invocador una instancia de la clase Subject. Un subject es simplemente un grupo de identidades que refieren a quien quiere ser autenticado. Algo interesante de JAAS es que no define un concepto claro de cuándo alguien está o no autenticado ya que este estado booleano acotaría la generalidad que se está intentando obtener. Podría ocurrir el caso en que alguien falle al autenticar y en este caso se le asigne una identidad fantasma con ciertos permisos según la hora del día en el que intentó la acción. En este caso tener un rol por defecto para acceder a ciertas acciones no basta. Así es que se deja que el LoginModule inserte tantos Principal como crea necesario para lo que le parezca y el que hizo el llamado de autenticación tendrá que saber interpretar el resultado. Cada Principal va a ser una implementación concreta de la interfaz que va a quedar disponible a través del subject.<br />Inmediatamente después de creada la instancia de LoginContext ya se le puede pedir el subject, este subject, al no haber pasado nunca por ningun LoginModule, va a encontrarse vacío de todo principal, pero es válido pedir su referencia.<br />Las semánticas para esta lista de Principal son múltiples, una lista vacía puede indicar un usuario todavía no autenticado, alguien autenticado que no puede hacer nada, alguien sobre el que falló la autenticación, entre otras. Así como también la presencia de Principals puede referir a múltiple información sobre el sujeto en cuestión: roles, claves públicas, vcards, etc.</p>
<p><span style="font-size:large;">Implementación:</span><br /> La solución de JAAS puede ser usada tanto para una aplicación web como <a style="color:#204A87;" href="#para">para</a> una aplicación standalone de manera similar. No existe un <i>servicio</i> de autenticación ni mucha magia detrás del hecho de entender que el LoginContext obtiene de una configuración la lista de LoginModule que tiene que instanciar para cada dominio de autenticación. Además también tiene que suministrar el callback a través de los cuales cada LoginModule requerirá datos de entrada.<br /> Los puntos oscuros de esta generalidad se encuentran fundamentalmente en dos lugares. Primero al momento de implementar el CallbackHandler, ya que el LoginModule sabe qué va a requerir pero al tener una interfaz genérica solo puede pedir <i>cualquier cosa</i> que implemente la interfaz Callback y esperar a que en runtime lo que yo quiero en mis callbacks sean bien llenados por quien los implementó. Esto se va a ver más claro con algo de código:
<ul>
<li>Al instanciar el LoginModule se le pasa un CallbackHandler.</li>
<li>En el método login el LoginModule hace uso del CallbackHandler para obtener lo que espera para autenticar.</li>
<li>Lo muestro en orden inverso ya que me parece más claro para entender el problema</li>
</ul>
<p>[LoginModule#login]<span style="background:yellow;"><br /></span><br /><span style="font-family:monospace;">RightFingerCallback fingerCallback = new RightFingerCallback();<br />USBKeyCallback() usbCallback = new USBKeyCallback()<br />callbackHandler.handle(new Callback(){fingerCallback, usbCallback});<br />metodoDeAutenticacionExtranho(fingerCallback.getFingerprintAsGifImage(), usbCallback.getKeyHardwired());</span></p>
<p>[Clase que intenta autenticar algo]<br /><span style="font-family:monospace;"><br />LoginContext loginContext = new LoginContext(&#8220;dominio-raro-y-seguro&#8221;, new CallbackHandler(){<br /> public void handle(Callback[] callbacks) throws &#8230;{<br />  for(Callback callback : callbacks){<br />   if(callback instanceof RightFingerCallback){<br />    ((RightFingerCallback) callback).setFingerprintAsGifImage(obtainFprint());<br />   } else if (callback instanceof USBKeyCallback){<br />   &#8230;<br />   }<br />  }<br /> }<br />}<br /></span>
<ul>
<li>Sí, hay instanceof&#8230; se pueden hacer en algunos contextos juegos de polimorfismo pero en la mayoría de los casos hay que enfrentarse con esta situación y es importante saber que uno va a salir ligeramente herido en este camino.</li>
</ul>
<p> El segundo lugar donde se busca generalidad es en la asignación de identidades ya que no todas las aplicaciones manejan roles, ni vcards, ni claves públicas, etc. Así se llega al punto donde así como se tienen Callbacks específicos para mis necesidades, se tienen Principal específicos para identificar la información que el autenticador me puede dar.<br /> Otra vez algo de implementación:
<ul>
<li>Los principal se agregan en el metodo commit ya que no hay que olvidar que nuestro LoginModule convive eventualmente en una cadena de módulos de autenticación y es posible que alguno de ellos no valide con lo que si completamos el subject antes de llamar a todos los login() del dominio vamos a darle identidades a nuestro sujeto que no queremos (o sí, pero estas cuestiones se manejan en cuanto a la configuración de cómo interactúan los módulos entre sí -demasiado avanzado para esta introducción conceptual-)</li>
</ul>
<p>[LoginModule#commit]<br /><span style="font-family:monospace;">&#8230;<br />getSubject().getPrincipals().add(new MyPrincipal());<br />&#8230;</span></p>
<p> Así que, una vez ejecutado el método login del LoginContext va a quedar un subject hidratado (dependiendo si autenticó) con los Principal que definirán su identidad dentro de nuestro dominio, pudiendo filtrarlos e inspeccionarlos para decidir si son autorizados o no.</p>
<p><span style="font-size:large;">Dentro de JBoss Application Server:</span><br />Siendo <a style="color:#204A87;" href="#jaas">JAAS</a> un modelo de seguridad tan independiente, el AS no puede proveer demasiado para su funcionalidad básica. Hablando de la rama 4.2.x, se cuenta con el mbean XMLLoginConfig que hace más amigable la escritura de dominios mediante xml que por defecto se encuentra en &lt;name&gt;/conf/login-config.xml, el archivo en sí es bastante autoexplicativo y por cualquier duda más allá de lo evidente, se puede consultar el dtd en docs/dtd/security_config.dtd</p>
<p><span style="font-size:large;">Resources (o &#8220;no dije mucho más de lo que aparece en los siguientes links&#8221;):</span>
<ul>
<li><a style="color:#3465A4;" href="http://www.j2ee.me/j2se/1.4.2/docs/guide/security/jaas/tutorials/GeneralAcnOnly.html">http://www.j2ee.me/j2se/1.4.2/docs/guide/security/jaas/tutorials/GeneralAcnOnly.html</a></li>
<li><a style="color:#3465A4;" href="http://www.j2ee.me/j2se/1.4.2/docs/guide/security/jaas/tutorials/SampleLoginModule.java">http://www.j2ee.me/j2se/1.4.2/docs/guide/security/jaas/tutorials/SampleLoginModule.java</a></li>
</ul>
<p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/locademiaz.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/locademiaz.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/locademiaz.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/locademiaz.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/locademiaz.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/locademiaz.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/locademiaz.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/locademiaz.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/locademiaz.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/locademiaz.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/locademiaz.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/locademiaz.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/locademiaz.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/locademiaz.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=locademiaz.wordpress.com&amp;blog=13144684&amp;post=30&amp;subd=locademiaz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://locademiaz.wordpress.com/2009/08/28/un-poco-de-jaas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/138ff7a37f402e8887945b9ce927ddea?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">diega</media:title>
		</media:content>
	</item>
	</channel>
</rss>
