synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charith Wickramarachchi <charith.dhanus...@gmail.com>
Subject Re: Make enable Synapse to configure in others ways
Date Fri, 20 Feb 2009 09:29:25 GMT
On Fri, Feb 20, 2009 at 1:09 PM, indika kumara <indika.kuma@gmail.com>wrote:

> Hi Charith
>
> FOR ME , there are some issues ...
>
> One issue is there are no java documents and logging. And code has not
> been formatted.



> Sure I'll will reformat the code with some documentation and logging
>
> Another issue is you have used java reflection to detect methods
> 'createConfigurationContext' and 'createSynapseConfiguration'. One
> thing is, this is not a requirement to use reflection. These methods
> are important to synapse as they setup synapse. You must use
> "interfaces'.  Using reflection is something like that you are trying
> to find a way to get work done forcibly, when someone says he cannot
> do.


   The problem with using an interface to this abstraction layer is this:


> By providing this abstraction layer my intention is to enable users to plug
> there SynapseConfiguration and ConfigurationContext.

   If i use an interface i have to force the user to use the specific type
of parameters to create synapse Configuration.which i think is       not  a
good way.What i did using reflections is allow users to use a methode which
can accept any type as a parameter.

  For clarification i will  explain how a user can use ConfigurationBuilder
in there code to to plug their own Builder

  ConfigurationBuilder cb=ConfigurationBuilder.getInstence();
  cb.setEnable(true);
  paramSynapseConfig[0]=applicationContext;

cb.setBuilderClass("org.noname.atech.esb.synapse.UserSynapseConfigurationBuilder");
  cb.setParameters(paramSynapseConfig);

   as in above code users can set the parameters that are need to build the
configuration and the builder class. In the class they use to
initialise.

> So that when the server manager starts Configuration builder It will find
> the correct methode from the specified class with correct parameters and
> invoke it to build the Configuration.
> So i think this way is much flexsible than using an Interface (Specially in
> this senario).
> You can create something time 'SynapseConfigurationFactory' and add method
>
> 'createSynapseConfiguration(List<String> confPaths)'
>
> List of path may be needed if it is needed to merge a configurations
> from multiple configurations or create a
> 'CompositeSynaseConfiguration' without merging but just keep as
> children configurations
>
> There is another thing. It is important to avoid (as possible) when
> setting and getting instance properties of a class, use of 'Map',
> 'List'. This breaks the one of most important OOP principle –
> encapsulation. You always expose internal data structure. Therefore,
> It is better to use 'add< relates word – property, parameter>(
> key,value)' and  returning 'Iterator'  for getters. This is only
> important if you care OOP. Other is don't try to use toString for
> anything other than logging.
>
> I am not sure in this way you can achieve what you want. You have hard
> coded both 'ConfigurationContextBuilder' and 'ConfigurationBuilder'
> (those are not interfaces'. And I can see method like
>
> 'synapseConfiguration=builder.getSynapseConfiguration(
> builder.getBuilderClass(),builder.getParameters());'
>
> I may misunderstand these. Sorry if it is.
>
> If you want to differentiates the ways that synapse configuration
> provides (xml based DSL or some other). You need a
> 'SynapseConfigurationProvider or SynapseConfigurationFactory'
> implementations … You can get this using many ways. Simplest thing is
> to specify as a property in the synapse.properties. It is very simple,
> declarative, will work in any environment (Example OSGI) without any
> additional code, will work in any deployment mode (web app,
> standalone) and other is , this is mostly a one property not like
> mediators.  You can use many other ways, system property (need to
> avoid, a security hole), inti parameter, java service provider API,
> discovery, etc….
> You simply what need here a 'SynapseConfigurationProvider' finding
> strategy. You can have single strategy with assigned precedence order
> to each ways of finding 'SynapseConfigurationProvider' class. For
> example, you can first look at synapse.properties , then init
> parameter , system properties , SPI ,etc………
>
>
> SynapseConfigurationProvider provider =
> SynapseConfigurationProviderFindingStrategy.find(..);
>
> Within find method, it is needed to implement the strategy
>
> If this 'provider' is null you can use default our existing
> XMLBasedConfigurationBuilder
>
> To get synapse configuration
>
> SynapeConfiguration = proiver.getSynapseConfiguration(List<String>
> confPaths)
>
> (If you use 'SynapseConfigurationFactory' instead of
> 'SynapseConfigurationProvider' use can call
> 'createSynapseConfiguration(List<String> confPaths)'
> )..
>
> This is only a way (untested) and you never want to do this …You can
> think and do it in better way than this.
>
> For your knowledge, existing synapse language is a DSL. It is focused
> on domain ESB or a middleware with some properties that make it
> special. It is too an external DSL. Actually, according to the
> 'martinfowler' - one of well recognized scientist, XML is the worst
> thing for external DSL. There are more resources at [1] .
> Thank you for the link this is really useful.
> Thanks
> Indika
>
> [1] http://martinfowler.com/dslwip/
>
>
> On Fri, Feb 20, 2009 at 9:18 AM, Charith Wickramarachchi
> <charith.dhanushka@gmail.com> wrote:
> > Hi devs,
> >
> > In order to be able to configure synapse in other ways than the XML
> > configuration language, I have abstracted out the initialization into a
> > one level higher layer where you can specify the mechanism by which you
> >  want to load the configuration. This will not affect the usual synapse
> > initialization flow, but is just an abstraction layer.
> >
> >  With this users will be able to plug their own Synapse Configuration and
> > ConfigurationContext with out touching the synapse code base.
> >
> >  Following is a brief  description of this improvement and if this is OK
> >  to be committed into synapse I will attach the patch for further
> reviews.
> >
> >  org.apache.synapse.ConfigurationBuilder
> >
> >  This is the abstraction layer added to Synapse for it to be able to
> >  extend or rather use new Configuration mechanism (DSL) than using the
> >  default Synapse Configuration Language. With this improvement users can
> >  use other Configurations by enabling the ConfigurationBuilder.
> >
> >  Eg: ConfigurationBuilder cbuilder=ConfigurationBuilder.getInstence();
> >  cbuilder.setEnable(true);
> >  (this is done in users code not in synapse codebase)
> >
> >  Then users must set the Builder Class in the ConfigurationBuilder.(This
> >  must be the fully qualified name of the Builder Class that users use to
> >  build the Configuration) And then users can set parameters needed to the
> >  build the configuration. The only restriction that Builder Class (the
> >  third party class that used to build the configuration) have is its
> >  configuration builder method must have the name
> >  "createSynapseConfiguration".
> >
> >  The Configuration Builder class will find the appropriate method form
> >  the Builder class using the class name and the parameter list and then
> >  it will build the Synapse configuration.The advantage of using this
> >  abstraction layer is Synapse ServerManager does not depend on the third
> >  party Synapse configuration builders.
> >
> >  org.apache.synapse.ConfigurationContextBuilder
> >
> > This is the abstraction layer added to the Synapse project to Start
> > Axis2 and Synapse using a Different application context this works as
> > same as the ConfigurationBuilder described above. Users who wants to
> > extent synapse to Start using a different application context can use
> this.
> > Here the restriction that is given to the Builder class is it must have
> > the method "createConfigurationContext" to Create configuration
> > context.The ConfigurationContextBuilder will locate the correct method
> > and build the Configuration Context to start the Axis2 and Synapse in
> > that context.
> >
> > thank you,
> > Charith Dhanushka Wickramarachchi
> > http://charithwiki.blogspot.com/
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
> For additional commands, e-mail: dev-help@synapse.apache.org
>
>


-- 
Charith Dhanushka Wickramarachchi
http://charithwiki.blogspot.com/

Mime
View raw message