package com.ds.listing.properties;

import com.ebay.sdk.ApiContext;
import com.ebay.sdk.ApiCredential;
import java.util.Random;

/**
 * ebay auth credentials
 * Created by bithack on 3/31/15.
 */
public class eBayAuth {
    private static eBayAuth _instance = null;
    private ApiContext _apiContext = null;
    private int _version = 0;

    protected eBayAuth(){
        Random randomGenerator = new Random();
        _version = randomGenerator.nextInt(1000000);
    }

    public static eBayAuth getInstance(){
        if(_instance == null){
            _instance = new eBayAuth();
        }
        System.out.println("eBay Auth: ID# "+ Integer.toString(_version));
        return _instance;
    }

    public ApiContext getApiContenxt(){
        if(_apiContext == null){
            setupContext();
        }
        return _apiContext;
    }

    private void setupContext(){
        _apiContext = new ApiContext();
        ApiCredential cred = _apiContext.getApiCredential();
        cred.seteBayToken(UserProperties.getInstance().getValue("ebaytoken"));
        _apiContext.setApiServerUrl(UserProperties.getInstance().getValue("ebaysoapurl"));
    }

}

@@ -120,16 +120,86 @@
 .Random;
+%0Aimport javax.inject.Singleton;%0Aimport javax.annotation.PostConstruct;
 %0A%0A/**%0A *
@@ -259,16 +259,28 @@
 15.%0A */%0A
+ @Singleton%0A
 public c
@@ -303,49 +303,8 @@
     
-private static eBayAuth _instance = null;
 %0A   
@@ -382,26 +382,44 @@
     
-protected eBayAuth
+@PostConstruct%0A    private void init
 ()%7B%0A
@@ -522,138 +522,8 @@
 0);%0A
-    %7D%0A%0A    public static eBayAuth getInstance()%7B%0A        if(_instance == null)%7B%0A            _instance = new eBayAuth();%0A        %7D%0A
     
@@ -605,25 +605,22 @@
     
-return _instance;
+setupContext()
 %0A   
@@ -1073,17 +1073,22 @@
 url%22));%0A
-
     %7D
+%0A    
 %0A%0A%7D%0A

Update eBayAuth.java