Overview
Before implementing a Resource Writer see the Content Framework for alternatives.
A ResourceWriter
is an object used to store or delete a Resource
. ResourceWriter
objects should be registered within the OSGi Service Registry so clients can retrieve an instance when clients need to store a Resource
. See the Working with Resources section in the Developer's guide for more information.
Prerequisites
- Understand the desired component for development as described in the DDF Catalog section.
- Review existing implementations in the source code and application documentation.
- Have an IDE and the ability to create OSGi bundles.
- Understand the Use of the Whiteboard Design Pattern section and how to publish services to the OSGi service registry.
Creating a New ResourceWriter
Creating a ResourceWriter
consists of these main steps:
Create a Java class that implements the
ddf.catalog.resource.ResourceWriter
interface.ResourceWriter Implementation Skeletonimport java.io.IOException; import java.net.URI; import java.util.Map; import ddf.catalog.resource.Resource; import ddf.catalog.resource.ResourceNotFoundException; import ddf.catalog.resource.ResourceNotSupportedException; import ddf.catalog.resource.ResourceWriter; public class SampleResourceWriter implements ResourceWriter { @Override public void deleteResource(URI uri, Map<String, Object> arguments) throws ResourceNotFoundException, IOException { // WRITE IMPLEMENTATION } @Override public URI storeResource(Resource resource, Map<String, Object> arguments)throws ResourceNotSupportedException, IOException { // WRITE IMPLEMENTATION return null; } @Override public URI storeResource(Resource resource, String id, Map<String, Object> arguments) throws ResourceNotSupportedException, IOException { // WRITE IMPLEMENTATION return null; } }
Register the implementation as a Service in the OSGi Service Registry.
Blueprint Service Registration Example... <service ref="[[ResourceWriterReference]]" interface="ddf.catalog.resource.ResourceWriter" /> ...
- Deploy the OSGi bundled packaged service to the DDF run-time.
- Check the Working with OSGi - Bundles section.
ResourceWriter Javadoc
See the DDF Catalog API Javadoc for more information as to the methods required in implementing the interface.