You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "caojiele (GitHub)" <gi...@apache.org> on 2019/03/25 03:43:31 UTC
[GitHub] [incubator-dubbo-website] caojiele commented on issue #329:
Something error with local stub introduction
> [Local Stub](http://dubbo.apache.org/en-us/docs/user/demos/local-stub.html) introduction has some error as following
>
> ```java
> package com.foo;
> public class BarServiceStub implements BarService {
> private final BarService barService;
>
> // The real remote proxy object is passed in through the constructor
> public (BarService barService) {
> this.barService = barService;
> }
>
> public String sayHello(String name) {
> // The following code is executed on the client. You can do local ThreadLocal caching on the client side, or verify parameters, etc.
> try {
> return barService.sayHello(name);
> } catch (Exception e) {
> // You can return the mock data.
> return "MockData";
> }
> }
> }
> ```
>
> the constructor's signature should be
>
> ```java
> public BarServiceStub(BarService barService)
> ```
>
> and
>
> > <dubbo:service interface="com.foo.BarService" stub="true" />
> > <dubbo:service interface="com.foo.BarService" stub="com.foo.BarServiceStub" />
>
> dubbo:service should be dubbo:reference
Modify the following:
```java
package com.foo;
public class BarServiceStub implements BarService {
private final BarService barService;
// The real remote proxy object is passed in through the constructor
public BarServiceStub(BarService barService){
this.barService = barService;
}
public String sayHello(String name) {
// The following code is executed on the client. You can do local ThreadLocal caching on the client side, or verify parameters, etc.
try {
return barService.sayHello(name);
} catch (Exception e) {
// You can return the mock data.
return "MockData";
}
}
}
```
right?
[ Full content available at: https://github.com/apache/incubator-dubbo-website/issues/329 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org