Как использовать Java с примером фреймворка Braid: косичка? - PullRequest
0 голосов
/ 09 января 2019

Я пытаюсь определить сервер Braid в Java следующим образом: repo . И вот мой класс BootstrapBraidService:

@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 не может получить дескриптор служб:

{ 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/' }

Может кто-нибудь сказать мне, как решить эту проблему? Спасибо.

Обновление: скриншот оболочки узла

1 Ответ

0 голосов
/ 10 января 2019

Причина, по которой это не работает, заключается в том, что BraidConfig является неизменяемым классом с плавным API, но ваш код использует его как классический изменяемый POJO, что означает, что ни одно из ваших изменений не применяется к BraidConfig.

Следующее должно работать нормально:

@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

...