Package org.wso2.carbon.mediation.initializer.persistence

# Class MediationPersistenceManager

java.lang.Object
org.wso2.carbon.mediation.initializer.persistence.MediationPersistenceManager

public class MediationPersistenceManager extends Object
Manages all persistence activities related to mediation configuration. Takes care of saving configurations to the file system, registry and updating such configurations as and when necessary. All the mediation components (proxy services, sequences etc) should use this implementation to handle their persistence requirements. This class does not immediately carry out persistence requests. Requests are first queued up and then executed as batch jobs. Therefore admin services which initiate persistence requests does not have to 'wait' for disk and network I/O often associated with persistence activities. This improves the UI response times and system usability in a great deal.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MediationPersistenceManager(String configPath, org.apache.synapse.config.SynapseConfiguration synapseConfiguration, long interval, String configName)`
  Initialize the mediation persistence manager instance and start accepting and processing persistence requests.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addCAppArtifactsAfterPersist(org.apache.synapse.config.SynapseConfiguration synapseConfiguration, org.apache.synapse.config.SynapseConfiguration cAppConfig)`
  Add the CApp artifact configuration to the current configuration, after persist the other artifacts into the default location
  `void`
  `deleteItem(String name, String fileName, int itemType)`
  Delete a particular item in the saved mediation configuration.
  `void`
  `destroy()`
  `protected Lock`
  `getLock(org.apache.axis2.engine.AxisConfiguration axisConfig)`
  `boolean`
  `isInitialized()`
  `org.apache.synapse.config.SynapseConfiguration`
  `removeCAppArtifactsBeforePersist(org.apache.synapse.config.SynapseConfiguration synapseConfiguration)`
  `void`
  `saveFullConfiguration(boolean registryOnly)`
  Make a request to save the complete mediation configuration (the entire SynapseConfiguration) to be saved to the file system and the registry.
  `void`
  `saveItem(String name, int itemType)`
  Save changes made to a particular item of the mediation configuration.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### MediationPersistenceManager

    public MediationPersistenceManager(String configPath, org.apache.synapse.config.SynapseConfiguration synapseConfiguration, long interval, String configName)
    Initialize the mediation persistence manager instance and start accepting and processing persistence requests. Persistence requests are carried out on the local file system and if required on the registry as well.
    Parameters:
      `configPath` - Path to the file/directory where configuration should be saved in
      `synapseConfiguration` - synapse configuration to be used
      `interval` - The wait time for the mediation persistence worker thread
      `configName` - Name of the configuration to be used

- ## Method Details

  - ### destroy

    public void destroy()

  - ### isInitialized

    public boolean isInitialized()

  - ### saveItem

    public void saveItem(String name, int itemType)
    Save changes made to a particular item of the mediation configuration. Changes are saved to the local file system and if required to the registry as well. Types of supported mediation configuration items are defined in ServiceBusConstants. If the item to be saved should be written to its own configuration file, the file name attribute must be set on the item (in the SynapseConfiguration). Leaving the file name as null will cause the item to be persisted into the top level synapse.xml file.
    Parameters:
      `name` - Name/ID of the configuration item
      `itemType` - type of the configuration item

  - ### deleteItem

    public void deleteItem(String name, String fileName, int itemType)
    Delete a particular item in the saved mediation configuration. Item is removed from the local file system and if required to the registry as well. Types of supported mediation configuration items are defined in ServiceBusConstants.
    Parameters:
      `name` - Name/ID of the configuration item
      `fileName` - Name of the file where the item is currently saved in
      `itemType` - Type of the configuration item

  - ### saveFullConfiguration

    public void saveFullConfiguration(boolean registryOnly)
    Make a request to save the complete mediation configuration (the entire SynapseConfiguration) to be saved to the file system and the registry. This will remove all the existing requests already in the job queue and add a single new entry.
    Parameters:
      `registryOnly` - Whether or not to save the configuration to the registry only

  - ### addCAppArtifactsAfterPersist

    public void addCAppArtifactsAfterPersist(org.apache.synapse.config.SynapseConfiguration synapseConfiguration, org.apache.synapse.config.SynapseConfiguration cAppConfig)
    Add the CApp artifact configuration to the current configuration, after persist the other artifacts into the default location
    Parameters:
      `synapseConfiguration` - Current Configuration
      `cAppConfig` - CApp artifact configuration

  - ### removeCAppArtifactsBeforePersist

    public org.apache.synapse.config.SynapseConfiguration removeCAppArtifactsBeforePersist(org.apache.synapse.config.SynapseConfiguration synapseConfiguration)
    Parameters:
      `synapseConfiguration` - Contains all the configuration includes CApp artifact configs
    Returns:
      new Configuration which removes all the CApp related configs

  - ### getLock

    protected Lock getLock(org.apache.axis2.engine.AxisConfiguration axisConfig)