Skip to content

Instantly share code, notes, and snippets.

@saksmt
Created September 9, 2014 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saksmt/a145365672f9acfff365 to your computer and use it in GitHub Desktop.
Save saksmt/a145365672f9acfff365 to your computer and use it in GitHub Desktop.
package com.smt.todo.model;
public class UnitOfWork {
private static UnitOfWork soleInstance = null;
private FinderInterface finder;
public static UnitOfWork getInstance() {
UnitOfWork.initialize();
return UnitOfWork.soleInstance;
}
private static void initialize() {
if (UnitOfWork.soleInstance == null) {
try {
UnitOfWork.soleInstance = new UnitOfWork();
} catch (Exception e) {
}
}
}
public UnitOfWork() throws Exception {
if (UnitOfWork.soleInstance != null) {
throw new Exception("Singletons MUST be single!");
}
this.configure();
}
private void configure() {
this.finder = new DummyTodoFinder();
}
public FinderInterface getFinder() {
return this.finder;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment