Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ecf-dev] Async-Methods

Hi folks, 

I just found out that ECF also supports async-methods  and tried to set up a small example using the XMPP-provider. Unfortunately I get an exception trying to call async-methods: java.lang.NoSuchMethodException.

Just to make sure I got everything right:

1. I have a service called IExampleService:
public interface IExampleService {
public String getName();
}

2. I've created a second Interface: IExampleServiceAsync in the same package:
public interface IExampleServiceAsync extends IAsyncRemoteServiceProxy {
public void getNameAsync(String param, IAsyncCallback<String> callback);

3. My ServiceImpl implements both interfaces (I've also tried it without implementing IExampleServiceAsync, but same exception):
public class ExampleServiceImpl implements IExampleService,
IExampleServiceAsync {
@Override
public String getName() {
return "ExampleService";
}

@Override
public void getNameAsync(String param, IAsyncCallback<String> callback) {
System.out.println("ExampleServiceImpl.getNameAsync()");

callback.onSuccess(getName() + "yeahhh!!!");
}
}

4. I've registered the service twice using only one interface:
getRemoteServiceContainerAdapter().registerRemoteService(new String[] { IExampleService.class.getName()}, service,
null);

5. I've started service host and consumer with the ECF-bundles attached in the screenshot.

6. Get the a remote service proxy (using a helper method):
IExampleServiceAsync remoteService = (IExampleServiceAsync) sessionService
.getRemoteServiceForClient(IExampleService.class.getName(),
clientID, null);

7. When I try to call the async method "getNameAsync" on the proxy I get an exception saying:  java.lang.NoSuchMethodException: No such method: getName([class java.lang.String])

remoteService.getNameAsync("test", new IAsyncCallback<String>() {
@Override
public void onSuccess(String result) {
System.out.println("   ++++ onSuccess: Remote service says: "+ result);
}

@Override
public void onFailure(Throwable exception) {
System.out.println("   ++++ onFailure: Remote service says: "+ exception);
}
}); 

Regards,
Eugen



Back to the top