Sunday, September 18, 2011

Me at WSO2Con 2011-Day 1


This blog will provide you my experience at WSO2Con 2011, as one of the witness from the large crowd participated in such a successful and valuable open-source programming conference.

Location- Colombo,Sri Lanka
Date- 12th Sep-16th Sep 2011

The key reason for blogging about this event is NOT due to I'm a member of the WSO2 team,but I want to share the value added knowledge and experience I was gained from the conference.The event continued with two tutorials days with three days of main conference.It's not only covered the technical stuff,but also cultural aspects with highlighting Sri Lankan signature in each of the conference day evenings.

The agenda can be found from here

Following is the summary what I learnt from some of the sessions out from the all sessions which I was able to participated in the conference.I'll  present the details of those sessions as linked multiple posts.

Day 1-      12th of September 2011

Tutorial 1-Practical SOA for the Solution Architect

Presenter-Ganesh  Prasad,Independent Consultant.


Summary of what I learnt

SOA[Service oriented architecture]-in a simple way which means eliminating all the unnecassary dependencies among components in a system while keeping the required dependencies in  a specified way.
Solution architects has to concern two different aspects of SOA,if they are going to develop SOA based solutions;.

1.Technology Layer-This layer contains three components as Service Container,Broker and Process Co-ordinator.Service container is used to keep logic code if required while connect with a service.Broker is used to function as a mediator/adapter/etc,which can be used to connect with legacy systems.Process co-ordinator can be used to handle and process different functions in a system.The presenter highlighted that mis-use of the broker.That's most of the people try to use one andonly broker for whole system.But then it reduces availability and performance of the system.

2.Data Layer-SOA Data Layer has set of principles which we need to follow-up when we going to develop SOA based solutions.

  •   Identify dependencies[implicit & explicit]
  •   Make all implicit dependencies as explicit.
  •   Eliminate unnecassary dependencies.
  •  Map domain data to message data[Don't derive/generate one from other] eg:-Do a person need to know motor engineering[as domain data] just for learning car-driving[as message data].

Above points are the reminded data which I have,but the presenter described more than above with the most important aspect.That was presenter gave three real world examples to the audience for trying SOA based solutions for them.
  
Tutorial 2-Introduction to Web and SOA Security
Presenters-Thilina Buddhika; Amila Jayasekara,WSO2

Summary of what I learnt

SOA security is mostly dealing with xml security.It focused on ensuring confidentiality[xml encryption] and intergrity[xml signature] of xml docs.

Web services security uses existing xml security to secure SOAP messsages.

Adding to above presenters explain about cryptography,SSL[Secure Socket Layer],TLS[Transport Layer Security],Single sign on methods[OpenID,SAML],STS[Security Token Service],authentication aspects as encryption,authorization aspects[either role based or attributes based] as XACML[attributes based authorization],WS-security policies,Practical solutions from WSO2 Identity Server for above security aspects and real world scenarios implemented using WSO2 Identity Server.



Sunday, August 28, 2011

Good Bye!!!


It was nearly a month ago while a guest couple has chosen a wall lamp near to our in front-door as their home.Though the couple has not get any invitation from us or neither they had provided the boardin charge ;),but they started to build their house in the lamp.Guess who had come to acompany with us??



Yaa,it was a couple of birds. Unfortunately none of our family knew their names.That's because they are not from a kind as much as familiar in our gardens as 'demalichcha,polkichcha,mayna' does.
As I observed they were hard workers and had a great relationship between them,hence they were able to buid their home step by step by going far-away to gather the home-made stuff as little plants,etc and finished the house building very fast.
It was a small but a nice home.Later I saw birds has started to live in their home,but actually not both of them.Only the female-bird was lived in their home and male-bird was stayed at a tree in our garden.I noticed that though they were in different places,some times male-bird was coming to their home as well female-bird was flying away from home to find foods.
All of our family decided not to disturb for their freedom and we just observe about them selves always from a distance.As time past,on last Saturday I saw heads of two little baby birds are coming out from their home and mother-bird was feeding them.


It was a very nice scene to watch for a while and I realized that there is no difference on parents love for a kid among humans as well as animals or birds.On a later time I noticed father-bird also came to their home several times and then at a time,I surprised that all of them are not in their home.
Hence I had a walk around the garden to search them and guess what I have found.That's the parent birds were teaching kids to fly.

I watched them for a while.First few times were not much successful,since that's only the starting time, little kids flying.But after few rehearsals I noticed they were doing well.Final round came.Parent birds with little two kids flied to a large tree at once.That's the last time I saw them and we all really missed them.Though they came to our home without any pre-notice later they were become a part of our home.Finally I want to say for them, Good Bye!!! Have a safe journey!!!

Monday, July 25, 2011

Add a new servlet to an OSGI bundle



Servlets are useful while handling requests coming from web browsers and setting responses according to the requests and after process them.
In WSO2 carbon environment,OSGI UI bundles are exposed to web and sometimes there might be cases where we need to use a servlet and process on it according to web browser requests.Following steps will help you in such cases when you need to add a servlet for an UI bundle.

Pre-requesties-
  • Any product server from WSO2 Carbon products [1]
  • IntelliJ IDEA 10.0
  • Maven 2.1.0 or higher
  • JDK 1.6 or higher

1.First create a servlet class by extending HttpServlet abstract class inside an OSGI bundle.You can create a new UI-bundle by creating a new maven project and add this servlet class inside it..You can refer the WSO2 dashboard UI bundle code structure from here[2].Else For a new bundle you need to import 'javax.servlet' package from bundle pom.xml as we did for wso2 dashboard UI bundle pom.xml[3].


2.Then you need to add a runtime reference to 'servlet.context.service' and made available it to the bundle by the Service Component Runtime as below.

You can get an idea on this,by refering how we have done for WSO2 dashboard UI bundle as in DashboardUiServiceComponent.java class [4].

3.Then you need to register that created servlet to the OSGI bundle by adding following entry to component.xml file which is in resources/META-INF/component.xml.



In above is used to execute the servlet by mapping this entry value with incoming request URLs to the server. You can have a look on how we have registered GadgetServlet in WSO2 dashboard UI bundle by referring[5].

4.Add the functionalities that you need to process in the servlet to the overridden doGet() method or doPost() methods of the servlet.
4.Build the bundle you added the servlet.Then to test the servlet,if you have created a new bundle(maven project) build it and copy it to the location WSO2_Product_server_home/repository/components/dropins.Then re-start the server and access the following URL.

http(s)://hostName:port/pattern>

Here equal to the value you have added earlier for the entry in component.xml file.

For your easier I have uploaded a sample OSGI UI bundle that has registered one servlet in it.You can download it from here.This UI bundle named as HelloWorld and a servlet called 'HelloWorldServlet' has registered in it by following above steps.Download it,unzip it and have a look on the code of it.Then build it and add the generated .jar file in target folder to the location server_home/repository/components/dropins,and start your WSO2 product server.Try whether you can access the following URL.

http(s)://hostName:port/hello

When accessing above url you'll see 'helloWorld' word will print on web browser.
Such that the HelloworldServlet has successfully registered in UI bundle.



Sunday, July 24, 2011

Love Green...!!!

After staying a week in a dusty brown colored,busy town with full of vehicles noise as in Colombo,what do u prefer in your weekend? Get away from there right?

Yaa,this weekend I was able to go through green colored village and have a wonderful time on there.

Walk through paddy fields,listen to wind.Watch multi-colored birds,Wash hands from water canals.


This facilitates me to come back Colombo on starting of next week with a fresh mind.But what about future?With current human actions,is it guaranteed future kids will get such moments in their lives.I think we have to think this for a while.Money is not all about life.We are part of the nature.We have to protect Nature in sake of survival of ourselves.Hence please don't sell nature for a bundle of money and watch it's end.

The most valuable lession teach by Nature is ''Simplicity".If you obey this lession you will never hurt nature. :):):)






Friday, July 15, 2011

WSO2 ESB learning part1-Usage of a class mediator in a makeFault mediator

Class Mediator-The class mediator creates an instance of a custom specified class and sets it as a mediator. The class must implement the org.apache.synapse.api.Mediator interface.For more info

makeFault mediator-The fault mediator transforms the current message into a SOAP fault message.but does NOT send it. The mediator needs to be invoked to send a fault message created this way.For more info

Sample makeFault mediator

Below is the sample fault mediator that we are going to use in ESB sequence.


Creating a new class mediator

There is a good article on how to create a new class mediator which can be found here.Hence I'm not going to repeat those steps.But for your easier,i'll give the overview of a class mediator.Any class mediator must have to extend 'AbstractMediator' abstract class and hence such a mediator need to implement the method 'mediate()'.The purpose of creating the class mediator here,is to set the property value 'ERROR_CODE' which is going to use as the fault code value in above makeFault mediator.How we have done it using the class mediator is shown as below.
package org.wso2.carbon.mediator;


import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
import javax.xml.namespace.QName;

public class SynapseMessageContextMediator extends AbstractMediator{
public boolean mediate(MessageContext messageContext) {
QName qname=new QName("http://www.w3.org/2003/05/soap-envelope","soap12Env:Receiver");
messageContext.setProperty("ERROR_CODE",qname);
return true;

}
}
Since ESB supports SOAP 1.2,based on SOAP 1.2 specification,the fault code value should contains the same prefix of the SOAP envelope namespace.Hence we have set 'ERROR_CODE' property value as a QName,which has a namespace and a prefix.

How to make usage of created class mediator into the makeFault mediator.

To do this we have to add above both class mediator and fault mediator into synapse.xml file.Then add a log mediator exactly after the makeFault mediator.Then once we have accessed http://localhost/8280 we can see the SOAP fault[which follows SOAP 1.2 specification] which is corresponding to the above created makeFault mediator in ESB server log as below.



You can see the above soap envelope fault code value has set to 'soap12Env:Receiver' by using the class mediator we have created.






JMX configurable Support from WSO2 Carbon

When a user start-up any WSO2 product and while having a look on the log displays while server starting he/she could see a URL called JMX Service URL as in [1] displays on the log.This is the URL use to connect with JConsole to monitor memory consumption,thread utility,manage MBeans and more.

As above each of the products from WSO2 family,provides in-built support from Carbon platform to manage and monitor of its resources such as applications,services,JVM using JMX [Java Management Extensions] support.

You can see each JMX service url contains host names and port values.In early Carbon released versions [before 3.2.0 release],these values couldn't be change according to user's preference.Those values directly taken from system properties own by running Carbon server.But there are some use-cases where users need to create JMX URLs according to their preference.For example when apache proxy server configured infront of ESB and user need to connect to JConsole by using apache proxy host name and port values.

Hence from Carbon release 3.2.0 onwards,we have introduce a new config file called jmx.xml [in carbon_home/repository/conf/advanced/jmx.xml] and from that file a user can set the property values for JMX URL as below.




To enable configuring property values from this jmx.xml file,first the property value 'StartRMIServer' should be set to 'true'.

Note that the two JMX port values are included in carbon.xml [in carbon_home/repository/conf/carbon.xml] file too.And the same port values included in jmx.xml file are overridden by the values included in carbon.xml file.
Once user configured JMX RMI property values as he/she required he/she can re-start the server and watch the log displays while server starting.We say these property values as RMI values because we use these property values to transmit client requests[carbon server request] to remote JMX MBean Server [JConsole] .Finally copy the custom JMX Service URL displayed in server log and paste into JConsole connections section called 'Remote Process' as below.




Then you'll able to connect with server you want and monitor resources consumption of it.

[1] service:jmx:rmi://localhost:11111/jndi/rmi://localhost:9999/jmxrmi

For further information,refer following links.


Saturday, May 14, 2011

Flowers

When I got leisure times,I began my new hobby to take photos of flowers in our garden.For that I used samsung digital camera[12mb pixel resolution].Though I'm not an experty in photography and with a small photo collection,felt those were have good quality to share with others. :)










Tuesday, May 10, 2011

Exec Maven Plugin

This plugin is very useful while executing system and java programs.It provides two goals as;
  • exec:exec execute programs and Java programs in a separate process.
  • exec:java execute Java programs in the same VM.
The benefit of this plugin is we can execute the program without any IDE and using this maven plugin.
I will explain how to use exec:java goal in a simple helloWorld program.
  • First create a new maven project.Here I used IntelliJIDEA.
  • Then add a java class to it with having the main method.For the moment just add a System.out in that method.
  • Then add the following configurations to it's pom.xml file.

  • Next build the project using 'mvn install' .
  • Finally invoke 'mvn exec:java -o'.
  • Then the program will execute and the terminal result will displays as follows.

For further info,visit

Monday, May 9, 2011

Summarizing WSO2 Gadget Server

Near after eight months,that I have joined WSO2 team,I feel it's the better time to share some information regarding the product,that I have almost contributed there.It's non other than WSO2 Gadget Server-The Enterprise Information Portal,which provides a framework built on top of the Google gadget specification.For more information regarding Google gadget specification visit .

Simply saying,the key idea of GS is to keep all the relevant information in a single place in a well organized manner according to the portal user's preference.And the user can change this web space as a dynamical information store or either static information store according to his/her requirements.

Accepting the idea of one picture could say more than 1000 words,before going to deep on it,below shows the screen-shot of the portal view of GS.



Highlighted features of Gadget Server...
  • Embedded Gadget Repository
It is to store gadget xml files and add them to portal once user required.Gadget repository view of GS,provides information of how many users using the gadget,whether it is already added to the portal,gadget description and its ratings.


  • Allow two ways of adding gadgets to the portal
-- Store the gadget xml in WSO2 gadget repository ,and add it to GS portal.


-- Link to a gadget xml in different location and add it to GS portal.
  • Maintain role-based gadgets
Once a gadget stored in GS embedded registry,access to that gadget can be limited by setting permissions as below,in gadget permissions part.

  • Portal Theming Support
Upto now,users could able to customize portal theme from three different customized themes.

  • Portal custom layout support
Currently portal,supports six layout templates (such as one column layout,2-column layout,3- column layout,2- column 2-row layout,etc).Following is an example for a portal view having such a custom layout template.


Above mentioned are not all the features provide by GS,but a part from that stack.You can get more information from;

Sunday, March 20, 2011

Add a keyboard shortcut using javascript

When reading a web page,it's more comfortable for a user if that page supports keyboard shortcuts,since then a web user always no need to struggle with mouse.

Add a keyboard shortcut means an event which triggers once a keyboard key is pressed.Hence the javascript event listener 'onkeyup' is used for it.
This method allow you to perform an action when a key is pressed.Each keyboard key have its own keyboard code.

For example;
Tab key code is 9
Enter key code is 13
Shift key code is 16
Ctrl key code is 17
Left Arrow key code is 37

We can defined our own custom keyboard keys association for a shortcut.And what we have to do is,once a user pressed keyboard keys, just need to verify that keys pressed and compare the returned value with the keyboard code associated with the keys used in our custom defined keyboard shortcut.

Example:
var isShift = false; document.onkeyup=function(e) {
if(e.which == 16) isShift=false;
}document.onkeydown=function(e){
if(e.which == 16) isShift=true;
if(e.which == 37 && isShift == true){
alert('Keyboard shortcut(shift key+left arrow key) is activated!');
return false;
}
}

In the above example,we verify the key pressed down by the user. If the key pressed are Shift+Left Arrow Key, a function will be triggered.First verify that Shift is pressed by user.
If yes,then isShift variable is set to true.If the keys are releases then isShift will set to false again.Once done,we hav to verify that the second pressed key is left arrow key.
As the shortcut consists of a keyboard combination,we also have to check isShift variable has value true.If the isShift variable is set to true and the second pressed key is left arrow key,then the triggered javascript alert will display as a message.

For more information regarding keyboard shortcuts visit;





    

Sunday, January 9, 2011

Tribute to my father...



This is an idea came to my mind several times that I should post into blog someday.This is a real story of my father which gave me an important lession -
"Never give up.Try and Try.One day
you'll be success".

So thought of sharing with others too.
Couple of years back,when my father was retired(on Jan 2009) he was so upset about it, with the mind of what else remian to do by him afterwards.So on first two months he spent it with a lazy plan-sleep,eat,a simple walk,read newspapers,so on.
But finally he got a different idea of starting back his hobby of planting.But then the major issue appeared.So is there any enough space remain in our garden,except cutting down current planted trees? No way.Why no way?Yaa there is a one way.Finally he found it.Ya he thought to him self "I must starting planting on the slab".



In our home,up-floor was not yet built.So slab is remaining.But when he told this idea to us,we were wondering how he could manage the task.No soil on the slab,only concrete.When we arose this question,he told 'I'm going to plant in bags.I can manage to carry prepared soil bags from ground to slab,then planting and looking after them'.So that's how the starting of slab plantation began.He planted vegetables as
  • Tomatoes,



  • Ladies Fingers,



  • String Beans,


  • Green Peppers,


  • Bitter Gourds,


  • 'Malu Miris'


  • 'pathola','dabala',someof leaves as mugunuwenna','gotukola','gendha','sarana','nivithi'


  • 'rathu thampala'


and also some of 'kulubadu' as 'kaha'and 'ighuru'.



(sorry I don't no m
eanings for some planted types.So I mentioned their sinhala names).
The important part of the story happened middle of it's going.Though I mentioned it as the important part , to me it's a very sad situation.because my father paralyzed as unexpected and one leg of his was unavailable to move while got a severe difficulty to talk. But even in such a situation he never lose his encourage,with the treatments and excercises he could able to recover and make his leg for some improving status -with able to walk.But it's not means he recovered 100% and doctors advised him to rest.But he was able to manage walking and talking. When he was in hospital,we looked after his plantation,since we knew he was worrying about it.So when he got back to home from hospital we had a doubt of whether he'll continue with his gardening.But you know,story happened in the other way.He again started his hobby.It's really hard and painful to step up to slab from ground with plant bags full of sand.But he never lose his courage.Any how he did it.All the time we couldn't give our support.But he put his effort and somehow manage it with keeping a smile.All the photos included in here express the result of his never loosing courage.
And the current story is,we are so lucky to get home made fresh vegetables,and leaves for our meals.That's because of your courage dear father.I know how hard and painful to do slab plantaion with having a problem in walking.But you succeded.Thank you very much dear father for your life time valuable lession tought us in a silent way.Any thing in our life can be made as our wish ,if we set our mind to 'wisdom'.