Java annotations that can be applied to services to automatically generate JSON metadata files.
<dependency>
<groupId>org.lappsgrid</groupId>
<artifactId>annotations</artifactId>
<version>${see.above}</version>
</dependency>
There are three annotation types that can be used to generate JSON metadata.
- org.lappsgrid.annotations.CommonMetadata
Use this on super classes to provide common metadata for all sub-classes. This annotation only works in conjunction with the@ServiceMetadata
annotation. - org.lappsgrid.annotations.ServiceMetadata
Used to declare metadata fororg.lappsgrid.api.WebService
objects. - org.lappsgrid.annotations.DataSourceMetadata
Used to declare metadata fororg.lappsgrid.api.DataSource
objects.
@CommonMetadata(
vendor="http://www.anc.org",
license="apache2",
format="gate",
encoding="UTF-8"
)
public abstract class ParentClass implements WebService { ... }
@ServiceMetadata(
requires = "token",
produces = "sentence"
)
public class ServiceClass extends ParentClass { ... }
Note that you can use a discriminator's short name as defined in http://vocab.lappsgrid.org/discriminators.html any time a discriminator URI is required.
To generate the JSON metadata files the Java compiler must be configured to use the LAPPS annotation processor.
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessors>
<annotationProcessor>org.lappsgrid.annotation.processing.MetadataProcessor</annotationProcessor>
</annotationProcessors>
</configuration>
</plugin>
...
</plugins>
<dependencies>
<dependency>
<groupId>org.lappsgrid</groupId>
<artifactId>annotations</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
The generated JSON files will be created in src/main/resources/metadata
and will use
the fully qualified class name of the service class. For example, if the above SeviceClass
is in the org.anc.examples
package the name of the generated metadata file will be
org.anc.examples.ServiceClass.json
.
Since the metadata files are automatically generated during the compile
phase it makes sense to delete them during the clean
phase. To do this
we need to configure the maven-clean-plugin
to delete the metadata
directory.
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>src/main/resources/metadata</directory>
</fileset>
</filesets>
</configuration>
</plugin>