Interface design query!!

Hi all,

I want to define a generic interface with set of operations, and the the different implementations of this interface are having different operations signiture. i.e how to define a generic interface for which each of the implementation can have operations with different signitures?

Waiting for the reply,

Thanks in advance.

MK

[365 byte] By [MithunKa] at [2007-10-3 8:11:24]
# 1

hi mithun,

i can explain this to u with a sdimple example

in the interface add a method that takes an object as a parameter...... so no matter what arguement u pass everything belongs to the Object Class

if u want to pass primitives as parameters then wrap them with wrapper classes and that should work fine

Thanks and Regards

Naveen

Novice_inJAVAa at 2007-7-15 3:15:57 > top of Java-index,Other Topics,Patterns & OO Design...
# 2

Hi Naveen,

Thanks for the reply. The problem here is the parameters are going to differ in each of the implementation.

For ex. below is the generic interface which client would talk to

interface generic{

public void login(String userName, String password)

}

Now in two different scenarios, the implementation requires different set of params like

case 1:public void login(String userName)

case2:public void login(String userName, String password, String port)

So in such cases how to define a generic interface operations, where even if we think of taking an object as a parameter, the object structure is going to differ.

MithunKa at 2007-7-15 3:15:57 > top of Java-index,Other Topics,Patterns & OO Design...
# 3

well, you overload the login() method

login(String username, String password)

login(String username)

the password-less method would simply delegate to the 2-arg method, with a suitable argument for 'password' eg

void login(String username) {

login(username, NO_PASSWORD_NEEDED);

}

georgemca at 2007-7-15 3:15:57 > top of Java-index,Other Topics,Patterns & OO Design...
# 4
Here its not that simple, as each implementation is a webservice, so cant go for overloading here.
MithunKa at 2007-7-15 3:15:57 > top of Java-index,Other Topics,Patterns & OO Design...
# 5
why not? your webservice will still ultimately be invoking methods, why can't you provide these two? what's your actual problem?
georgemca at 2007-7-15 3:15:57 > top of Java-index,Other Topics,Patterns & OO Design...