
nl.pvanassen.steam.store.StoreFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of steam-api Show documentation
Show all versions of steam-api Show documentation
A Java API to access the Steam community market through the HTTP interface. This may be against the TOS so be careful using it!
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