synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Supun Kamburugamuva <supu...@gmail.com>
Subject Re: Design-Flaw in AbstractDBMediatorFactory and sub classes?
Date Thu, 05 Nov 2009 08:14:12 GMT
+1, this makes sense. It would be really great if we could enforce this
behavior as well.

Supunn..

On Wed, Nov 4, 2009 at 1:52 PM, Hubert, Eric <Eric.Hubert@foxmobile.com>wrote:

>  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 process:
> 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(*
> DataSourceHelper.java:108*)      at
> org.apache.synapse.commons.datasource.DataSourceHelper.getRepositoryBasedDataSourceFinder(
> *DataSourceHelper.java:122*) at
> org.apache.synapse.config.xml.AbstractDBMediatorFactory.lookupDataSource(*
> AbstractDBMediatorFactory.java:145*) at
> org.apache.synapse.config.xml.AbstractDBMediatorFactory.buildDataSource(*
> AbstractDBMediatorFactory.java:121*)
>
> ...
>
>
>
> Regards,
>
>    Eric
>
>
>



-- 
Software Engineer, WSO2 Inc
http://wso2.org
supunk.blogspot.com

Mime
View raw message