Writing about technology, traveling, politics and more

Wednesday, December 31, 2008

Starting with OSGi - Tutorial 1

This is the first part of a series of tutorials which show how you can build context-aware applications with the MUSIC Context System. This system is part of the general MUSIC Middleware, developed by the MUSIC Consortium. As the MUSIC Context System is built on top of OSGi and it leverages Declarative Services (which are based on Service Binder), we start with an introduction to these technologies. For an additional, well-structured tutorial on OSGi and Declarative services, you can also check out this blog.

OSGi Component Framework Basics

The Open Service Gateway initiative (OSGi) commonly refers to a standard specifying a Java-based service platform that can be remotely managed. The core part of the specifications is a framework that defines an application life cycle management model, a service registry, an Execution environment and Modules (see Wikipedia entry on OSGi). There are currently five certified implementations complying to OSGi specification R4, including Eclipse Equinox and Knopflerfish.

As component frameworks, OSGi implementations provide a way to encapsulate and package functionality into well-defined packages. In this case, the packages correspond to bundles, which can import and export services as a way of interacting with other bundles. These bundles are packaged in JAR files which enclose the Java classes of the implementing code, along with the required metadata (i.e., the MANIFEST file).

Components and Services

Before we delve into the core of OSGi installation and use, we need to provide some additional explanation as per the motive for OSGi. Since the early 70's, computer scientists realized the importance of encapsulation (see this classic work from Parnas for example).

Encapsulation allows implementing complex software with only a small fraction of it (the API) exposed to its users. This makes it possible to edit and update the internal implementation of the software without requiring any action from its users. In its most modern form, encapsulation (or information hiding) is enabled using components and services.

One of the most popular definitions of software components specifies them as "[software components] are units of composition with contractually specified interfaces and explicit context dependencies only; [software components] can be deployed independently and is subject to composition by third parties" (Component Software - Beyond Object-Oriented Programming book). On the other hand, services are used to indicate a predefined set of functionality through an interface (functional logic) along with some policies and/or contracts defining its extra-functional properties, such as Quality of Service (QoS) contracts, etc.

In OSGi, encapsulation is achieved via software components and services. The former can register (i.e., provide) or use (i.e., consume) services dynamically, as needed. Services allow loose coupling of components, i.e., the service providers do not know about their users and the service users do not know about their providers. Notably, in OSGi the coupling is done dynamically (i.e., at runtime) which provides much more functionality and reliability to the systems.

Downloading and Installing the Framework

While there are multiple implementations of the OSGi specification, for the purposes of this tutorial we will use Eclipse's Equinox.

Your first step is to download Equinox. At the time of writing this tutorial, version 3.4.1 is the latest one, and is available for download at this link.

Once it is downloaded, you should unzip the file to the folder of your choice (e.g., in "c:\", which creates the "c:\eclipse\..." folders).

The core of the Equinox implementation of OSGi is in the "plugins" folder, in a JAR file named "org.eclipse.osgi_3.4 ... .jar". Copy that file to "c:\" and rename it to "equinox.jar".

Starting the OSGi Console

To start the (console view) of the framework, simply issue the following command:
C:\eclipse>java -jar equinox.jar -console

osgi>
The framework is up. You can issue your first command to the console. Try "help" or "ss". The first one prints a list of available commands. The second one, shows the short status of the framework, as in the following:
osgi> ss

Framework is launched.

id State Bundle
0 ACTIVE org.eclipse.osgi_3.4.2.R34x_v20080826-1230
This output says that there is only one bundle installed in the framework (the core OSGi implementation by Equinox), which is assigned the ID "0" and is currently "active". Each bundle can be further introspected with the "bundle" command, as follows:
osgi> bundle 0
System Bundle [0] Id=0, Status=RESOLVED
Registered Services {org.eclipse.osgi.framework.console.CommandProvider}={service.ranking=2147483647, service.id=1} {org.eclipse.osgi.framework.log.FrameworkLog}={service.ranking=2147483647, service.pid=0.org.eclipse.core.runtime.adaptor.EclipseLog, service.vendor=Eclipse.org, service.id=4} {org.eclipse.osgi.framework.log.FrameworkLog}={service.ranking=-2147483648, performance=true, service.pid=46org.eclipse.core.runtime.adaptor.EclipseLog, service.vendor=Eclipse.org, service.id=5} {org.eclipse.osgi.service.runnable.ApplicationLauncher}={service.id=22}
Services in use: {org.eclipse.osgi.framework.console.CommandProvider}={service.ranking=2147483647, service.id=1}
No exported packages [PackageAdmin service is not registered]
As it was already mentioned in the OSGi Basics, bundles interact with each other via services. In this case, the services are abstracted and correspond to plain Java Interfaces. As such, each bundle specify a list of offered (i.e., registered) and needed (i.e., used) services. Notably, this status shows that the Equinox bundle offers (and uses) the "org.eclipse.osgi.framework.console.CommandProvider" interface. This is a service which allows interfacing with the Command Line Interface (i.e., the console), and it will be revisited in one of the following tutorials.

Getting ready for Declarative Services

While the current bundle is sufficient for the core OSGi, additional bundles are needed in order to add more functionality. For example, in order to deploy bundles which use Declarative Services, you need to install the following bundles: "org.eclipse.equinox.ds_1. ... .jar", "org.eclipse.equinox.util_1. ... .jar" and "org.eclipse.osgi.services_3. ... .jar".

Please note that all the needed JAR files are available in the "./plugins" folder, and they can be installed by referencing them directly as follows:
osgi> install file:plugins\org.eclipse.equinox.ds_1.0.0.v20080427-0830.jar
Bundle id is 1

osgi> install file:plugins\org.eclipse.equinox.util_1.0.0.v20080414.jar
Bundle id is 2

osgi> install file:plugins\org.eclipse.osgi.services_3.1.200.v20071203.jar
Bundle id is 3

osgi> ss

Framework is launched.

id State Bundle
0 ACTIVE org.eclipse.osgi_3.4.2.R34x_v20080826-1230
1 INSTALLED org.eclipse.equinox.ds_1.0.0.v20080427-0830
2 INSTALLED org.eclipse.equinox.util_1.0.0.v20080414
3 INSTALLED org.eclipse.osgi.services_3.1.200.v20071203

osgi> start 1

osgi> start 2

osgi> start 3

osgi> ss

Framework is launched.

id State Bundle
0 ACTIVE org.eclipse.osgi_3.4.2.R34x_v20080826-1230
1 ACTIVE org.eclipse.equinox.ds_1.0.0.v20080427-0830
2 ACTIVE org.eclipse.equinox.util_1.0.0.v20080414
3 ACTIVE org.eclipse.osgi.services_3.1.200.v20071203
Finally, please note that after you install a bundle, it is copied in "./configuration" (which is created by OSGi the first time you launch it) and thus it is not needed to keep it at the source folder anymore.

In this case, we have started all the bundles and executed the short status (ss) command afterwards.

Shutting the OSGi console down

To exit the console, you can simply issue the "shutdown" command followed by "exit" command:
osgi> shutdown

osgi> ss

Framework is shutdown.

id State Bundle
0 RESOLVED org.eclipse.osgi_3.4.2.R34x_v20080826-1230

osgi> exit

Homework 1.1: Run the "help" command in the console. Report what each of the following commands does:
  • status
  • diag ID
  • h ID
  • services
  • packages
  • close
Homework 1.2: Read the first chapter (Introduction) of Neil Bartlett's book. You can skip sections 1.3 and 1.8.

Tuesday, December 30, 2008

Tutorials for OSGi, Declarative Services and the MUSIC Context System

As a research associate at the University of Cyprus, I work for the MUSIC-IST (somehow, the anagram for "Self-Adapting Applications for Mobile Users in Ubiquitous Computing Environments"), which is an FP7 IP project funded by the European Union. It aims at enabling the development of context-aware, self adaptive applications. One of the most important novelties of MUSIC, is that it provides a comprehensive development methodology. This means that the developers have a plethora of guidance, tools and libraries available when they depart developing such an application. Furthermore, as it is based on a Middleware architecture, MUSIC provides flexibility and facilitates code reuse.

As part of my research, I am the principal architect and developer of the MUSIC Context System. In the following posts, I will describe how this system can be used to build context-aware applications. As this system builds on top of OSGi, and especially leverages the Declarative Services specification, the first tutorials cover the basics of OSGi, starting from installing and launching the framework. As new tutorials become available, I will update the list in this blog entry.

OSGi and Declarative Services
MUSIC Context System
The only requirement for attending these tutorials is a reasonable command of Object-Oriented programming in Java.

For comments, or suggestions regarding these tutorials, please contact the author via email (you can find it in my homepage: http://member.acm.org/~nearchos).

Resources
  1. OSGi website and and the Specifications of Release 4 (R4)
  2. Neil Bartlett's blog entries on Getting Started with OSGi and the first chapters of his book (in draft)
  3. A 6-page quick-start introduction to OSGi and Equinox (requires registration): Getting Started with Equinox and OSGi Refcard
  4. Andre L. C. Tavares, Marco Tulio Valente, A Gentle Introduction to OSGi, SIGSOFT Software Engineering Notes, Vol. 33, No. 5 (Aug. 2008), pp. 1-5
  5. A few books by Amazon are unfortunately not available until Summer ("Equinox and OSGi" and "OSGi in Action: Creating Modular Applications in Java")

Monday, December 29, 2008

2nd Workshop on Context-aware Adaptation Mechanisms for Pervasive and Ubiquitous Services (CAMPUS 2009)

Building on last year's success, the "2nd Workshop on Context-aware Adaptation Mechanisms for Pervasive and Ubiquitous Services (CAMPUS 2009)" will be organized again, in conjunction with the "4th International federated conference on Distributed Computing Techniques (DisCoTec 2009)".

As a member of the Program Committee of the workshop, I encourage you to consider submitting any work you have done relevant to "Context-awareness" or "Adaptation Mechanisms" for Pervasive and Ubiquitous Services. I honestly think is a good forum, with experienced reviewers, for discussing and potentially presenting your work.

Important dates:
Paper submission: March 20, 2009
Paper notification: April 24, 2009
Camera ready: May 08, 2009
Workshop: June 12, 2009

iPod touch

As promised in a blog entry some weeks ago, I now post my impressions of iPod touch.

I bought an iPod touch (2nd generation) as a gift to myself while we were visiting Hawaii. The Apple Store I got it from was great! So was the price ($230 plus tax), considering how much more expensive iPods are in Europe. Let me say here that I chose iPod to iPhone for two simple reasons: First, I already have a NOKIA phone with which I am very happy and, second, I wanted a device primarily for browsing the Internet without a laptop and for killing my time in airports etc.

The first impression was actually not very positive. I got frustrated because I could not get iPod paired with my iTunes account. The reason was that iTunes purchases are available only in selected countries (and Cyprus is not one them yet), which was OK with me. The problem was that although I did not mind not being able to buy staff (I have plenty of CDs already), I still wanted to be able to get the freely available products (mostly apps and podcasts). Thanks to instructions from this site, I was finally able to set up my iTunes account without having to enter any data for a credit card or mailing address (it is too bad Apple did not make it easier to skip attaching a credit card to an iTunes account).

Other than this little glitch though, I have to admit that iPod touch is an amazing gadget. Most of all, I enjoy the touch UI, and the orientation sensors which add a lot to the user experience (especially in the context of game apps). MUSIC and video playback are excellent. In my last 4.5h flight back from Schiphol, I felt as if time flew by! I was using my iPod touch to watch video snippets of stand-up comedy from Comedy Central and also I was playing with what has become my favorite iPod game: TAP Defense.

I would like to also cover the development aspects of iPhone/iPod touch, but unfortunately I soon realized that the development tools for iPhone and iPod touc are limited to Macs only.

In summary, the pros:
1. Great UI
2. Excellent web and mail applications
3. Great audio and video playback
4. The appstore is a vibrant active community generating challenging and useful apps
5. As a device, it is small and light
6. It charges from USB

and cons:
1. It does not have an embedded microphone
2. Docking base comes as an extra
3. Its accessories (e.g. docking station, video connector, power adapter) are quite expensive
4. The Development tools are available for Macs only

Sunday, December 28, 2008

Photos from Hawaii

It's been more than a month since we visited Hawaii now. But I need to write this blog entry so that I don't forget how wonderful everything was. I think Oahu is a gorgeous island, even though I understand that the other islands of Hawaii might be even prettier (at least less developed = more natural).

While Honolulu is a nice city, Waikiki is too touristic for my taste. But apart from this, the rest of the island is amazing. Even just outside the limits of the city, there are tropical forests and wonderful waterfalls. Just a few miles east of Honolulu, Hanauma bay, which is typically very busy, provides an astonishing experience. Then, the Polynesian Cultural Center to the northeast of the island is definitely worth visiting. Although the day we visited the Polynesian Cultural Center was quite rainy, it was still a quite memorable experience. And of course, the beaches of Hawaii, especially Kailua, is a must visit/must swim activity for everyone visiting Oahu.

I am looking forward to the next opportunity to visit Hawaii!

This and other pictures from Oahu are posted in my Picasa account: "Oahu, Hawaii".

Tuesday, November 04, 2008

Gearing up for Hawaii

Just a week before heading for Hawaii, I am all excited about visiting these tropical islands in the middle of the Pacific. Adding up to the big-brother-is-watching-me [1] feeling, GMail offered some Hawaii-related hotel offers while watching a completely unrelated message. Lucky guess, or does Google actually know more about me than I thought? I am sure that somewhere in the future, we will be able to query Google "where to is my next trip?" and receive the right answer!

One of the many things I am anticipating to for this trip is shopping. Actually, I am always happy when I visit the States as there are always some things (usually gadgets) I would like to buy. This time, I have set my eyes on iPod touch. As it has been almost five years since I bought my last iPod (2nd or 3rd generation, white with 20Gb disk), technology has progressed a lot. I am especially looking forward to the touchscreen with gestures experience. Although I have considered iPhone too, I am going with iPod touch for several reasons: First, I am already quite happy with my Nokia E65 phone (we all know that Nokia knows how to make good phones); Second, I hear that iPhone has some rough edges, at least wrt its phone aspects; Third, it is quite expensive to buy it in Europe and in the US it is locked and requires a 2-year contract. I will probably follow up with a blog with my experiences with iPod touch once I try it long enough.

[1]. Actually, to me the "big brother" term is quite unsuccessful; my big brother has always looked after me in the metaphorical sense only! I guess I am lucky :-)

Wednesday, September 17, 2008

Dude, where is my computer?

You know how you sometimes read an article somewhere and you think this is so cool, I should write a blog entry about this as well? Well, I do!

I was just reading an article on cloud computing in IEEE Spectrum (by the way, an excellent magazine for technology lovers). This article, titled the cloud is the computer, discusses how Paul McFedries (the author) expects cloud computing to power the future of pervasive (or ubiquitous) computing. This makes two of us! (Well, most likely more.)

Being a researcher in pervasive computing technologies, and an active user of several cloud computing-based applications myself, has affected my thinking of how the future of computing could be. The original idea behind ubiquitous computing, as expressed by Mark Weiser, is for technologies that result to computing receding to the background of our lives. In other words, the users continue receiving the benefit of using their favorite services without necessarily having to bother about the actual machinery that offers them.

If you think about it, when you connect to GMail from your desktop's favorite browser, you do not bother about the complex machinery that is required to enable that. You rather concentrate on your goal, which in this case is textual communication. Later on in the day, when you access your account using GMail for mobile on your smart-phone, you still have access to similar functionality, which (ideally) is adapted to your context. For instance, a smaller screen, lower bandwidth and a more constrained keyboard.

Personally, I think that GMail is currently the most successful, and definitely the most widespread, example of a pervasive computing application. Although we are still not at the point where the service is experienced with absolute transparency of the machinery, still this is the best example of how truly useful pervasive computing will be.

Thursday, August 21, 2008

Google Docs success story

As a member of the organizing committee of the 17th International Conference on Information Systems Development (ISD 2008), I spent some time (and still do as of today) in updating the conference's website (the original pages were created by the National University of Ireland, Galway for ISD2007, and we were granted the right to reuse them).

During this exercise, I found that Google Docs, and especially the spreadsheet application is extremely useful. For instance, while the authors were registering and submitting the camera-ready version of their papers, we used a dynamically updated spreadsheet to indicate the status of their paper.

Furthermore, while filling in the slots for session chairs and forming the program, we used another dynamically updated page which indicated which slots were empty. This page was updated in almost real time, as we edited the spreadsheet as soon as we handled the incoming emails and then the corresponding web-page was updated within minutes.

Finally, an important aspect of each conference is the publication of its statistics. In this regard, Google spreadsheets really rocks, not only because it allows to publish information dynamically, but also because it allows the creation of graphs which are also dynamically updated along with their associated data. For instance, we were able to publish a graph with information about the number of submitted papers per track, along with their acceptance ratio. Furthermore, using the nice gadgets available in the web application, we were also able to publish a map that illustrates the origin of the (affiliation of the) authors of accepted papers and the program committee.

Evidently, although an excellent tool, Google Docs is not perfect yet. One limitation I found is that I could not insert isolated fields of information in my web-pages (i.e., corresponding to a single cell). For instance, in one of the spreadsheets, I maintain information like the total number of accepted papers (which changes as some authors withdraw theirs). Unfortunately, that number had to be hard-coded in HTML, because I could not find a way to insert isolated (but dynamically updated) fields in my page. I understand that this can be solved with a custom gadget (if not done already), but of course it would be nice if it was provided as a standard gadget.

Although not perfect yet, Google Docs have really helped us with the organization of the conference, and I think this is something worth mentioning. As I really did not want to deal with anything but static HTML pages, Google Docs has proved to be an extremely useful tool.

Tuesday, August 19, 2008

Testing Google Maps for mobile again

Like I mentioned before, I am using Google Maps for mobile. While in my previous entry I praised the accuracy of the automatic positioning feature, I soon found out that this is not always the case. While at the new campus of the University of Cyprus, my phone centered my location as shown in the following screen-shot:





















It took some zooming out to realize that this is actually Buenos Aires :-) Only 12270 Km away ;-)

Update: Today (September 17th, 2008) I tried again and this time it gave me a somewhat more accurate reading. Again from the University of Cyprus campus, it showed me at the headquarters of my carrier (Cytamobile Vodafone) with an accuracy of 5 Kms. This of course covers more or less the whole city of Nicosia. Well, at least the results were imrpoved by a magnitude of X2454!

Tuesday, August 12, 2008

Google Maps in Cyprus

I have been using Google Maps for mobile for a while. Recently, I had to reset my E65 to install the latest firmware from NOKIA. When I reinstalled Google Maps, I apparently got a new version where the My Location feature if finally working (in Cyprus). Interestingly, the results were quite accurate (at least while close to the center of Nicosia).

If you own a supported device (most NOKIA smart-phones are supported), then check it out. Although the actual location is determined by inquiring the cell IDs via GSM, a WiFi or GPRS connection is needed for the map data.

Sunday, August 03, 2008

The beginning

This is the beginning of my blogging life. Actually the beginning of my English blogging life. I was blogging in Greek before (and still do sometimes). But to enlarge my audience and allow more people to benefit from my wisdom, I started this blog in English as well.

Let me introduce myself. My name is Nearchos Paspallis and I was born and live in Cyprus (which is such a small and complicated country that people tend to add a link to its Wikipedia entry when they first mention her).

Back to myself, I spend most of my time in front of a computer screen. However, my tan (seen in my profile picture) is mostly natural due to sunlight I am exposed to during coffee breaks (rather than to LCD radiation). There are primarily two main reasons I spend this much time in front of my computer: First, I work as a researcher in Software Engineering (so, you could say it's because of my job). Second, I pursue a PhD in Computer Science.

The motivation for this blog is that it will help me organize my [public] thoughts, and have an archive of them in case I need to recall them. For instance, I plan to blog about technical stuff, and also thoughts related to my PhD research (e.g., try-and-fail lessons). Hopefully my ideas and opinion will not be completely useless to everyone.