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.
- Java 11
Either build and install SANE WoT by yourself...
...or pull it from public repo:
Add GitLab Maven Repository to
<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
<dependency> <groupId>city.sane.wot-servient</groupId> <artifactId>wot-servient-all</artifactId> <version>1.1-SNAPSHOT</version> </dependency>
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
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 GNU Lesser General Public License v3.0.