Tuesday, August 11, 2009

Using Spring with multiple databases Part 1

This series of articles is about how to use the Spring framework within your application to reference multiple databases or in Java parlance datasources.
In a previous project, I used NHibernate and ActiveRecord and I was able to relatively painlessly use multiple databases. In Spring, to use multiple databases it took longer since my googling came up with some examples , but not complete enough that when tested gave me what I needed. In the Spring framework world and in the Java world in general there all several database persistences technologies. There is plain vanilla Hibernate, there is JPA via Hibernate, there is JPA via TopLink, there is Spring's HibernateTemplating, and plenty more.
To setup Spring with multiple databases, we are going to do the following:
Prerequisite:
Download and setup SpringFramework 3.0 from the Trunk.
Download and setup Hibernate 3.5 from the Trunk.
Download and setup Atomikos Transaction Manager. (optional download sources)
1) Setup our datasources in our applicationcontext.xml
2) Setup SessionFactory configurations in our applicationcontext.xml
3) Setup JTATransactionManager configurations in our applicationcontext.xml
4) Create a custom JTATransactionFactory class to deal with Hibernate bug: HHH-3110
5) Configure Atomikos (turn off logging on Atomikos)
6) Configure Dao and Controllers with @Transactional annotation
Editors Note: Need @Transactional annotation in Controller , having @Transactional in Dao did not always create a Transaction.
7) Create Unit Tests
8) Take a break!

In part 2, we will setup our datasources. In part 3, we will setup our SessionFactories.

Wednesday, July 1, 2009

Add Any Gadget to Your Gmail (including ours)

After watching a presensation online at Google I/O , they demonstrated that in addition to being able to add gadgets to you google home page ( www.google.com/igoogle), you can also add gadgets to you gmail page.
Here is how you do it:
To add a gadget to the left nav of your Gmail account, follow these steps:

1. Go to the 'Labs' tab under Gmail Settings.
2. Enable the 'Add any gadget by URL' experiment and click 'Save Changes.'
3. Now you'll have a 'Gadgets' tab under Settings.
4. Enter the URL of an OpenSocial gadget spec and click 'Add'.

In EnduroTracker.com's case the url is: http://endurosocial.googlecode.com/svn/trunk/trunk/qaendurotrackeroauth.xml

Wednesday, June 17, 2009

On Newsstands now, Wired - July 2009 - Athletes - Track your Data

As software developer who works on a site that does exactly this,
I was very pleased to see the cover of Wired this month (July 2009) covering
Athletes who now Track their data using Gps devices, heart rate monitors, etc.
and also use different websites similar to mine (http://www.EnduroTracker.com )to plan, track, and analyze their data.

Thursday, June 11, 2009

Gadgets and Widgets Oh My!

In this blog post I thought I would talk about OpenSocial Gadgets since Google starting promoting Gadgets last week by way
of having celebrities share their iGoogle setup with selected Gadgets.
At a high level a container site like iGoogle (http://www.google.com/igoogle) let's users add gadgets to their customizable home page.
A gadget is a web application in itself, and can do pretty much anything a standard web page can do (except its real estate/size on page is restricted).
For example, you can add Espn's gadget to your iGoogle page, and it will display headlines from Espn. You can also add things like a weather gadget, and even a Google gmail gadget so you can read your email without leaving iGoogle. As an avid internet user I find that after a while, I can end up with 20 or more browser tabs or browser windows open when I'm browsing thru my favorite sites. However, if all my favorite sites had gadgets I could just have 1 tab open to iGoogle and I browse my favorites from all in one place. It is great for consolidating and streamlining how you use the internet.
Being a fan of making users internet experience better, I took the plunge and developed a OpenSocial Gadget for http://www.EnduroTracker.com.
To add the Gadget to your iGoogle page just click the google icon on the bottom of the site.
If you are developer and want to take the plunge I have a few suggestions.
There is some good documentation out there. The first documentation to read is the igoogle developer's guide, http://code.google.com/apis/igoogle/docs/igoogledevguide.html
After reading thru the majority of this documentation, it is a good idea to create a simple Hello World gadget using google's sandbox.
If you need to utilize security/authentication to pull data from your site, then you will need to implement OAuth. It is a good idea to first read the documentation and demos
at http://oauth.net .
A good code example of using OAuth from both a provider and consumer perspective, is http://lab.madgex.com/oauth-net/
If you are going down the OAuth path and are choosing to create a Gadget for iGoogle, your site will need to implemented an OAuth Provider.
I have implemented an OAuth provider using the Open Source MVC framework for .Net (C#) Castle MonoRail, if anyone using Castle MonoRail is interested in
viewing or using my OAuth provider code let me know by leaving a comment and I can share it via code.google.com.
In a nutshell, you will need a Container (iGoogle), a OAuth provider (your site), and your Gadget code (an xml file).
Once you have picked your Container (google has one as does yahoo, myspace, etc), written your OAuth provider code, and have a some Gadget code,
you should test all your code locally. This way you can have your own local sandbox to step thru your code as you work out the kinks.
How can I implement a Container like igoogle locally? Well, the short answer is that you can use Shindig which is an open source container.
It is available here: http://incubator.apache.org/shindig/
If you want to setup Shindig, see my March 16th blog entry below.
There are major benefits to using OpenSocial and OAuth. Both projects are standards driven meaning that they work with lots of different sites and vendors
to come up with best standards for all parties involved. This means that lots of sites are using OpenSocial and OAuth. The major players being Google, Yahoo,
Twitter, and MySpace. Once you implemented OpenSocial and OAuth for one of these sites, it will be very easy to integrate with the other sites. This means developers
don't have to write separate integration code for each site. Developers can use the DRY principle (don't repeat yourself).

Thursday, June 4, 2009

Nice Article on General Setup of Fedora 9

Here is a decent article on how to setup Fedora 9 in general using yum.
http://www.mjmwired.net/resources/mjm-fedora-f9.html#yum

Thursday, May 28, 2009

New Feature Google Gadget

We are proud to now offer the ability to view your current weekly mileage statistics on your Google home page by using our EnduroTracker Gadget.
There are 2 ways to add the EnduroTracker Gadget to your Google home page. The first and easiest is to go to www.EnduroTracker.com
and click the Google icon on the bottom of the page.
The second way is to log into your Google home page at www.google.com/ig, click Add Stuff link on the top right hand side. On the next page, click on the Add Feed or gadget link located on the left side midway down the page. Enter or paste the following url into the input box: http://endurosocial.googlecode.com/svn/trunk/trunk/qaendurotrackeroauth.xml
To personalize the gadget , click the personalize link within the gadget, and login using your EnduroTracker credentials.


Also you can click the link below, to add the EnduroTracker Gadget to your Google home page



Add EnduroTracker's Gadget to your Personalized Google Start Page

Monday, May 18, 2009

New Amazon EC2 Features

Amazon EC2 just added some higher level applications/services
like AutoScaling, Load Balancing, and Monitoring , link : http://aws.amazon.com/autoscaling/

Setting up Load Balancing and Monitoring on your own is straight forward, but AutoScaling is not easy. AutoScaling could be extremely useful to most people using EC2.