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!