Re: Using multiple instances of Saxon processors

That's my gut feeling as well; obviously it’s always hard to judge without knowing the API intricacies, and without being proficient in the host language (Scala).

Singletons in general also make components more difficult to test in isolation, are harder to setup with dependency-injected patterns, etc.

For the record, our use of Calabash does *not* involve parallel configurations. We do however have mechanisms to (dynamically) add/remove steps to the configuration.

Romain.


On 14 déc. 2013, at 18:00, David Lee <dlee@calldei.com> wrote:

> My knee jerk reaction is don't do it.
> Once you go singleton you can't go back.
> Callers could still make your class a singleton but I have been bit hard by libraries that make the assumption that they are the only center of the world 
> 
> Sent from my iPad (excuse the terseness) 
> David A Lee
> dlee@calldei.com
> 
> 
>> On Dec 14, 2013, at 11:13 AM, "Norman Walsh" <ndw@nwalsh.com> wrote:
>> 
>> Hi,
>> 
>> In the architecture of XML Calabash V2, there's a different API.
>> There's an XProcEngine (name's kind of awful but whatever) that
>> contains the Saxon processor and other "global" configuration data.
>> You obtain a pipeline compiler and runtime from the engine.
>> 
>> I am sorely tempted to make the engine a singleton. The only drawback
>> that I can see is that it wouldn't then be possible to write a program
>> that ran multiple pipelines with different Saxon configurations (Saxon
>> HE and EE, for example) or with different implementations of the same
>> step.
>> 
>> The advantage is API simplification. Everywhere that the Saxon
>> processor or some other bit of global configuration is needed, it has
>> to be passed around either as part of the constructor for an object or
>> as a parameter to static methods because there's no way other way to
>> get at it. With a singleton engine object, it would always be
>> available.
>> 
>> Most users would never notice, but I know some folks have used the XML
>> Calabash APIs to build larger systems.
>> 
>> Anyone feel like pushing back on the singleton idea?
>> 
>>                                       Be seeing you,
>>                                         norm
>> 
>> -- 
>> Norman Walsh
>> Lead Engineer
>> MarkLogic Corporation
>> Phone: +1 512 761 6676
>> www.marklogic.com
> 

Received on Saturday, 14 December 2013 18:12:09 UTC