Coder Social home page Coder Social logo

aries-rsa-example's Introduction

Aries RSA Example

This is an example application showing how to use Apache Aries RSA and Gradle.

It uses the org.dm.bundle plugin to bundlify the jar and osgi-run to build the OSGi runtime.

It uses the Protobuffer-TCP DistributionProvider, so the remote services rely on Protobuffer for serialization.

Service wiring is performed via Declarative services annotations and a XML descriptor for the client to find the remote service (this is implemented by the Local Discovery Aries bundle).

Building and running

To build the server distribution, simply run:

./gradlew creOsgi

This will create a OSGi environment under build/server/.

To build the client:

./gradlew creOsgi -Pclient

This will create a OSGi environment under build/client/.

To run the server on Linux/Mac:

bash build/server/run.sh

On Windows:

build/server/run.bat

Similarly, to run the client:

bash build/client/run.sh

On both server and client, a OSGiaaS-CLI shell is started, which allows you to inspect the OSGi environment.

For example, run ps to see the installed bundles, or headers 3 to see the configuration of bundle with ID 3.

The client exports a command called send-msg which can be used to send a String to the server.

Example:

osgiaas> send-msg hello server
Sending TestInfo message: hello server
Got response back: info {
  testClass: "class java.lang.String"
  testMethod: "hello server"
}
status: SUCCESS

Project structure

There are 3 modules in this project:

API module

Contains the Protobuffer definitions, i.e. the serializable objects that will be exchanged between client and server.

The Protobuffer definitions can be found in messages.proto.

This module also defines a very simple service interface, MessageService.

osgi-server module

The server-side of this application. It simply implements MessageService with a class named TestServer.

As you can see in the Java class, the service is exported using the Declarative Services annotation:

@Component(immediate = true, property = {
        "service.exported.interfaces=*",
        "com.athaydes.protobuf.port=5561"
})
public class TestServer implements MessageService

service.exported.interfaces=* marks the service for remote export. com.athaydes.protobuf.port=5561 tells the Protobuffer-TCP provider which port to use.

osgi-client module

Client-side module. It contains only a single class, MessageSender, which consumes the MessageService service, and locally exports the org.apache.felix.shell.Command service so that the CLI can see the send-msg command it implements.

To find the remote MessageSender service, this bundle provides a XML descriptor which is used by the Local Discovery Aries bundle to wire the service.

OSGi environment

All bundles required to run this application can be found in the build.gradle file, under dependencies and the runOsgi blocks.

Type ./gradlew dep to see the dependency tree, or, after starting the CLI, type ps to see all installed bundles.

IMPORTANT: Notice that the RSA Topology Manager must have a start level higher than the RSA Core bundle otherwise the Topology Manager might fail to see the RSA Admin Service.

aries-rsa-example's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.