org.n52.connectors.core
Class LocalConnectorTypeRegistry

java.lang.Object
  extended by org.n52.connectors.core.AbstractConnectorTypeRegistry
      extended by org.n52.connectors.core.LocalConnectorTypeRegistry
All Implemented Interfaces:
ConnectorTypeRegistry

public class LocalConnectorTypeRegistry
extends AbstractConnectorTypeRegistry

Handling of requests on the same system as the factory is located. The local registry is created by a client program and has access to locally defined connectors. These connectors must be found on a path given at creation time of the connector. Note that the namespace of the conenctors is of significance here (that is dont include them in the path).

Author:
martin schouwenburg

Field Summary
private  java.util.ArrayList<Connector> connectorList
           
private  java.lang.String connectorPath
           
 
Fields inherited from class org.n52.connectors.core.AbstractConnectorTypeRegistry
defaultMapping, logger
 
Constructor Summary
LocalConnectorTypeRegistry(java.lang.String path)
           
 
Method Summary
private  void addConnector(java.lang.String className, java.lang.String connectorFolder)
          Adds the specified connector to the connectorList member
 java.lang.String getConnectorClass(ServiceRequest request)
          return an XML String describing a Connector with requested functionality.
private  java.lang.String getConnectorInfo(ServiceRequest request, Connector conn)
           
private  void LoadDefaultMapping()
          Loads the defualt mapping for the use of functionality from the connectorConfiguration.xml and puts it in internal hashmap
private  java.lang.String nameToXml(Connector conn, java.net.URL connectorUrl, ServiceRequest request)
          Composes an XML String that describes a connector.
private  java.lang.String normalizePath(java.lang.String path)
           
private  void ReadConnectors(java.lang.String connectorFolder, java.lang.String pattern)
          Loads all connectors found in connectorFolder into the connectorList array.
 
Methods inherited from class org.n52.connectors.core.AbstractConnectorTypeRegistry
setDefaultConnector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectorList

private java.util.ArrayList<Connector> connectorList

connectorPath

private java.lang.String connectorPath
Constructor Detail

LocalConnectorTypeRegistry

public LocalConnectorTypeRegistry(java.lang.String path)
                           throws org.n52.connectors.core.exceptions.WrappedException,
                                  org.n52.connectors.core.exceptions.IllegalDefaultSettingException
Throws:
org.n52.connectors.core.exceptions.WrappedException
org.n52.connectors.core.exceptions.IllegalDefaultSettingException
Method Detail

LoadDefaultMapping

private void LoadDefaultMapping()
                         throws org.n52.connectors.core.exceptions.WrappedException,
                                org.n52.connectors.core.exceptions.IllegalDefaultSettingException
Loads the defualt mapping for the use of functionality from the connectorConfiguration.xml and puts it in internal hashmap

Throws:
org.n52.connectors.core.exceptions.WrappedException - contains java exceptions encountered during execution of this method.
org.n52.connectors.core.exceptions.IllegalDefaultSettingException

getConnectorClass

public java.lang.String getConnectorClass(ServiceRequest request)
                                   throws org.n52.connectors.core.exceptions.IllegalConnectorRequestException,
                                          org.n52.connectors.core.exceptions.WrappedException,
                                          org.n52.connectors.core.exceptions.ParameterDoesNotExistException
Description copied from interface: ConnectorTypeRegistry
return an XML String describing a Connector with requested functionality. Depending on the request, the connector returned is either the default for the service or the connector explicitly requested for. In the XML string all needed information should be that enables a factory to create a proper connector with the correct initialization

Parameters:
request - contains all information that is needed to find a suitable connector
Returns:
a connector that supports the request, in an XML String
Throws:
org.n52.connectors.core.exceptions.IllegalConnectorRequestException - request could not be fullfilled
org.n52.connectors.core.exceptions.WrappedException
org.n52.connectors.core.exceptions.ParameterDoesNotExistException

getConnectorInfo

private java.lang.String getConnectorInfo(ServiceRequest request,
                                          Connector conn)
                                   throws java.net.MalformedURLException
Parameters:
request -
conn -
Throws:
java.net.MalformedURLException

ReadConnectors

private void ReadConnectors(java.lang.String connectorFolder,
                            java.lang.String pattern)
                     throws org.n52.connectors.core.exceptions.WrappedException
Loads all connectors found in connectorFolder into the connectorList array.

Parameters:
connectorFolder - the folder where all connectors reside
pattern - the extension of the connector files (normally ".class")
Throws:
org.n52.connectors.core.exceptions.WrappedException

addConnector

private void addConnector(java.lang.String className,
                          java.lang.String connectorFolder)
                   throws org.n52.connectors.core.exceptions.WrappedException
Adds the specified connector to the connectorList member

Parameters:
className: - the plain class name of the connector (thus excluding namespace)
connectorFolder: - the path where the connector resides: used to generate the namespace
Throws:
org.n52.connectors.core.exceptions.WrappedException

nameToXml

private java.lang.String nameToXml(Connector conn,
                                   java.net.URL connectorUrl,
                                   ServiceRequest request)
Composes an XML String that describes a connector.

Parameters:
connectorName - the name of the connector
classUrl - the URL location of the connector's class file
Returns:
the two parameters in an XML String

normalizePath

private java.lang.String normalizePath(java.lang.String path)