Java Code Examples for javax.enterprise.context.Conversation#end()

The following examples show how to use javax.enterprise.context.Conversation#end() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoginController.java    From enkan with Eclipse Public License 1.0 5 votes vote down vote up
public HttpResponse login(Parameters params, Conversation conversation) {
    if (!conversation.isTransient()) conversation.end();
    CustomerDao dao = daoProvider.getDao(CustomerDao.class);
    String email = params.get("email");
    Customer customer = dao.loginByPassword(email, params.get("password"));
    if (customer == null) {
        return templateEngine.render("guestbook/login");
    } else {
        Session session = new Session();
        session.put("principal", new LoginPrincipal(email));
        return builder(redirect(GuestbookController.class, "list", HttpResponseUtils.RedirectStatusCode.SEE_OTHER))
                .set(HttpResponse::setSession, session)
                .build();
    }
}
 
Example 2
Source File: GuestbookController.java    From enkan with Eclipse Public License 1.0 5 votes vote down vote up
@Transactional
public HttpResponse post(Parameters params, UserPrincipal principal, Conversation conversation) {
    if (!conversation.isTransient()) conversation.end();
    GuestbookDao dao = domaProvider.getDao(GuestbookDao.class);
    Guestbook guestbook = builder(new Guestbook())
            .set(Guestbook::setName,    principal.getName())
            .set(Guestbook::setMessage, params.get("message"))
            .set(Guestbook::setPostedAt, LocalDateTime.now())
            .build();
    dao.insert(guestbook);
    return redirect(GuestbookController.class, "list", SEE_OTHER);
}
 
Example 3
Source File: ConversationStateController.java    From enkan with Eclipse Public License 1.0 4 votes vote down vote up
public HttpResponse page3(Conversation conversation) {
    if (!conversation.isTransient()) conversation.end();
    return templateEngine.render("conversationState/page3");
}