Created
September 9, 2014 16:38
-
-
Save saksmt/a145365672f9acfff365 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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