org.wso2.carbon.mediation.initializer.persistence
Class MediationPersistenceManager

java.lang.Object
  extended by 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
MediationPersistenceManager(org.wso2.carbon.registry.core.session.UserRegistry registry, 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
 void deleteItem(String name, String fileName, int itemType)
          Delete a particular item in the saved mediation configuration.
 void deleteItemFromRegistry(String name, int itemType)
          Delete the specified item from the registry only.
 void destroy()
           
 boolean isInitialized()
           
 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.
 void saveItemToRegistry(String name, int itemType)
          Save the specified item to the registry only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MediationPersistenceManager

public MediationPersistenceManager(org.wso2.carbon.registry.core.session.UserRegistry registry,
                                   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:
registry - The UserRegistry instance to be used for persistence or null
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 Detail

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

saveItemToRegistry

public void saveItemToRegistry(String name,
                               int itemType)
Save the specified item to the registry only. This method accepts request if and only if registry persistence is enabled for mediation configuration items. It is not recommended to use this method unless it is required to save something to the registry only. To save an item properly one must use the saveItem method.

Parameters:
name - Name/ID of the configuration item
itemType - Type of the configuration item

deleteItemFromRegistry

public void deleteItemFromRegistry(String name,
                                   int itemType)
Delete the specified item from the registry only. This method accepts request if and only if registry persistence is enabled for mediation configuration items. It is not recommended to use this method unless it is required to delete something from the registry only. To delete an item properly one must use the deleteItem method.

Parameters:
name - Name/ID of the configuration item
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


Copyright © 2015 WSO2. All rights reserved.