------------ CLIENT SIDE ------------

class View {
  uiBinder()....
}

class Presenter {
  onbind() {
    newUserButton() {
      dispatch(new NewUserAction("name", "lastname"), ...);
    }
  }
}

------------ SERVER SIDE ------------

class NewUserActionHandler {
  private final UserService userService;

  @Inject
  public NewUserActionHandler(UserService userService) {
    this.userService = userService;
  }

  public NewUserResult execute(NewUserAction action, ...) {
    this.userService.createNewUser(action.getName(),
action.getLastName());
  }
  ...
}

class UserService {
  private final UserDao userDao;

  @Inject
  UserService(UserDao userDao) {
    this.userDao = userDao;
  }

  Long createNewUser(String name, String lastName) {
     return userDao.storeUser( new User(name, lastName));
  }

}

class UserDao {
  private final Provider<EntityManager> em;

  @Inject
  public UserDao(Provider<EntityManager> em) {
    this.em = em;
  }

  public Long storeUser(User user) {
    this.em.get().persist(user);
    return user.getId();
  }
}

On May 10, 4:02 am, Bin Wu <[email protected]> wrote:
> Hello everyone,
>
> I am pretty new to Guice and even J2EE, and I am currently trying to build a
> webapp which ues (GWT, Google-gin, gwt-platform, Guice, Hibernate etc.). My
> problem here is, at the server side, I am bit confused about how those
> components can collaborate with each other in a  good manner. Anyone here
> has a good example which uses Guice, Hibernate and a DAO layer?
>
> Thanks a lot.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to