lundi 16 mai 2016

How to create a common wrapper for two independent library in java

I'm working with a java networking related project where two independent libraries have been kept for same purposes.

For example,

public class L1
{
    public T1 sendRequest(Type1 t1, Type2 t2, Type3 t3)
    {

    }

    public T2 getLastResponse(Type1 t1, Type1 t1, Type4 t4)
    {

    }

    .....
}

public class L2
{
    public T1 sendMessage(Type1 t1, Type3 t4)
    {

    }

    public T2 getLastMessage(Type1 t1, Type1 t2, Type4 t4, Type1 t1)
    {

    }

    .....
}

Here, L1 is representing one library and L2 is representing another library.

There is no relationship between L1 and L2 and function names can be different. Like, L1 has a function named sendRequest and L2 has a function named sendMessage. But both can perform same action and their return type are same.

I want to create wrapper between L1 & L2 library for an user. In that wrapper, user will be able to select either L1 or L2 library but not both.

What would be a good approach to create this type of wrapper? Suggestion about a design pattern will be helpful.

Aucun commentaire:

Enregistrer un commentaire