Saturday, May 30, 2009

My Elder brother Graduated in May 28th 2009

This weekend is a very interesting one for all of my family members since My elder brother graduated last Thursday and one of my younger brother came home after nearly a month by finishing his first exam at faculty of medicine University of Peradeniya...
My brothers convocation held in BMICH in colombo and parents were there to see their son's victory. This was my moms whole life since we were in our childhood. I always remember she was pointing to University of Ruhuna which is by the road of my fathers place and advising us to study hard...Yeah, she used to do that since I was in Grade 1...
I'm thanking all of them who helped him to become a graduate..and wishing him all the success for his future endovours !!!! I think he's going to get another degree in couple of months and will be posting again on that !!!

Monday, May 11, 2009

Configuring Airtel HSDPA on Ubuntu

Today I bought an Airtel Data bundle and tried to configure it on my Ubuntu 9.04.I have been accessing internet through my Mobitel connection for sometime and I thought it would be easy to configure it to Airtel.Yes it was easy but I had to do couple of things since the debian package did not had Airtel information in Sri Lankan service providers list. If you are a user willing to configure your Airtel HSDPA(Sri Lankan) connection on Ubuntu with your mobile this blog is for you.

1.In the current mobile-broadband package which ships with Ubuntu 9.04 doesn't contain Airtel as service provider for Sri Lanka.So you have to get the latest update of the package. In order to do that,install subversion on your machine and get and svn check out from here :
http://svn.gnome.org/svn/mobile-broadband-provider-info/trunk

2.Copy serviceprovider.xml and serviceprovider.dtd file in to /usr/share/mobile-broadband-provider-info/

3. You can see a computer at the panel which show the status of the network, right click it and select edit-Connections and select Mobile-Broadband tab.

4. If you have already define one connectioin please remove it and add a new one. After copying that new file it will show you Airtel as a Sri Lankan Service Provider during the wizard.

5. According to configuration now this should connect to the internet through Airtel Access point. But Unfortunately it didn't connect for me. The Access point on the latest trunk of the package is wrong and you have to double click on the newly added connection to reconfigure it and select the Access Point to

AirtelLive (No Spelling mistakes and I'm don't have time to test the case sensitivity, just copy and paste this)

6. Now you are done. Now when you click the icon which show the network status with a computer icon you can see the Airtel to select and click on it will connect to the internet if you have enough signal....:-)

For me it work fine since I'm in galle right now and hopefully it'll work fine in Dehiwelle... (I used to stay there during week days)

Sunday, May 10, 2009

Problems with Jar files

As a developer from a company which uses OSGi for most of their products I thought of discussing the problems we are having with typical jar files. Most of those issues are solved in OSGi Environment.Don't think twice OSGify your products to achieve real modularity for your software.
First and major issue with simple jar files is not having a runtime concept, they are meaningful only during compile time. At runtime no changes could be done to a jar,it is just expose in to all the jar files in the environment which import it.Jar files doesn't contain any meta data about their dependencies and we do not have any control over the dependency management of jar files. All the classes in the jar is expose in to all the packages of the environment. In simple there's not information hiding between jar files in the Java runtime Environment. So I could say those words something like this. With OOP(Object Oriented Programming) we are achieving information hiding in class level but that's is, how nice if we could achieve that in modular level like exposing some of the packages(making public as we do in public methods and public variables in a class) and hide other packages of a particular jar file. And we can consider this as no communication mechanism between jar files in the horizontal direction, it just allow users to communication through the vertical direction by importing packages. No horizontal communication at all ....:-(

With typical jar files if we have different versions of the same jar it will just pick the appropriate class from the classpath according to the order we are specifying the classpath, so we couldn't consider this as a proper versioning system.

Next issue I would discuss is lack of dependency information in a single jar file. Most of the jar files are always depends on other third party jar, but we do not have any proper way of keeping that meta data describe the dependency for a given Jar file. This cause people to get a very popular Exception called ClassNotFoundException.

Keeping only the dependency information in not enough, we should have a proper understanding about the versions of those dependencies otherwise we couldn't guarantee the behaviour since different versions could be having different behaviours. So with the dependency we should have the version information included on it.

I have described couple of issues we are having with typical jar files and I will be blogging on how OSGi(Open System Gateway initiative) is going to solve almost all of the above issues and Lead Software Development in to new Modularity concept which will be an elegant feature of Java world.

Saturday, May 9, 2009

WSO2 Registry Initialization

Since I was assigned to work with Registry team at WSO2 I had a look in to the Registry Core source code which ships as a separate bundle with Carbon. I read the code from the Declarative Service level code and thought of blog about the Registry Initialization.
Since this is a bundle of Carbon Environment it calls most of the methods of OSGI(Open Services Gateway Initiative) but other than calling them all the initialization happens inside the start method of the bundle itself.
At the very first stage it will create the class RegistryConfiguration which mainly go through the carbon.xml and find what type of initialization is configured. It could be a Remote Registry or an Embedded Registry(Default Initialization). If it's a Remote Registry users have to give the values for following parameters like URL,UserName and Password in the carbon.xml.After reading carbon.xml it simply validate the configuration and create the RegistryContext object by reading registry.xml and passing RegistryRealm object in to RegistryContext. Almost all the initialization happed during the time of creation of RegistryContext. Major tasks are reading registry.xml and registering Handlers and configurating most of the database configurations in programmatical stage.

After initializing the registry service based on the carbon.xml it add it to carbon environment by calling addCarbonRootCollection method and now RegistryCore is up and running in Carbon Environment. In the latest trunk all the bundle initializations are done using Declarative Service and you won't be able to find Tracker Classes or Activators any more in Carbon platform.

I will be writing more about the structure of the Registry-Core in near future since it could be useful to understand the internal implementation for who ever is going to implement their own repository management system.

Saturday, May 2, 2009

Object Passing between JSP's and Normal Java Classes

Recently I was assigned to work with Java Web Component stuff and I was encountered a problem when I was developing new Web Services Component to WSO2 registry. Let me explain my problem....
I have developed a web Service and generated the code for the client side. If you have a look on my JSP code it's calling the method getProfile by passing arguments path,data,session. My requirement in this method is calling the web service client and get the output of the Web service in to the variable data. When I debug the class GetProfileUtil I notice the expected behaviour of variable data but when the JSP runs it throws a Null Pointer Exception when call the get method of the data(Map>). So the modifications happen inside the method getProfile to the variable data is not visible to the JSP.

String path =request.getParameter("path");
Map defaultprofile = null;
Map> data = null;

try {
GetProfileUtil.getProfile(path,data,config,session);
defaultprofile = data.get(UserCoreConstants.DEFAULT_PROFILE);
} catch (Exception e) {
CarbonUIMessage uiMsg = new CarbonUIMessage(CarbonUIMessage.ERROR, e.getMessage(), e);
session.setAttribute(CarbonUIMessage.ID, uiMsg);
}

But when I modify my method like this to create the object inside the method and return it, it worked fine. I simply avoid passing the variabl in to the method getProfile but rather create a data variable and return it.

String path =request.getParameter("path");
Map defaultprofile = null;
Map> data = null;

try {
data =GetProfileUtil.getProfile(path,config,session);
defaultprofile = data.get(UserCoreConstants.DEFAULT_PROFILE);
} catch (Exception e) {
CarbonUIMessage uiMsg = new CarbonUIMessage(CarbonUIMessage.ERROR, e.getMessage(), e);
session.setAttribute(CarbonUIMessage.ID, uiMsg);
}

when I access the bean variable I got all the modifications happen inside the method.
Is this the typical behaviour of JSP's and it's totally different from the way Java hadle object passing between classes and methods.
As far as I understand only wrong thing I have done in my first case is pointing to a null value for data variable....Otherwise it should work...I don't know that approach might be a worst thing to do...