synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hubert, Eric" <>
Subject Design-Flaw in AbstractDBMediatorFactory and sub classes?
Date Wed, 04 Nov 2009 21:52:09 GMT
Hi Synapse-Devs,

While having a glance on the way Synapse creates its internal memory representation of the
Synapse configuration I think I stumbled across a design flaw in the AbstractDBMediatorFactory
and its sub classes.

Please correct me, if I’m wrong on the following assumptions:
-          the process of building the in-memory object representation of the Synapse configuration
has to be separated from the initialisation of mediators
-          it is not the responsibility of mediator factories to initialize mediators, but
to create the mediator (object representation) of the mediator configuration as part of the
Synapse configuration
-          this allows one to create a configuration model from a synapse configuration (e.g.
stored in an XML file) without the need to have an initialized environment running
-          this separation is also manifested in different execution phases within the startup
1) create Synapse configuration
2) create Synapse environment
3) initialize Synapse configuration with Synapse environment (calls init() on all config elements
supporting some kind of lifecycle)

Unfortunately I noticed that my assumptions are wrong, although I honestly think they SHOULD
be correct. It is currently not possible to create a Synapse Configuration from a synapse.xml
which makes use of mediators which are created based on the AbstractDBMediatorFactory.
The reason is, mediator creation and initialization are mixed and the factories take responsibility
of both. During the creation defined datasources are build (including datasource lookup which
can only work, if the DataSourceHelper has been initialized).
I think the creation of the synapse configuration model itself should not depend on external
dependencies. The initialization should rather be done in the init-Method of the AbstractDBMediator,
instead of the create-method of the AbstractDBMediatorFactory.

What do others think?

Here is the current stacktrace, if someone tries to build a synapse configuration with standalone
code like this:

SynapseConfiguration synapseConfiguration = scb.getConfiguration(synapseConfigFileName);

org.apache.synapse.commons.SynapseCommonsException: DataSourceHelper has not been initialized,
it requires to be initialized at org.apache.synapse.commons.datasource.DataSourceHelper.assertInitialized(
     at org.apache.synapse.commons.datasource.DataSourceHelper.getRepositoryBasedDataSourceFinder(
at org.apache.synapse.config.xml.AbstractDBMediatorFactory.lookupDataSource(
at org.apache.synapse.config.xml.AbstractDBMediatorFactory.buildDataSource(


View raw message