Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

Version 1 Current »

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

  1. Understand the desired component for development as described in the DDF Catalog section.
  2. Have an IDE and the ability to create OSGi bundles.
  3. 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:

  1. Create a Java class that implements the ddf.catalog.resource.ResourceWriter interface.

    ResourceWriter Implementation Skeleton
    import 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;
     }
    }
  2. Register the implementation as a Service in the OSGi Service Registry.

    Blueprint Service Registration Example
    ...
    <service ref="[[ResourceWriterReference]]" interface="ddf.catalog.resource.ResourceWriter" />
    ...
  3. Deploy the OSGi bundled packaged service to the DDF run-time.

ResourceWriter Javadoc

See the DDF Catalog API Javadoc for more information as to the methods required in implementing the interface. 

  • No labels