Skip to content

Instantly share code, notes, and snippets.

View marchy's full-sized avatar

Marcel Bradea marchy

View GitHub Profile
@marchy
marchy / gist:6bda172592ad6ae359a0
Created January 13, 2015 16:29
Strict Service Locator
public class ServiceLocator {
//
// instance fields
//
private final static Map<Class, Object> _Services;
//
// constructors
// resolve system services
SharedPreferences sharedPreferences = context.getSharedPreferences( "Foodo", Context.MODE_PRIVATE );
// create app services
LocationService locationService = new LocationService( context );
AccountService accountService = new AccountService( sharedPreferences );
ServiceLocator.registerLocationService( locationService );
ServiceLocator.registerAccountService( accountService );