Showing posts with label OSGI. Show all posts
Showing posts with label OSGI. Show all posts

Step by Step Tutorial of OSGI- Chapter 1

.
View Comments

OSGI is a very existing technology, it provides an open common architecture for service providers, developers, software vendors. It provides an general-purpose, secure and managed framework that support the deployment of extensible and downloadable applications called BUNDLES

Bundles are like plugins. A developer can extend the framework to his wildest dreams by making bundle and installing into the framework.
Bundle are small applications or service which can be used and can be removed when not required.

A the lifecyle of bundles are managed by framework.

The functionality of framework is divided into for four important layers

Security layer
Module Layer
Life Cycle Layer
Actual Service.

Brief Description of each layer is mentioned below. We will not going to dive deep into layers in this post of the tutorial.
Of-course we will learn the layers in coming post while we are coding as well.
Reading is all good but unless and until we will not get our hands dirty with we will not learn properly.

Ok Lets get down to brief description of layers.

Module Layer.

It defines the modularization modal of java. Module a.k.a bundles have to follow strict rules for sharing java packages between each other. For example only providing the api interfaces available to other bundle while hiding the implementation.

Lets say module layer holds bundles which can be treated as tiny applications running inside the framework


Life Cycle layer.

This layer define how bundles are started and stopped as well as how bundles are installed, updated, and uninstalled.

Service layer.

As the name specifies service layer is responsible for service provided by bundles. it simplifies the development and deployment of service bundles by de-coupling the service's specification(java interface) and its implementation.
This layers allows developer to hide the actual implementation and only provide the interface to use the service provided by bundles.

By the way we are also going to create a little project while we will be learning the OSGI concepts. Excited ? I know me too.
Actually I wanted to create a group to learn with us. I mean couple of people learning together so that we can discuss and have a creative conversation about it.

Next part of tutorial we will discuss about the Module layer necessary to make us start coding while understanding the concept.

Are you in ? Drop me a comment..Lets get this Tutorial started :)

Read More »»


Google has released WAVE Protocol code and intructions. The first step towards my bleeding tech thought :P

.
0 comments


Today Google has released the code of wave protocol which allows you to run Wave Server.

Source Code

Google Wave is a new tool for communication and collaboration on the web. Watch the demo video below if you don't know what google wave is.

What is Google WAVE: The Video

Some of the key features of Wave Technology is

Real-time collaboration Video
Natural language tools Video
Extending Google Wave Video

I bet after knowing about wave technologies many of the developers are itching to use it or play with it.


Since I am Technology freak and loves to play with bleeding technology and these days got some kind of freekiness about OSGI love...(Am sure most of the technology hungry programmers can feel my thoughts) :)

A cool and interesting idea struck into my head ..AGAIN ???? O Noooo....

Calm down its just an idea at the moment. I was thinking wouldn't it be very interesting to amalgamate OSGI and Google WAVE technologies to get benefits from both technologies in Enterprise environment and Social media environment ?.

Your thoughts are welcome

Read More »»


How to RUN/USE Derby on Equinox and Apache Felix

.
0 comments

It been two days I am playing a lot with OSGI framework and also in a process of learning the technology so stay clam if you find any mistakes.

While learning I came across a challenge to use Derby as a service in OSGI framework.

The Googling BEGINS !!!!

After searching for a while I came across that there is a plugin for derby in eclipse but I was reluctant to use eclipse plugin because I wanted to use the service on other implementation of OSGI framework without other dependences that eclipse will import in, while creating a bundle.

OK the Idea is to create a standalone derby database service which other bundles can use it.

So in a process of hunting information on web I found THE LINK for OSGI bundle repositories

Searched for derby bundle in the repository and lucky found it.

Downloaded the derby : Derby Bundle.

Now as a new learner of OSGI it was a challenge for me to use this third party service in eclipse environment.

So I created a testDerby bundle which is supposed to use the Derby bundle I have downloaded.

Oh MY Dayssss

I didn't realize that eclipse can be a pain. As far as I know eclipse don't have any options to import third party plugin residing in a directory of your own choice.

It seems that you can only use plugin in eclipse which are in the plugin directory of eclipse installation directory..

So I tried to copy the derby bundle to plugin directory of the eclipse (It may sound absurd to many eclipse gurus but hey I tired every means.)

Well still no success.

After couple of hours of banging my head in front of my laptop. An alternate way struck in my head. :P

Eclipse have a feature to create a OSGI bungle/plugin from a third party jar file.

Wait a minute!!! Isn't a derby bundle I download is a OSGI bundle already ? Yes it is..

So we gonna play with a jar and create a new OSGI bundle from eclipse

Right, created a new Project on eclipse. By following the steps mentioned below

File-> New-> Project-> Select "Plugin from an Existing Jar Archive".

Click on Add External

Select the Derby.jar you have downloaded from the osgi website I have mentioned above

Click Finish.

Volla!!!!

Eclipse have created a new Project which include a derby.jar which we have downloaded.

Right, work is not done yet.

Now Click on the MANIFEST.MF file or the newly created derby project.

Click on the MANIFEST.MF Tab of the tabpane.

And change the following Headers

Export-Package
Import-Package

To the mentioned below :


Export-Package: org.apache.derby.authentication,
org.apache.derby.database,
org.apache.derby.iapi.jdbc,
org.apache.derby.io,
org.apache.derby.jdbc,
org.apache.derby.vti

Import-Package: javax.naming.spi,
javax.naming.directory,
javax.transaction.xa,
javax.crypto,
org.osgi.framework; version="1.3.0",
javax.sql,
javax.crypto.spec,
javax.naming


Add bundle activator the bundle


Bundle-Activator: org.apache.derby.osgi.EmbeddedActivator


You don't have to write an EmbeddedActivator class , it is already in the derby bundle we have downloaded.

Right almost done...

Now we have to export the project as plugin with the help of eclipse.

So in the package Explorer pane Right click on derby project and click on Export

In Export window

Click on Deployable plug-ins and fragments option

Click Next-> select the "derby"

Browse the Directory you want to export the plugin

Go to the directory which you selected and Volla!!!
You got a brand new derby bundle which will work with equinox and Apache felix and also a eclipse project which can be used to create/test bundle requiring Derby functionality .

Now you can create you test bundle to test the derby database baby.

So the Zest of post is that now we can create other bundles requiring Derby functionality with the help of the derby project we have just created. And also now we don't have to use the eclipse derby bundle which comes with other dependencies.


Hope the post made sense to you guys/gals

And also if you know any other ways to use third party bundle in eclipse please do help me out as well

Thanks

Read More »»


JAVA: The Question of the week

.
0 comments


In OSGI framework, How an OSGI bundle going to read from a properties file [or any configuration file for that matter].

At the moment any property file created for OSGi is added into the bundle [jar file] thus making it real tough for the user to modify its contents. Is there any other way to provide/read a configuration/property file which is outside bundle ?


Read More »»