[Perl-workflow-devel] Allowing multiple factories
Brought to you by:
jonasbn
From: Alexander K. <ak-...@cy...> - 2007-05-22 07:44:28
|
Hi all, in OpenXPKI, we are currently doing funny things with having multiple different configurations available in the system and we would like to have multiple Workflow::Factory instances with different configuration. Unfortunately, Workflow::Factory is singleton for now. What would you think about adding a 'force' parameter to Workflow::Factory->new() that would allow people to create a new (second, third, ...) instance? The alternative of subclassing Workflow::Factory works, but is not very elegant. The RT bug #18159 gets it correctly when saying that subclassing Workflow::Factory is broken. Even though I can have my own Factory class and instance, once objects are created (i.e. Workflow::State objects), they use 'use Workflow::Factory qw( FACTORY )' instead of my factory (instance). Changing that would probably involve passing the factory instance to every 'new()' there is, which seems like a lot of work. For now, we are using the ugly hack of changing the symbol table: *Workflow::State::FACTORY = sub { return $factory } (and so on for different classes as well). If someone has an easy solution that solves this bug, I'd be happy to implement it as well (because people might want to change their factory in ways different to ours and that is a good thing) ... Best regards, Alex -- Dipl.-Math. Alexander Klink | IT-Security Engineer ak-...@cy... | working @ urn:oid:1.3.6.1.4.1.11417 |