You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
UserverService userService = ProxyUtil.createClientProxy(
UserverService.class.getClassLoader(), UserverService.class,
jsonRpcClient, socket);
ContentService contentService = ...;
BlackJackService blackJackService = ...;
Object compositeService = ProxyUtil.createCompositeServiceProxy(
this.getClass().getClassLoader(),
new Object[] { userService, contentService, blackJackService},
new Class<?>[] { UserService.class, ContentService.class, BlackJackService.class},
true);
// now compositeService can be used as any of the above service, ie:
User user = ((UserverService)compositService).createUser(...);
Content content = ((ContentService)compositService).getContent(...);
Hand hand = ((BlackJackService)compositService).dealHand(...);
Now, suppose both UserverService and ContentService extend a super-interface OperationService, which declares a method getOperation();
Then both calls:
int id = ((UserverService)compositService).getOperation();
int id = ((ContentService)compositService).getOperation();
will throw the following exception:
java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.googlecode.jsonrpc4j.ProxyUtil$1.invoke(ProxyUtil.java:103)
at com.sun.proxy.$Proxy6.getOperation(Unknown Source)
The text was updated successfully, but these errors were encountered:
Following the example in the documentation, a composite server is created as:
And then the corresponding client-side code is:
Now, suppose both UserverService and ContentService extend a super-interface OperationService, which declares a method getOperation();
Then both calls:
will throw the following exception:
java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.googlecode.jsonrpc4j.ProxyUtil$1.invoke(ProxyUtil.java:103)
at com.sun.proxy.$Proxy6.getOperation(Unknown Source)
The text was updated successfully, but these errors were encountered: