Tuesday, February 05, 2008

Environment specific properties - the spring way.

This problem is easily solved via the use of 2 Spring IoC bean post-processor classes viz:

org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
org.springframework.beans.factory.config.PropertyOverrideConfigurer


To use this functionality you would need to have them declared in your app-context config files
as follows:


<bean id="ppConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="1" />
<property name="locations">
<list>
<value>classpath:ppc-sample.properties</value>
</list>

</property>

</bean>
<bean id="poConfigurer"
class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
<property name="location"
value="classpath:poc-sample-${my.env}.properties" />
<property name="order" value="10" />
<property name="ignoreResourceNotFound" value="true" />
</bean>


They are like any other bean definitions but there are few properties in their definitions that need special attention
as they are responsible for the magic. They are order, location and ignoreResourceNotFound.


order - determines how these post processors are loaded or applied to beans via Spring IoC.
location - (atleast in the case of the PropertyOverrideConfigurer bean) matters because of the use of an ant/JSTL/groovy property.
This is where the PropertyPlaceholderConfigurer comes in. It is used to define the default value for the my.env environment variable. Without this the PropertyOverrideConfigurer will have problems when Spring tries to load it.
ignoreResourceNotFound - makes sure there are no complaints by Spring when initialising the PropertyOverrideConfigurer bean.

Any bean where you want to use environment specific values can now be defined in your poc-sample-${my.env}.properties file.
Given the following bean configurations where you wish to use this functionality

<bean id="myBean" class="com.lhfville.sample.POC"
lazy-init="true">
<property name="prop1" value="${prop1}" />
</bean>

<bean id="myBean" class="com.lhfville.sample.POC"
lazy-init="true">
<property name="prop1" value="hi" />
</bean>

you can have poc-sample-dev.properties poc-sample-test.properties poc-sample-prod.properties files in your classpath with varying values for myBean.prop1.


Thats pretty much it.

Monday, February 04, 2008

Facebook Foray - dead in the water

Like any fairy tale this one has come to a screeching halt looking more like a nightmare. Well my facebook app will be dying a natural death as a consequence of the woeful display by my team in the Africa nations cup. I thought they'd have the balls to march all the way to the finals after surviving the scare of a horrid first round. Even after the lifeline of a penalty and a sending off for their opponents...they still lost.

Well at the very least this dilettant has enjoyed working with the Facebook API. Who knows I might do something with it again in the near future.

Have a swell week!

Wednesday, January 30, 2008

Facebook foray - extended

As promised, I am happy to tell you that my team DID progress to the next stages of the competition. This means that the motivation to keep @ my facebook application has been rekindled. The coming days will see me trying to implement the features as promised.

Stay tuned.

Tuesday, January 29, 2008

Facebook Foray

Decided to build a facebook app for the african cup of nations. Not sure that it was a useful exercise now that the fate of my favorite team hangs in the balance. For now all the application does is to allow users make predictions on the games in the first round. Features to come include:
  • Placing stories in the user's mini feed after a prediction has been added.
  • Making predictions about the highest goal scorer, number of cards etc.
I'll tell you if I get around to doing it after the fate of my team is decided today. Stay tuned.

Thursday, September 20, 2007

Adieu Jose


This is to mourn the loss of a great manager..the best that Chelsea FC has ever had. Now I definitely know that the board is decidedly crazy and has no ambitions. My last post as a Chelsea FC fan. Jose we will miss you. Over and Out!













Photo Credits:
http://pinker.wjh.harvard.edu/photos/Iceland/pages/iron%20grave%20marker.htm

Sunday, July 15, 2007

Groovy Weblogic Migration

This is a bit of a change in direction being that I prefer to rant about football and other such easy-on-the-eye material but I thought I'd bore you a bit with techie stuff...read on.

In the past few months I have begun to re-acquaint myself with Scripting/Dynamic languages and would say that they have become quite sexy and even more expressive than I remembered. I have had cause to look at Ruby and Groovy in more detail and they each have unique selling points for me. Ruby because of its expressive nature and its wicked cohort Rails and Groovy for its near Java syntax and its inherent support for all things Java. Blessings like JSR 223 and more support in the JVM for dynamic languages (JRuby and Jython) seem to have helped.

So you can imagine that the first chance I got to make something really helpful with a scripting language I decided to give Groovy a spin. I will say that it has good documentation and is quite mature. My use case? I needed to migrate a number of system resources (DataSources and Mail Sessions) from Weblogic 8.1 to Weblogic 9.2.

I had heard from a team member on my project about WLST (Weblogic Scripting Tool) and the administrative magic you could do with it..so my head started ticking. I bet there are a number of ways I could have gone about migrating these resources (I welcome suggestions) but a notion had formed in my mind about the path I would go.

The change in configuration information structure was much between the two versions so I decided I was going to read a WLS 8.1 config.xml, then generate WLST scripts to recreate interesting elements from it in WLS 9.2. Initially I wrote the first rough sketch in Java (being a masochist :-D ) but after it became unmanageable, I had written XSLT code in lieu of JAXP or XSD and JAXB, I decided to re-implement in Groovy and I am loving every minute of it..XmlSlurper rocks! I made sure to pepper my script with closures right Groovy-newbie that I am. I have put up a copy of the code here for your viewing....free gift eh?
So without further ado here is the code. Enjoy!


class Migrator {

static void main(args) {
def domain = new XmlSlurper().parse(new File(args[0]))
def msClosure = {ms ->
new PrintWriter(new FileOutputStream("c:\\stuff\\migration\\"+ms.@Name.text().replaceAll(" ","")+".py")).withWriter {writer ->
writer.println("connect('${args[1]}','${args[2]}','${args[3]}')")
writer.println("edit()")
writer.println("startEdit()")
writer.println("myMailSession = create('${ms.@Name.text()}','MailSession')")
writer.println("myMailSession.setJNDIName('${ms.@JNDIName.text()}')")
writer.println("myMailSession.setProperties(makePropertiesObject('${ms.@Properties.text()}'))")
writer.println("myMailSession.addTarget(getMBean('Clusters/${ms.@Targets.text()}'))")
writer.println("save()")
writer.println("activate(block='true')")
writer.println("dumpStack()")
writer.println("disconnect()")
}
}
def dsClosure = {ds ->
def wlstOut = new PrintWriter(new FileOutputStream("c:\\stuff\\migration\\"+ds.@Name.text().replaceAll(" ","")+".py")).withWriter {writer ->
def poolInfo = domain.JDBCConnectionPool.find{it.@Name.text() == ds.@PoolName.text()}
def startPos = poolInfo.@Properties.text().toString().indexOf("user=")
if (startPos > -1) {
def userName = poolInfo.@Properties.text().substring(startPos+5)
writer.println("connect('${args[1]}','${args[2]}','${args[3]}')")
writer.println("edit()")
writer.println("startEdit()")
writer.println("jdbcSR = create('${ds.@Name.text()}','JDBCSystemResource')")
writer.println("theJDBCResource = jdbcSR.getJDBCResource()")
writer.println("connectionPoolParams = theJDBCResource.getJDBCConnectionPoolParams()")
writer.println("connectionPoolParams.setConnectionReserveTimeoutSeconds(25)")
writer.println("connectionPoolParams.setMaxCapacity(100)")
writer.println("connectionPoolParams.setTestTableName('SQL SELECT 1 FROM DUAL')")
writer.println("dsParams = theJDBCResource.getJDBCDataSourceParams()")
writer.println("dsParams.addJNDIName('${ds.@JNDIName.text()}')")
writer.println("driverParams = theJDBCResource.getJDBCDriverParams()")
writer.println("driverParams.setDriverName('oracle.jdbc.OracleDriver')")
writer.println("driverProperties = driverParams.getProperties()")
writer.println("proper = driverProperties.createProperty('user')")
writer.println("proper.setValue('${userName}')")
writer.println("driverParams.setPassword('${userName}')")
if (args.length > 4) {
writer.println("driverParams.setUrl('${args[3]}')")
writer.println("jdbcSR.addTarget(getMBean('Clusters/${ds.@Targets.text()}'))")
} else {
writer.println("driverParams.setUrl('${poolInfo.@URL.text()}')")
writer.println("jdbcSR.addTarget(getMBean('Clusters/${ds.@Targets.text()}'))")
}
writer.println("save()")
writer.println("activate(block='true')")
writer.println("dumpStack()")
writer.println("disconnect()")
}
}
}

domain.JDBCTxDataSource.collect dsClosure
domain.JDBCDataSource.collect dsClosure
domain.MailSession.collect msClosure
}

Friday, February 16, 2007

Valentine Splash

Woah! Its was that time of the year a few days ago when you have love songs crooning on the radio, the gift shops swirling with most folks trying to surprise..or at the very least impress their lovers, restaurants all trying to out-do each other. Well yours truly was not about to be left out but, being of the regular and boring sort, I went down the safe gift route (don't ask dont tell).

I am sure that most folks know the saying that Diamonds are a girl's best friend but I daresay that conventional piece of wisdom was challenged in Gloucestershire this Valentines. How? Well the laudable Herr Jasin Boland gave as a token (though that would be an understatement) of his love a £500,000 shrink-wrapped house to his fiancee (BBC Story). I know there have been sensational gifts in the past but this one was gob-smacking. He put me and my boring gift idea to shame and that has got me thinking.....next year!

I bet his only problem now is how to beat this achievement next year. What in your opinion will knock that gift next valentines? A wedding in Rome? ;) What love luxury did you splash out on? Are you looking to better it?

Have a great weekend!

Tuesday, February 06, 2007

Hairapy

Its amazing the lengths people will go to actually get their hair looking all shiny and pretty. I was reading somewhere in the metro last week that there is a new hair treatment using bull semen. It actually costs £55 a pop and allegedly brings body and shine to your hair. Wow!
Who knows what next people will be trying out on their hair. In my uni days, some of my pals with hairlines receding faster than that of their contemporaries were partial to honey. They had to answer to ants though seeing that we were based in a tropical town. Some have used hemp, eggs...all sorts.

What are you willing to do for your hair?


Have a great week ahead!

Wednesday, March 08, 2006

Read the little print

Something strange caught my attention this morning. I picked up a pack of mango juice and after taking a swig looked at the labelling. It reads: "free from artificial flavorings, sweetners..." and then when I was just starting to believe them, I looked at the Ingredients section. Lo and behold it reads: Mango,...,flavorings,... Well that came as a shock but well it seems that we can expect more wordplay/blunders/deception like this, unless agencies set up to check excesses of this nature become more effective.


The moral: always read the little print.

Tuesday, March 07, 2006

Sad day for Chelsea

All of the Chelsea FC faithful who couldnt make it to the game at the Nou Camp will have been religiously glued to their sets earliet tonite. I was one of them and was sad to see Chelsea crash out of the competition on the back of the sending off of Del horno two weeks ago.
I guess its not yet time for the English champions to move ahead in the Champions league..but no doubt we rule the roost here at home so that is something to be grateful for.

For the records Barca is yet to beat us 11 against 11 ;)...we will be back in ferocious form next season.

See ya

Tuesday, May 10, 2005

Yet another day

Today was uneventful..got to work late and funny enough met my project manager on my way to work this morning...nabbed! Well i guess we all do it atimes - get to the office late and fib on our timesheets. In anycase the day went by without stopping.

Saw pictures of a grim-looking Jose Mourinho in the papers on my way home. I wish they didnt lose to Liverpool but I guess atimes you win some and then you lose some. Talking of changing fortunes our dear Prime Minister has selected his new cabinet and this is raising some dust plus most folks think he should resign...hmmmmm..dunno only time will tell. In the midst of all the news in the papers and some book I have been trying to read for some days now I managed to fall asleep on the tube ride home ;)...we all do it once in a while. My candid advice? Don't get caught! Atleast not by a pretty dame.

Met FA Brims online today was actually nice chatting with the lad atleast he's broken his silence. I am tryin hard to study tonight and its going to be hard so wish me luck!

Curtains......................

Sunday, May 08, 2005

Been away

Its close to 2months now since I last blogged! Why? Ok i'll tell you. Have been a bit choked up trying to strike the ultimate balance between work and other facets of my life and believe me its been like some form of high wire act.
Between the last blog and today there has been a wide range of activities from a day out to a theme park (Alton Towers), to being invited to Passover Seder, to preparing for my exams, to installing a new OS on my laptop...(on which I am posting now) to .....well just being lazy.
I have touched base with some members of the crew. FABrims and Skai have been quiet though..but spoke to Poombah some days ago. Called K earlier to say Happy birthday...time flies right? Its already May.
In any case it has been an eventful 2months which went pretty fast....havent had time to see any movies of late and havent been slushing either. Have grown a beard though and my afro is beginnning to take shape. Think i should keep the beard??? tell me in your responses to this post.
I promise not to keep away from you for that length of time again. Before I forget, the general elections have come and gone and well...Blair is still here.

Aloha

Wednesday, March 23, 2005

Mad Week

Gosh the past few days have rushed by pretty quickly. The holidays are near once again and in most parts of the world there's the usual step up in the rate of commercial activity at times like this. Its no exception here.

Well I havent really been a holiday freak and so its pretty much business as usual. Events in the past few days have also taken a strange turn as yesterday there was yet another case of under-aged gun violence in the US. Its distasteful and I can imagine what it feels like for all those families who lost lives to the reckless outburst of a certain 15-year-old. Hard pill to swallow I am sure.

Away from the sadness, theres set to be a relaunch of the sci-fi series "Dr Who" here and I cant tell what to make of it. I always loved the program and wonder if this remake will be as good as the original. For one thing the good doctor is younger now.

I wonder what to do for the holiday period especially now that the gloomy weather has given way to a bold pretty new phase. I guess I should get out and enjoy the pretty weather.
I look forward to my swimming classes this evening, as I have been away for a while now. Am yet to master the breast stroke and hope my instructor will take it easy with me today.

I will have more to tell you once I am in later this evening 'cause I know I have been away from you for two days and I am sorry. Will make it up to you when I get back. Did I mention that Skai the great Lolo touched bases with me earlier this week? Oh before I rush off the man Ziggi is at it again...he has sent me yet another set of images which I believe keep him amused...maybe I'll show you some. Then again I think not.

Ciao.

Sunday, March 20, 2005

Chill-pill Sunday

Today has been a day of relaxation and rest. Cleaned up this morning, did some washing as well. Read "The Punch" online and saw some gory tales that I'd rather leave untold.

Started reading Clinton's bio, "My Life" and already am engrossed in it....well that was until I had to do lunch/dinner 'cause I had a rather dishevelled eating pattern today. But its all good. Caught up with the OC, kinda like watching it atimes. Another pointer to weddings was shown today :)) "The wedding planner"...had seen it before but saw it yet again.

It would appear that my period of hibernation is finally over! The rat-race begins yet again tomorrow. Gosh I dread going on the tube on my way to work but its just got to be done. Ah well I'll try and sleep as much as I can 'cause the day ahead is going to be an exercise in tedium :) trust me I know what I am talking about.

Ok I'll leave you in peace.

Hitch weekend

Went to see a movie but before I tell u about that guess what?. I had an argument with my partner. Its sufficient for you to know she's nick-named after her A-list chocolate...Ferrero. We made up eventually ;) and had Italian for dinner...great way to make up init?

Hmmm yeah mentioned I was going to see a movie. I saw "HITCH"...yeah thats the one. A great movie about a date doctor. Its a hilarious romcom that promises value for your money. I think Will Smith did justice to his part and Eva Mendes is mighty fit.

Thought about Timon and Poombah earlier on and wonder how they'll be finding camp. Guess they'll both cope quite well. It was a chilly Heineken-ny close to the evening. Not bad when u think about it...Tomorrow is the start to the week...Monday's around the corner but well theres still about 24 hrs in the weekend so I am safe....Sleep safe.

Saturday, March 19, 2005

Its been a long week

Men its been a hectic week just gone by. Have had to tackle pressure on more than three fronts but yet I survive. Actually spoke to Ziggi and Mademan today and we shared a couple of laffs and some gist about future plans and getting married :). Imagine me talking about marriage and the like a few years ago...it was impossible.

Also spoke to K and she's preparing for her pageant...pray she wins cos that would give her a boost. Shes always wanted a career in modelling and all, this might well be her chance.
Hmm will go to the movies tonight seeing that i have lazed about all day.

Am new to blogging and might sound a bit off or incoherent but forgive me I guess u only get better with time. I'll tell u what movie I saw and how I found it when i get back. Till then.....

Sayonara.