package com.ds.listing.properties;

import com.ebay.sdk.ApiContext;
import com.ebay.sdk.ApiCredential;
import java.util.Random;
import javax.ejb.Singleton;
import javax.annotation.PostConstruct;

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

    @PostConstruct
    private void init(){
        Random randomGenerator = new Random();
        _version = randomGenerator.nextInt(1000000);
        System.out.println("eBay Auth: ID# "+ Integer.toString(_version));
        setupContext();
    }

    public ApiContext getApiContext(){
        if(_apiContext == null){
            setupContext();
        }
        return _apiContext;
    }
    
    public String getVersion(){
        return "V - " + Integer.toString(_version);
    }

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

}

@@ -187,16 +187,44 @@
 nstruct;
+%0Aimport javax.inject.Inject;
 %0A%0A/**%0A *
@@ -398,16 +398,63 @@
 n = 0;%0A%0A
+    @Inject%0A    private UserProperties props;%0A%0A
     @Pos
@@ -1099,36 +1099,13 @@
 ken(
-UserProperties.getInstance()
+props
 .get
@@ -1165,36 +1165,13 @@
 Url(
-UserProperties.getInstance()
+props
 .get

Update eBayAuth.java