Created
February 12, 2016 19:29
-
-
Save Pacane/a5f93b22b46ca66cacd1 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.arcbees.client.application.services; | |
import java.util.HashMap; | |
import java.util.Map; | |
import com.arcbees.client.application.events.UserDeletedEvent; | |
import com.google.gwt.event.shared.GwtEvent; | |
import com.google.gwt.event.shared.HasHandlers; | |
import com.google.inject.Inject; | |
import com.google.web.bindery.event.shared.EventBus; | |
// Dummy implementation of a UserService | |
public class UserServiceImpl implements UserService, HasHandlers { | |
private final EventBus eventBus; | |
private Map<Integer, String> usernames; | |
@Inject | |
public UserServiceImpl(EventBus eventBus) { | |
this.eventBus = eventBus; | |
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; | |
} | |
@Override | |
public void deleteUser(int userId) { | |
usernames.remove(userId); | |
UserDeletedEvent.fire(this); | |
} | |
@Override | |
public void fireEvent(GwtEvent<?> gwtEvent) { | |
eventBus.fireEventFromSource(gwtEvent, this); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment