You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tasks/astrid/rmilk-src/org/weloveastrid/rmilk/MilkDependencyInjector.java

57 lines
1.6 KiB
Java

/**
* See the file "LICENSE" for the full license governing this code.
*/
package org.weloveastrid.rmilk;
import org.weloveastrid.rmilk.data.MilkListService;
import org.weloveastrid.rmilk.data.MilkMetadataService;
import com.todoroo.andlib.service.AbstractDependencyInjector;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService.ErrorReporter;
/**
* RTM Dependency Injection for service classes
*
* @author Tim Su <tim@todoroo.com>
*
*/
public class MilkDependencyInjector extends AbstractDependencyInjector {
/**
* variable to prevent multiple copies of this injector to be loaded
*/
private static MilkDependencyInjector instance = null;
/**
* Initialize list of injectables. Special care must used when
* instantiating classes that themselves depend on dependency injection
* (i.e. {@link ErrorReporter}.
*/
@Override
@SuppressWarnings("nls")
protected void addInjectables() {
injectables.put("milkMetadataService", MilkMetadataService.class);
injectables.put("milkListService", MilkListService.class);
}
/**
* Install this dependency injector
*/
public static void initialize() {
if(instance != null)
return;
synchronized(MilkDependencyInjector.class) {
if(instance == null)
instance = new MilkDependencyInjector();
DependencyInjectionService.getInstance().addInjector(instance);
}
}
MilkDependencyInjector() {
// prevent instantiation
super();
}
}