Monday, April 9, 2012

Comparison between Open Source Service Registry and Repository

Yesterday I was exploring WSO2 SOA Registry in detail and I noticed that some times when I was trying to add some WSDL and XSD files, application started generating internal exceptions, and there is no clear explanation of these exceptions.

At that point I decided to explore some more stable open source registries which we can use in our environment with minimal changes. During my research I explored following four registries in details and did some comparative analysis between these services

  1. Mule Galaxy (
  2. WebSphere Service Registry and Repository (Not open source but high recommendations)
  3. Membrane Registry (
  4. WSO2 Governance Registry

Mule Galaxy
Light Weight,
Easy Integration with Tomcat,
Support WSDL, XSD and Spring Configuration
No Concept of Services. You can just use it as an artefacts repository
WebSphere Service Registry and Repository

Complete Registry and Repository software
Price is less than 500GBP
Require Web sphere Application Server as a prerequisite which itself a very expensive software
Built in SOAP Client,

XML Schema Comparison,

Periodically checks for availability of the service and raises events on availability changes
No concept of Repository

You can’t add WSDL and XSD as a file. You need to define URL  of your WSDL and XSD files

Not ability to categorize services. No ability to write Service Description and details
Designed to store, index, and manage enterprise metadata related to SOA artefacts.

Includes versioning features

Easy to configure

Fully open source with active development community
Application Bugs.

As per my analysis WSO2 is most suitable product for our environment and based on our requirements. We need to live with its open bugs; at least we have an active development community for this product who can support in case of any code bug
Next step is to find answers of following questions.  I tried to answer few of them
  1. Is it possible to modify or customize WSO2 Registry based on our requirements?
  2. Is there any special licensing required for Corporate or deployment in Production environment?
  3. Is it possible to implement Role based Security?
    1. Application supports Role based separation of actions and approval processes
  4. Is it possible to integrate it with our existing development and operation tools?
    1. IDE integration with Eclipse plug-in
  5. Identify useful gadgets which we can integrate with application
  6. Is it possible to enhance Governance Dashboard based on our organization requirements?
  7. Is there any Reporting Mechanism available in the tool?
  8. Is it possible to Plug-In with IDE?
    1. IDE integration with WSO2 Carbon Studio, Eclipse plug-in, Microsoft Visual Studio
  9. Is there any Automate approval or change management processes present in the tool?
    1. Application supports Role based separation of actions and approval processes 

Wednesday, December 7, 2011

Algorithms: Bubble Sort in Java

Bubble sort, also known as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted.
Although the algorithm is simple, it is not efficient for sorting large lists; other algorithms are better.

Worst case performance О(n2)
Best case performance О(n)
Average case performance О(n2)

where n is the number of items being sorted

Formula of Bubble Sort should be n(n-1). For 8 elements there should be 56 possible comparison

public class BubbleSort {

                public static void main(String args[]){
                                int[] array={5,3,8,4,6};
                                int comparison=0;
                                for(int j=0;j<array.length;j++){
                                for(int i=0;i<array.length-1;i++){
                                                int a=array[i];
                                                int b=array[i+1];
                public static void printArray(int[] array){
                                for(int i:array){

WikiPedia has very good article about Sorting Algorithms

Patterns: Factory Method

Factory Method

  1. Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
  2. Defining a “virtual” constructor.
  3. The new operator considered harmful.

Facotry Method is a Creational Pattern and it deals with Creation of Object without specifying the exact class of object that will be created. Object creation some times requires complex processes not required and it’s not appropriate to write all this code in composing object

Facotry Method design pattern handles this problem by creation of a separate method for creation of object which Subclass can override to provide its own implementation

Essence of Factory Method Pattern is

“Define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses”

public class TestFactoryMethod {

      public static void main(String[] args) {
            Skin s=SkinFactory.getSkin("web");

class SkinFactory{
      public static Skin getSkin(String type){
            if(type!=null && type.equals("web"))
                  return new WebbasedSkin();
                  return new DesktopbasedSkin();

interface Skin{
      public void printSkin();

class WebbasedSkin implements Skin{
      public void printSkin(){
            System.out.println("I am Web based Skin");

class DesktopbasedSkin implements Skin{
      public void printSkin(){
            System.out.println("I am DesktopbasedSkin Skin");

Important Concepts To Remeber during Written Java Test

Point 1)
The code below is executed by "java -Dmyprop=myprop Test". Which two, placed instead of "//some code goes here", will produce the output "myprop"? (Choose two)
public class Test { 
    public static void main(String args[]) {
        String prop = //some code goes here//
 A) System.getEnv("myprop");
 B) System.load("myprop");
 D) System.getProperty("myprop");
 E) System.get("myprop");
 F) System.getProperties().getProperty("myprop");
Answers: D, F
System.getProperty functions gets the system property indicated by the specified key.

Point 2)
Always Remember
A Static method can call other Static Methods in same class
A Static method can not call other Non Static Methods directly in same class
A Non Static Method can call static method directly

Point 3)
public class Room {
    public int roomNr;
    private Date beginDtm;
    private Date endDttm;
    public void book(int roomNr, Date beginDttm, Date endDttm) {
        this.roomNr = roomNr;
        this.beginDtm = beginDttm;
        this.endDttm = endDttm;
The variable roomNr breaks encapsulation.

Point 4)
Object myObj = new String[]{"one", "two", "three"}; is valid declaration and initiation

Point 5)
 public void waitForSomething() {
        SomeClass o = new SomeClass();
        synchronized (o) {
A) This code may throw an InterruptedException
B) This code may throw an IllegalStateException
C) This code may throw a TimeOutException
D) Reversing the ofrer of o.wait() and o.notify() will cause this method to complete normally.
Answer: A.
public final void wait() throws InterruptedException

Point 6)
String s="abcd";

Will print 3 because chatAt starts from 0

Point 7)
Given the code. What is the result?
public class Hotel implements Serializable {
    private Room room = new Room();
    public static void main(String[] args) {
        Hotel h = new Hotel();
        try {
            FileOutputStream fos = new FileOutputStream("Hotel.dat");
            ObjectOutputStream oos = new ObjectOutputStream(fos);
        } catch(Exception ex) {
class Room {
 A) Compilation fails.
 B) An instance of Hotel is serialized.
 C) An instance of Hotel and an instance of Room are both serialized.
 D) An exception is thrown at runtime.
Answer: D. is thrown at runtime. All variables of a class being serialized must be serializable as well.
If Room become transient then its fine private transient Room room = new Room();

Point 8)
      public static void main(String[] args) {

            Integer[] a=new Integer[10];
            printValue(a); // Problem here. Integer can not be passed in Double. Compile time error

      public static void printValue(Double[] d){
            public static void main(String[] args) {

            Integer[] a=new Integer[10];
            printValue(a); // Problem here. Integer can not be passed in Long. Compile time error


      public static void printValue(Long[] d){