Skip to content

Enabling FDC3 API within a Java App #38

@mark-buhagiar

Description

@mark-buhagiar

I'm following the example here (FDC3Example.java) in order to set up FDC3 communication for a proof of concept. I'm encountering an issue when trying to connect to the fdc3client using fdc3Client.connect (line 185 in the example). This never gets to either the onSuccess or the onError. I ran into the same issue when trying to run the example. I was later going through the docs here, and I found the following wrt JS:

Enabling FDC3 is as simple as adding it to your application manifest.

Therefore, I created a quick test JS app, and added "fdc3Api": true to my manifest.
Now my Java app works, since the FDC3 service has been launched and my Java app is able to connect to it.

As such, I am now looking for some way to enable the FDC3 service directly in the Java app. I have found references in the .NET API to enabling FDC3 (here and here), however have been unable to find anything of the sort for the Java API.

Any help would be appreciated, thanks in advance.


The below is an excerpt of my code. Entry point is launchOpenFin at the bottom.

    private void setUpFDC3IntentListener(String intent, JTextField textField) {
        fdc3Client.addIntentListener(intent, new IntentListener() {
            @Override
            public JSONObject onIntent(Context context) {
                textField.setText(String.format("Received Intent: %s", context.toString()));
                context.put("comment", "Java rules");
                return context;
            }
        }, new AckListener() {
            @Override
            public void onSuccess(Ack ack) {
                if (ack.isSuccessful()) {
                    System.out.println("Registered intent listener");
                } else {
                    System.out.println(String.format("Failed to register intent listener %s", ack.getReason()));
                }
            }

            @Override
            public void onError(Ack ack) {
                System.out.println(String.format("Failed to register intent listener %s", ack.getReason()));
            }
        });
    }
    
    void setUpFDC3() {
        OpenFinJavaDemo.this.fdc3Client = FDC3Client.getInstance(OpenFinJavaDemo.this.desktopConnection);

        OpenFinJavaDemo.this.fdc3Client.connect(new AckListener() {
            @Override
            public void onSuccess(Ack ack) {
                System.out.println(String.format("Connected to FDC3 service"));
                setUpFDC3IntentListener(TOPIC, fdc3ReceiptTextField);
            }

            @Override
            public void onError(Ack ack) {
                System.out.println(String.format("Failed to Connect to FDC3 service"));
            }
        });
    }

    void launchOpenFin() throws DesktopIOException, IOException, DesktopException {
        RuntimeConfiguration runtimeConfiguration = new RuntimeConfiguration();
        runtimeConfiguration.setRuntimeVersion("16.83.53.26");
        runtimeConfiguration.setAdditionalRuntimeArguments("--v=1");
        this.desktopConnection = new DesktopConnection("openfin-IAB-java-demo");
        this.desktopConnection.connect(runtimeConfiguration, new DesktopStateListener() {

            @Override
            public void onReady() {
                OpenFinJavaDemo.this.openFinSystem = new OpenFinRuntime(OpenFinJavaDemo.this.desktopConnection);
                try {
                    openFinSystem.addEventListener("application-platform-api-ready", e -> {
                        System.out.println("application-platform-api-ready: " + e.getEventObject());
                        String uuid = e.getEventObject().getString("uuid");
                        System.out.println(uuid);
                    }, null);

                    setUpFDC3();

                } catch (DesktopException e) {
                    e.printStackTrace();
                }
                SwingUtilities.invokeLater(() -> {
                    OpenFinJavaDemo.this.glassPane.setVisible(false);
                });
            }
            .
            .
            .
            .
            .
        });
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions