All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.pvanassen.steam.store.StoreFactory Maven / Gradle / Ivy

Go to download

A Java API to access the Steam community market through the HTTP interface. This may be against the TOS so be careful using it!

There is a newer version: 3.0.8
Show newest version
package nl.pvanassen.steam.store;

import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;

/**
 * Store factory for getting an instance
 *
 * @author Paul van Assen
 */
public class StoreFactory {
    
    private StoreFactory() {
        super();
    }
    
    /**
     * Factory method for getting a store instance
     *
     * @param cookies Cookies to use
     * @param username Username for the referral
     * @return Instance of the store service
     */
    public static StoreService getSteamStore(String cookies, String username) {
        synchronized (CACHE_MAP) {
            WeakReference key = new WeakReference<>(cookies);
            WeakReference service = CACHE_MAP.get(key);
            if ((service != null) && (service.get() != null)) {
                return service.get();
            }
            service = new WeakReference(new SteamService(cookies, username));
            CACHE_MAP.put(key, service);
            return service.get();
        }
    }

    private static final Map, WeakReference> CACHE_MAP = new HashMap<>();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy