Friday, June 29, 2007

Midway

Oh happy day it is, when my SoC project reaches its halfway point. The aim of the project was to allow Eclipse plugins to automatically find all the resources they needed on a computer. Well, I have finished implementing the component that routes resources to the plugins that need them.

In other words, I finished implementing org.eclipse.ecf.discovery.IDiscoveryContainerAdapter. However, it was just today when I wrote an example service finder and service consumer and they both communicated to each other via the container adapter that I realized that I'd hit a milestone.

What is left now is to actually devise a JRE finder that will locate all JREs installed on a system (for example) and communicate that to another plugin that needs the information. With a solid example like that, we can then start writing manuals and articles on using our Discovery plugin, and evangelizing to the ends of the Eclipse community.

By the way, visited the Lava Lounge yesterday. It had 3 separate dance floors with their own DJs on each of its three floors. Wow! I must say, there is something to living in the big city.

Wednesday, June 27, 2007

Where are you, Amanda Bayliss?

I've spent the past two days trying to implement the central component for Discovery. Even though I'd done it before, reimplementing it in the new style my mentors told me is proving tedious.

Well y'see, the org.eclipse.ecf.discovery interfaces are part of the larger ECF that is, while beautiful, a tad complex. I'm mostly done with IDiscoveryContainerAdapter (which keeps track of services as they come and go and notifiies consumers about these services) and it kinna hurt. For instance, to implement registerService(IServiceInfo serviceInfo), I had to implement IServiceInfo. The IServiceInfo constructor needs to take an IServiceID, and IServiceID needs 4 methods to be implemented. And it goes on, for almost each method, I'd need to create some class that implemented some interface, and then I'd need to write tests for the class I'd just created *and* for the IDiscoveryContainerAdapter I was originally working on. Its been slow, but now I've got only two methods to go...

I just finished reading The Yiddish Policemen's Union: A Novel, a novel about the Jewish state of Sitka (in Alaska, not Israel) and a Yiddish policeman whose life seems to be crumbling around him. Its very Jewish, very funny, and it had me howling in sorrow when the book finally ended.

Monday, June 18, 2007

Rearchitecturings

I had a chat with Scott Lewis on the #eclipse-soc channel at irc.freenode.net. He's one of the developers for ECF Discovery. ECF Discovery aims to (I hope I get this right) provide a high-level API for remote i.e. network based, services to keep aware of each other. Hmm, sounds a lot like the Discovery project I'm working on. My mentors sicced me on ecf.discovery to figure out if we could reuse any of their components, and after talking with Scott Lewis, it seems like we can use a lot of their code. Looks like a fair bit of my code will be going out the window soon...

In other news, I read The Little MLer yesterday and it provided a very easy-to-understand introduction to ML, a programming language family I've been trying to learn for a while now. I still don't fully understand signatures and functors, ML's version of Java interfaces and classes. If I do, ML might just supplant Scheme as my favorite class of languages.

Thursday, June 14, 2007

Synchronize

Spent yesterday trying to configure my plug-in so my mentors would be able to run it on their machines. Who would have thought it'd be so hard to get the same program to run exactly the same way on multiple machines when using a "cross platform" language like Java?

Anyway, I'm also reading "Eclipse: building commercial quality plug-ins." I'm just on the third chapter and I've already learnt quite a lot. Most importantly, I found out that Eclipse has a Find in Files feature. I'd always gone round telling people that NetBeans is better than Eclipse because it had Find in Files and Eclipse didn't. Well whaddaya know: Ctrl+H and clicking on the Java tab does just the trick. Granted, its nearly impossible to find but still, its there!

Monday, June 11, 2007

It works

Today I finished the SimpleConsumer plug-in that bugged me last week and so, there now exists a full suite of plug-ins that shows how Discovery is meant to work. Simply download the sources (you'll probably want to use the J9 6.0 JRE. We're using it for compatibility with Provisioning), and start the Discovery, SimpleFinder, and SimpleConsumer bundles as OSGi services (and probably in that order, too :-) ). On the console, you should see a message saying that a certain string has been found. Wala! It works.

Of course, its not very interesting right now but its what's behind the scenes that's really groovy. Discovery, when started, waits until Finder services are started and then it makes a note of them and what programs they can find. Then, when a Consumer is registered, it requests a ServiceDiscovery service that was started by the Discovery bundle; the ServiceDiscovery then allows the Consumer to query for programs that have been found. A tad over-engineered? Sure sounds like it, but this architecture allows all Finders and Consumers and Discovery itself to come and go as they please while the system as a whole keeps working. As usual, thanks to Markus and Remy for pointing me in the right direction at our weekend meeting.

In other news, I went to Halo again on Saturday and, miracle of miracles, four ladies started dancing with me unbidden. Yes, F-O-U-R. At once. That made for another interesting night, and pushed Halo up in my ranking of best places to hang out.

Can you guess what I'll be doing tonight...you guessed right!

Friday, June 8, 2007

Hi Dad, Hi Mom

Past two days: frustrating. I took on two tasks and have failed at them both.

1. I wrote a simple UI plugin that would query Discovery for the services sent to it by the various finders. However, I could not figure out a way to query the Discovery plugin from the UI plugin. Hmm, I thought. I ran to Barnes & Noble, read the book on Eclipse programming, thought I had the answer, came back and tried it. It didn't work.

2. I'd written a MultiMap class (a hash table from keys to multiple values) and then tried to write tests for it. Here's the code

public class MultiMap extends HashMap {

/* If KEY exists, insert VALUE under its Set,
* otherwise insert VALUE
into a new Set.
*/

public Object put(Object key, Object value) {
Object oldValue = this.get(key);

if (oldValue != null){
oldValue = ((HashSet)oldValue).clone();
((HashSet)(this.get(key))).add(value);
}else {
super.put(key, new HashSet().add(value));
}

return oldValue;
}

and here's the exception

java.lang.ClassCastException: java.lang.Boolean


For some reason, get(key) was returning Booleans instead of HashSets! Why? And no, I was not inserting Booleans of any sort into the MultiMap.

Oh well, here's hoping I get some inspiration by tomorrow...

P.S. Hi Dad. Hi Mom. Like my blog?

Wednesday, June 6, 2007

Refactorings

There's not much to say today. I refactored the source code, added comments, and then sent it over to my mentors for their advice. Hopefully they'll have lots of comments and I can be productive tomorrow. Otherwise, I might find myself playing Quake 3 Arena all of tomorrow...ahem...as I spent much of today doing.

Also, last night I read Kill the Messenger in Reader's Digest condensed book form. It was a snappy, if slightly simplistic, murder mystery. What I really loved was the author's visual imagery, as when a female detective who seemed to the reader to be much more interested in fashion that police work showed up to a murder scene in the middle of the night in head-to-toe skin-tight leather. Very entertaining.

Tuesday, June 5, 2007

Step 1 again

Yes, I know...I was a bad boy for not blogging (or doing much work either) yesterday, but I came back with a bang. Since my task for this week was to do what I'd done previously, but using OSGi services instead of extension points, I followed these excellent articles to figure out how to get my task done. The end result: I now have the basic infrastructure for adding and removing service finders. The next step will be to define a convenience library for finding things on a filesystem, and defining extension points so that service consumers can find the discovered services (yeah, still have to do EPs). Here are the latest sources for your browsing pleasure.

By the way, over the weekend I read Sam Harris' The End of Faith: a book that partly tells how religious moderates are endangering the world by tolerating fanatics. I also finished Applied Cryptography, a programmer's introduction to the subject that manages to insert humor into the myriad stories of Alice and Bob and Eve; it was a strangely satisfying read.

P.S. I was motivated to work long and hard today, thanks to a long and interesting night last night at Halo that broke the monotony of a week spent reading and coding. However, I have to ask, Why are so many Atlantans partying on a Monday night?

Friday, June 1, 2007

Lethargy

Didn't get much done by way of productive work. However, I read the Eclipse coding standards and a couple other documents and I think I've got a good handle on what yesterday's discussion was all about.

Part of the reason I've been so unproductive is that I had (my first ever) $10 cocktail at Trois bar. From the way I felt this morning, it was certainly worth it.