Use singleton factory pattern for
----------------------------------
Key: TUSCANY-1280
URL: https://issues.apache.org/jira/browse/TUSCANY-1280
Project: Tuscany
Issue Type: Improvement
Components: Java SCA Kernel
Affects Versions: Java-SCA-0.90
Environment: Windows XP
Reporter: Simon Nash
Assigned To: Simon Nash
Fix For: Java-SCA-0.90
DefaultAssemblyFactory, DefaultPolicyFactory, DefaultWSDLFactory, and
DefaultWebServiceBindingFactory are SPIs that extend from non-SPI factory
implementation code. A cleaner solution is to use a singleton factory pattern
to avoid the need for SPI classes to extend from non-SPI implementation
classes.. See discussion from
http://www.mail-archive.com/[email protected]/msg17590.html quoted below
>>> 3. DefaultAssemblyFactory is in the interface package
>>> org.apache.tuscany.assembly, but it extends from AssemblyFactoryImpl
>>> which is in the implementation package
>>> org.apache.tuscany.assembly.impl.
>>> This means that "impl" code is showing up indirectly as part of an
>>> SPI interface. The same arrangement is used for
>>> DefaultPolicyFactory,
>>> DefaultWSDLFactory, and DefaultWebServiceBindingFactory.
>>
>>
>>
>> I don't find this shocking and I don't have a better (and reasonably
>> simple) idea to improve this. Do you have a proposal?
>> - move the XyzDefaultFactory to the impl package?
>> - get rid of XyzDefaultFactory and have the people new up a
>> XyzFactoryImpl directly?
>> - any other suggestion?
>>
> On further consideration, I think this pattern is OK because there's
> no direct reference from extension code to any impl class. Other
> arrangements are possible, such as:
>
> package org.apache.tuscany.assembly;
>
> import org.apache.tuscany.assembly.impl.AssemblyFactoryImpl;
>
> public class DefaultAssemblyFactory {
>
> private static AssemblyFactory defaultFactory;
>
> public static AssemblyFactory getDefaultFactory() {
> if (defaultFactory == null)
> defaultFactory = new AssemblyFactoryImpl();
> return defaultFactory;
> }
> }
>
> I think this is slightly cleaner, but it's not a big deal one way
> or the other.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]