Back to project page InfuseFactory.
The source code is released under:
/** * Copyright (c) 2014 Lazu Ioan-Bogdan * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from ...
If you think the Android project InfuseFactory listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.factory.infuse; //from www .java 2 s . co m import java.util.Map; import java.util.WeakHashMap; import android.content.Context; import com.factory.infuse.internal.InfuserGlobal; import com.factory.infuse.internal.InfuserScoped; import com.factory.infuse.internal.scope.ScopeFactory; public class InfuseCreator { private Map<Object, Infuser> scopedInfusers; private Infuser globalInfuser; private Scope scopeGlobal; private Context context; public InfuseCreator() { scopedInfusers = new WeakHashMap<Object, Infuser>(); globalInfuser = InfuserGlobal.getInfuserInstance(); scopeGlobal = ScopeFactory.getGlobalScope(); } // Clear and populate the global scope public void clearGlobalInstances() { scopeGlobal.clearScope(); scopeGlobal.markScoped(Context.class, context); } // Set the context and populate the global scope public void setContext(Context context) { this.context = context; clearGlobalInstances(); } public Infuser obtainScopedInfuser(Object key) { if(scopedInfusers.containsKey(key)) { return scopedInfusers.get(key); } else { Infuser infuser = new InfuserScoped(); scopedInfusers.put(key, infuser); return infuser; } } // public void deleteScopedInfuser(Object key) { // if(scopedInfusers.containsKey(key)) { // scopedInfusers.remove(key); // } // } public Infuser obtainGlobalInfuser() { return globalInfuser; } }