<?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>fabricioepa blog - Talking about tech world</title>
	<atom:link href="http://fabricioepa.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://fabricioepa.wordpress.com</link>
	<description></description>
	<lastBuildDate>Thu, 16 Dec 2010 13:25:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='fabricioepa.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>fabricioepa blog - Talking about tech world</title>
		<link>http://fabricioepa.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://fabricioepa.wordpress.com/osd.xml" title="fabricioepa blog - Talking about tech world" />
	<atom:link rel='hub' href='http://fabricioepa.wordpress.com/?pushpress=hub'/>
		<item>
		<title>D-BUS Tips 3.0: Performing asynchronous/synchronous method invocations and dbus-binding-tool</title>
		<link>http://fabricioepa.wordpress.com/2010/12/16/d-bus-tips-3-0-performing-asynchronoussynchronous-method-invocations-and-dbus-binding-tool/</link>
		<comments>http://fabricioepa.wordpress.com/2010/12/16/d-bus-tips-3-0-performing-asynchronoussynchronous-method-invocations-and-dbus-binding-tool/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 13:09:47 +0000</pubDate>
		<dc:creator>fabricioepa</dc:creator>
				<category><![CDATA[D-BUS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tecnologia]]></category>

		<guid isPermaLink="false">http://fabricioepa.wordpress.com/?p=113</guid>
		<description><![CDATA[To easy perform a synchronous remote method invocation you have just to use GLib bindings  for DBus Proxy API (DBusGProxy), that is our first example. The second example shows how to use generated code by dbus-binding-tool to implement remote calls faster. Examples bellow are implemented accessing org.freedesktop.NetworkManager interface of NetworkManager API. Example 1 int main() [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=113&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>To easy perform a synchronous remote method invocation you have just to use GLib bindings  for DBus Proxy API (DBusGProxy), that is our first example. The second example shows how to use generated code by dbus-binding-tool to implement remote calls faster. Examples bellow are implemented accessing org.freedesktop.NetworkManager interface of <a href="http://projects.gnome.org/NetworkManager/developers/spec.html">NetworkManager API</a>.</p>
<p><strong>Example 1 </strong></p>
<pre class="brush: cpp;">

int main()
{
	g_type_init();

	GError *error = NULL;
	DBusGConnection *conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &amp;error);

	if (error != NULL) {
		g_error(&quot;D-BUS Connection error: %s&quot;, error-&gt;message);
		g_error_free(error);
	}

	if (!conn) {
		g_error(&quot;D-BUS connection cannot be created&quot;);
		return EXIT_FAILURE;
	}

	DBusGProxy *proxy = dbus_g_proxy_new_for_name(conn,
			&quot;org.freedesktop.NetworkManager&quot;,
			&quot;/org/freedesktop/NetworkManager&quot;,
			&quot;org.freedesktop.NetworkManager&quot;);

	if (!proxy) {
		g_error(&quot;Cannot create proxy&quot;);
		return EXIT_FAILURE;
	}

	g_message(&quot;Calling NetworkManager.sate synchronously&quot;);
	guint state;
	GError *error = NULL;
	if (!dbus_g_proxy_call(proxy, &quot;state&quot;, &amp;error, G_TYPE_INVALID,
			G_TYPE_UINT, &amp;state, G_TYPE_INVALID)) {
		if (error-&gt;domain == DBUS_GERROR &amp;&amp; error-&gt;code
					== DBUS_GERROR_REMOTE_EXCEPTION) {
			g_error(&quot;Caught remote method exception %s: %s&quot;,
					dbus_g_error_get_name(error),
					error-&gt;message);
		} else {
			g_error(&quot;D-BUS: %s&quot;, error-&gt;message);
		}
	}
	print_network_manager_state(state);

	g_object_unref(proxy);
	dbus_g_connection_unref(conn);
	return EXIT_SUCCESS;
}
</pre>
<p>The code is self explaining. Be careful to use the right type parameters, otherwise the call will not work, at D-Bus tutorial page you can find <a href="http://dbus.freedesktop.org/doc/dbus-tutorial.html#glib-typemappings">GLib – DBus type mapping</a>. If you want to use more complex types outside this mapping, GLib may show you the message <em>“No marshaller for signature of …” </em>and you will need to register a custom marshaller to this type, but this is a subject for future posts.</p>
<p><strong>Example 2</strong></p>
<p>A faster way to call a remote method is to generate client stub. First you need to get XML API of object interface, you can use d-feet tool to call DBus Introspectable interface and get that.</p>
<p><a href="http://fabricioepa.files.wordpress.com/2010/12/instrospect.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="instrospect" src="http://fabricioepa.files.wordpress.com/2010/12/instrospect_thumb.png?w=244&#038;h=190" border="0" alt="instrospect" width="244" height="190" /></a></p>
<p>Then execute the following command passing <a href="http://gitorious.org/dbus-glib-sample/dbus-glib-sample/blobs/master/src/network-manager-api.xml">network-manager-api.xml </a>file:</p>
<pre class="brush: bash;">

dbus-binding-tool --mode=glib-client network-manager-api.xml &gt;  network-manager-client-stub.h
</pre>
<p>And you will simply get the code ready to execute D-BUS calls and they are properly typed according to method signatures. The example show you an asynchronous call using the stub:</p>
<pre class="brush: cpp;">
#include &quot;network-manager-client-stub.h&quot;

void network_state_callback(DBusGProxy *proxy, guint state, GError *error, gpointer userdata)
{
	print_network_manager_state(state);
	g_main_loop_quit(loop);
}

static GMainLoop *loop;
int main()
{
	loop = g_main_loop_new(NULL, FALSE);
	g_type_init();

	GError *error = NULL;
	DBusGConnection *conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &amp;error);

	if (error != NULL) {
		g_error(&quot;D-BUS Connection error: %s&quot;, error-&gt;message);
		g_error_free(error);
	}

	if (!conn) {
		g_error(&quot;D-BUS connection cannot be created&quot;);
		return EXIT_FAILURE;
	}

	DBusGProxy *proxy = dbus_g_proxy_new_for_name(conn,
			&quot;org.freedesktop.NetworkManager&quot;,
			&quot;/org/freedesktop/NetworkManager&quot;,
			&quot;org.freedesktop.NetworkManager&quot;);

	if (!proxy) {
		g_error(&quot;Cannot create proxy&quot;);
		return EXIT_FAILURE;
	}

	g_message(&quot;Calling NetworkManager.sate asynchronously&quot;);
	org_freedesktop_NetworkManager_state_async(proxy, network_state_callback , NULL);

	g_message(&quot;Waiting D-BUS callback&quot;);
	g_main_loop_run(loop);

	g_message(&quot;Exiting glib mainloop&quot;);

	g_main_loop_unref(loop);
	g_object_unref(proxy);
	dbus_g_connection_unref(conn);
	return EXIT_SUCCESS;
}
</pre>
<p>See full code example in method-invocation.c at <a href="http://gitorious.org/dbus-glib-sample/">dbus-glib-sample</a> project.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabricioepa.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabricioepa.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabricioepa.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabricioepa.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabricioepa.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabricioepa.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabricioepa.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabricioepa.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabricioepa.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabricioepa.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabricioepa.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabricioepa.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabricioepa.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabricioepa.wordpress.com/113/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=113&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabricioepa.wordpress.com/2010/12/16/d-bus-tips-3-0-performing-asynchronoussynchronous-method-invocations-and-dbus-binding-tool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fce1b2a6387a8d4a7fede7a78286c4be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fabricioepa</media:title>
		</media:content>

		<media:content url="http://fabricioepa.files.wordpress.com/2010/12/instrospect_thumb.png" medium="image">
			<media:title type="html">instrospect</media:title>
		</media:content>
	</item>
		<item>
		<title>D-BUS Tips 2.0: Listening to D-BUS signals in C with D-Bus Glib bindings</title>
		<link>http://fabricioepa.wordpress.com/2010/12/02/d-bus-tips-2-0-listening-to-d-bus-signals-in-c-with-d-bus-glib-bindings/</link>
		<comments>http://fabricioepa.wordpress.com/2010/12/02/d-bus-tips-2-0-listening-to-d-bus-signals-in-c-with-d-bus-glib-bindings/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 13:55:25 +0000</pubDate>
		<dc:creator>fabricioepa</dc:creator>
				<category><![CDATA[D-BUS]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">https://fabricioepa.wordpress.com/?p=77</guid>
		<description><![CDATA[I will present two ways to handle signals from D-BUS, the first consists in use a connection filter to register callback function that should be invoked when the corresponding match occurs, the second uses a proxy. First, let us choose the signal we want to listen. To see current active D-BUS services on system (I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=77&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I will present two ways to handle signals from D-BUS, the first consists in use a connection filter to register callback function that should be invoked when the corresponding match occurs, the second uses a proxy.</p>
<p>First, let us choose the signal we want to listen. To see current active D-BUS services on system (I am using Ubuntu 10.04), you can open a debugger tool like <a href="http://live.gnome.org/DFeet/">d-feet</a> and see something like that:</p>
<p><a href="http://fabricioepa.files.wordpress.com/2010/12/debugger.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="debugger" src="http://fabricioepa.files.wordpress.com/2010/12/debugger_thumb.jpg?w=244&#038;h=217" border="0" alt="debugger" width="244" height="217" /></a></p>
<p>Let us catch ‘StateChange’ signal from NetworkManager Interface (API definition <a href="http://projects.gnome.org/NetworkManager/developers/spec.html#org.freedesktop.NetworkManager">link</a>), in our test case to dispatch this signal, you should connect or disconnect your active network connection after run the code sample.</p>
<pre class="brush: cpp;">
#include &lt;glib.h&gt;
#include &lt;dbus/dbus.h&gt;
#include &lt;dbus/dbus-glib.h&gt;
#include &lt;dbus/dbus-glib-lowlevel.h&gt;

DBusHandlerResult signal_filter(DBusConnection *connection, DBusMessage *msg,
		void *user_data)
{
	if (dbus_message_is_signal(msg, &quot;org.freedesktop.NetworkManager&quot;,
			&quot;StateChange&quot;)) {
		read_network_manager_state_change(msg);
	}
	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}

int main()
{
	GMainLoop *loop = g_main_loop_new(NULL, FALSE);
	DBusError error;

	dbus_error_init(&amp;error);
	DBusConnection *conn = dbus_bus_get(DBUS_BUS_SYSTEM, &amp;error);

	if (dbus_error_is_set(&amp;error)) {
		g_error(&quot;Cannot get System BUS connection: %s&quot;, error.message);
		dbus_error_free(&amp;error);
		return EXIT_FAILURE;
	}
	dbus_connection_setup_with_g_main(conn, NULL);

	char *rule = &quot;type='signal',interface='org.freedesktop.NetworkManager'&quot;;
	g_message(&quot;Signal match rule: %s&quot;, rule);
	dbus_bus_add_match(conn, rule, &amp;error);

	if (dbus_error_is_set(&amp;error)) {
		g_error(&quot;Cannot add D-BUS match rule, cause: %s&quot;, error.message);
		dbus_error_free(&amp;error);
		return EXIT_FAILURE;
	}

	g_message(&quot;Listening to D-BUS signals using a connection filter&quot;);
	dbus_connection_add_filter(conn, signal_filter, NULL, NULL);

	g_main_loop_run(loop);

	return EXIT_SUCCESS;
}
</pre>
<p>The filter function return <em>DBUS_HANDLER_RESULT_HANDLED</em>, other handlers will not receive this message, but in example code we want the other BUS listeners catch the network connection signal.</p>
<p>Do not forget to call <em>dbus_connection_setup_with_g_main</em> function since the connection was created from <em>dbus_bus_get function</em>, otherwise the GLib mainloop and D-BUS callbacks will not work properly and will you be very sad, belive me.</p>
<p>To read the message you can use <a href="http://dbus.freedesktop.org/doc/api/html/group__DBusMessage.html">D-BUS Message API</a>, it is part of <a href="http://dbus.freedesktop.org/doc/api/html/group__DBus.html">D-Bus low-level public API</a>.</p>
<pre class="brush: cpp;">
void read_network_manager_state_change(DBusMessage *msg)
{
	DBusError error;
	dbus_error_init(&amp;error);

	guint32 state = 0;

	if (!dbus_message_get_args(msg, &amp;error, DBUS_TYPE_UINT32, &amp;state,
			DBUS_TYPE_INVALID)) {
		g_error(&quot;Cannot read NetworkManager state change message, cause: %s&quot;, error.message);
		dbus_error_free(&amp;error);
		return;
	}
	print_network_manager_state(state);
}
</pre>
<p>The second example show how to receive the same signal, but using a proxy from remote object.</p>
<pre class="brush: cpp;">
#include &lt;glib.h&gt;
#include &lt;dbus/dbus.h&gt;
#include &lt;dbus/dbus-glib.h&gt;
#include &lt;dbus/dbus-glib-lowlevel.h&gt;

void state_changed_callback(DBusGProxy *proxy, guint32 state,
		gpointer user_data)
{
	print_network_manager_state(state);
}

int main()
{
	GMainLoop *loop = g_main_loop_new(NULL, FALSE);

	g_type_init();

	GError *error = NULL;
	DBusGConnection *conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &amp;error);

	if (error != NULL) {
		g_error(&quot;D-BUS Connection error: %s&quot;, error-&gt;message);
		g_error_free(error);
	}

	if (!conn) {
		g_error(&quot;D-BUS connection cannot be created&quot;);
		return EXIT_FAILURE;
	}

	DBusGProxy *proxy = dbus_g_proxy_new_for_name(conn,
			&quot;org.freedesktop.NetworkManager&quot;,
			&quot;/org/freedesktop/NetworkManager&quot;,
			&quot;org.freedesktop.NetworkManager&quot;);

	if (!proxy) {
		g_error(&quot;Cannot create proxy&quot;);
		return EXIT_FAILURE;
	}

	dbus_g_proxy_add_signal(proxy, &quot;StateChange&quot;, G_TYPE_UINT,
			G_TYPE_INVALID);

	dbus_g_proxy_connect_signal(proxy, &quot;StateChange&quot;,
			G_CALLBACK(state_changed_callback), NULL, NULL);

	g_message(&quot;Waiting D-BUS proxy callback for signal&quot;);
	g_main_loop_run(loop);

	return EXIT_SUCCESS;
}
</pre>
<p>Next post I will talk about asynchronous/synchronous calls.</p>
<p>Download full example code at gitorious <a href="http://gitorious.org/dbus-glib-sample">dbus-glib-sample</a> project.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabricioepa.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabricioepa.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabricioepa.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabricioepa.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabricioepa.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabricioepa.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabricioepa.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabricioepa.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabricioepa.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabricioepa.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabricioepa.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabricioepa.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabricioepa.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabricioepa.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=77&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabricioepa.wordpress.com/2010/12/02/d-bus-tips-2-0-listening-to-d-bus-signals-in-c-with-d-bus-glib-bindings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fce1b2a6387a8d4a7fede7a78286c4be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fabricioepa</media:title>
		</media:content>

		<media:content url="http://fabricioepa.files.wordpress.com/2010/12/debugger_thumb.jpg" medium="image">
			<media:title type="html">debugger</media:title>
		</media:content>
	</item>
		<item>
		<title>D-BUS Tips 1.0: Getting in D-BUS world</title>
		<link>http://fabricioepa.wordpress.com/2010/12/01/d-bus-tips-1-0-getting-in-d-bus-world/</link>
		<comments>http://fabricioepa.wordpress.com/2010/12/01/d-bus-tips-1-0-getting-in-d-bus-world/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 16:59:25 +0000</pubDate>
		<dc:creator>fabricioepa</dc:creator>
				<category><![CDATA[D-BUS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[d-bus linux ipc]]></category>

		<guid isPermaLink="false">https://fabricioepa.wordpress.com/?p=73</guid>
		<description><![CDATA[This is the first of a sequence of posts related to D-BUS communication. I guess this can help you to find an easy and painless way to work with this technology since official documentation is under development. D-Bus is a system for interprocess communication (IPC), and it is a good way to integrate operating system/desktop [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=73&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is the first of a sequence of posts related to D-BUS communication. I guess this can help you to find an easy and painless way to work with this technology since official documentation is under development.</p>
<p>D-Bus is a system for interprocess communication (IPC), and it is a good way to integrate operating system/desktop applications on linux, the windows port is under development. You can find details about “what is D-BUS?” at <a href="http://dbus.freedesktop.org/doc/dbus-tutorial.html">tutorial page</a>.</p>
<p>Next post will describe how to listen to application signals.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabricioepa.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabricioepa.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabricioepa.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabricioepa.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabricioepa.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabricioepa.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabricioepa.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabricioepa.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabricioepa.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabricioepa.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabricioepa.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabricioepa.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabricioepa.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabricioepa.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=73&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabricioepa.wordpress.com/2010/12/01/d-bus-tips-1-0-getting-in-d-bus-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fce1b2a6387a8d4a7fede7a78286c4be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fabricioepa</media:title>
		</media:content>
	</item>
		<item>
		<title>Protocol Buffers</title>
		<link>http://fabricioepa.wordpress.com/2010/11/05/protocol-buffers/</link>
		<comments>http://fabricioepa.wordpress.com/2010/11/05/protocol-buffers/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 16:54:57 +0000</pubDate>
		<dc:creator>fabricioepa</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[Tecnologia]]></category>
		<category><![CDATA[buffers]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[protocol]]></category>
		<category><![CDATA[protocol buffers]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">https://fabricioepa.wordpress.com/?p=65</guid>
		<description><![CDATA[Olá pessoal, estou postando minha apresentação sobre protocol buffers no JATIC. Esta tecnologia é uma alternativa de formato de serialização de dados frente aos que comumente usamos em aplicações (XML, JSON, CSV), ou outros formatos binários que seguem padrões estritos como ASN1, etc… Consiste um uma maneira simples de especificar a estrutura de sua informação [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=65&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Olá pessoal, estou postando minha apresentação sobre protocol buffers no <a href="http://lti.cesed.br/jatic/">JATIC</a>.</p>
<p>Esta tecnologia é uma alternativa de formato de serialização de dados frente aos que comumente usamos em aplicações (XML, JSON, CSV), ou outros formatos binários que seguem padrões estritos como ASN1, etc…</p>
<p>Consiste um uma maneira simples de especificar a estrutura de sua informação (IDL), e gerar automaticamente os objetos para encapsular as informações e métodos para serialização/deserialização.</p>
<p>Longe de se tornar um padrão internacional e inter-corporativo como XML, a proposta do PB é otimização da troca de dados, tamanho da informação, e compatibilidade com versões anteriores de mensagens, permitindo upgrades de serviço on-the-fly.</p>
<p>Por isso, desde que você tenha domínio/influência entre os serviços que irão conversar usando este protocolo sejam internos ou externos a sua corporação, pode ser uma boa alternativa de otimização.</p>
<iframe src="http://r.office.microsoft.com/r/rlidPowerPointEmbed?p1=1&#038;p2=1&#038;p3=SDD3C88AA13E398A89!247&#038;p4=" width="402" height="327" frameborder="0" scrolling="no"></iframe>
<p><a href="http://dl.dropbox.com/u/3420496/Protocol%20Buffers.pdf">Download (.pdf)</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabricioepa.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabricioepa.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabricioepa.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabricioepa.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabricioepa.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabricioepa.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabricioepa.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabricioepa.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabricioepa.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabricioepa.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabricioepa.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabricioepa.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabricioepa.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabricioepa.wordpress.com/65/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=65&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabricioepa.wordpress.com/2010/11/05/protocol-buffers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fce1b2a6387a8d4a7fede7a78286c4be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fabricioepa</media:title>
		</media:content>
	</item>
		<item>
		<title>Maemo Eclipse Integration 2nd Edition PreFinal Released</title>
		<link>http://fabricioepa.wordpress.com/2009/09/11/maemo-eclipse-integration-2nd-edition-prefinal-released/</link>
		<comments>http://fabricioepa.wordpress.com/2009/09/11/maemo-eclipse-integration-2nd-edition-prefinal-released/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 19:10:36 +0000</pubDate>
		<dc:creator>fabricioepa</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[esbox]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[maemo]]></category>
		<category><![CDATA[maemosdk]]></category>
		<category><![CDATA[n900]]></category>
		<category><![CDATA[nokia]]></category>
		<category><![CDATA[pluthon]]></category>
		<category><![CDATA[signove]]></category>
		<category><![CDATA[signove.com]]></category>

		<guid isPermaLink="false">http://fabricioepa.wordpress.com/?p=51</guid>
		<description><![CDATA[Para quem conhece os dipositivos da nokia que usam a plataforma maemo (maemo.org) segue uma boa notícia. Acabamos de lançar a versão pré-final do ambiente de desenvolvimento integrado com Eclipse IDE para estes dispositivos, daí o nome Maemo IDE Integration.  Ele também já suporta o mais novo dispositivo nokia para maemo e recém lançado no [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=51&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Para quem conhece os dipositivos da nokia que usam a plataforma maemo (<a title="maemo.org" href="http://maemo.org" target="_blank">maemo.org</a>) segue uma boa notícia. Acabamos de lançar a versão pré-final do ambiente de desenvolvimento integrado com Eclipse IDE para estes dispositivos, daí o nome Maemo IDE Integration.  Ele também já suporta o mais novo dispositivo nokia para maemo e recém lançado no mercado,  é simplesmente uma máquina clique e vejam o <a title="N900" href="http://maemo.nokia.com/n900/" target="_blank">N900</a> !!</p>
<p>Vejam as duas linhas do produto e os screenshots disponíveis em:</p>
<p><a title="ESbox" href="http://esbox.garage.maemo.org" target="_blank"><strong>ESbox</strong> </a>- IDE para aplicações C/C++ e Python, requer instalação de SDK para executar c<em>ross</em>-<em>compilation </em>para o dispositivo.</p>
<p><a title="PluThon" href="http://pluthon.garage.maemo.org" target="_blank"><strong>PluThon</strong></a>-  IDE leve para aplicações  python utilizando diretamente o dispositivo como plataforma de desenvolvimento, não requer SDK.</p>
<p>Existem muitas features novas legais além de um novo sistema de ajuda sensível  para o desenvolvedor que é dinamicamente atualizado pelos mantenedores <img src='http://s1.wp.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ! =]</p>
<p>Para criação destes dois produtos eclipse,  foi desenvolvido um o novo framework base: <strong>Mica </strong>(Maemo IDE Common Architecture -  <a href="http://mica.garage.maemo.org/2nd_edition/">http://mica.garage.maemo.org/2nd_edition/</a>), matendo a aquitetura de cada produto bastante simplificada e fácil para quem desejar colaborar ou estender os mesmos ou ainda criar o seu&#8230;.  hein? Sim o código é inteiramente open-source e tem licensa <a title="EPL" href="http://www.eclipse.org/legal/epl-v10.html" target="_blank">EPL </a>.</p>
<p>O link oficial do anúncio: <a style="text-decoration:none;" href="http://maemo.org/news/announcements/maemo_eclipse_integration_2nd_edition_prefinal_released/">http://maemo.org/news/announcements/maemo_eclipse_integration_2nd_edition_prefinal_released/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabricioepa.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabricioepa.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabricioepa.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabricioepa.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabricioepa.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabricioepa.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabricioepa.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabricioepa.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabricioepa.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabricioepa.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabricioepa.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabricioepa.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabricioepa.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabricioepa.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=51&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabricioepa.wordpress.com/2009/09/11/maemo-eclipse-integration-2nd-edition-prefinal-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fce1b2a6387a8d4a7fede7a78286c4be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fabricioepa</media:title>
		</media:content>
	</item>
		<item>
		<title>JEE Quick Start &#8211; Web Tier</title>
		<link>http://fabricioepa.wordpress.com/2009/03/11/jee-quick-start-web-tier/</link>
		<comments>http://fabricioepa.wordpress.com/2009/03/11/jee-quick-start-web-tier/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 23:34:26 +0000</pubDate>
		<dc:creator>fabricioepa</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[java web]]></category>
		<category><![CDATA[jee]]></category>
		<category><![CDATA[jsp]]></category>
		<category><![CDATA[jstl]]></category>
		<category><![CDATA[servlets]]></category>

		<guid isPermaLink="false">http://fabricioepa.wordpress.com/2009/03/11/jee-quick-start-web-tier/</guid>
		<description><![CDATA[Para aqueles que desejam entrar no mundo JEE Web e precisam de um ponta pé inicial, nada melhor que uma apresentação curta e grossa com uma visão simplificada do assunto. Registre sua dúvida ou opinião sobre o mini-workshop http://fabricioepa.googlepages.com/jeequickstart-webtier<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=41&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Para aqueles que desejam entrar no mundo JEE Web e precisam de um ponta pé inicial, nada melhor que uma apresentação curta e grossa com uma visão simplificada do assunto.</p>
<p>Registre sua dúvida ou opinião sobre o mini-workshop  <a href="http://fabricioepa.googlepages.com/jeequickstart-webtier">http://fabricioepa.googlepages.com/jeequickstart-webtier</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabricioepa.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabricioepa.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabricioepa.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabricioepa.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabricioepa.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabricioepa.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabricioepa.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabricioepa.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabricioepa.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabricioepa.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabricioepa.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabricioepa.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabricioepa.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabricioepa.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=41&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabricioepa.wordpress.com/2009/03/11/jee-quick-start-web-tier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fce1b2a6387a8d4a7fede7a78286c4be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fabricioepa</media:title>
		</media:content>
	</item>
		<item>
		<title>JBean File Storage</title>
		<link>http://fabricioepa.wordpress.com/2008/08/20/jbean-file-storage/</link>
		<comments>http://fabricioepa.wordpress.com/2008/08/20/jbean-file-storage/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 18:36:44 +0000</pubDate>
		<dc:creator>fabricioepa</dc:creator>
				<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[file management]]></category>
		<category><![CDATA[file storage]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[JBeanFileStorage]]></category>
		<category><![CDATA[JBFS]]></category>

		<guid isPermaLink="false">http://fabricioepa.wordpress.com/?p=13</guid>
		<description><![CDATA[Após um bomtempo sem publicar devido a minha dedicação ao projeto &#8220;Easy Accept Web&#8221; (mas isso fica para outro post), anuncio um novo componente para auxílio a manipulação e associação de caminhos de arquivos/diretórios com POJOS. Muito útil quando sua aplicação trabalha em conjunto com framework ORM (Hibernate like), onde se deseja por exemplo associar [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=13&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Após um bomtempo sem publicar devido a minha dedicação ao projeto &#8220;Easy Accept Web&#8221; (mas isso fica para outro post),  anuncio um novo componente para auxílio a manipulação e associação de caminhos de arquivos/diretórios com POJOS.  Muito útil quando sua aplicação trabalha em conjunto com framework ORM (Hibernate like), onde se deseja por exemplo associar uma entidade com um determinado diretório de arquivos (para upload/download por exemplo), seu nome por enquanto é :</p>
<h3><strong> JBean File Storage</strong></h3>
<p style="text-align:left;">
<p style="text-align:left;">O componente ainda apesar de implementado ainda não está disponibilizado publicamente pois ainda necessita de revisão, documentação e algumas possíveis melhorias embora esta versão esteja presente em 2 projetos já em produção.</p>
<p>A idéia chave foi associar um caminho a um tipo java, eu mentiria se dissesse que a idéia foi completamente minha pois me baseei numa solução proposta por Luciano Logrado ao trabalharmos juntos em um outro projeto, digamos que eu incrementei a idéia para suportar polimorfismo e com isto será possível:</p>
<ul>
<li> Associar um caminho a uma tipo (classe ou interface) e seus subtipos também estarão associados</li>
<li>Usar uma Expression Language (semelhante a do JSP 2.0) mínima para usar caminhos dinâmicos</li>
<li>Herdar um caminho dum outro POJO</li>
<li>Manter na hierarquia de diretórios a hierarquia nas associações dos POJOS</li>
</ul>
<p>Estes dois últimos são importantes caso por exemplo existam dois POJO&#8217;s com relacionamento de pai/filho e ao excluir o pai os filhos devem ser excluídos:</p>
<p>Cliente -&gt;* Conta</p>
<p>Desta forma o caminho de arquivos do cliente poderia ser:</p>
<p>$/Cliente_99</p>
<p style="padding-left:30px;">/Conta_33</p>
<p style="padding-left:60px;">MeuExtrato1.txt</p>
<p style="padding-left:30px;">/Conta_34</p>
<p style="padding-left:60px;">Extrato2008.txt</p>
<p>Com uma operação de exclusão do diretório do cliente haverá propagação no sistema de arquivo para os subdiretórios, ou seja, as contas. Além de manter a organização dos arquivos numa hierarquia de pastas de fácil entendimento visual e manipulação.</p>
<p>Veja detalhes do uso:</p>
<p><span id="more-13"></span></p>
<h3><strong>Configuração</strong></h3>
<p>Consiste em definir num arquivo xml os caminhos (paths) e as formas de amazenamento de arquivos utilizada (Stores).</p>
<p><strong>Arquivo:</strong> test-file-storage.xml</p>
<pre class="brush: xml;">

&lt;jbfs-conf&gt;
    &lt;stores&gt;
        &lt;local-system-file-store
          name=&quot;MySampleFileStorage&quot;
          rootDir=&quot;C:/temp&quot; /&gt;
    &lt;/stores&gt;
&lt;paths&gt;
&lt;path name=&quot;root&quot; &gt;/MyRootDir&lt;/path&gt;
&lt;path name=&quot;fatherDir&quot; type=&quot;jbfs.test.FatherBean&quot;&gt;
          ${root}/Father/${_bean.name}
       &lt;/path&gt;
&lt;path name=&quot;childSubdir&quot;&gt;
            ${fatherDir}/ChildSubdir
       &lt;/path&gt;
&lt;path name=&quot;childFileName&quot; type=&quot;jbfs.test.ChildBean&quot; &gt;
             ${_bean.father}/ChildDir/${_bean.childName}.txt
       &lt;/path&gt;
    &lt;/paths&gt;
&lt;/jbfs-conf&gt;
</pre>
<h3><strong>Uso</strong></h3>
<p>Basta recuperar a instância do JBFS e utlizar os dois objetos principais:</p>
<ul>
<li><strong>PathResolver</strong> (Resolvedor de Caminhos) -&gt; Resolve qual caminho associado ao objeto ou um nome utilizando os <em>paths</em> configurados.</li>
<li><strong>FileStorage </strong>(O armazenamento de arquivos) -&gt; Representa uma <em>Store </em>configurada e <em>e</em>xecuta as operações sobre o sistema de arquivo escolhido.
<ul>
<li>Podem existir várias implementações de FileStorage conforme o sistema de arquivo utilizado: FTP, sistema de arquivos remoto, etc. Por enquanto só existe a implementação de armazenamento em disco local: &lt;local-system-file-store /&gt;</li>
</ul>
</li>
</ul>
<p>Segue abaixo um teste unitário que exemplifica o uso duma possível classe cliente do nosso componente:</p>
<pre class="brush: java;">

package jbfs.test;

public class TestPathResolver {

    protected JBeanFileStorage jbfs;

   //CONFIGURANDO
    @Before
    public void setUp() {
        jbfs = new JBeanFileStorage(&quot;test-storage.xml&quot;); //File must be on classpath
    }

    //Resolvendo um diretório baseado em um nome
    @Test
    public void testResolveSimplePathFromName() {

        String path = jbfs.getPathResolver().resolveName(&quot;root&quot;, null);

        assertEquals(&quot;/MyRootDir&quot;, path);

    }

    //Resolvendo um diretório baseado em um Bean
    @Test
    public void testResolvePathFromBean() {

        FatherBean bean = new FatherBean(&quot;fatherName&quot;);

        String path= jbfs.getPathResolver().resolveBean(bean);

        assertEquals(&quot;/MyRootDir/Father/fatherName&quot;, path);
    }

    @Test
    public void testResolveComplexPathFromBean() {

        ChildBean bean = new ChildBean(&quot;childFile&quot;, new FatherBean(&quot;fatherName&quot;));

        String filePath = jbfs.getPathResolver().resolveBean(bean);

        assertEquals(&quot;/MyRootDir/Father/fatherName/ChildDir/childFile.txt&quot;, filePath);
    }

//TESTANDO MANIPULAÇÃO DOS ARQUIVOS
@Test
    public void testFileCRUD() {

        ChildBean bean = new ChildBean(&quot;childFile&quot;, new FatherBean(&quot;fatherName&quot;));

        String filePath= jbfs.getPathResolver().resolveBean(bean);

       FileStorage storage = jbfs.getStore(&quot;MySampleFileStorage&quot;);

        try {
            storage.createNewFile(filePath, &quot;hellow&quot;.getBytes());

            assertTrue(storage.exists(filePath));

            assertEquals(&quot;hellow&quot;, new String(storage.getBytes(filePath)));

            storage.delete(filePath);

            assertFalse(storage.exists(filePath));

        } catch (IOException e) {
            e.printStackTrace();
            fail(&quot;Test fail&quot;);
        }
   }
}
</pre>
<h3><strong>Integração com outros Componentes</strong></h3>
<p>Quando trabalhando com um framework ORM como Hibernate, pode ser interessante apagar os arquivos associados de uma entidade automaticamente quando for removida do Banco de Dados. Seguindo o exemplo Cliente -&gt; *  Conta, quando a transação que remove a entidade Cliente for confirmada os arquivos do cliente e suas contas serão excluídos. Para isto interceptador como o implementado abaixo pode ser utilizado em conjunto com o JBFS:</p>
<pre class="brush: java;">
/**
 * File Garbage Collector tries to remove file paths associated with deleted
 * Hibernate Entities.
 *
 * @author Fabrí­cio Silva
 *
 */
public class FileGarbageCollector extends EmptyInterceptor {

	private FileStorage repository;
	private PathResolver pathResolver;
	private JBeanFileStorage jbfs;
	private static SessionFactory hibernateSessionFactory;

	private Map trash = new HashMap();

       public FileGarbageCollector (SessionFactory hibernateSessionFactory){
            this.hibernateSessionFactory = hibernateSessionFactory;
        } 

	@Override
	public void onDelete(Object entity, Serializable id, Object[] state,
			String[] propertyNames, Type[] types) {

		if (jbfs.getConfiguration().hasPolimorficPath(entity)) {
			putPathInGarbageForDeletion(pathResolver.resolveBean(entity));
		}
	}

	@Override
	public void afterTransactionCompletion(Transaction tx) {
		performGarbageDeletion(tx);
	}

	private void performGarbageDeletion(Transaction tx) {
		Garbage g = trash.remove(tx);
		if (g != null &amp;&amp; tx.wasCommitted() &amp;&amp; !tx.wasRolledBack()) {
			for (String path : g.paths) {
				try {
					repository.deleteQuietly(path);
				} catch (Exception e) {
					logger.debug(
							&quot;Error when file garbage collector try to delete path:&quot;
									+ path, e);
				}
			}
		}
	}

       private void putPathInGarbageForDeletion(String path) {
		Transaction tx = hibernateSessionFactory.getCurrentSession()
				.getTransaction();

		Garbage g = trash.get(tx);
		if (g == null) {
			g = new Garbage();
			trash.put(tx, g);
		}
		g.addPath(path);
	}

       class Garbage {
		protected List paths = new LinkedList();

		void addPath(String path) {
			paths.add(path);
		}

		List getPaths() {
			return paths;
		}

		void setPaths(List paths) {
			this.paths = paths;
		}

	}

     //O código que inicializa as variáveis de instância foi omitido...
}
</pre>
<p>Por o JFBS ser um POJO ele pode facilmente se integrar com qualquer framework ou componente de sua aplicação, em especial no framework Spring sua configuração é tão simples como de qualquer outro bean:</p>
<pre class="brush: xml;">
&lt;!-- File Storage --&gt;
&lt;bean id=&quot;jbfs&quot;
	class=&quot;easyaccept.util.file.jbfs.JBeanFileStorage&quot; scope=&quot;singleton&quot; &gt;
&lt;property name=&quot;confLocation&quot;&gt;
		&lt;value&gt;file-storage.xml&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;
</pre>
<p>Espero que tenham gostado, quando o componente estiver com o mínimo aceitável de documentação será publicado aqui. Futuramente outras implementações de armazenamento estarão disponíveis:</p>
<ul>
<li>FTP</li>
<li>SVN</li>
<li>CVS</li>
<li>Remote System File</li>
</ul>
<p>Abraço.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/fabricioepa.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/fabricioepa.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabricioepa.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabricioepa.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabricioepa.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabricioepa.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabricioepa.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabricioepa.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabricioepa.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabricioepa.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabricioepa.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabricioepa.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabricioepa.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabricioepa.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabricioepa.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabricioepa.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=13&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabricioepa.wordpress.com/2008/08/20/jbean-file-storage/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fce1b2a6387a8d4a7fede7a78286c4be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fabricioepa</media:title>
		</media:content>
	</item>
		<item>
		<title>Fundamentos do Controle de Versão e SVN</title>
		<link>http://fabricioepa.wordpress.com/2008/04/21/fundamentos-do-controle-de-versao-e-svn/</link>
		<comments>http://fabricioepa.wordpress.com/2008/04/21/fundamentos-do-controle-de-versao-e-svn/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 21:50:32 +0000</pubDate>
		<dc:creator>fabricioepa</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Tecnologia]]></category>
		<category><![CDATA[colaborativo]]></category>
		<category><![CDATA[controle de versão]]></category>
		<category><![CDATA[desenvolvimento]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[team]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://fabricioepa.wordpress.com/?p=12</guid>
		<description><![CDATA[Olá pessoal, estou publicando em minha página pessoal uma apresentação rápida que fiz sobre alguns fundamentos para desenvolvimento de projetos em equipes de maneira colaborativa. Em suporte a este propósito utilizei os recursos do Subversion (SVN), por ser open-source e de livre distribuição, além de integrar novos recursos em relação ao famoso sistema de controle [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=12&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Olá pessoal, estou publicando em minha página pessoal uma apresentação rápida que fiz sobre alguns fundamentos para desenvolvimento de projetos em equipes de maneira colaborativa.</p>
<p>Em suporte a este propósito utilizei os recursos do Subversion (SVN), por ser open-source e de livre distribuição, além de integrar novos recursos em relação ao famoso sistema de controle de versão CVS.</p>
<p>O foco do estudo foi relacionado aos usuários de um repositório, como também o recurso de integração com Java/Eclipse IDE.</p>
<p>Enjoy it =) !</p>
<p><a class="alignleft" title="Fundamentos de Controle de Versão e SVN" href="http://fabricioepa.googlepages.com/fundamentosdocontroledevers%C3%A3oesvn" target="_blank">Fundamentos do Controle de Versão e SVN</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/fabricioepa.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/fabricioepa.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabricioepa.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabricioepa.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabricioepa.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabricioepa.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabricioepa.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabricioepa.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabricioepa.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabricioepa.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabricioepa.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabricioepa.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabricioepa.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabricioepa.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabricioepa.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabricioepa.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=12&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabricioepa.wordpress.com/2008/04/21/fundamentos-do-controle-de-versao-e-svn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fce1b2a6387a8d4a7fede7a78286c4be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fabricioepa</media:title>
		</media:content>
	</item>
		<item>
		<title>BugBuster 1.0 &#8211; Hibernate Exception: Illegally attempted to associate a proxy with two open Sessions</title>
		<link>http://fabricioepa.wordpress.com/2008/04/19/bugbuster-10-hibernate-exception-illegally-attempted-to-associate-a-proxy-with-two-open-sessions/</link>
		<comments>http://fabricioepa.wordpress.com/2008/04/19/bugbuster-10-hibernate-exception-illegally-attempted-to-associate-a-proxy-with-two-open-sessions/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>fabricioepa</dc:creator>
				<category><![CDATA[BugBuster]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[excetption]]></category>

		<guid isPermaLink="false">http://fabricioepa.wordpress.com/?p=11</guid>
		<description><![CDATA[O referido erro também ocorre com mesagem semelhante: Illegal attempt to associate a collection with two open sessions Causa: O erro é provocado quando um hiberObject associado a uma sessão tenta ser alterado por outra sessão do hibernate. Solução: Esqueça os métodos session.get/load/update você pode conseguir o mesmo efeito com session.refresh/merge. Contexto do Problema: Isso [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=11&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>O referido erro também ocorre com mesagem semelhante:</p>
<p><span class="l">Illegal attempt to associate a collection with two open</span> sessions</p>
<h2><strong>Causa:</strong></h2>
<p>O erro é provocado quando um hiberObject associado a uma sessão tenta ser alterado por outra sessão do hibernate.</p>
<h2><strong>Solução:</strong></h2>
<p><strong>Esqueça os métodos session.get/load/update você pode conseguir o mesmo efeito com session.refresh/merge.</strong></p>
<h2><strong>Contexto do Problema:</strong></h2>
<p>Isso acontece devido a associação de um objeto gerenciado pelo hibernate (hiberOjbect) com a sessão que o carrega.  Tecnicamente se um objeto foi carregado por uma sessão, até que o objeto seja desconectado (passando para o estado <em>Detached</em>) ele permanece associado a ela. O que pode ser feito invocando os métodos:</p>
<pre class="brush: java;">
//Apenas se os relacionamentos do hiberOject
//que possuem cascade=&quot;evict&quot; eles serão também desconectados
session.evict(hiberObject);
session.clear();
session.close();
 </pre>
<p>Se outra sessão tentar alterá-lo sem ele estar destacado da última sessão, o erro será lançado.</p>
<h2><strong>Problemas Típicos:</strong></h2>
<p>1. 0 Quando se deseja usar um objeto em outra sessão sem fechar a primeira use o evict, lembrando que se os relacionamentos não possuirem cascade=&#8221;evict&#8221; o efeito do método não servirá para eles e provavelmente o mesmo erro ocorrerá para o &#8220;proxy&#8221; dos relcionamentos (que podem ser coleções causando <span class="l">Illegal attempt to associate a collection with two open</span> sessions) .</p>
<p>2.0  Em Aplicações WEB Java tipicamente carregamos um hiberObject e o setamos em alguma variável do contexto web (request, session, sevletContext), após algum uso pela camada de apresentação fazemos outra chamada a camada do hibernate usando esse mesmo hiberObject onde ocorre falha com o dito erro. Neste caso temos dois pontos:</p>
<ul>
<li>Se a sessão que o carregou anterior ainda estava aberta você recai no erro 1.0</li>
</ul>
<ul>
<li>Caso a velha sessão já tenha morrido, o seu hiberObject não está mais conectado a mesma, porém os seus relacionamentos ainda podem ter algum &#8220;proxy&#8221; para a velha sessão. Nesse caso é mais simples usar um dos metódos:</li>
</ul>
<pre class="brush: java;">

//Caso queira reconectar e recarregar
//no seu objeto os dados do banco
session.refresh(detachedHiberObject);

//Caso queira reconectar o objeto fazer um update no banco
//de dados com as novas informações setadas no objeto
connectedHiberObject = session.merge(detachedHiberObject);
</pre>
<p>O merge/refresh tem funções diferentes, mas ambos reconectam o objeto a uma sessão, seja a mesma ou não, sem provocar erro.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/fabricioepa.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/fabricioepa.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabricioepa.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabricioepa.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabricioepa.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabricioepa.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabricioepa.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabricioepa.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabricioepa.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabricioepa.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabricioepa.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabricioepa.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabricioepa.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabricioepa.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabricioepa.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabricioepa.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=11&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabricioepa.wordpress.com/2008/04/19/bugbuster-10-hibernate-exception-illegally-attempted-to-associate-a-proxy-with-two-open-sessions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fce1b2a6387a8d4a7fede7a78286c4be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fabricioepa</media:title>
		</media:content>
	</item>
		<item>
		<title>JavaTips 3.0 &#8211; Performance Generics + AutoBox/UnBox</title>
		<link>http://fabricioepa.wordpress.com/2008/03/19/javatips-30-performance-generics-autoboxunbox/</link>
		<comments>http://fabricioepa.wordpress.com/2008/03/19/javatips-30-performance-generics-autoboxunbox/#comments</comments>
		<pubDate>Wed, 19 Mar 2008 16:18:06 +0000</pubDate>
		<dc:creator>fabricioepa</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[Autobox]]></category>
		<category><![CDATA[autoboxing]]></category>
		<category><![CDATA[Generic]]></category>
		<category><![CDATA[Generics]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Unbox]]></category>

		<guid isPermaLink="false">http://fabricioepa.wordpress.com/?p=10</guid>
		<description><![CDATA[AutoBox/UnBox é a conversão de forma automática entre objetos e tipos primitivos, dicas: Use somente quando houver “descasamento” entre tipos primitivos e objetos empacotadores Não abuse: um Integer não substitui um int (a performance é pior) Cuidado, unboxing com objetos null lança exceção Probolema: Generics não trabalha com tipos primitivos Após executar o seguinte teste [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=10&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>AutoBox/UnBox é a conversão de forma automática entre objetos e tipos primitivos, dicas:</p>
<ul>
<li> Use somente quando houver “descasamento” entre tipos primitivos e objetos empacotadores</li>
<li> Não abuse: um Integer não substitui um int (a performance é pior)</li>
<li> Cuidado, unboxing com objetos null lança exceção</li>
</ul>
<p><strong>Probolema:</strong></p>
<ul>
<li> Generics não trabalha com tipos primitivos</li>
</ul>
<p>Após executar o seguinte teste de performance, constatou-se uma diferênça em média de 25% com uso do autobox. O algoritimo de teste baseou-se em comparar as duas execuções:</p>
<ol>
<li>faça 1000 vezes
<ul>
<li>varra um ArrayList&lt;Integer&gt;,  capturando  o valor sem fazer autobox</li>
</ul>
</li>
<li>faça 1000 vezes
<ul>
<li>varra um ArrayList&lt;Integer&gt; usando <em>enhanced-loop </em>fazendo automaticamente unbox para int, capturando o valor e fazendo autbox novamente para um objeto Integer.</li>
</ul>
</li>
</ol>
<p><strong>Resultado da execução:</strong></p>
<p>___________________________________</p>
<p>autoBoxUnBox()&#8230;java.lang.NullPointerException<br />
Sem autoboxing = 6531ms<br />
Com autobox/unbox= 8734ms<br />
Diferença de 26%</p>
<p>___________________________________</p>
<p><strong>Conclusão:</strong></p>
<p><strong> </strong>Se sua aplicação é &#8220;Performance Driven&#8221;, estruturas como  o  IntHashMap visto no blog anterior entre outras coleções da API que não trabalhem com Generics podem ser a melhor saída para escovar milisegundos de processamento.</p>
<p>Abaixo segue a classe usada no teste:</p>
<p><span id="more-10"></span></p>
<pre class="brush: java;">

package update5.boxing;

import java.util.*;

/**
 *
 * @author Fabrício Silva Epaminondas
 */
public class AutoboxingUnboxing {

    static void autoBoxUnBox() {
        // Antes
        int prim = 10;// primitivo
        Integer obj = new Integer(20);// objeto
        Integer nullObj = null;

        // Java 5
        Integer c = 30;// autobox Integer c = new Integer(30)
        prim = obj;// unbox prim = obj.intValue();
        obj = prim;// autobox obj = new Integer(prim);

        try{
            prim = nullObj;// throw NullPointerException
        }catch (NullPointerException e) {
            System.out.println(&quot;autoBoxUnBox()...&quot; + e);
        }
    }

    @SuppressWarnings(&quot;unchecked&quot;)
    static void autoboxComGenerics() {

        // Antes
        Map products = new HashMap();
        products.put(new Integer(2779), new Float(20.45f));
        products.put(Integer.valueOf(922), Float.valueOf(99.99f));
        float price = new Float((Float) products.get(new Integer(922)
                .intValue())).floatValue();

        // AutoBoxing com Generics
        Map&lt;Integer, Float&gt; products2 = new HashMap&lt;Integer, Float&gt;();
        products2.put(10, 20.45f);
        products2.put(20, 99.99f);
        float price2 = products2.get(10);

        // Problema: Performance
        // Generics só aceita Tipos de Objetos e não primitivos

        // Ex: ArrayList de Integers..
        Collection&lt;Integer&gt; values = new ArrayList&lt;Integer&gt;();
        for (int i = 0; i &lt; 100000; i++) {
            values.add(i);
        }

        Integer intObj = null;

        // Teste de Performance 1 (Sem Autobox)
        long time = System.currentTimeMillis();

        // repete 1000 vezes
        for (int i = 0; i &lt; 1000; i++) {
            // for em coleção de objetos Integer
            for (Integer val : values) {
                intObj = val;// sem autobox
            }
        }
        long performance1 = System.currentTimeMillis() - time;
        System.out.println(&quot;Sem autoboxing = &quot; + performance1 + &quot;ms&quot;);

        // Teste de Performance 2 (Com Autobox/Unbox)
        time = System.currentTimeMillis();

        // repete 1000 vezes
        for (int i = 0; i &lt; 1000; i++) {
            // for em coleção de objetos Integer
            for (int val : values) {// executando unboxing para int
                intObj = val;// autobox para Integer
            }
        }
        long performance2 = System.currentTimeMillis() - time;
        System.out.println(&quot;Com autobox/unbox= &quot; + performance2 + &quot;ms&quot;);

        System.out.println(&quot;Diferença de &quot; + percentGain(performance1,performance2) + &quot;%&quot;);
    }

    static long percentGain(long num, long div) {
        return (100 - num*100/div);
    }

    public static void main(String[] args) {

        autoBoxUnBox();

        autoboxComGenerics();
    }
}</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/fabricioepa.wordpress.com/10/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/fabricioepa.wordpress.com/10/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fabricioepa.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fabricioepa.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fabricioepa.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fabricioepa.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fabricioepa.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fabricioepa.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fabricioepa.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fabricioepa.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fabricioepa.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fabricioepa.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fabricioepa.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fabricioepa.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fabricioepa.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fabricioepa.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fabricioepa.wordpress.com&amp;blog=3009806&amp;post=10&amp;subd=fabricioepa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fabricioepa.wordpress.com/2008/03/19/javatips-30-performance-generics-autoboxunbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fce1b2a6387a8d4a7fede7a78286c4be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fabricioepa</media:title>
		</media:content>
	</item>
	</channel>
</rss>
