photopcf / magja

Automatically exported from code.google.com/p/magja
0 stars 0 forks source link

Change getInstance behavior #39

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I don't really understand what's the purpose of INSTANCE_CUSTOM, and in my 
implementation it makes a lot of sense if i can initialize the INSTANCE with a 
defined SoapConfig that could be used throughout the run-time. I really would 
like to bypass the PROPERTIES loading.

Purposed code that works in both situations:

    /**
     * MagentoSoapClientHolder is loaded on the first execution of
     * MagentoSoapClient.getInstance() or the first access to
     * MagentoSoapClientHolder.INSTANCE, not before.
     */
    public static MagentoSoapClient getInstance(SoapConfig soapConfig) {
        if (INSTANCE_DEFAULT == null) {
            INSTANCE_DEFAULT = new MagentoSoapClient(soapConfig);
        }
        return INSTANCE_DEFAULT;
   }

    public static MagentoSoapClient getInstance() {
        return getInstance(new SoapConfig(PropertyLoader.loadProperties(CONFIG_PROPERTIES_FILE)));
    }

Original issue reported on code.google.com by marcolopespt on 26 Aug 2011 at 6:30