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.
- Java 11
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>io.github.sane-city</groupId>
<artifactId>wot-servient</artifactId>
<version>1.15</version>
</dependency>
https://git.informatik.uni-hamburg.de/sane-public/wot-servient/-/releases
No time for explanations? Running examples can be found in the
wot-servient-examples
sub module.
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();
Thing thing = new Thing.Builder()
.setId("counter")
.setTitle("My Counter")
.setDescription("This is a simple counter thing")
.build();
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
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();
Thing thing = wot.fetch(new URI("http://localhost:8080/counter")).get();
ConsumedThing consumedThing = wot.consume(thing);
Object value = consumedThing.getProperty("count").read().get();
More information can be found in the (still very short) documentation.
This project is licensed under the MIT License.