Twitter github

An Eclipse-based Facebook Application (Part 2)

Since we have a plug-in available to exercise the Facebook API (see Part 1), the next step is to create a ‘org.eclipse.facebook.ui’ plug-in that will exercise that API. What I generally do when testing some new code in Eclipse is to create a simple view. In this case, I’ll create a stub view with a hyperlink to launch some Facebook login wizard (along with some other test hyperlinks):

Now that I have the basic code infrastructure in place, let’s get our Web 2.0 on by using that Facebook API! In Eclipse land, to take advantage of another plug-ins’ classes, you need to express a dependency on it. So in order for me to use the Facebook API plug-in I created in Part 1, we need to depend on it. We can do this in the plug-in manifest editor by going to the dependencies page and adding a dependency for the ‘com.facebook.api’ plug-in:

After reading the Facebook API in detail… it seems the API for logging in is straightforward albeit a bit tricky for a deskop-based application. In essence, you have to point to a special URL given to you by Facebook to login… once a user logs in, you need to capture a token that you use to create a REST client for Facebook API access. Ok, translating this into Eclipse terms, I figure all I need is a popup dialog and an SWT Browser widget with a clever listener. So here it is:

All this code does is create an embedded browser within a popup dialog and fishes for a particular authentication token from Facebook. If it finds the particular token, it will create a session with Facebook, if not, it will keep the dialog open until the user properly authenticates.

I was initially having trouble logging in to the service because I was stupid in how I was parsing the authentication token. I didn’t solve the problem until I enabled some tracing information. One interesting way to allow tracing for your Eclipse-based applications is to use the Platform debug facilities.

The basic gist is to create a .options file in the root of your plug-in. Here is how the ‘org.eclipse.osgi’ plug-in .options file looks like:

Pretty simple right…? Now, when you go to launch Eclipse applications, there is a tracing tab that allows you to tweak this options on and off to see what type of tracing information you would like:

I basically enabled this tracing ability within the facebook plug-in:

I then peaked at the console after I logged into see some tracing output:

So there, now I have a simple little framework to enable configurable tracing within my Eclipse-based applications.

That’s it for Part 2. In Part 3, we will cover things like separating core code from user interface code, Eclipse Forms and amongst whatever else pops up in my head.

Lessons Learned

  • Start simple and iterate as you make progress
  • A simple view provides a good way to test code
  • Trace early, trace often
  • Platform debug tracing provides a simple way to enable configurable development time debugging

Thanks for listening.

I love transparency

I have to admit it, I love interviewing potential interns almost as much as I love plug-ins and double chocolate-chip macadamia nut cookies.

I enjoy hiring interns for two main reasons:

  • Mentoring is incredibly enjoyable for me, especially with students
  • I get to have a field day searching for stuff on Google, Facebook, Myspace.

Why am I bringing this up… well, I came across this article today on teachers and how the transparency of the internet is making things problematic. In the case of my lucky interns, it makes for a sometimes comical interview process. I’m usually suspicious of the candidate if I can’t find anything via a google search or some other mechanisms. Sure, I search avenues like CIA.vc, Ohloh and SF.net for more important information, but what’s the point to life without a little comedy :)?

The point I’m trying to make is that the internet is changing the way the workforce operates. It is making the activities of people transparent in ways never imagined. It’s almost like having a little camera follow you around. For example, I just noticed Peter Friese ‘tag’ me in a photo trying to save the Modeling community with bug 109137:

Sure, there’s nothing wrong with this photo, it’s legit, it proves that I was working at Eclipse Forum Europe instead of drinking German beer!

In the end, transparency is here to stay, whether you want it or not. The question is how we deal with it and how it will change the workforce? How have your companies or projects adapted to this new world? How have YOU adapted to this new world? Are you avoiding social sites and pro-actively trying not to be indexed by the internet? Do you plan to name your kid ‘Mike Smith’ (a common American name) and hope it’s impossible to find relevant information? Are you becoming a Luddite :)?

Thoughts? I’m just curious how people are living with this new reality.

Eclipse Meet and Greet @ EFE Tonight

Just a reminder for those out there at Eclipse Forum Europe… there is an Eclipse Meet and Greet tonight starting at 9:15pm

Rumor on the street is that Eclipse evangelist Wayne Beaton will be doing magic tricks for everyone.

Fair and Balanced @ JavaOne

I just noticed that at JavaOne, there will be a “fair and balanced” Eclipse RCP versus the Netbeans Platform talk given by Kai Toedter from Siemens and Geertjan Wielenga from Sun.

I’m not one to say anything… but is this really fair and balanced? Wouldn’t it be better to have Kai moderate and maybe have someone like Wayne Beaton represent Eclipse …and Geertjan represent Netbeans?

Plug-in Development Tip

Ever wanted to browse for a Java class but not import the whole universe in your workspace? Well here is a tip for you… I’ll do it in pictures.

I start with an empty workspace… and I want to find the EObject class from EMF. I Ctrl+Shift+T my way to sadness:

πŸ™

However, there is a Plug-ins view in Eclipse from PDE that allows me to add plug-ins to ‘Java Search.’

Now I try searching for my EObject class:

Now I’m happy πŸ™‚

Ohayo!

From the looks of it, I think we have our first Japanese Eclipse blogger on PlanetEclipse. Welcome Hiroki Kondo! He has also written an Equinox article over in Japan too!

Everyone should welcome him! He was a bit worried to be syndicated on the planet because he thought his English wasn’t good enough… but I disagree! English wasn’t my first language either, but I found that the more I write in it, the better I get! Plus, it makes for a convenient excuse if I say something silly πŸ™‚

On the whole, I love to see fresh faces on PlanetEclipse, especially when they come from cool countries like Japan! Here’s to making more inroads with the Japanese Eclipse community! Kampai! Cheers!

Hello Wiesbaden and EFE 2008

Eclipse Forum Europe (EFE) 2008 started today in Wiesbaden, Germany. I’m only suffering minor jet lag at the moment πŸ™‚

There was a lot of interesting tutorials today. Since I love plug-ins, I decided to stop by the ‘Developing Rich Client Applications’ tutorial hosted by Benjamin Pasero (not working on Jazz work items at the moment ;p), Matthias Lübken and Stefan Reichert. There was a good number of attendees that did a really good job of following the tutorial content:

Now it’s time for a jet-lag induced afternoon nap.

An Eclipse-based Facebook Application (Part 1)

So, the first thing I do when I write an Eclipse-based application, or any application for that matter is set a quick baseline of what I want done. For my first milestone, I decided I simply wanted to be able to log into Facebook. I figured, this would be a good start… it would require me to use the Facebook API in some fashion. This would force me to create a plug-in for the Facebook API which I would reuse when I started to do things like update my status from Eclipse. So my first stop was to look at the Facebook Java APIs since that would make life easier for me.

I found a cool project hosted at Google Code that contained some Java APIs. The only problem was that it seemed you needed a million jars to use these APIs. As an Eclipse plug-in afficiandio, I knew how to handle this… I’ll create a new plug-in! I downloaded all the jars and then launched the ‘New Plug-in Project from Exisiting Jars’ wizard which allows me to quickly create a plug-in by pointing to those existing jars.

To give my newly created plug-in some polish, I’ve decided to do a couple things. First, I’ll only export the packages that my consumers will need to work with the Facebook API:

In the Eclipse and OSGi world, Java packages are the unit of modularity. My consumers shouldn’t care about the other packages and I don’t feel like supporting those packages downstream so I won’t expose them. Since I don’t expose them, my consumers won’t be able to use any classes from those non-exported packages. This provides a nice way to keep your API really “internal.” For my next magic trick, I will make sure to set the Bundle-RequiredExecutionEnvironment (BREE) for my plug-in to J2SE-1.5:

BREEs are a way of telling Eclipse and OSGi that your plug-in at a minimum, requires Java 5.0 to run. This is cool because the Eclipse runtime won’t activate your plug-in if it’s running on Java 1.4… only Java 5.0 and above. The runtime will also give a message out stating that the plug-in can’t activate because the mininum BREE hasn’t been yet… also cool!

So with my new Facebook API plug-in setup and polished to my liking, we can go and start exercising that API in interesting ways. The first way will be finding a way to log-in to Facebook and that will be discussed in Part 2.

  • Lessons Learned
    • Start simple and iterate as you make progress
    • Use the ‘New Plug-in Project From Existing Jars’ wizard to package your dependencies
    • Don’t forget to set BREEs, they can save your consumers some heartache!
    • Export packages from plug-ins that consumers are only interested in


If you like this type of material, let me know. If there’s a good response, that’s usually motivation for me to do things faster.

Facebook on a Plane

So, for the past couple of weeks, I’ve been doing some hacking while being on long airplane flights. Usually, I hack Eclipse-related things that somehow end up in milestone releases, but I figured I needed to enlighten myself with something new and refreshing.

For inspiration, I went and talked to an old college buddy of mine I trust. I happen to trust crazy people who preferred to do back-tracing solvers in PHP instead of LISP or C++ given a choice, but that’s another story (those were the days). This college buddy of mine ended up drinking the web 2.0 koolaid recently… he told me I should be writing Facebook applications (because Facebook is the greatest thing ever). He also called me an old fart for not writing Web 2.0 applications. Since I trust him and I don’t want to be an old fart, I took the bait and said OK, I’ll give this stuff a try at least.

So I went on my quest to write a facebook application and when I was going through the online documentation, I found that I could write a desktop-based facebook application. Furthermore, there were some Java APIs available. I thought to myself, Java… Desktop… I know that space pretty well… why not throw some Eclipse love in there? So within about 20 minutes of reading facebook documentation, I was on my way to writing an Eclipse-based facebook application.

As I was about to start coding, I thought to myself, why not do a blog series about this topic to help people better understand how to create Eclipse-based applications? Maybe it will be useful, may it won’t, but it should be fun! And to be honest, I also had some selfish goals. First, I needed something to kill the time on long airplane flights. Second, I want to be able to update my facebook status in Eclipse and to be able to poke other Eclipse committers like Dave Steinberg, Wassim Melhem and Kim Horne. Also, I didn’t like being called an old fart. So, if you’re interested, I’ll be posting things in parts as time passes and if people show interest. In the end, I want something that kind of looks likes this:

To start, continue reading on to creating An Eclipse-based Facebook Application (Part 1).

Deutschland!

Ah, Deutschland! The land of good beer, fast trains and David Hasselhoff music videos. I’m headed to Eclipse Forum Europe next week in Germany to do a couple talks. I always enjoy my trips to Germany because everyone loves Eclipse there and is very hospitable! Germans seems to love EMF and Model Driven Development (MDD) too… everywhere I go people seem to be doing something with EMF. Now that I think about it, maybe Ed Merks should move to Germany… he could be the David Hasselhoff of the Eclipse community in Germany πŸ™‚

All jokes aside, I’m looking forward to the trip and spreading the Eclipse love! Eclipse Forum Europe is a well run conference with quality speakers. If anyone is up for a beer or for one of those famous Stammtisch’s, please let me know!