首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何结合使用java和Braid框架示例: pigtail?

如何结合使用java和Braid框架示例: pigtail?
EN

Stack Overflow用户
提问于 2019-01-09 18:33:18
回答 1查看 174关注 0票数 1

我尝试在java中定义编织服务器,就像这样的repo。下面是我的BootstrapBraidService类:

代码语言:javascript
复制
@CordaService
public class BootstrapBraidService extends SingletonSerializeAsToken{
    private AppServiceHub appServiceHub;
    private BraidConfig braidConfig;
    public BootstrapBraidService(AppServiceHub appServiceHub){
        this.appServiceHub = appServiceHub;
        this.braidConfig = new BraidConfig();
        // Include a flow on the Braid server.
        braidConfig.withFlow(ExtendedStatusFlow.IssueFlow.class);
        // Include a service on the Braid server.
        braidConfig.withService("myService", new BraidService(appServiceHub));
        // The port the Braid server listens on.
        braidConfig.withPort(3001);
        // Using http instead of https.
        braidConfig.withHttpServerOptions(new HttpServerOptions().setSsl(false));
        // Start the Braid server.
        braidConfig.bootstrapBraid(this.appServiceHub,Object::notify);
    }
}

然而,节点在没有我设置情况下启动,比如端口使用默认值(8080)而不是我的设置(3001)。NodeJS服务器获取服务描述符失败:

代码语言:javascript
复制
{ Error: failed to get services descriptor from
http://localhost:8080/api/
at createHangUpError (_http_client.js:331:15)
at Socket.socketOnEnd (_http_client.js:423:23)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9) code: 'ECONNRESET', url: 'http://localhost:8080/api/' }

有人能告诉我如何解决这个问题吗?谢谢。

更新:the node shell screenshot

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-10 21:07:59

这不起作用的原因是因为BraidConfig是一个具有流畅API的不可变类,但是您的代码将它用作一个经典的可变POJO,这意味着您的任何更改都不会应用于BraidConfig。

以下代码应该可以很好地工作:

代码语言:javascript
复制
@CordaService
public class BootstrapBraidService extends SingletonSerializeAsToken{
    private AppServiceHub appServiceHub;
    private BraidConfig braidConfig;
    public BootstrapBraidService(AppServiceHub appServiceHub){
        this.appServiceHub = appServiceHub;
        this.braidConfig = new BraidConfig()
            // Include a flow on the Braid server.
            .withFlow(ExtendedStatusFlow.IssueFlow.class)
            // Include a service on the Braid server.
            braidConfig.withService(new BraidService(appServiceHub))
            // The port the Braid server listens on.
            braidConfig.withPort(3001)
            // Using http instead of https.
            braidConfig.withHttpServerOptions(new HttpServerOptions().setSsl(false));
        // Start the Braid server.
        braidConfig.bootstrapBraid(this.appServiceHub,null);
    }
}

问候你,Fuzz

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54108095

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档