<?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>organic thoughts</title>
	<atom:link href="http://blog.vladimirvivien.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.vladimirvivien.com</link>
	<description></description>
	<lastBuildDate>Wed, 14 Dec 2011 02:31:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.vladimirvivien.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>organic thoughts</title>
		<link>http://blog.vladimirvivien.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.vladimirvivien.com/osd.xml" title="organic thoughts" />
	<atom:link rel='hub' href='http://blog.vladimirvivien.com/?pushpress=hub'/>
		<item>
		<title>A Pattern for Creating Custom Android Content Providers</title>
		<link>http://blog.vladimirvivien.com/2011/11/19/a-pattern-for-creating-custom-android-content-providers/</link>
		<comments>http://blog.vladimirvivien.com/2011/11/19/a-pattern-for-creating-custom-android-content-providers/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 22:27:44 +0000</pubDate>
		<dc:creator>vladimirvivien</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.vladimirvivien.com/?p=94</guid>
		<description><![CDATA[When creating apps in Android, you have access to numerous data sources. In fact, Android comes with a built-in instance of SQLite, provides access data to local storage, gives direct access to remote resources over HTTP. In additions to these native data providers, you can setup your own application to be a data provider. Since [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=94&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When creating apps in Android, you have access to numerous data sources. In fact, Android comes with a built-in instance of SQLite, provides access data to local storage, gives direct access to remote resources over HTTP.  In additions to these native data providers, you can setup your own application to be a data provider.  Since Android does not allow applications to share data directly  with one another,  you can make your data accessible to (components in your application or) other applications using the ContentAPI.  For instance, Android has a phonebook content provider which lets you search, add, modify contacts.</p>
<p>A <code>ContentProvider</code> is a first-class Android component (like Activity, Service, etc). It is registered in the manifest file like any other high-level components. You can read about Android ContentProviders from Android’s website at:</p>
<ul>
<li><a href="http://developer.android.com/reference/android/content/ContentProvider.html">http://developer.android.com/reference/android/content/ContentProvider.html</a> &#8211; API doc</li>
<li><a href="http://developer.android.com/guide/topics/providers/content-providers.html">http://developer.android.com/guide/topics/providers/content-providers.html</a> &#8211; Content Provider usage</li>
</ul>
<p>The intent of this write up is to present a simple approach to create and work with your own ContentProvider. It is not meant to be an introduction to data storage in Android. If you have not used data storage in Android, visit the Android’s developer web site and look for data storage.</p>
<div>
<h2>ContentProvider Overview</h2>
<div>
<p>As mentioned above, one of the primary purposes for the use of ContentProvider is data sharing.  Since databases and other internal data stores are application-scoped, there’s no way to share information between applications.  A content provider lets you expose access to your application’s data in a structured and uniform manner.</p>
<p>ContentProdviders are considered data access objects (a software <a href="http://en.wikipedia.org/wiki/Data_access_object">pattern</a>).  Their backing data store can be a database, data from local storage, data from a remote server over HTTP, or a custom data source.  For this write up, I will use the SQLite database as the backing datastore for the sample content provider that will be be demonstrated.  This will keep things simple since the API for SQLite maps nicely to the method used by the ContentProvider API.</p>
</div>
</div>
<div>
<h3>The Example</h3>
<div>Imagine a simple application that keeps track of your favorite restaurants and save that information in the local SQLite database.  For the sake of keeping things simple, the code only saves a few columns about the restaurants including name, address, city, state, etc. You can download the example from its GitHub location at <a title="GitHub Code Repository" href="https://github.com/vladimirvivien/workbench/tree/master/android-tutorials/ContentProviderSample" target="_blank">https://github.com/vladimirvivien/workbench/tree/master/android-tutorials/ContentProviderSample</a>.</div>
<h3>How to Do It</h3>
<div>The ContentProvider API is a bit heavy and can be complex.  To get a custom ContentProvider written, you need to implement several boilerplate methods. This writeup makes things easier by providing a set of guidelines for implementing your own ContentProvider. Here is how to do it:</div>
<div>
<ul>
<li><em>Define data model</em> &#8211; figure out what will be in stored</li>
<li><em>Create a Descriptor class</em> &#8211; to help describe the data that you will work with.  This is not part of any of the APIs.  It is a class that I have used to help with with creation of providers.</li>
<li><em>Create a Database Class</em> &#8211; the database class is implemented as a <code>SQLiteOpenHelper</code> intended to help with creation/management of the database instance itself.</li>
<li><em>Define your ContentProvider</em> &#8211; the content provider will use the classes created above to install the database, access, and manipulate the data in it.  This is also the class that Activity classes will use to access the data.</li>
</ul>
</div>
<h3>Define the Data Model</h3>
<div>While it may sound trivial, the first step to this pattern is to figure out what your data will look like. Recall that the ContentProvider exposes data in tabular form, so listing out your data columns is a good first step for your design.  For our favorite restaurant example, we will use the following fields which represent the name and address of our favorite eateries:</p>
<ul>
<li><code>ID</code></li>
<li><code>NAME</code></li>
<li><code>ADDRESS</code></li>
<li><code>CITY</code></li>
<li><code>ZIP</code></li>
</ul>
<p>It&#8217;s good practice to define an ID column as an identifier for the data row. The ContentProvider&#8217;s URI mechanism uses the ID to refer to saved data entities.</p></div>
</div>
<h3>Descriptor Class</h3>
<div>The Descriptor class is not part of the ContentProvider API.  I use it as a registry for meta data that describes the content exposed by the ContentProvider class.  The Descriptor class manages the following meta data:</div>
<div>
<div>
<ul>
<li><em>URI Authority</em> &#8211; the authority portion of the URI representing this entity.  In our example it is “com.favrestaurant.contentprovider”</li>
<li><em>URI Matcher</em> &#8211; this is an internal registry used to map a URI path (serviced by the ContentProvider) to an integer value.</li>
<li><em>Entity Class</em> &#8211; an inner static class that represents the entity to be managed by the ContentProvider. In our example, this class is called Restaurant.  It exposes meta data such as the entity name, supported URIs, etc.</li>
<li><em>Class EntityClass.Cols</em> &#8211; the entity class provides an inner class called Cols.  As you may have guessed, this class exposes the name of the columns to exposed by the ContentProvider for the entity.</li>
</ul>
<p><pre class="brush: java;">
public class ContentDescriptor {
	public static final String AUTHORITY = &quot;demo.contentprovider.restaurant&quot;;
	private static final Uri BASE_URI = Uri.parse(&quot;content://&quot; + AUTHORITY);
	public static final UriMatcher URI_MATCHER = buildUriMatcher();

	private ContentDescriptor(){};

	private static  UriMatcher buildUriMatcher() {
        final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
        final String authority = AUTHORITY;

        matcher.addURI(authority, Restaurant.PATH, Restaurant.PATH_TOKEN);
		matcher.addURI(authority, Restaurant.PATH_FOR_ID, Restaurant.PATH_FOR_ID_TOKEN);

        return matcher;
	}

	public static class Restaurant {
		public static final String NAME = &quot;restaurant&quot;;

		public static final String PATH = &quot;restaurants&quot;;
		public static final int PATH_TOKEN = 100;
		public static final String PATH_FOR_ID = &quot;restaurants/*&quot;;
		public static final int PATH_FOR_ID_TOKEN = 200;

		public static final Uri CONTENT_URI = BASE_URI.buildUpon().appendPath(PATH).build();

		public static final String CONTENT_TYPE_DIR = &quot;vnd.android.cursor.dir/vnd.favrestaurant.app&quot;;
		public static final String CONTENT_ITEM_TYPE = &quot;vnd.android.cursor.item/vnd.favrestaurant.app&quot;;

		public static class Cols {
			public static final String ID = BaseColumns._ID; // convention
			public static final String NAME = &quot;restaurant_name&quot;;
			public static final String ADDRESS  = &quot;restaurant_addr&quot;;
			public static final String CITY = &quot;restaurant_city&quot;;
			public static final String STATE = &quot;restaurant_state&quot;;
			public static final String ZIP = &quot;restaurant_zip&quot;;
		}

	}
}</pre></p>
<h4>What&#8217;s going on&#8230;</h4>
<ul>
<li>The first thing to notice in the code above is the definition of variables <code>AUTHORITY</code> and <code>BASE_URI</code>.  Together these form the URI that identifies the ContentProvider.  The URI is used by Android for registering the ContentProvider as part of the application.  As you will see later, a ContentResolver class will locate and use the ContentProvider based on the provided URI.
</li>
<li>Private method <code>buildMatcher()</code> creates an instance of <code>URIMatcher</code> for the ContentProvider.
</li>
<li>Inner class <code>Restaurant</code> exposes meta data that defines the Restaurant entity managed by the associated ContentProvider.</li>
<li>Furthermore, inner class <code>Restaurant.Cols</code> define meta values for the columns associated with the Restaurant entity.
</ul>
<p>If none of this makes sense, read on to see how the <code>Descriptor</code> class is used.</p>
</div>
<h3>The Database Class (SQLiteOpenHelper)</h3>
<div>Since the backing data store for our <code>ContentProvider</code> implementation is a database, we will use the SQLLite API here to define the database.  The purpose of class <code>RestaurantDatabase</code> is to create, install, and help manage the SQLLite database. The Android’s ContentProvider API (along with the ContentResolver class) uses this class to run DDL scripts to install and update the database. If you implement the <code>onUpgrade()</code> method and change the version of the database, the database will be upgraded automatically next time the code is executed.</p>
<p>The one notable portion of the code below is its use of the <code>ContentDescriptor</code> class (see defined above) to provide meta data the table and fields used in the database.
</div>
<p><pre class="brush: java;">
public class RestaurantDatabase extends SQLiteOpenHelper {
	private static final String DATABASE_NAME = &quot;fav_restaurnt.db&quot;;
	private static final int DATABASE_VERSION = 2;

	public RestaurantDatabase(Context ctx){
		super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(&quot;CREATE TABLE &quot; + ContentDescriptor.Restaurant.NAME+ &quot; ( &quot; +
				ContentDescriptor.Restaurant.Cols.ID + &quot; INTEGER PRIMARY KEY AUTOINCREMENT, &quot; +
				ContentDescriptor.Restaurant.Cols.NAME + &quot; TEXT NOT NULL, &quot; +
				ContentDescriptor.Restaurant.Cols.ADDRESS 	+ &quot; TEXT , &quot; +
				ContentDescriptor.Restaurant.Cols.CITY + &quot; TEXT, &quot; +
				ContentDescriptor.Restaurant.Cols.STATE + &quot; TEXT, &quot; +
				ContentDescriptor.Restaurant.Cols.ZIP + &quot; TEXT, &quot; +
				&quot;UNIQUE (&quot; +
					ContentDescriptor.Restaurant.Cols.ID +
				&quot;) ON CONFLICT REPLACE)&quot;
			);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        if(oldVersion &lt; newVersion){
        	db.execSQL(&quot;DROP TABLE IF EXISTS &quot; + ContentDescriptor.Restaurant.NAME);
        	onCreate(db);
        }
	}

}</pre></p>
</div>
<h3>The ContentProvider Class</h3>
<div>Next, we implement the <code>ContentProvider</code> class with the logic for data access and update. The ContentProvider API exposes several methods for inserting, updating, querying, and deleting data.  The example code only implements the <code>insert()</code> and <code>query()</code> methods.  Note the usage of the <code>ContentDescriptor</code> to provide naming and configuration meta data for the <code>ContentProvider</code>.</p>
<p><pre class="brush: java;">
public class RestaurantContentProvider extends ContentProvider {
	private RestaurantDatabase restaurantDb;

	@Override
	public boolean onCreate() {
		Context ctx = getContext();
		restaurantDb = new RestaurantDatabase(ctx);
		return true;
	}

	@Override
	public String getType(Uri uri) {
		final int match = ContentDescriptor.URI_MATCHER.match(uri);
		switch(match){
		case ContentDescriptor.Restaurant.PATH_TOKEN:
			return ContentDescriptor.Restaurant.CONTENT_TYPE_DIR;
		case ContentDescriptor.Restaurant.PATH_FOR_ID_TOKEN:
			return ContentDescriptor.Restaurant.CONTENT_ITEM_TYPE;
        default:
            throw new UnsupportedOperationException (&quot;URI &quot; + uri + &quot; is not supported.&quot;);
		}
	}

	@Override
	public Uri insert(Uri uri, ContentValues values) {
		SQLiteDatabase db = restaurantDb.getWritableDatabase();
		int token = ContentDescriptor.URI_MATCHER.match(uri);
		switch(token){
			case ContentDescriptor.Restaurant.PATH_TOKEN:{
				long id = db.insert(ContentDescriptor.Restaurant.NAME, null, values);
				getContext().getContentResolver().notifyChange(uri, null);
				return ContentDescriptor.Restaurant.CONTENT_URI.buildUpon().appendPath(String.valueOf(id)).build();
			}
            default: {
                throw new UnsupportedOperationException(&quot;URI: &quot; + uri + &quot; not supported.&quot;);
            }
		}
	}

	@Override
	public Cursor query(Uri uri, String[] projection, String selection,
			String[] selectionArgs, String sortOrder) {
		SQLiteDatabase db = restaurantDb.getReadableDatabase();
		final int match = ContentDescriptor.URI_MATCHER.match(uri);
		switch(match){
			// retrieve restaurant list
			case ContentDescriptor.Restaurant.PATH_TOKEN:{
				SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
				builder.setTables(ContentDescriptor.Restaurant.NAME);
				return builder.query(db, null, null, null, null, null, null);
			}
			default: return null;
		}
	}

	@Override
	public int update(Uri uri, ContentValues values, String selection,
			String[] selectionArgs) {
		return 0;
	}

	@Override
	public int delete(Uri uri, String selection, String[] selectionArgs) {
		return 0;
	}
}
</pre></p>
<h4>What&#8217;s going on&#8230;</h4>
<ul>
<li><code>The onCreate()</code> method is called when the provider is instantiated (by the <code>ContentResolver</code> class).  It is, in turn, used to bootstrap the database via the <code>RestaurantDatabase</code> class (see above) instance db.</li>
<li>The <code>getType()</code> method uses the <code>ContentDescriptor.URI_MATCHER</code> (see <code>ContentDescriptor</code> above) to lookup the MIME type for a given URI.</li>
<li>All of the data access &amp; update methods (including <code>query()</code>, <code>insert()</code>, <code>update()</code>, and <code>delete()</code>) take a URI parameter.  The URI provides hints such as the entity (and cardinality) being queried or updated.  For instance, in our example, if the URI to passed to the query() method looks like <code>content://com.favrestaurant.contentprovider/restaurants/*</code> the method will return all restaurant rows in the database.  This is accomplished by using the <code>ContentDescriptor.URI_MATCHER</code> to determine how to process the URI.
</li>
</ul>
</div>
<h3>Using the ContentProvider</h3>
<div>
<p>Once you have all of your pieces in place, you can access the data exposed by the content provider using the <code>ContentResolver</code>. There are certainly more robust ways to use to access data from a ContentProvier. This write up shows the simplest (non-production ready) way of doing it. You should investigate which way works best for your use (see http://developer.android.com/guide/topics/providers/content-providers.html).</p>
<p><pre class="brush: java;">

public class FavRestaurantActivity extends Activity {
	TextView txtName;
	TextView txtAddr;
	TextView txtState;
	TextView txtCity;
	TextView txtZip;

    ContentResolver contentResolver;
    Cursor cur;
    SimpleCursorAdapter adapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ...
        contentResolver = this.getContentResolver();
    }

    @Override
    public void onStop() {
    	super.onStop();
    	if(cur != null) cur.close();
    }

    private void loadContent() {
        cur = this.getContentResolver().query(ContentDescriptor.Restaurant.CONTENT_URI, null, null, null, null);
    	...
    }

    private void saveContent(){
    	ContentValues val = new ContentValues();
    	val.put(ContentDescriptor.Restaurant.Cols.NAME, (this.txtName.getText() != null) ? this.txtName.getText().toString() : null);
    	val.put(ContentDescriptor.Restaurant.Cols.ADDRESS, (this.txtAddr.getText() != null) ? this.txtAddr.getText().toString() : null);
    	val.put(ContentDescriptor.Restaurant.Cols.CITY, (this.txtCity.getText() != null) ? this.txtCity.getText().toString() : null);
    	val.put(ContentDescriptor.Restaurant.Cols.STATE, (this.txtState.getText() != null) ? this.txtState.getText().toString() : null);
    	val.put(ContentDescriptor.Restaurant.Cols.ZIP, (this.txtZip.getText() != null) ? this.txtZip.getText().toString() : null);
    	contentResolver.insert(ContentDescriptor.Restaurant.CONTENT_URI, val);
    	loadContent();
    }
}
</pre></p>
<h4>What is going on&#8230;</h4>
<ul>
<li>First, let me point out that the code used above to access data from the <code>Activity</code> class is not optimal for production.  You should optimize any io-bound code that has propensity to hang the UI by using an asynchronous task.  Nevertheless, the code presented above uses an instance of <code>ContentResolver</code> to access data managed by the backing ContentProvider.  The <code>ContentResolver</code> uses the URI value passed in to select the proper ContentProvider registered in the AndroidManifest.xml file (not shown).</li>
<li>
The <code>saveContent()</code> shows how you can use the Descriptor class to create an instance of ContentValues (from the ContentProvider API) to save data.  Each column is mapped to its value using the ContentProvider to provide the column name.
</li>
<h2>Conclusion</h2>
<p>This write up provides a guide for those of you, brave enough, to use the ContentProvider API directly.  I have introduced the Descriptor class as a container to register meta data to describe the data element captured by the ContentProvier.  The hope is to make using the ContentProvider API more organized and provide some structure when putting your own data access code together.
</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vladimirvivien.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vladimirvivien.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vladimirvivien.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vladimirvivien.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vladimirvivien.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vladimirvivien.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vladimirvivien.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vladimirvivien.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vladimirvivien.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vladimirvivien.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vladimirvivien.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vladimirvivien.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vladimirvivien.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vladimirvivien.wordpress.com/94/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=94&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.vladimirvivien.com/2011/11/19/a-pattern-for-creating-custom-android-content-providers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">vladimirvivien</media:title>
		</media:content>
	</item>
		<item>
		<title>Loader/Launcher &#8211; A Pattern to Bootstrap Java Applications</title>
		<link>http://blog.vladimirvivien.com/2011/10/07/86/</link>
		<comments>http://blog.vladimirvivien.com/2011/10/07/86/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 17:03:40 +0000</pubDate>
		<dc:creator>vladimirvivien</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.vladimirvivien.com/?p=86</guid>
		<description><![CDATA[There is still a great number of Java developers out there who are not doing web apps. They use the JDK’s Java launcher directly to bootstrap their apps using public static void main() (abbreviated thereafter as PSVM). And if you are one of those developers, you understand the implications of having a large classpath. It [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=86&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div>
<p>There is still a great number of Java developers out there who are not doing web apps. They use the JDK’s Java launcher directly to bootstrap their apps using public static void main() (abbreviated thereafter as PSVM). And if you are one of those developers, you understand the implications of having a large classpath. It is not uncommon to see shell command with no less than a dozen jars listed on the classpath.</p>
<p>Of course over the years many options have been provided to help with this issue. One of the most recent is from Java 6 where you can reduce the length of the command to launch your Java application by specifying wildcards values in the classpath as shown below:</p>
<pre>$ java -cp path1/*.jar:path2:/*:path3/*.jar package.name.ClassName</pre>
<p>This write up proposes an alternative approach where your code loads your application’s classes programatically. This pattern, named Loader/Launcher, separates the loading of your application’s classes from the booting of your application logic. The idea is to provide your own loader class that will load your classpath then delegates further bootstrapping responsibilities to a launcher class. One benefit of this approach is that your command to launch your application can be reduced to something like this (no matter the size of your class dependency graph):</p>
<pre>$ java -jar package.name.ClassName</pre>
<h2>The Loader/Launcher Pattern</h2>
<p>The way that the Loader/Launcher pattern works is to de-entangle class-loading concerns from application execution concerns. The loading of classes is handled by a Main class with a PSVM method. The native Java command-line launcher loads the Main class. The execution of the application is delegated to a launcher class that implements the Launcher interface. The Launcher is instantiated and invoked by the Main class.</p>
<div class="wp-caption alignnone" style="width: 744px"><a href="http://s3.amazonaws.com/vladimirvivien.com/blogs/LoaderLauncher/Blog-LoaderLauncherSequence.png"><img class=" " title="Loader/Launcher Sequence" src="http://s3.amazonaws.com/vladimirvivien.com/blogs/LoaderLauncher/Blog-LoaderLauncherSequence.png" alt="Loader/Launcher Sequence" width="734" height="422" /></a><p class="wp-caption-text">Loader/Launcher Sequence</p></div>
<p>To implement this pattern, you will need the following high-level components:</p>
<ul>
<li>The Launcher interface that will be used as a starting point for your app.</li>
<li>The Main class where a PSVM method is defined.</li>
<li>A Launcher implementation to execute the application.</li>
</ul>
<h3>The Launcher Interface</h3>
<p>Implementation of this interface is intended to be the starting point of your application’s bootup process. Instead of starting your application directly in the PSVM method, as is done traditionally, you would relocate the logic for your application’s boot up sequence in a class that implements this interface. When the PSVM method is invoked by the native Java launcher, it would delegate the boot sequence of your application to your Launcher instance (see interface below Listing-1).</p>
<p><pre class="brush: java;">
public interface Launcher {
	public int launch(Object ... params);
}
</pre></p>
<p>Listing-1</p>
<p>This is a simple interface with a single method, launch(). The method takes an array of objects that can be used to pass in arguments to launcher. The method’s signature makes easy to maintain the semantic of PSVM when using the Launcher.</p>
<h3>The Main Class</h3>
<p>The Main class is designed to be the starting point for the native Java launcher by exposing a PSVM method. The role of this class, in the Loader/Launcher Pattern, is summed up below:<br />
It creates and loads the application’s classpath. Internally, it instantiates a ClassLoader that is used to load the application’s classpath from a specified location.<br />
Once the classpath is in place, it creates an instance of Launcher, from the classpath, to boot up the application by calling launch().</p>
<p>Listing-2 shows the content of a Main class.</p>
<p><pre class="brush: java;">
public class Main {
	private static String CLASSPATH_DIR = &quot;lib&quot;;
	private static String LIB_EXT = &quot;.jar&quot;;
	private static String LAUNCHER_CLASS = &quot;demo.launcher.AppLauncher&quot;;

	private static ClassLoader cl;
	static{
		try {
			cl = getClassLoaderFromPath(
				new File(CLASSPATH_DIR),
				Thread.currentThread().getContextClassLoader()
			);
			Thread.currentThread().setContextClassLoader(cl);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	// Returns a ClassLoader that for the provided path.
	private static ClassLoader getClassLoaderFromPath(File path, ClassLoader parent) throws Exception {
		// get jar files from jarPath
		File[] jarFiles = path.listFiles(new FileFilter() {
			public boolean accept(File file) {
				return file.getName().endsWith(Main.LIB_EXT);
			}
		});
		URL[] classpath = new URL[jarFiles.length];
		for (int j = 0; j &lt; jarFiles.length; j++) {
			classpath[j] = jarFiles[j].toURI().toURL();
		}
		return new URLClassLoader(classpath, parent);
	}

	public static void main(String[] args) throws Exception{
		Launcher launcher = Launcher.class.cast(
			Class.forName(LAUNCHER_CLASS, true, cl).newInstance()
		);
		launcher.launch(new Object[]{&quot;this string is capitalized&quot;});
	}
}
</pre></p>
<p>Listing-2</p>
<p>The first thing to notice is the static declarations at the start of the listing. The first three declarations setups the “lib” directory as the location for the classpath, provides “.jar” as the file extension, and specifies demo.launcher.AppLauncher as the name of the Launcher class to load from the classpath. The static code block uses method getClassLoaderFromPath() to initialize a URLClassLoader instance (that points to the lib directory) that will serve as the class loader for the rest of the application.</p>
<p>When the public static void main() method in the Main class is invoked (by the Java launcher), it searches and loads an instance of class demo.launcher.AppLauncher which implements Launcher. Then, the code calls Launcher.launch() to delegate the execution of the rest of the application by passing in a String parameter.</p>
<h3>The Launcher Class</h3>
<p>The Launcher class is responsible for starting up the application-specific logic. Implementation of the launch() method maintains the same signature as the the PSVM method from the Main class to maintain the familiar semantic. Parameters are passed in as arrays of objects and the method is expected to return an integer. A return value of 0 means everything is OK while anything else means something up to the discretion of the implementor. Listing-3 shows a simple implementation of the Launcher class.</p>
<p><pre class="brush: java;">
public class AppLauncher implements Launcher {
	public int launch(Object ... args) {
		String result = org.apache.commons.lang3.text.WordUtils.capitalize((String)args[0]);
		System.out.println (result);
		return 0;
	}
}
</pre></p>
<p>Listing-3</p>
<h3>How It Works</h3>
<p>This implementation uses Apache Commons-Lang to capitalize the value of an argument that was passed in. While this is a simple example, it shows exactly how the pattern would work.  When the application is invoked from the command-line using</p>
<pre>$ java -jar demo.launcher.Main</pre>
<p>The Main class resolves the classpath by loading jars from the jar directory.  The classpath directory contains all jars that satisfies the dependency graph of the application.  In this example the application depends on the Apache-Commons Lang jar.  When Main instantiates its ClassLoader instance, the jar will be added on the classpath and thus be available for use.</p>
<h3>An Example</h3>
<p>You can download example code that shows how this works from the location below:<br />
An example &#8211; <a title="GitHub - Loader/Launcher Example" href="https://github.com/vladimirvivien/workbench/tree/master/CustomLauncher" target="_blank">https://github.com/vladimirvivien/workbench/tree/master/CustomLauncher</a></p>
<p>The example comes in three separate projects:</p>
<ul>
<li>Launcher-Api &#8211; contains the definition of the Launcher interface.</li>
<li>Launcher-Impl &#8211; contains an implementation of the Launcher interface.</li>
<li>Laucnher-Main &#8211; contains the Main class that is used as the starting point of the application.</li>
</ul>
<h3>Conclusion</h3>
<p>The Loader/Launcher Pattern is an attempt to decouple two distinct activities that occur when a Java application is started: that of class loading and and application start up. The pattern uses a Main class as the entry point from the Java native launcher and is used to  load the application’s classpath from a given location.  The act of activating the application is then relegated to a Launcher class.  The launcher is responsible for actually starting up the application-specific logic in the code.  Some of the benefit of adopting this pattern is, firstly, the tighter control over how classes are loaded.  You no longer have to rely on the native Java launcher to resolve your classpath.  Another benefit is the separation of concerns for the start up sequence of the app.  The pattern provides a location, the Launcher interface, where to define what should happen when the application itself (not loading of classpath) is starting.  Hope this was helpful.</p>
<h3>Reference</h3>
<p><a title="GitHub - Loader/Launcher Example" href="https://github.com/vladimirvivien/workbench/tree/master/CustomLauncher" target="_blank">https://github.com/vladimirvivien/workbench/tree/master/CustomLauncher</a> - the example</p>
<p><a href="http://code.google.com/p/clamshell-cli/">http://code.google.com/p/clamshell-cli/</a> - tool that uses this pattern</p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vladimirvivien.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vladimirvivien.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vladimirvivien.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vladimirvivien.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vladimirvivien.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vladimirvivien.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vladimirvivien.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vladimirvivien.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vladimirvivien.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vladimirvivien.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vladimirvivien.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vladimirvivien.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vladimirvivien.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vladimirvivien.wordpress.com/86/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=86&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.vladimirvivien.com/2011/10/07/86/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">vladimirvivien</media:title>
		</media:content>

		<media:content url="http://s3.amazonaws.com/vladimirvivien.com/blogs/LoaderLauncher/Blog-LoaderLauncherSequence.png" medium="image">
			<media:title type="html">Loader/Launcher Sequence</media:title>
		</media:content>
	</item>
		<item>
		<title>Try to Be Like Steve</title>
		<link>http://blog.vladimirvivien.com/2011/10/05/try-to-be-like-steve/</link>
		<comments>http://blog.vladimirvivien.com/2011/10/05/try-to-be-like-steve/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 03:15:28 +0000</pubDate>
		<dc:creator>vladimirvivien</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.vladimirvivien.com/?p=79</guid>
		<description><![CDATA[All of us in the tech field (specially those in position to create) have an undeniable responsibility to those who use our creation. Steve showed that our creation can be imaginative, usable, and of quality. He showed us that user experience is also a feature. Usability starts from the moment your users open that box [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=79&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>All of us in the tech field (specially those in position to create) have an undeniable responsibility to those who use our creation. Steve showed that our creation can be imaginative, usable, and of quality. He showed us that user experience is also a feature. Usability starts from the moment your users open that box and pull out the shiny new toy and ends with their ability to effectively use your products to be productive, entertained, or enlightened.</p>
<p>The best tribute to Steve is to imitate some of his legacies. So, in your next project, make your creation better. If you are designing an API, add that extra function that makes your developers productive; if you are creating a web site , add that feature that will surprise and make your users smile; if you are creating a new product, plan to make it great, plan to make it usable, plan to make it awesome.</p>
<p>I can only hope that the people at Apple don&#8217;t fall prey to the temptation of only pleasing the Street but continue Steve&#8217;s long-term strategic vision of bringing quality and imaginative products out to the market. As Apple&#8217;s recent history attests to, people will gravitate toward quality and the Street will take notice.</p>
<p>Thank you Steve Jobs </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vladimirvivien.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vladimirvivien.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vladimirvivien.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vladimirvivien.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vladimirvivien.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vladimirvivien.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vladimirvivien.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vladimirvivien.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vladimirvivien.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vladimirvivien.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vladimirvivien.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vladimirvivien.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vladimirvivien.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vladimirvivien.wordpress.com/79/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=79&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.vladimirvivien.com/2011/10/05/try-to-be-like-steve/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">vladimirvivien</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating Android View Adapters Is Easy, but Beware!</title>
		<link>http://blog.vladimirvivien.com/2011/09/09/creating-android-view-adapters-is-easy-but-beware/</link>
		<comments>http://blog.vladimirvivien.com/2011/09/09/creating-android-view-adapters-is-easy-but-beware/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 11:07:15 +0000</pubDate>
		<dc:creator>vladimirvivien</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://vladimirvivien.wordpress.com/?p=50</guid>
		<description><![CDATA[Instead of a pure MVC approach, Android provides a simple Adapter API that lets you bridge views with their underlying data source(s).  There are several good examples on the web (search for Android Adapter) on how to use the built-in adapters that come with the android SDK.  These links below provide two examples non-trivial examples [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=50&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Instead of a pure MVC approach, Android provides a simple Adapter API that lets you bridge views with their underlying data source(s).  There are several good examples on the web (search for Android Adapter) on how to use the built-in adapters that come with the android SDK.  These links below provide two examples non-trivial examples from the Android documentations that you should check out if this is your first time using adapters:</p>
<ul>
<li><a href="http://developer.android.com/resources/tutorials/views/hello-listview.html">http://developer.android.com/resources/tutorials/views/hello-listview.html</a> - shows a simple example on how to use the ArrayAdapter when your data source (as you would guess) is the form of a array (Java type or XML array resource).</li>
<li><a href="http://developer.android.com/resources/tutorials/views/hello-gridview.html">http://developer.android.com/resources/tutorials/views/hello-gridview.html</a> - shows how to create grid view along with an Adapter to provide data for the the view.</li>
</ul>
<p><span style="font-size:large;">Create Your Own Adapters</span></p>
<p>In non-trivial Android development, chances are you have a complex data graph to maintain states.  Rather then trying to fit your data structure to work with the out-of-the-box adapters, it is relatively easy to just create your own.  As a measure of practice, you should create a custom Adapter implementation for your views (specially ListView instances).  Why?  Your own Adapter class will be more flexible and you will add just enough functionality needed and avoid carrying around bloated code.</p>
<p><span class="Apple-style-span" style="font-size:large;">A Simple Implementation</span></p>
<p>The following is derived from a simple implementation which prompted this writing.  I have a simple class Application which I want to bind to a ListView.  Since we are going to use an Adapter we will break down the components as follow: list_layout.xml, item_layout, a data transfer object, and the activity where everything is displayed.</p>
<p><strong>Main Layout &#8211; list_layout.xml</strong><br />
This is used for the Activity layout.  It contains the ListView instance that will be bound to the adapter.</p>
<p><pre class="brush: xml;">
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;&gt;
    &lt;ListView
        android:id=&quot;@+id/my_list&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;fill_parent&quot;
        android:layout_weight=&quot;1&quot;
        android:drawSelectorOnTop=&quot;false&quot;
        android:textFilterEnabled=&quot;false&quot;
        android:stackFromBottom=&quot;false&quot;/&gt;
&lt;/LinearLayout&gt;
</pre></p>
<p><strong>Row Layout &#8211; item_layout.xml</strong><br />
This layout is used by the Adapter instance to generate the view used for each item (row) in the ListView.  Use this layout to customize how you want each row in the bounded list view to appear.  In this example, we are going to have a simple TextView instance in each row.</p>
<p><pre class="brush: xml;">
&lt;LinearLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    android:orientation=&quot;horizontal&quot;
    android:padding=&quot;12sp&quot;&gt;

        &lt;TextView android:id=&quot;@+id/data_item&quot;
            android:textSize=&quot;18sp&quot;
            android:textStyle=&quot;bold&quot;
            android:layout_width=&quot;fill_parent&quot;
            android:layout_height=&quot;wrap_content&quot;/&gt;

&lt;/LinearLayout&gt;
</pre></p>
<p><strong>Data Transfer Object</strong><br />
This object is part of the internal object graph that is used to maintain state.  It is used by the Adapter as the data source for information bound to the view.</p>
<p><pre class="brush: java;">
public class MyData{
    private String item;
    public String getItem(){return name;}
    public void setItem(String n){name = n;}
}
</pre></p>
<p><strong>The Activity (Abbreviated)</strong><br />
The following shows an abbreviated version of a definition for an Activity class that uses the defined ListView (see above).  Although it looks intimidating, this Activity class contains all the basics of a normal Activity class.  However, part of the definition an Adapter class used to bind data to the ListView (see class MyListAdapter).</p>
<p><pre class="brush: java;">
public class MyListActivity extends Activity{
    ListView listView;
    List&lt;MyData&gt; dataSource;
    MyListAdapter adapter;

    ...

    @Override
    public void onCreate(Bundle savedInstanceState) {
        this.setContentView(R.layout.list_layout);
        listView = (ListView) findViewById(R.id.my_list);
        dataSource = new ArrayList&lt;MyData&gt;();
        adapter = new MyListAdapter(this, R.layout.item_layout, dataSource);
        listView.setAdapter(adapter);
        ...
	}

	// private Adapter for my list
	private static class MyListAdapter extends BaseAdapter {
	    private Activity parentActivity;
	    private int itemLayoutId;
	    private List&lt;MyData&gt; dataSource;
	    private LayoutInflater inflater;

		// constructor for adapter
    	    public MyListAdapter(Activity activity, int layoutId, List&lt;MyData&gt; ds){
    		parentActivity = activity;
    		itemLayoutId = layout;
    		dataSource = ds;
    		inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    	    }

		@Override
		public View getView(int pos, View convertView, ViewGroup parentView){
			View view = null;
			if(convertView == null){
				view = inflater.inflate(itemLayoutId, parentView, false);
				TextView textView = (TextView)view.findViewById(R.id.data_item);
				String data = dataSource.get(pos).getItem();
				textView.setText(data);
			}else{
				view = convertView;
			}
			return view;
		}
	}
}
</pre></p>
<p>If you have implemented an <a title="Activity" href="http://developer.android.com/reference/android/app/Activity.html">Activity</a> before, the beginning should look familiar.  In the onCreate() method, we bind the Activity to the main layout my_list.  Next we pull out the ListView instance from that layout and set its adapter to an instance of the custom adapter class defined by MyListAdapter.</p>
<p>The class MyListAdapter is simple.  It extends the <a title="BaseAdapter" href="http://developer.android.com/reference/android/widget/BaseAdapter.html">BaseAdapter</a> which is provided by the SDK as a starting point for custom adapters.  You must override public method getView() as shown above.  This method will be called by the View instance, bound to this adapter, to draw the portion of the View that displays the data at the specified position in the data set.  In the snippet, we use and Inflater to reconstruct the View represented by R.layout.item_layout.  Then bind the data to a TextView instance contained in the layout.  The entire inflated View instance is returned by getView() to be used by the parent view.</p>
<h3><strong>Beware!</strong></h3>
<p>While getView() provides the core logic for your adapter to expose your custom data.  I found that it&#8217;s also <strong>important to override the following methods</strong> shown below.  If not you will spend hours trying to figure out why your list is not displaying properly.</p>
<p><pre class="brush: java;">
    private static class MyListAdapter extends BaseAdapter{
    ...
        @Override
	public int getCount() {
		return (dataSource != null) ? dataSource.size() : 0;
	}

	@Override
	public Object getItem(int idx) {
		return (dataSource != null) ? dataSource.get(idx) : null;
	}

	@Override
	public long getItemId(int position) {
		return  position;
	}

	@Override
	public boolean hasStableIds(){
		return true;
	}

	@Override
	public int getItemViewType(int pos){
		return IGNORE_ITEM_VIEW_TYPE;
	}

	@Override
	public int getViewTypeCount(){
		return 1;
	}
    }
</pre></p>
<p>While these methods look simple, they are used by the Adapter API to figure out how render the bounded views.  You can find more information about them from the SDK Android doc page for <a title="Adapter" href="http://developer.android.com/reference/android/widget/Adapter.html">Adapter</a>.</p>
<p>I hope this was helpful to your Android development efforts!  I have written enough.  Until next time!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vladimirvivien.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vladimirvivien.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vladimirvivien.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vladimirvivien.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vladimirvivien.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vladimirvivien.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vladimirvivien.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vladimirvivien.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vladimirvivien.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vladimirvivien.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vladimirvivien.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vladimirvivien.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vladimirvivien.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vladimirvivien.wordpress.com/50/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=50&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.vladimirvivien.com/2011/09/09/creating-android-view-adapters-is-easy-but-beware/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">vladimirvivien</media:title>
		</media:content>
	</item>
		<item>
		<title>Returning to Blogging</title>
		<link>http://blog.vladimirvivien.com/2011/06/18/returning-to-blogging/</link>
		<comments>http://blog.vladimirvivien.com/2011/06/18/returning-to-blogging/#comments</comments>
		<pubDate>Sat, 18 Jun 2011 21:55:00 +0000</pubDate>
		<dc:creator>vladimirvivien</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vladimirvivien.wordpress.com/2011/06/18/returning-to-blogging</guid>
		<description><![CDATA[I haven&#8217;t written down my thoughts in so long using blog that I forgot I had a blogging website.  Last couple of years have been moving fast so I adopted a medium that moves just fast, Twitter.  However, Twitter can be noisy.  While Twitter is a good source for info junky like myself, the stream [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=6&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t written down my thoughts in so long using blog that I forgot I had a blogging website.  Last couple of years have been moving fast so I adopted a medium that moves just fast, Twitter.  However, Twitter can be noisy.  While Twitter is a good source for info junky like myself, the stream of text that it provides tend to drown quickly good ideas and posts as they are swept away with every refresh.  So, to provide a more permanent place to my rant, ideas, and thoughts, I have decided to return back to blogging.
<div></div>
<div>Yes, it will be fun again.</div>
<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-6012930774887568189?l=blog.vladimirvivien.com' alt='' /></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vladimirvivien.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vladimirvivien.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vladimirvivien.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vladimirvivien.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vladimirvivien.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vladimirvivien.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vladimirvivien.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vladimirvivien.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vladimirvivien.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vladimirvivien.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vladimirvivien.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vladimirvivien.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vladimirvivien.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vladimirvivien.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=6&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.vladimirvivien.com/2011/06/18/returning-to-blogging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">vladimirvivien</media:title>
		</media:content>

		<media:content url="https://blogger.googleusercontent.com/tracker/17720202-6012930774887568189?l=blog.vladimirvivien.com" medium="image" />
	</item>
		<item>
		<title>The JavaFX Cookbook</title>
		<link>http://blog.vladimirvivien.com/2010/08/26/the-javafx-cookbook/</link>
		<comments>http://blog.vladimirvivien.com/2010/08/26/the-javafx-cookbook/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 21:30:00 +0000</pubDate>
		<dc:creator>vladimirvivien</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vladimirvivien.wordpress.com/2010/08/26/the-javafx-cookbook</guid>
		<description><![CDATA[You know that feeling you have after you run (if you run) a long distance that you have been trying to break for the longest.  Well, I have that same feeling of hard-work-pays-off with the publishing of my first book &#8220;JavaFX 1.2 Application Development Cookbook.&#8221;  As of yesterday, 8/25/10, I received a note from Packt [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=7&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You know that feeling you have after you run (if you run) a long distance that you have been trying to break for the longest.  Well, I have that same feeling of hard-work-pays-off with the publishing of my first book &#8220;JavaFX 1.2 Application Development Cookbook.&#8221;  As of yesterday, 8/25/10, I received a note from Packt Publishing that the book is going to the printer and I will have my copies soon. </p>
<p>Despite all the delays and the inevitable curve balls life throws at you (I had quite a few last and this year), the book is done.  Like anything worth doing its a gratifying feeling.  Now, let&#8217;s see if Oracle will come out with some extraordinarily good news for JavaFX  (at JavaOne 2010) to give wind to my JavaFX wings. </p>
<p>Go to <b><a href="http://www.javafxcookbook.com/">http://www.javafxcookbook.com/</a></b> for how-to&#8217;s and tutorials and (if you don&#8217;t mind) pick up a copy of the book.  Thanks!
<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-1721942798668913621?l=blog.vladimirvivien.com' alt='' /></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vladimirvivien.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vladimirvivien.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vladimirvivien.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vladimirvivien.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vladimirvivien.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vladimirvivien.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vladimirvivien.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vladimirvivien.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vladimirvivien.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vladimirvivien.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vladimirvivien.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vladimirvivien.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vladimirvivien.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vladimirvivien.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=7&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.vladimirvivien.com/2010/08/26/the-javafx-cookbook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">vladimirvivien</media:title>
		</media:content>

		<media:content url="https://blogger.googleusercontent.com/tracker/17720202-1721942798668913621?l=blog.vladimirvivien.com" medium="image" />
	</item>
		<item>
		<title>iPhone 3GS + iOS 4.0 = Wait for 4.1</title>
		<link>http://blog.vladimirvivien.com/2010/07/08/iphone-3gs-ios-4-0-wait-for-4-1/</link>
		<comments>http://blog.vladimirvivien.com/2010/07/08/iphone-3gs-ios-4-0-wait-for-4-1/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 11:30:00 +0000</pubDate>
		<dc:creator>vladimirvivien</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vladimirvivien.wordpress.com/2010/07/08/iphone-3gs-ios-4-0-wait-for-4-1</guid>
		<description><![CDATA[Couple weeks ago I updated my phone to the new iOS4.  I was excited to be able to play Pandora in the background while texting (or doing whatever else to enjoy multitasking).  After I download the new version of Pandora multitasking, I was able to run Pandora and do something else on the phone without [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=8&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Couple weeks ago I updated my phone to the new iOS4.  I was excited to be able to play Pandora in the background while texting (or doing whatever else to enjoy multitasking).  After I download the new version of Pandora multitasking, I was able to run Pandora and do something else on the phone without Pandora stopping.</p>
<p>Besides multitasking there are some other nice features in 4.0 that I like:</p>
<ul>
<li>GUI Speed &#8211; that is the first thing you notice, things are snappier</li>
<li>Folders &#8211; group application into folders</li>
<li>App Tray &#8211; double click the home button and you get a list of currently running/paused apps that you can quickly switch from</li>
<li>Camera &#8211; got nice update, simulated shutter speed is improved, digital zoom added</li>
<li>Bluetooth &#8211; voice command works via bluetooth now</li>
</ul>
<p>However, my excitement started to wear thin as I notice some annoyances that keep reoccurring:</p>
<ul>
<li>Phone Crash &#8211; the most annoying is the phone crashing.  Prior to 4.0, I never had to do a restart on my phone.  With 4.0 I had to do that 3 times already.  Sometimes in the middle of a conversation phone becomes unresponsive and must be restarted</li>
<li>More frequent drop calls </li>
<li>Bluetooth transition slow &#8211; now, phone will ring first before it switch to my car</li>
</ul>
<p>Conclusion: iOS4 is great, but wait for iOS 4.1 if you own the 3GS.  Hopefully that will address some of the issues I mentioned (actually the iPhone4 has its own set of bugs that 4.1 will also address, so just wait).
<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-6263406905616297345?l=blog.vladimirvivien.com' alt='' /></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vladimirvivien.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vladimirvivien.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vladimirvivien.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vladimirvivien.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vladimirvivien.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vladimirvivien.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vladimirvivien.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vladimirvivien.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vladimirvivien.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vladimirvivien.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vladimirvivien.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vladimirvivien.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vladimirvivien.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vladimirvivien.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=8&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.vladimirvivien.com/2010/07/08/iphone-3gs-ios-4-0-wait-for-4-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">vladimirvivien</media:title>
		</media:content>

		<media:content url="https://blogger.googleusercontent.com/tracker/17720202-6263406905616297345?l=blog.vladimirvivien.com" medium="image" />
	</item>
		<item>
		<title>Google Buys On2. JavaFX Gains?</title>
		<link>http://blog.vladimirvivien.com/2009/08/05/google-buys-on2-javafx-gains/</link>
		<comments>http://blog.vladimirvivien.com/2009/08/05/google-buys-on2-javafx-gains/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 20:42:00 +0000</pubDate>
		<dc:creator>vladimirvivien</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vladimirvivien.wordpress.com/2009/08/05/google-buys-on2-javafx-gains</guid>
		<description><![CDATA[When Google purchased YouTube back in 2006, the Flash video (FLV) format got an astronomical boots almost overnight. The media format became even more popular, the Flash/Flex pair gained notoriety as a viable platform, Adobe fortified its arsenals in the battle for media dominance. This single act shadowed other players such as Real, Microsoft, and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=9&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal"><span style="font-size:10pt;">When Google purchased YouTube back in 2006, the Flash video (FLV) format got an astronomical boots almost overnight.  The media format became even more popular, the Flash/Flex pair gained notoriety as a viable platform, Adobe fortified its arsenals in the battle for media dominance.  This single act shadowed other players such as Real, Microsoft, and to a certain extent Apple&#8217;s QuickTime (when was the last time you embedded a Microsoft Media Player on your website).</span></p>
<p class="MsoNormal"><span style="font-size:10pt;">Today (in <a href="http://www.techcrunch.com/2009/08/05/google-acquires-video-compression-technology-company-on2-for-106-million/" target="_blank">TechChruch</a>), it was announced that Google is purchasing On2, the media compression technology company behind many of the most popular media codecs including FLV.  This has the potential to change the course of online video technologies once again.  One can only imagine some of the implications this purchase will have</span></p>
<ul>
<li class="MsoNormal"><span style="font-size:10pt;">It moves Google higher in the      media compression food chain and gives it complete control of the most      popular codecs used on the web.  </span></li>
<li class="MsoNormal"><span style="font-size:10pt;">Google may      open source the current proprietary VP6 (on which Flash video is based)      &amp; VP7 codec formats that On2 licenses to companies.   They      may decide to provide needed support for the Ogg Theora format and make it      first class citizen in the compression stack.</span></li>
<li class="MsoNormal"><span style="font-size:10pt;">With Google&#8217;s push of HTML5      which includes the notion of built-in video/audio support, one can rightly      guess that we will see On2 technologies in Chrome Browser, Chrome OS, and      Android and anywhere else Google control (which is wide and far). </span></li>
<li class="MsoNormal"><span style="font-size:10pt;">As Ogg (Vorbis and Theora)      becomes the open source format of choice for media delivery, Google      will wield its influence on the format and direction of media deliver on the web. </span></li>
</ul>
<p class="MsoNormal"><span style="font-size:10pt;">Why am I rambling about On2, Ogg, and video codec formats? Well, it all has to do with JavaFX.  One of the selling point of JavaFX is portable playback of Video/Audio basedon VP6 (consequently FLV). With the purchase of On2, Google will have a direct control of the destiny of media codec supported by JavaFX.<span>  </span>Depending on how Google proceeds, we, in the Java community, may see positive developments for JavaFX and this is how:</span></p>
<ul>
<li><span style="font-size:10pt;">Google open sources the On2 codec stack: big win for JavaFX (to a certain extent Adobe).  This will imply that JavaFX applications can take part in the online media revolution with lowered entry points.We probably will see Java bindings to the codec&#8217;s API&#8217;s which means building both encoders and players in Java/JavaFX.</span></li>
<li><span style="font-size:10pt;">If the stack is open source, this may also mean eventual support on JavaFX mobile platforms. </span></li>
<li><span style="font-size:10pt;">Google may make On2 encoding tools available for free: another win for JavaFX! More videos being created with the supported On2 formats means more opportunities for JavaFX developers to create players.</span></li>
</ul>
<p class="MsoNormal"> <span style="font-size:10pt;">Or, Google may decide to just sit on the technologies use them to further their ambitions in Mobile, desktop OS, and web markets.   Only time will tell.</span></p>
<p class="MsoNormal"><span style="font-size:10pt;"> </span></p>
<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-3669275754667308859?l=blog.vladimirvivien.com' alt='' /></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vladimirvivien.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vladimirvivien.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vladimirvivien.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vladimirvivien.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vladimirvivien.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vladimirvivien.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vladimirvivien.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vladimirvivien.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vladimirvivien.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vladimirvivien.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vladimirvivien.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vladimirvivien.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vladimirvivien.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vladimirvivien.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=9&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.vladimirvivien.com/2009/08/05/google-buys-on2-javafx-gains/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">vladimirvivien</media:title>
		</media:content>

		<media:content url="https://blogger.googleusercontent.com/tracker/17720202-3669275754667308859?l=blog.vladimirvivien.com" medium="image" />
	</item>
		<item>
		<title>NetBeans 6.7.1 + Mac OS = Sweetness</title>
		<link>http://blog.vladimirvivien.com/2009/07/30/netbeans-6-7-1-mac-os-sweetness/</link>
		<comments>http://blog.vladimirvivien.com/2009/07/30/netbeans-6-7-1-mac-os-sweetness/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 17:18:00 +0000</pubDate>
		<dc:creator>vladimirvivien</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vladimirvivien.wordpress.com/2009/07/30/netbeans-6-7-1-mac-os-sweetness</guid>
		<description><![CDATA[I just updated my netbeans to 6.7.x on the Mac and the difference is vivid.Even faster start timeSnappier GUIOn the Mac, the new look makes it look nativePlus all the other goodies (Groovy, JavaFX, etc)<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=10&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I just updated my netbeans to 6.7.x on the Mac and the difference is vivid.<br />Even faster start time<br />Snappier GUI<br />On the Mac, the new look makes it look native<br />Plus all the other goodies (Groovy, JavaFX, etc)
<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17720202-2117679714381316348?l=blog.vladimirvivien.com' alt='' /></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vladimirvivien.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vladimirvivien.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vladimirvivien.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vladimirvivien.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vladimirvivien.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vladimirvivien.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vladimirvivien.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vladimirvivien.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vladimirvivien.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vladimirvivien.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vladimirvivien.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vladimirvivien.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vladimirvivien.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vladimirvivien.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=10&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.vladimirvivien.com/2009/07/30/netbeans-6-7-1-mac-os-sweetness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">vladimirvivien</media:title>
		</media:content>

		<media:content url="https://blogger.googleusercontent.com/tracker/17720202-2117679714381316348?l=blog.vladimirvivien.com" medium="image" />
	</item>
		<item>
		<title>Introducing JmxLogger &#8211; Real-time Application Log Monitoring with JMX</title>
		<link>http://blog.vladimirvivien.com/2009/04/12/introducing-jmxlogger-real-time-application-log-monitoring-with-jmx/</link>
		<comments>http://blog.vladimirvivien.com/2009/04/12/introducing-jmxlogger-real-time-application-log-monitoring-with-jmx/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 08:21:00 +0000</pubDate>
		<dc:creator>vladimirvivien</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vladimirvivien.wordpress.com/2009/04/12/introducing-jmxlogger-real-time-application-log-monitoring-with-jmx</guid>
		<description><![CDATA[For past month, I have been working (on/off) on JmxLogger, a logging API which lets you monitor your Java Logging or Log4J application log events in real-time using JMX. I have had the idea for a while, but decided to finally capture it as project. So, here it is. http://code.google.com/p/jmx-logger/ JmxLogger JmxLogger makes it easy [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=11&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For past month, I have been working (on/off) on JmxLogger, a logging API which lets you <span style="font-weight:bold;">monitor your Java Logging or Log4J application log events in real-time using JMX</span>. I have had the idea for a while, but decided to finally capture it as project. So, here it is.<br />
<a href="http://code.google.com/p/jmx-logger/"><br />
<span style="font-weight:bold;">http://code.google.com/p/jmx-logger/ </span></a></p>
<p><span style="font-size:180%;">JmxLogger</span><br />
JmxLogger makes it easy to <span style="font-weight:bold;">broadcast your Java Logging or your Log4J log events</span> as JMX notifications. As such, you can easily monitor your application&#8217;s activity logs in real-time. Using familiar logging API and configuration mechanism (i.e. log4j.xml or Java Logging properties file), developers can quickly integrate realtime application log monitoring into their existing deployed code. All it takes is a logging configuration change.</p>
<p>The JmxLogger API provides a <span style="font-weight:bold;">Java Logging Handler</span> and a <span style="font-weight:bold;">Log4J Appender</span> which can be used to integrate between your favorite logging framework and JMX. <span style="font-weight:bold;">JmxLogger hides the complexity of dealing with JMX</span>. You simply configure your logging framework as you normally do, and that&#8217;s it. You are ready to broadcast your logging events as JMX notification events.</p>
<h2><a name="Features"></a>Features</h2>
<ul>
<li><a name="Features"></a>Support for <strong>Java Util Logging</strong> API</li>
<li><a name="Features"></a>Support for the <strong>Log4J</strong> logging API</li>
<li><a name="Features"></a><strong></strong></li>
<li><a name="Features"></a><strong>Easy integration</strong> with your favorite logging framework</li>
<li><a name="Features"></a><strong>No coding</strong> required, simply <strong>configure your logging framework</strong> to get started.</li>
<li><a name="Features"></a><strong>Specify and control</strong> the level of event to broadcast</li>
<li><a name="Features"></a><strong></strong></li>
<li><a name="Features"></a><strong>Monitor event</strong> through a console or listener scripts</li>
<li><a name="Features"></a>Realtime monitoring of your application activity logging via JMX.</li>
</ul>
<h2><a name="Getting_Started"></a>Getting Started</h2>
<ul>
<li><a name="Getting_Started"></a>Download the jar (generic or with log4j support)</li>
<li><a name="Getting_Started"></a>Add jar to your classpath (in case of Log4J, you will need log4j.jar on your classpath)</li>
<li><a name="Getting_Started"></a>Configure your favorite logging framework</li>
<li><a name="Getting_Started"></a></li>
<li>Use JMX console (JConsole or VisualVM) to monitor your log actvities.<a name="Getting_Started"></a></li>
</ul>
<h3><a name="Logs"></a>JmxLogger Events</h3>
<p>When you log your application events using either Java Logging or Log4J (see project site for more detail), your <span style="font-weight:bold;">log events</span> will <span style="font-weight:bold;">get routed</span> to the <span style="font-weight:bold;">JmxLogger Java Logging Handler</span> or <span style="font-weight:bold;">Log4J Appender</span> defined in your application&#8217;s logging configuration file.</p>
<p>Below you can see a configuration that sends log messages to the Console and a JmxLogger Logging Handler.</p>
<p>Using a command-line Console you can see your log message messages as they are logged in your application.</p>
<p><img src="http://jmx-logger.s3.amazonaws.com/jmx-logger-console.png" alt="" /></p>
<p>The same log events are also emitted as JMX notifications. Using <span style="font-weight:bold;">JConsole</span>, you can <span style="font-weight:bold;">see these events as they are logged in your application in real-time</span>.</p>
<p><img src="http://jmx-logger.s3.amazonaws.com/jmx-logger-jconsole.png" alt="" /></p>
<p>That&#8217;s it! You have seen how JmxLogger can effortlessly integrate JMX and the two standard logging API&#8217;s available (Java Logging and Log4J).</p>
<div class="blogger-post-footer"><img src="https://blogger.googleusercontent.com/tracker/17720202-5384378840389113503?l=blog.vladimirvivien.com" alt="" width="1" height="1" /></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vladimirvivien.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vladimirvivien.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vladimirvivien.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vladimirvivien.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vladimirvivien.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vladimirvivien.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vladimirvivien.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vladimirvivien.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vladimirvivien.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vladimirvivien.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vladimirvivien.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vladimirvivien.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vladimirvivien.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vladimirvivien.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.vladimirvivien.com&amp;blog=27119686&amp;post=11&amp;subd=vladimirvivien&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.vladimirvivien.com/2009/04/12/introducing-jmxlogger-real-time-application-log-monitoring-with-jmx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">vladimirvivien</media:title>
		</media:content>

		<media:content url="http://jmx-logger.s3.amazonaws.com/jmx-logger-console.png" medium="image" />

		<media:content url="http://jmx-logger.s3.amazonaws.com/jmx-logger-jconsole.png" medium="image" />

		<media:content url="https://blogger.googleusercontent.com/tracker/17720202-5384378840389113503?l=blog.vladimirvivien.com" medium="image" />
	</item>
	</channel>
</rss>
