Class HttpJsonTrustedContractNegotiatorPlugin

  • All Implemented Interfaces:
    ArTrustedContractNegotiatorPlugin, se.arkalix.plugin.Plugin

    public class HttpJsonTrustedContractNegotiatorPlugin
    extends java.lang.Object
    implements ArTrustedContractNegotiatorPlugin
    A HTTP/JSON plugin that helps manage the sending and receiving of contract negotiation messages.

    The plugin can be used as in following example:

         // Provide plugin to created system.
         final var system = new ArSystem.Builder()
             .identity(identity)
             .trustStore(trustStore)
             .plugins(HttpJsonCloudPlugin.viaServiceRegistryAt(srSocketAddress),
                 new HttpJsonContractNegotiationTrustedPlugin())
             .build();
    
         // Collect the plugin's facade.
         final var negotiator = system.pluginFacadeOf(HttpJsonTrustedContractNegotiatorPlugin.class)
             .map(facade -> (ArTrustedContractNegotiatorPluginFacade) facade)
             .orElseThrow(() -> new IllegalStateException("Negotiator facade not available"));
    
         // Send a negotiation offer to some relevant party and register response handlers.
         negotiator.offer(someOffer, new ArTrustedNegotiationHandler() {
             @Override
             public void onAccept(final TrustedContractNegotiationDto negotiation) {
                 System.out.println("Accepted offer in " + negotiation);
             }
    
             @Override
             public void onOffer(final TrustedContractNegotiationDto negotiation, final TrustedContractNegotiatorResponder responder) {
                 System.out.println("Received counter-offer in " + negotiation);
                 System.out.println("Rejecting counter-offer ...");
                 responder.reject()
                     .ifSuccess(ignored -> System.out.println("Rejected counter-offer"))
                     .onFailure(Throwable::printStackTrace);
             }
    
             @Override
             public void onReject(final TrustedContractNegotiationDto negotiation) {
                 System.out.println("Rejected offer in " + negotiation);
             }
         });
     
    Use of this plugin requires that another plugin is available that performs service resolution, such as the HttpJsonCloudPlugin.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      se.arkalix.util.concurrent.Future<se.arkalix.plugin.PluginAttached> attachTo​(se.arkalix.ArSystem system, java.util.Map<java.lang.Class<? extends se.arkalix.plugin.Plugin>,​se.arkalix.plugin.PluginFacade> dependencies)  
      java.util.Set<java.lang.Class<? extends se.arkalix.plugin.Plugin>> dependencies()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface se.arkalix.plugin.Plugin

        ordinal
    • Constructor Detail

      • HttpJsonTrustedContractNegotiatorPlugin

        public HttpJsonTrustedContractNegotiatorPlugin()
    • Method Detail

      • dependencies

        public java.util.Set<java.lang.Class<? extends se.arkalix.plugin.Plugin>> dependencies()
        Specified by:
        dependencies in interface ArTrustedContractNegotiatorPlugin
        Specified by:
        dependencies in interface se.arkalix.plugin.Plugin
      • attachTo

        public se.arkalix.util.concurrent.Future<se.arkalix.plugin.PluginAttached> attachTo​(se.arkalix.ArSystem system,
                                                                                            java.util.Map<java.lang.Class<? extends se.arkalix.plugin.Plugin>,​se.arkalix.plugin.PluginFacade> dependencies)
        Specified by:
        attachTo in interface se.arkalix.plugin.Plugin