Skip to content

LaunchComponent

Thomas Schwotzer edited this page Mar 21, 2023 · 2 revisions

OnStart(ASAPPeer)

The first method that is called on your component after starting a peer is onStart(ASAPPeer peer);

Your component get a reference of a running ASAP peer. The whole system is initialized at this moment. From that moment on, it is no longer different then programming a standalone ASAP app.

Example

Following code is copied from our Shark PKI component implementation.

It is just an example.

@Override
    public void onStart(ASAPPeer asapPeer) throws SharkException {
        this.asapPeer = asapPeer;
        try {
            ASAPStorage asapStorage = asapPeer.getASAPStorage(ASAPCertificateStorage.PKI_APP_NAME);
            CharSequence peerName = this.ownerName != null ? this.ownerName : asapPeer.getPeerID();
            this.asapCertificateStorage =
                new ASAPAbstractCertificateStore(asapStorage, asapPeer.getPeerID(), peerName);

            if(this.asapKeyStore == null) {
                this.asapKeyStore = new InMemoASAPKeyStore(asapPeer.getPeerID());
            }

            this.asapPKIStorage = new FullAsapPKIStorage(this.asapCertificateStorage, this.asapKeyStore);

            // get notified about new peer in the neighbourhood
            this.asapPeer.addASAPEnvironmentChangesListener(this);
        } catch (IOException | ASAPException e) {
            throw new SharkException(e);
        }
    }

Details are of less interest but the bigger picture.

Once we have access to a peer we have also access to its storage. In that case a ASAPStorage is accessed.

Our software can (and in most cases must) add itself as listener to incoming messages.

That's plain ASAP programming again.

Introduction

Shark Components

  1. Describe your component
  2. Component initialization
  3. Setup Shark App
  4. Component launch

ASAP Hub Management

  1. What's a hub
  2. hub information management
  3. connection management
Clone this wiki locally