org.n52.connectors.core
Interface Connector


public interface Connector

A connector is a support class that is needed to contain all administrative information that is needed to access service providers. It is able to initialize and retrieve/create objects that give access to a service provider To understand the role of the connector, below is a short scenario how a normal request works out

  1. A client formulates a ConnectorRequest by stating that he wants to do an operation, say resample operation using bicubic.
  2. The ConnectorFactory receives the request and passes it the ConnectorRegistry
  3. The registry looks if it knows a connector which is able to support this operation. If so it returns to the factory an XML string which contains all information to create such a connector
  4. The ConnectorFactory receives the string and through the ClassLoader creates a connector.
  5. The newly created connector creates and initializes a ServiceAdapter that gives access to a resource that can do a resample operation (e.g. a library)
  6. The object is returned to the client
  7. The user formulates all the parameters that are needed for the resampling and passes them the service adapter
  8. The parameters are passed to the execute method of the service adapter and it returns one or more objects as result of the operation; or it throws an exception I cases where some erroneous condition exists

Author:
martin schouwenburg

Method Summary
 void factorySideInitialization(org.w3c.dom.Document xmlConfiguration, org.n52.connectors.core.ServiceRequest request)
          Initializes the connector with information contained in the request.
 java.lang.Object getImplementingObject(org.n52.connectors.core.ServiceRequest req)
          Returns an object that supports the desired functionality or gives (indirectly)access to the desired functionality.
 org.geotools.metadata.iso.MetadataEntity getMetadata(java.lang.String s)
           
 java.lang.String getName()
          access to the name field of a connector
 boolean isSupported(org.n52.connectors.core.ServiceRequest request)
          This method checks according to the information in the ServiceRequest if this connector has access to desired functionality.
 java.lang.String registrySideInitialization(org.n52.connectors.core.ServiceRequest request)
          Creates an Xml string that contains initialization inforamtion needed by the factory to properly created the connector implied by the request.
 

Method Detail

getMetadata

org.geotools.metadata.iso.MetadataEntity getMetadata(java.lang.String s)
Parameters:
s - a metadata identifier based on ISO 19115. see..
Returns:
returns a metadataentity based on geotools (ISO 19115)

isSupported

boolean isSupported(org.n52.connectors.core.ServiceRequest request)
This method checks according to the information in the ServiceRequest if this connector has access to desired functionality. In many cases this is simply a check against a string that is an unique identification for the operation e.g. For the unique identification (see also the paragraph Function names); for resample this would be : “ImageGeometryModel.Conversion”. Operation may or may not have a second tag called “method”. A method further refines an operation to a specific algorithm. Conceptual the same thing is done but using a different method. In our example the method would be “Bicubic”. These kind of unique identifications are tagged as “service’ in the request. So in code this could look like

if ( String(“ImageGeometryModel.Conversion”).equals( (String)request.get(“service”)) {
if ( (String)request.get(“method”).equals(“bicubic))
return true;
}

This is the only thing it is supported function is supposed to do. When creating a connector one can pick unique id’s form the existing list or create new ones if they don’t exist yet. The basis of the naming scheme is given by ISO 19119 in their limited taxonomy; in almost all cases one needs to extend on this as it is fairly limited.

Parameters:
request - contains all information that is needed to find a suitable connector
Returns:
true if the information in the request matches with the properties of this connector

factorySideInitialization

void factorySideInitialization(org.w3c.dom.Document xmlConfiguration,
                               org.n52.connectors.core.ServiceRequest request)
                               throws org.n52.connectors.core.exceptions.N52Exception
Initializes the connector with information contained in the request. This initialization happens at the client side (factory) with parameters that do not need to be send to the registry. The method also ensures that initialization information send by the registry to the factory is properly used to initialize the connector This methode can be overruled in an appropraite connector

Parameters:
xmlConfiguration - xml DOM document containing the information returned by the registry
request - The original request may contain initialization information used as the client side
Throws:
org.n52.connectors.core.exceptions.IllegalConnectorRequestException - requested parameters where not present or invalid in the request
org.n52.connectors.core.exceptions.ParameterDoesNotExistException
org.n52.connectors.core.exceptions.N52Exception

registrySideInitialization

java.lang.String registrySideInitialization(org.n52.connectors.core.ServiceRequest request)
Creates an Xml string that contains initialization inforamtion needed by the factory to properly created the connector implied by the request. This initialization happens at the server side (registry) with parameters that are only present at the server side. This methode can be overruled in an appropraite connector

Parameters:
request - The original request may contain information that is needed by the server side to create extra initialization information
Throws:
org.n52.connectors.core.exceptions.IllegalConnectorRequestException - requested parameters where not present or invalid in the request

getName

java.lang.String getName()
access to the name field of a connector

Returns:
a name of the connector

getImplementingObject

java.lang.Object getImplementingObject(org.n52.connectors.core.ServiceRequest req)
                                       throws org.n52.connectors.core.exceptions.N52Exception
Returns an object that supports the desired functionality or gives (indirectly)access to the desired functionality.

Parameters:
req -
Returns:
Throws:
org.n52.connectors.core.exceptions.N52Exception