All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opendaylight.jsonrpc.bus.messagelib.package-info Maven / Gradle / Ivy

/*
 * Copyright (c) 2018 Lumina Networks, Inc. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

/**
 * This package contains public API that can be used to create instances of
 * various session types and proxy objects.
 *
 * 

Requester proxy - send request to remote responder instance * and read response back. To create requester proxy, follow these steps: *

    *
  1. create responder (on remote peer) by providing implementation of known * API
  2. *
  3. connect requester proxy to it (on local peer) using known API and * URL
  4. *
  5. send request and read response
  6. *
* *
 * interface SomeAPI {
 *     int method1(int num, String str);
 * }
 *
 * // Instance of this class is exposed on remote peer
 * class SomeService implements SomeAPI {
 *     @Override
 *     int method1(int num, String str) {
 *         return 10;
 *     }
 * }
 * 
* *

step 1 (remote peer) * *

 * TransportFactory tf = ...
 *
 * SomeService svc = tf.createResponder("zmq://192.168.1.10:20000", new SomeService());
 *
 * 
* *

step 2 (local peer) * *

 *
 * TransportFactory tf = ...
 * SomeService svc = tf.createRequesterProxy(SomeAPI.class, "zmq://192.168.1.10:20000");
 *
 * 
* *

step 3 (local peer) * *

 * int x = svc.method1(1, "ABC"); // return value assigned to x is 10 (see
 *                                // implementation above)
 * 
* *

This will result in following communication on bus: * *

 * > { "id" : 1, "jsonrpc" : "2.0", "method" : "method1", params: [1, "ABC"] }
 * < { "id" : 1, "jsonrpc" : "2.0", "result" : 10 }
 * 
* *

Publisher proxy - send notification to all channels * subscribed on remote publisher instance. To create publisher proxy instance, * follow these steps: *

    *
  1. create publisher proxy (provide interface and URL - local peer)
  2. *
  3. connect (multiple) subscribers to it (remote peers)
  4. *
  5. invoke notification method on publisher proxy (provided interface)
  6. *
* *

Example of API: * *

 * interface SomeAPI {
 *     void notification_method1(String info); // return type must be void
 * }
 *
 * class SomeSubscriber implements SomeAPI {
 *     @Override
 *     void notification_method1(String info) {
 *         // this method will be called when notification comes in
 *     }
 * }
 * 
* *

step 1 - local peer * *

 * TransportFactory tf = ...
 *
 * SomeAPI proxy = tf.createPublisherProxy(SomeAPI.class, "ws://192.168.1.12:12345");
 * 
* *

step 2 - (multiple) remote peers * *

 * TransportFactory tf = ...
 * SomeSubscriber session = tf.createSubscriber("ws://192.168.1.12:12345", new SomeSubscriber());
 * 
* *

step 3 - local peer * *

 * proxy.notification_method1("ABC")
 * 
* *

This will send notification to all connected subscribers: *

 * { "jsonrpc" : "2.0", "method" : "notification_method1", params: ["ABC"] }
 * 
*/ package org.opendaylight.jsonrpc.bus.messagelib;




© 2015 - 2025 Weber Informatics LLC | Privacy Policy