com.ca.jcs
Class ConnectorPersister

java.lang.Object
  extended by com.ca.jcs.ConnectorPersister
Direct Known Subclasses:
FileConnectorPersister, NullConnectorPersister

public abstract class ConnectorPersister
extends Object

Abstract class containing common functionality for persisting ConnectorTypes and Connectors configuration to persistent storage, so that the configuration can be loaded after JCS restart.

Note: All concrete implementations should support notifying observers of state changes, regardless of how the state is persisted.


Nested Class Summary
static class ConnectorPersister.State
          Class representing the State of a ConnectorPersister.StateType.
static class ConnectorPersister.StateType
          An enum represeting the different types of state stored.
 
Field Summary
protected  ConnectorManager connectorManager
          Spring injected connector manager
protected  boolean enabled
          Spring managed property for whether file persistence is enabled
protected  Set<ConnectorPersisterObserver> observers
          Set of observers for state changes
 
Constructor Summary
ConnectorPersister()
           
 
Method Summary
 void addObserver(ConnectorPersisterObserver observer)
          Add an observer to get notified of state changes.
 void deleteConnectorState(LdapDN stateName, String connTypeName, String connName)
          Delete any state found for a given connector.
 void deleteConnectorTypeState(LdapDN stateName, String connTypeName)
          Delete any state found for a given connector type.
abstract  List<String> getConnectorList(String connTypeName)
          Method to get the names of all persisted connectors for a given connector type.
abstract  List<String> getConnectorTypeList()
          Method to get the names of all persisted connector types.
 boolean isEnabled()
           
 boolean isObfuscatedSplitRequired()
           
abstract  ConnectorPersister.State loadConnectorState(String connTypeName, String connName)
          Load a connector state from persistent storage.
abstract  ConnectorPersister.State loadConnectorTypeState(String connTypeName)
          Load a connector type state from persistent storage.
protected  void notifyStateDeleted(ConnectorPersister.StateType type, LdapDN stateName)
          Internal method to notify all observers a sate was deleted.
protected  void notifyStateSaved(ConnectorPersister.State state)
          Internal method to notify all observers a sate was saved.
 void removeObserver(ConnectorPersisterObserver observer)
          Add an observer to get notified of state changes.
 void saveConnectorState(Connector conn, ConnectorPersister.State state)
          Save the provided state for a connector.
 void saveConnectorTypeState(ConnectorType connType, ConnectorPersister.State state)
          Save the provided state for a connector type.
 void setConnectorManager(ConnectorManager connectorManager)
           
 void setEnabled(boolean enabled)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectorManager

protected ConnectorManager connectorManager
Spring injected connector manager


enabled

protected boolean enabled
Spring managed property for whether file persistence is enabled


observers

protected Set<ConnectorPersisterObserver> observers
Set of observers for state changes

Constructor Detail

ConnectorPersister

public ConnectorPersister()
Method Detail

isObfuscatedSplitRequired

public boolean isObfuscatedSplitRequired()
Returns:
true if the connector manager should split off sensitive attributes and obfuscate their values, otherwise false.

setConnectorManager

public void setConnectorManager(ConnectorManager connectorManager)
Parameters:
connectorManager -

addObserver

public void addObserver(ConnectorPersisterObserver observer)
Add an observer to get notified of state changes.

Parameters:
observer - the observer instance.

removeObserver

public void removeObserver(ConnectorPersisterObserver observer)
Add an observer to get notified of state changes.

Parameters:
observer - the observer instance.

saveConnectorTypeState

public void saveConnectorTypeState(ConnectorType connType,
                                   ConnectorPersister.State state)
                            throws IOException
Save the provided state for a connector type.

Parameters:
connType - the connector type to save.
state - an initialised state instance.
Throws:
IOException

saveConnectorState

public void saveConnectorState(Connector conn,
                               ConnectorPersister.State state)
                        throws IOException
Save the provided state for a connector. If conn is a meta connector then its MetaObjectClassMap can be accessed via its class mappings list and used to drive specialized logic if required. See isObfuscatedSplitRequired()

Parameters:
conn - the connector to save.
state - an initialised state instance.
Throws:
IOException

deleteConnectorTypeState

public void deleteConnectorTypeState(LdapDN stateName,
                                     String connTypeName)
                              throws IOException
Delete any state found for a given connector type.

Parameters:
stateName - the state name
connTypeName - the connector type name.
Throws:
IOException

deleteConnectorState

public void deleteConnectorState(LdapDN stateName,
                                 String connTypeName,
                                 String connName)
                          throws IOException
Delete any state found for a given connector.

Parameters:
stateName - the state name
connTypeName - the connector type name.
connName - the connector name.
Throws:
IOException

loadConnectorTypeState

public abstract ConnectorPersister.State loadConnectorTypeState(String connTypeName)
                                                         throws IOException
Load a connector type state from persistent storage.

Parameters:
connTypeName - the connector type name.
Returns:
an initialised state instance.
Throws:
IOException

loadConnectorState

public abstract ConnectorPersister.State loadConnectorState(String connTypeName,
                                                            String connName)
                                                     throws IOException
Load a connector state from persistent storage.

Parameters:
connTypeName - the connector type name.
connName - the connector name.
Returns:
an initialised state instance.
Throws:
IOException

getConnectorTypeList

public abstract List<String> getConnectorTypeList()
                                           throws IOException
Method to get the names of all persisted connector types.

Returns:
list of connector type names.
Throws:
IOException

getConnectorList

public abstract List<String> getConnectorList(String connTypeName)
                                       throws IOException
Method to get the names of all persisted connectors for a given connector type.

Parameters:
connTypeName - the connector type name
Returns:
list of connector names.
Throws:
IOException

notifyStateSaved

protected void notifyStateSaved(ConnectorPersister.State state)
Internal method to notify all observers a sate was saved.

Parameters:
state - the state that was saved.

notifyStateDeleted

protected void notifyStateDeleted(ConnectorPersister.StateType type,
                                  LdapDN stateName)
                           throws IOException
Internal method to notify all observers a sate was deleted.

Parameters:
type - the type of state entry deleted.
stateName - the name of the state deleted.
Throws:
IOException

isEnabled

public boolean isEnabled()
Returns:
the enabled

setEnabled

public void setEnabled(boolean enabled)
Parameters:
enabled - the enabled to set


Created 2011-07-14 13:27 EST