Extending the OSGI Console

I was going to submit this to the IBM Developer Works site but I did not want to wait the four weeks to get it published. So here is the short version of the original article, I may still post a more comprehensive one but it will contain an even further extension of the console.

One of the best things a developer can do is make his code easily testable and accessible to other developers and quality assurance engineers. I have always been one to promote enablement and ease of use over complexity. The easier you can make your programs to figure out the better bugs are found and then fixed. Diagnostic tools and automation are great starts but many times the actual product itself becomes a debugging tool. I learned this very early in my career by paying attention to the way servers are created. Then an even more interesting observation occurred when I installed the client version of Quake; it had a console! Not only could you change configuration settings but you could also affect the immediate game with live bot commands.

So now, I make it a precedence to provide things like command line utilities, debug options and now OSGI console commands in my Eclipse projects. My latest attempt was to get some basic query commands for the new WED client side Property Broker. The broker basically has a registry of Wires, Actions and Properties (just like Portal server). The problem is when you have many Wires, Actions and Properties you may loose track as to which ones are enabled, disabled, registered properly, etc.

By extending the OSGI console, I now give developers and QE a way to query the broker for what is going on in its registry. Currently there are only read only commands but you are only limited to your imagination.

So how is it done?

Extending the OSGI console in Eclipse is extremely simple. You start by creating a new class and implementing org.eclipse.osgi.framework.console.CommandProvider. Once the class is created, you provide the getHelp() version for your provider and a constructor where you register your CommandProvider with the console. Here is a sample constructor that registers the current class as an OSGI Service for the CommandProvider:

public MyNewConsoleCommands(BundleContext context){

Dictionary props = new Hashtable();
props.put(Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE-100));

context.registerService(CommandProvider.class.getName(), this, props);
}

Once your class is registered you can now start implementing commands. So what makes a command you ask? Well, its actually not very straightforward but once you hear it the concept is a piece of cake. You add commands to the console by simply creating public methods with an underscore in the front of the method name, that’s right “_”.


//This is the primary “show” command for the Property Broker
//from the console you simply type “pbsh actions and this method will be called.
//The second parameter will be the nextArgument() stored in the CommandInterpreter
//object passed in. In this case, the string next would be equal to “actions”.

public void _pbsh(CommandInterpreter ci) throws Exception {

String next = ci.nextArgument();

}

What is great about this concept is the console is only available when “-console” is added to the Eclipse executable command line. So it is only ever called if the console is in fact launched and a user types “help” and finds your commands in the console help. You can pretty much go nuts with adding commands to do all sorts of things. I noticed each release of Eclipse has more and more commands and extending the console is becoming popular even with other Eclipse based projects. You can even have undocumented commands that simply do not show up in the help. This could be considered “internal only” commands.

Go HP Support!

I bought my daughter the HP Slimline 7220 back in January and over the weekend it just stopped working. I did not get the extended Best Buy warranty so I started digging on the HP site and found they have a 12 month full replacement warranty. I felt a little better. I then did all of the basic debugging things to the PC and figured out either the motherboard is bad or the power supply is bad. I could not test the power supply because it looks like a special modified ATX plug and the pins are a little different, so the pin 13 jumper method didnt work.

So I get online to HP’s chat support and I needed to step back and let the guy do his job and just answer all of his questions. After a series of questions he concluded the power supply was bad! Now we were on to something. The immediately starts asking for shipping information (which amazed me) and then when I get done giving him that he states the power supply should arrive tomorrow! I was blown away.

And what really blew me away is I chatted with him around noon yesterday and FedEx shows up at my door at 8:40am this morning with the power supply. I quickly took the pc apart and installed the power supply and used the computer happily ever after.

The End

Ever wanted to explore writing games?

How about writing games and getting your kids to test them out on their Ninetendo DS or GameBoy? A few years back I got seriously back into writing small proof of concept games for the Ninetendo portable platforms (DS, GBA, etc) and found I could actually get up and going pretty quickly for under $200. I purchased the EZ-Flash II system for copying my code to a cartridge and viola, I could play my games! The “garage” type developer community for these machines is amazing. You can check out the GBA Devrs site for tons of information on getting started. If you want an extremely easy to use development IDE and compiler go and get the Ham Dev tools at GBA.org.

What I found interesting was how similar this platform is to the Commodore 64 and Amiga platforms with regards to development. It is definitely old style computing from a game programming point of view. You can easily do 2D sprites (movement and collision) and multi-level background scrolling with built in hardware functionality.

Americans Are Scarce in Top Programming Contest

Read this on Slashdot: http://developers.slashdot.org/article.pl?sid=06/05/10/0418218&from=rss

Which pointed to this WSJ online article: article here

Which makes me comment that if the WSJ has to write crap like this then it certainly won’t make me an enlightened reader. Is this news? I guess so. Does it make a point somewhere? Maybe…

I certainly do not think any “people” are smarter than another but it does make me ask the question, “where are all of our (American) college CS students?”. I understand professionals not getting in on things like this but why wouldn’t American college students enter? I know if I was in college I would enter things like this considering the impact it could have on a resume.

Goodbye to a family member

Scooter has been with the family for over 5 years. If it wasn’t for his brother Jack (a Jack Dempsey) he probably would have come close to his life expectency which is 10-18 years. Scooter was the reason I bought my current tank, he was the first fish and my son Bobby named him.

Scooter

Please send cards and donations to:

The Fish Fry Funeral Home
Whitesboro, NY 13492

Early Morning Golf

For the last two days (Saturday and Sunday) I have gotten up at 5:20 to be on the golf course by 6am. Some people may think it’s crazy (and even I had my doubts) but I have to admit the experience is really golf at its greatest. Both days were incredibly peaceful and relaxing; walking the course with no one in front of you holding you up or behind you pushing you or hitting into you. You see this is where nature and sport mix; you hear nothing but early morning bird calls and possibly see an occasional deer or two (or 5 like today) and the smell of freshly cut grass is all around you. It was such a great feeling walking outside in the nice green meadows with a touch of dew slowly leaving the grass. I have been struggling with my swing all year so far (yes it is still early) and for the last two days I shot in the 30′s for one of the nines. I was thinking maybe it is just my swing coming back but then I realized the perfect setting I played in each day most likely had a lot to do with it.

Using Linux at IBM

I took the plunge and used the extended 17GB of my laptop disk space and created a primary Linux partition and installed an internal test version of Linux and all of the critical business tools I need to work at the office. Which tools you ask? Well, Lotus Notes, my AT&T dialer, Sametime, Eclipse, Workplace Managed Client (with the IBM Editors) and much more. I am so impressed with the entire installation and responsiveness of the OS and the applications as well. I know it will not be long before Linux is just as common an operating system as windows in business.

Now, I can not wait to get Hannover running on it!