Skip to content
W3C Web of Things implementation for Java
Java Groovy Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitlab-ci
doc
wot-servient-binding-akka
wot-servient-binding-coap
wot-servient-binding-file
wot-servient-binding-http
wot-servient-binding-jadex
wot-servient-binding-jsonpathhttp
wot-servient-binding-mqtt
wot-servient-binding-value
wot-servient-cli
wot-servient-examples
wot-servient-integration-tests
wot-servient-scripting-groovy
wot-servient
.dockerignore
.gitignore
.gitlab-ci.yml
Dockerfile
LICENSE
README.md
SANE Codestyle.xml
ci_settings.xml
coverage-jacoco.sh
pom.xml

README.md

SANE Web of Things Servient

This project contains an implementation of the W3C Web of Things (WoT) architecture written in Java.

The WoT was created to enable interoperability across IoT platforms and application domains.

WoT provides mechanisms to formally describe IoT interfaces to allow IoT devices and services to communicate with each other, independent of their underlying implementation, and across multiple networking protocols. In addition, WoT offers a standardized way to define and program IoT behavior.

See also: https://www.w3.org/TR/wot-architecture/

As this implementation is primarily developed for the research project Smart Networks for Urban Participation (SANE), it only covers the parts of the WoT architecture necessary for the project. However, we are open to contributions.

This implementation was strongly inspired by node-wot.

You can either include this implementation in your own software stack or use the command line interface with the WoT Scripting API.

Requirements

  • Java 11

Installation

Maven

Either build and install SANE WoT by yourself...

mvn install

...or pull it from public repo:

Add GitLab Maven Repository to pom.xml:

<repositories>
    <repository>
        <id>gitlab-maven</id>
        <url>https://git.informatik.uni-hamburg.de/api/v4/groups/sane-public/-/packages/maven</url>
    </repository>
</repositories>

Add SANE WoT as dependency to your pom.xml:

<dependency>
    <groupId>city.sane.wot-servient</groupId>
    <artifactId>wot-servient-all</artifactId>
    <version>1.1-SNAPSHOT</version>
</dependency>

Official Build

https://git.informatik.uni-hamburg.de/sane/wot-servient/-/jobs/artifacts/master/download?job=build-dist

Usage

Examples

No time for explanations? Running examples can be found in the wot-servient-examples sub module.

Configuration

You can start using this library without defining any configuration, since sensible default values are provided. Later on you might need to amend the settings to change the default behavior or adapt for specific runtime environments.

The configuration is done in HOCON format in the resource application.conf. You can you can replace application.conf by defining -Dconfig.resource=whatever, -Dconfig.file=whatever, or -Dconfig.url=whatever.

Create Servient

Just create a new DefaultWot object. After that you can start exposing or consuming Things.

Wot wot = new DefaultWot();

// do your
// awesome stuff
// here

wot.destroy();

Create Thing

From Scratch

Thing thing = new Thing.Builder()
        .setId("counter")
        .setTitle("My Counter")
        .setDescription("This is a simple counter thing")
        .build();

From JSON-File

Thing thing = Thing.fromJson(new File("path/to/thing.json"));

Further examples can be found on https://github.com/thingweb/thingweb-playground/tree/master/WebContent/Examples/Valid

Expose Thing

ExposedThing exposedThing = wot.produce(thing);
exposedThing.addProperty("count", new ThingProperty.Builder()
                .setType("integer")
                .setDescription("current counter value")
                .setObservable(true)
                .setReadOnly(true)
                .build(),
     42);
exposedThing.expose();

Consume Thing

Thing thing = wot.fetch(new URI("http://localhost:8080/counter")).get();
ConsumedThing consumedThing = wot.consume(thing);
Object value = consumedThing.getProperty("count").read().get();

Documentation

More information can be found in the (still very short) documentation.

License

This project is licensed under the GNU Lesser General Public License v3.0.

You can’t perform that action at this time.