org.apache.synapse.config
Class SynapseConfiguration

java.lang.Object
  extended by org.apache.synapse.config.SynapseConfiguration
All Implemented Interfaces:
ManagedLifecycle, SynapseArtifact

public class SynapseConfiguration
extends Object
implements ManagedLifecycle, SynapseArtifact

The SynapseConfiguration holds the global configuration for a Synapse instance.


Constructor Summary
SynapseConfiguration()
           
 
Method Summary
 void addAPI(String name, API api)
           
 void addEndpoint(String key, Endpoint endpoint)
          Define a named endpoint with the given key.
 void addEndpoint(String key, Entry entry)
          Deprecated.  
 void addEndpointTemplate(String name, Template template)
           
 void addEntry(String key, Entry entry)
          Define a resource to the local registry.
 void addEventSource(String name, SynapseEventSource eventSource)
          Add an event source to the configuration.
 void addMessageProcessor(String name, MessageProcessor processor)
          Add message processor to the synapse configuration with given name
 void addMessageStore(String name, MessageStore messageStore)
          Add MessageStore to the configuration with a given name.
 void addPriorityExecutor(String name, PriorityExecutor executor)
          Add an executor
 void addProxyService(String name, ProxyService proxy)
          Add a Proxy service to the configuration.
 void addSequence(String key, Entry entry)
          Deprecated.  
 void addSequence(String key, Mediator mediator)
          Add a named sequence into the local registry.
 void addSequenceTemplate(String key, TemplateMediator mediator)
          Add a sequence-template into the local registry.
 void addStartup(Startup startup)
          Add a startup to the startups map in the configuration.
 void clearCache()
          Clears the cache of all the remote entries which has been cached in the configuration
 void clearCachedEntry(String key)
          Clears the cache of the remote entry with the key specified
 void destroy()
          This method will be called on the soft shutdown or destroying the configuration and will destroy all the stateful managed parts of the configuration.
 API getAPI(String name)
           
 Collection<API> getAPIs()
           
 SynapseArtifactDeploymentStore getArtifactDeploymentStore()
          Get the SynapseArtifactDeploymentStore which is used to store the information about the deployed artifacts
 AxisConfiguration getAxisConfiguration()
          Get the Axis2 AxisConfiguration for the SynapseConfiguration
 Map<String,Entry> getCachedEntries()
          Gives the set of remote entries that are cached in localRegistry as mapping of entry key to the Entry definition
 QName getDefaultQName()
          Get the default QName of the configuration.
 Map<String,Endpoint> getDefinedEndpoints()
          Returns the map of defined endpoints in the configuration excluding the fetched endpoints from remote registry
 Map<String,Entry> getDefinedEntries()
          Returns the map of defined entries in the configuration excluding the fetched entries from remote registry.
 Map<String,SequenceMediator> getDefinedSequences()
          Returns the map of defined sequences in the configuration excluding the fetched sequences from remote registry.
 String getDescription()
          Gets the configuration description
 Endpoint getEndpoint(String key)
          Get the definition of the endpoint with the given key
 Template getEndpointTemplate(String key)
           
 Map<String,Template> getEndpointTemplates()
          Returns the map of defined synapse endpoint templates in the configuration excluding the fetched sequences from remote registry.
 Object getEntry(String key)
          Get the resource with the given key
 Entry getEntryDefinition(String key)
          Get the Entry object mapped to the given key
 SynapseEventSource getEventSource(String name)
           
 Collection<SynapseEventSource> getEventSources()
           
 Mediator getFaultSequence()
          Return the fault sequence to be executed when Synapse encounters a fault scenario during processing
 Map getLocalRegistry()
          Return an unmodifiable copy of the local registry
 Mediator getMainSequence()
          Return the main/default sequence to be executed.
 Mediator getMandatorySequence()
          Gets the mandatory sequence, from the direct reference.
 Map<String,MessageProcessor> getMessageProcessors()
          Get all Message processors in the Synapse configuration
 MessageStore getMessageStore(String name)
          Get the Message store for the configuration with a given name.
 Map<String,MessageStore> getMessageStores()
          Get Message sotres defined
 List<SynapseObserver> getObservers()
           
 String getPathToConfigFile()
          The path to the currently loaded configuration file
 Map<String,PriorityExecutor> getPriorityExecutors()
          Get the executors map
 Properties getProperties()
          Gets the properties to configure the Synapse environment.
 String getProperty(String propKey)
          Gets the propety value if the property specified by the propKey is there or null else
 long getProperty(String propKey, long def)
          Gets the String representation of the property value if there is a property for the given propKey or returns the default value passed
 String getProperty(String propKey, String def)
          Gets the String representation of the property value if there is a property for the given propKey or returns the default value passed
 ProxyService getProxyService(String name)
          Get the Proxy service with the given name
 Collection<ProxyService> getProxyServices()
          Return the list of defined proxy services
 Registry getRegistry()
          Get the remote registry defined (if any)
 Mediator getSequence(String key)
          Return the sequence specified with the given key
 TemplateMediator getSequenceTemplate(String key)
          Return the template specified with the given key
 Map<String,TemplateMediator> getSequenceTemplates()
          Returns the map of defined synapse templates in the configuration excluding the fetched sequences from remote registry.
 Startup getStartup(String id)
          Get the Startup with the specified name
 Collection<Startup> getStartups()
          Get the startup collection in the configuration
 Timer getSynapseTimer()
          Get the timer object for the Synapse Configuration
 void init(SynapseEnvironment se)
          This method will be called in the startup of Synapse or in an initiation and will initialize all the managed parts of the Synapse Configuration
 boolean isAllowHotUpdate()
           
 void registerObserver(SynapseObserver o)
           
 void removeAPI(String name)
           
 void removeEndpoint(String key)
          Deletes the endpoint with the given key.
 void removeEndpointTemplate(String name)
           
 void removeEntry(String key)
          Deletes any reference mapped to the given key from the local registry
 void removeEventSource(String name)
          Remove an event source from the configuration.
 PriorityExecutor removeExecutor(String name)
          Removes an executor from the configuration
 MessageProcessor removeMessageProcessor(String name)
          remove the message processor from the synapse configuration
 MessageStore removeMessageStore(String name)
          Removes a Message store from the configuration
 void removeProxyService(String name)
          Deletes the Proxy Service named with the given name.
 void removeSequence(String key)
          Removes a sequence from the local registry
 void removeSequenceTemplate(String name)
          Removes a template from the local registry
 void removeStartup(String name)
          Removes the startup specified by the name.
 void setAllowHotUpdate(boolean allowHotUpdate)
           
 void setAxisConfiguration(AxisConfiguration axisConfig)
          Set the Axis2 AxisConfiguration to the SynapseConfiguration
 void setDefaultQName(QName defaultQName)
          Set the default QName of the Synapse Configuration
 void setDescription(String description)
          Sets the description of the configuration
 void setEventSources(Map<String,SynapseEventSource> eventSources)
           
 void setMandatorySequence(Mediator mandatorySequence)
          Sets the mandatory sequence direct reference
 void setPathToConfigFile(String pathToConfigFile)
          Set the path to the loaded synapse.xml
 void setProperties(Properties properties)
          Deprecated.  
 void setProperty(String key, String value)
          Sets the specified property to the Synapse configuration
 void setRegistry(Registry registry)
          Set the remote registry for the configuration
 void updateAPI(String name, API api)
           
 void updateEndpoint(String key, Endpoint endpoint)
           
 void updateEndpointTemplate(String name, Template template)
           
 void updateEntry(String key, Entry entry)
           
 void updatePriorityExecutor(String name, PriorityExecutor executor)
           
 void updateSequence(String key, Mediator mediator)
           
 void updateSequenceTemplate(String key, TemplateMediator mediator)
          Update a sequence-template into the local registry.
 void updateStartup(Startup startup)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SynapseConfiguration

public SynapseConfiguration()
Method Detail

addSequence

public void addSequence(String key,
                        Mediator mediator)
Add a named sequence into the local registry. If a sequence already exists by the specified key a runtime exception is thrown.

Parameters:
key - the name for the sequence
mediator - a Sequence mediator

addSequenceTemplate

public void addSequenceTemplate(String key,
                                TemplateMediator mediator)
Add a sequence-template into the local registry. If a template already exists by the specified key a runtime exception is thrown.

Parameters:
key - the name for the sequence
mediator - a Sequence mediator

updateSequenceTemplate

public void updateSequenceTemplate(String key,
                                   TemplateMediator mediator)
Update a sequence-template into the local registry. If a template already exists by the specified key a runtime exception is thrown.

Parameters:
key - the name for the sequence
mediator - a Sequence mediator

updateSequence

public void updateSequence(String key,
                           Mediator mediator)

addSequence

public void addSequence(String key,
                        Entry entry)
Deprecated. 

Allow a dynamic sequence to be cached and made available through the local registry. If a sequence already exists by the specified key a runtime exception is thrown.

Parameters:
key - the key to lookup the sequence from the remote registry
entry - the Entry object which holds meta information and the cached resource

getDefinedSequences

public Map<String,SequenceMediator> getDefinedSequences()
Returns the map of defined sequences in the configuration excluding the fetched sequences from remote registry.

Returns:
Map of SequenceMediators defined in the local configuration

getSequenceTemplates

public Map<String,TemplateMediator> getSequenceTemplates()
Returns the map of defined synapse templates in the configuration excluding the fetched sequences from remote registry.

Returns:
Map of Templates defined in the local configuration

getEndpointTemplates

public Map<String,Template> getEndpointTemplates()
Returns the map of defined synapse endpoint templates in the configuration excluding the fetched sequences from remote registry.

Returns:
Map of Templates defined in the local configuration

addAPI

public void addAPI(String name,
                   API api)

updateAPI

public void updateAPI(String name,
                      API api)

getAPIs

public Collection<API> getAPIs()

getAPI

public API getAPI(String name)

removeAPI

public void removeAPI(String name)

getSequenceTemplate

public TemplateMediator getSequenceTemplate(String key)
Return the template specified with the given key

Parameters:
key - the key being referenced for the template
Returns:
the template referenced by the key from local/remote registry

getMandatorySequence

public Mediator getMandatorySequence()
Gets the mandatory sequence, from the direct reference. This is also available in the getSequence(String) but this method improves the performance hence this will be required for all messages

Returns:
mandatory sequence direct reference in the local configuration

setMandatorySequence

public void setMandatorySequence(Mediator mandatorySequence)
Sets the mandatory sequence direct reference

Parameters:
mandatorySequence - to be set as the direct reference

getSequence

public Mediator getSequence(String key)
Return the sequence specified with the given key

Parameters:
key - the key being referenced
Returns:
the sequence referenced by the key

removeSequence

public void removeSequence(String key)
Removes a sequence from the local registry

Parameters:
key - of the sequence to be removed

removeSequenceTemplate

public void removeSequenceTemplate(String name)
Removes a template from the local registry

Parameters:
name - of the template to be removed

getMainSequence

public Mediator getMainSequence()
Return the main/default sequence to be executed. This is the sequence which will execute for all messages when message mediation takes place

Returns:
the main mediator sequence

getFaultSequence

public Mediator getFaultSequence()
Return the fault sequence to be executed when Synapse encounters a fault scenario during processing

Returns:
the fault sequence

addEntry

public void addEntry(String key,
                     Entry entry)
Define a resource to the local registry. All static resources (e.g. URL source) are loaded during this definition phase, and the inability to load such a resource will not allow the definition of the resource to the local registry. If an entry already exists by the specified key a runtime exception is thrown.

Parameters:
key - the key associated with the resource
entry - the Entry that holds meta information about the resource and its contents (or cached contents if the Entry refers to a dynamic resource off a remote registry)

updateEntry

public void updateEntry(String key,
                        Entry entry)

getCachedEntries

public Map<String,Entry> getCachedEntries()
Gives the set of remote entries that are cached in localRegistry as mapping of entry key to the Entry definition

Returns:
Map of locally cached entries

getDefinedEntries

public Map<String,Entry> getDefinedEntries()
Returns the map of defined entries in the configuration excluding the fetched entries from remote registry.

Returns:
Map of Entries defined in the local configuration

getEntry

public Object getEntry(String key)
Get the resource with the given key

Parameters:
key - the key of the resource required
Returns:
its value

getEntryDefinition

public Entry getEntryDefinition(String key)
Get the Entry object mapped to the given key

Parameters:
key - the key for which the Entry is required
Returns:
its value

removeEntry

public void removeEntry(String key)
Deletes any reference mapped to the given key from the local registry

Parameters:
key - the key of the reference to be removed

clearCachedEntry

public void clearCachedEntry(String key)
Clears the cache of the remote entry with the key specified

Parameters:
key - - String key of the entry

clearCache

public void clearCache()
Clears the cache of all the remote entries which has been cached in the configuration


addEndpoint

public void addEndpoint(String key,
                        Endpoint endpoint)
Define a named endpoint with the given key. If an endpoint already exists by the specified name a runtime exception is thrown.

Parameters:
key - the key for the endpoint
endpoint - the endpoint definition

updateEndpoint

public void updateEndpoint(String key,
                           Endpoint endpoint)

addEndpoint

public void addEndpoint(String key,
                        Entry entry)
Deprecated. 

Add a dynamic endpoint definition to the local registry. If an endpoint already exists by the specified name a runtime exception is thrown.

Parameters:
key - the key for the endpoint definition
entry - the actual endpoint definition to be added

getDefinedEndpoints

public Map<String,Endpoint> getDefinedEndpoints()
Returns the map of defined endpoints in the configuration excluding the fetched endpoints from remote registry

Returns:
Map of Endpoints defined in the local configuration

getEndpoint

public Endpoint getEndpoint(String key)
Get the definition of the endpoint with the given key

Parameters:
key - the key of the endpoint
Returns:
the endpoint definition

removeEndpoint

public void removeEndpoint(String key)
Deletes the endpoint with the given key. If an endpoint does not exist by the specified key a runtime exception is thrown.

Parameters:
key - of the endpoint to be deleted

addProxyService

public void addProxyService(String name,
                            ProxyService proxy)
Add a Proxy service to the configuration. If a proxy service already exists by the specified name a runtime exception is thrown.

Parameters:
name - the name of the Proxy service
proxy - the Proxy service instance

getProxyService

public ProxyService getProxyService(String name)
Get the Proxy service with the given name

Parameters:
name - the name being looked up
Returns:
the Proxy service

removeProxyService

public void removeProxyService(String name)
Deletes the Proxy Service named with the given name. If a proxy service does not exist by the specified name a runtime exception is thrown.

Parameters:
name - of the Proxy Service to be deleted

getProxyServices

public Collection<ProxyService> getProxyServices()
Return the list of defined proxy services

Returns:
the proxy services defined

getLocalRegistry

public Map getLocalRegistry()
Return an unmodifiable copy of the local registry

Returns:
an unmodifiable copy of the local registry

getRegistry

public Registry getRegistry()
Get the remote registry defined (if any)

Returns:
the currently defined remote registry

setRegistry

public void setRegistry(Registry registry)
Set the remote registry for the configuration

Parameters:
registry - the remote registry for the configuration

setAxisConfiguration

public void setAxisConfiguration(AxisConfiguration axisConfig)
Set the Axis2 AxisConfiguration to the SynapseConfiguration

Parameters:
axisConfig - AxisConfiguration to be set

getAxisConfiguration

public AxisConfiguration getAxisConfiguration()
Get the Axis2 AxisConfiguration for the SynapseConfiguration

Returns:
AxisConfiguration of the Axis2

getPathToConfigFile

public String getPathToConfigFile()
The path to the currently loaded configuration file

Returns:
file path to synapse.xml

setPathToConfigFile

public void setPathToConfigFile(String pathToConfigFile)
Set the path to the loaded synapse.xml

Parameters:
pathToConfigFile - path to the synapse.xml loaded

setDefaultQName

public void setDefaultQName(QName defaultQName)
Set the default QName of the Synapse Configuration

Parameters:
defaultQName - QName specifying the default QName of the configuration

getDefaultQName

public QName getDefaultQName()
Get the default QName of the configuration.

Returns:
default QName of the configuration

getSynapseTimer

public Timer getSynapseTimer()
Get the timer object for the Synapse Configuration

Returns:
synapseTimer timer object of the configuration

getStartups

public Collection<Startup> getStartups()
Get the startup collection in the configuration

Returns:
collection of startup objects registered

getStartup

public Startup getStartup(String id)
Get the Startup with the specified name

Parameters:
id - - String name of the startup to be retrieved
Returns:
Startup object with the specified name or null

addStartup

public void addStartup(Startup startup)
Add a startup to the startups map in the configuration. If a startup already exists by the specified name a runtime exception is thrown.

Parameters:
startup - - Startup object to be added

updateStartup

public void updateStartup(Startup startup)

removeStartup

public void removeStartup(String name)
Removes the startup specified by the name. If no startup exists by the specified name a runtime exception is thrown.

Parameters:
name - - name of the startup that needs to be removed

getProperties

public Properties getProperties()
Gets the properties to configure the Synapse environment.

Returns:
set of properties as Properties

setProperty

public void setProperty(String key,
                        String value)
Sets the specified property to the Synapse configuration

Parameters:
key - Name of the property
value - Value of the property to be set

setProperties

public void setProperties(Properties properties)
Deprecated. 

Sets the properties to configure the Synapse enviornment.

Parameters:
properties - - Properties which needs to be set

getProperty

public String getProperty(String propKey,
                          String def)
Gets the String representation of the property value if there is a property for the given propKey or returns the default value passed

Parameters:
propKey - - key for the property lookup
def - - default value
Returns:
String representation of the property value with the given key or the def value

getProperty

public long getProperty(String propKey,
                        long def)
Gets the String representation of the property value if there is a property for the given propKey or returns the default value passed

Parameters:
propKey - - key for the property lookup
def - - default value
Returns:
String representation of the property value with the given key or the def value

getProperty

public String getProperty(String propKey)
Gets the propety value if the property specified by the propKey is there or null else

Parameters:
propKey - - key for the property lookup
Returns:
String representation of the property value if found or null else

destroy

public void destroy()
This method will be called on the soft shutdown or destroying the configuration and will destroy all the stateful managed parts of the configuration.

Specified by:
destroy in interface ManagedLifecycle

init

public void init(SynapseEnvironment se)
This method will be called in the startup of Synapse or in an initiation and will initialize all the managed parts of the Synapse Configuration

Specified by:
init in interface ManagedLifecycle
Parameters:
se - SynapseEnvironment specifying the env to be initialized

addEventSource

public void addEventSource(String name,
                           SynapseEventSource eventSource)
Add an event source to the configuration. If an event source already exists by the specified name a runtime exception is thrown.

Parameters:
name - name of the event source
eventSource - the event source to be added

getEventSource

public SynapseEventSource getEventSource(String name)

removeEventSource

public void removeEventSource(String name)
Remove an event source from the configuration. If the specified event source does not exist a runtime exception is thrown.

Parameters:
name - name of the event source to be removed

getEventSources

public Collection<SynapseEventSource> getEventSources()

setEventSources

public void setEventSources(Map<String,SynapseEventSource> eventSources)

registerObserver

public void registerObserver(SynapseObserver o)

getObservers

public List<SynapseObserver> getObservers()

addPriorityExecutor

public void addPriorityExecutor(String name,
                                PriorityExecutor executor)
Add an executor

Parameters:
name - name of the executor
executor - executor

updatePriorityExecutor

public void updatePriorityExecutor(String name,
                                   PriorityExecutor executor)

getPriorityExecutors

public Map<String,PriorityExecutor> getPriorityExecutors()
Get the executors map

Returns:
executors map, stored as name of executor and executor

removeExecutor

public PriorityExecutor removeExecutor(String name)
Removes an executor from the configuration

Parameters:
name - name of the executor
Returns:
removed executor

getMessageStore

public MessageStore getMessageStore(String name)
Get the Message store for the configuration with a given name.

Parameters:
name - Name of the message store
Returns:
a MessageStore instance or null

addMessageStore

public void addMessageStore(String name,
                            MessageStore messageStore)
Add MessageStore to the configuration with a given name.

Parameters:
name - Name of the message store
messageStore - a MessageStore instance

getMessageStores

public Map<String,MessageStore> getMessageStores()
Get Message sotres defined

Returns:
message store map stored as name of the message store and message store

removeMessageStore

public MessageStore removeMessageStore(String name)
Removes a Message store from the configuration

Parameters:
name - name of the message store
Returns:
The message store with the specified name

addMessageProcessor

public void addMessageProcessor(String name,
                                MessageProcessor processor)
Add message processor to the synapse configuration with given name

Parameters:
name - of the Message processor
processor - instance

getMessageProcessors

public Map<String,MessageProcessor> getMessageProcessors()
Get all Message processors in the Synapse configuration

Returns:
Return Map that contains all the message processors

removeMessageProcessor

public MessageProcessor removeMessageProcessor(String name)
remove the message processor from the synapse configuration

Parameters:
name - of the message
Returns:
Removed Message processor instance

setDescription

public void setDescription(String description)
Sets the description of the configuration

Specified by:
setDescription in interface SynapseArtifact
Parameters:
description - tobe set to the artifact

getDescription

public String getDescription()
Gets the configuration description

Specified by:
getDescription in interface SynapseArtifact
Returns:
description of the configuration

getArtifactDeploymentStore

public SynapseArtifactDeploymentStore getArtifactDeploymentStore()
Get the SynapseArtifactDeploymentStore which is used to store the information about the deployed artifacts

Returns:
the SynapseArtifactDeploymentStore for this configuration

addEndpointTemplate

public void addEndpointTemplate(String name,
                                Template template)

updateEndpointTemplate

public void updateEndpointTemplate(String name,
                                   Template template)

removeEndpointTemplate

public void removeEndpointTemplate(String name)

getEndpointTemplate

public Template getEndpointTemplate(String key)

isAllowHotUpdate

public boolean isAllowHotUpdate()

setAllowHotUpdate

public void setAllowHotUpdate(boolean allowHotUpdate)


Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.