Last active
February 12, 2016 19:21
-
-
Save Pacane/d5076cf3cc5c12d13a26 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
// add these bindings | |
install(new DefaultModule.Builder().tokenFormatter(RouteTokenFormatter.class).build()); | |
bind(UserService.class).to(UserServiceImpl.class).asEagerSingleton(); |
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
public interface UserService { | |
String getUsername(int userId); | |
void saveUsername(int userId, String username); | |
Map<Integer, String> getUsers(); | |
} |
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
// Dummy implementation of a UserService | |
public class UserServiceImpl implements UserService { | |
private Map<Integer, String> usernames; | |
public UserServiceImpl() { | |
usernames = new HashMap<>(); | |
usernames.put(1, "Arcbees"); | |
usernames.put(2, "Joel"); | |
usernames.put(3, "Olivier"); | |
} | |
@Override | |
public String getUsername(int userId) { | |
return usernames.get(userId); | |
} | |
@Override | |
public void saveUsername(int userId, String username) { | |
usernames.put(userId, username); | |
} | |
@Override | |
public Map<Integer, String> getUsers() { | |
return usernames; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment