javax.enterprise.context.Conversation Java Examples
The following examples show how to use
javax.enterprise.context.Conversation.
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: SubscriptionWizardConversationTest.java From development with Apache License 2.0 | 6 votes |
@Before public void setup() { model = spy(new SubscriptionWizardConversationModel()); sdm = mock(ServiceDetailsModel.class); conversation = mock(Conversation.class); ui = mock(UiDelegate.class); subscriptionService = mock(SubscriptionService.class); userGroupService = mock(UserGroupService.class); menuBean = mock(MenuBean.class); sessionBean = mock(SessionBean.class); subscriptionServiceInternal = mock(SubscriptionServiceInternal.class); jsonConverter = spy(new JsonConverter()); jsonConverter.setUiDelegate(ui); userBean = spy(new UserBean()); pabv = mock(PaymentAndBillingVisibleBean.class); accountService = mock(AccountService.class); unitCtrl = new SubscriptionUnitCtrl(); unitModel = new SubscriptionUnitModel(); unitCtrl.setModel(unitModel); bean = spy(new SubscriptionWizardConversation()); decorateBean(); }
Example #2
Source File: BusinessProcess.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * @see #startTask(String) * * this method allows to start a conversation if no conversation is active */ public Task startTask(String taskId, boolean beginConversation) { if(beginConversation) { Conversation conversation = conversationInstance.get(); if(conversation.isTransient()) { conversation.begin(); } } return startTask(taskId); }
Example #3
Source File: LoginController.java From enkan with Eclipse Public License 1.0 | 5 votes |
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 #4
Source File: GuestbookController.java From enkan with Eclipse Public License 1.0 | 5 votes |
public HttpResponse list(Conversation conversation) { if (conversation.isTransient()) conversation.begin(); GuestbookDao dao = domaProvider.getDao(GuestbookDao.class); List<Guestbook> guestbooks = dao.selectAll(); return templateEngine.render("guestbook/list", "guestbooks", guestbooks); }
Example #5
Source File: GuestbookController.java From enkan with Eclipse Public License 1.0 | 5 votes |
@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 #6
Source File: ConversationStateController.java From enkan with Eclipse Public License 1.0 | 5 votes |
public HttpResponse page1(Conversation conversation) { if (conversation.isTransient()) conversation.begin(); int randomValue = new Random().nextInt(); ConversationState conversationState = new ConversationState(); conversationState.put("random", randomValue); return builder(templateEngine.render("conversationState/page1", "random", randomValue)) .set(HttpResponse::setConversationState, conversationState) .build(); }
Example #7
Source File: BusinessProcess.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * @see #startTask(String) * * this method allows to start a conversation if no conversation is active */ public Task startTask(String taskId, boolean beginConversation) { if (beginConversation) { Conversation conversation = conversationInstance.get(); if (conversation.isTransient()) { conversation.begin(); } } return startTask(taskId); }
Example #8
Source File: ConversationMiddleware.java From enkan with Eclipse Public License 1.0 | 5 votes |
@Override public HttpResponse handle(HttpRequest request, MiddlewareChain<HttpRequest, NRES, ?, ?> chain) { ConversationToken token = parseToken(readTokenFunc.apply(request)); if (!isGetRequest(request) && !token.isValid()) { return builder(HttpResponse.of("Invalid conversation.")) .set(HttpResponse::setHeaders, Headers.of("Content-Type", "text/plain")) .set(HttpResponse::setStatus, 403) .build(); } Conversation conversation; if (token.id == null) { conversation = new DefaultConversation(); } else { conversation = new DefaultConversation(token.id); ConversationState state = (ConversationState) store.read(token.id); request.setConversationState(state); } request.setConversation(conversation); HttpResponse response = castToHttpResponse(chain.next(request)); if (conversation.isTransient()) { if (conversation.getId() != null) { store.delete(conversation.getId()); } } else if (response.getConversationState() != null) { store.write(conversation.getId(), response.getConversationState()); } return response; }
Example #9
Source File: BusinessProcess.java From flowable-engine with Apache License 2.0 | 5 votes |
/** * @see #startTask(String) * <p> * this method allows to start a conversation if no conversation is active */ public Task startTask(String taskId, boolean beginConversation) { if (beginConversation) { Conversation conversation = conversationInstance.get(); if (conversation.isTransient()) { conversation.begin(); } } return startTask(taskId); }
Example #10
Source File: DefaultConversation.java From enkan with Eclipse Public License 1.0 | 4 votes |
@Override public boolean equals(Object another) { return another instanceof Conversation && Objects.equals(getId(), ((Conversation) another).getId()); }
Example #11
Source File: SubscriptionWizardConversation.java From development with Apache License 2.0 | 4 votes |
/** * Getters and setters part */ public void setConversation(Conversation conversation) { this.conversation = conversation; }
Example #12
Source File: UpgradeWizardConversation.java From development with Apache License 2.0 | 4 votes |
public void setConversation(Conversation conversation) { this.conversation = conversation; }
Example #13
Source File: UpgradeWizardConversation.java From development with Apache License 2.0 | 4 votes |
public Conversation getConversation() { return conversation; }
Example #14
Source File: ConversationAvailable.java From enkan with Eclipse Public License 1.0 | 4 votes |
default void setConversation(Conversation conversation) { setExtension("conversation", conversation); }
Example #15
Source File: ConversationAvailable.java From enkan with Eclipse Public License 1.0 | 4 votes |
default Conversation getConversation() { return (Conversation) getExtension("conversation"); }
Example #16
Source File: ConversationStateController.java From enkan with Eclipse Public License 1.0 | 4 votes |
public HttpResponse page3(Conversation conversation) { if (!conversation.isTransient()) conversation.end(); return templateEngine.render("conversationState/page3"); }
Example #17
Source File: LoginController.java From enkan with Eclipse Public License 1.0 | 4 votes |
public HttpResponse loginForm(Parameters params, Conversation conversation) { if (conversation.isTransient()) conversation.begin(); return templateEngine.render("guestbook/login", "url", params.get("url")); }
Example #18
Source File: ConversationInjector.java From enkan with Eclipse Public License 1.0 | 4 votes |
@Override public Conversation getInjectObject(HttpRequest request) { return request.getConversation(); }
Example #19
Source File: ConversationInjector.java From enkan with Eclipse Public License 1.0 | 4 votes |
@Override public boolean isApplicable(Class<?> type, HttpRequest request) { return Conversation.class.isAssignableFrom(type); }
Example #20
Source File: RenderTemplateMiddleware.java From enkan with Eclipse Public License 1.0 | 4 votes |
@Override public HttpResponse handle(HttpRequest request, MiddlewareChain<HttpRequest, NRES, ?, ?> chain) { HttpResponse response = castToHttpResponse(chain.next(request)); if (TemplatedHttpResponse.class.isInstance(response)) { TemplatedHttpResponse tres = TemplatedHttpResponse.class.cast(response); if (exports.contains(REQUEST)) { tres.getContext().put(exports.getExportName(REQUEST), request); } if (exports.contains(PARAMS)) { tres.getContext().put(exports.getExportName(PARAMS), request.getParams()); } if (exports.contains(USER_PRINCIPAL)) { Stream.of(request) .filter(Objects::nonNull) .map(PrincipalAvailable.class::cast) .findAny() .ifPresent(principal -> tres.getContext() .put(exports.getExportName(USER_PRINCIPAL), principal.getPrincipal())); tres.getContext().put("hasPermission", templateEngine.createFunction(HAS_PERMISSION)); tres.getContext().put("hasAnyPermissions", templateEngine.createFunction(HAS_ANY_PERMISSIONS)); tres.getContext().put("hasAllPermissions", templateEngine.createFunction(HAS_ALL_PERMISSIONS)); } if (exports.contains(SESSION)) { tres.getContext().put(exports.getExportName(SESSION), request.getSession()); } if (exports.contains(CONVERSATION)) { Conversation conversation = request.getConversation(); if (conversation != null && !request.getConversation().isTransient()) { String token = conversation.getId() + "$" + hmacEncoder.encodeToHex(conversation.getId() + "$" + conversation.getTimeout()) + "$" + conversation.getTimeout(); tres.getContext().put("conversationToken", token); } tres.getContext().put(exports.getExportName(CONVERSATION), conversation); } if (exports.contains(CONVERSATION_STATE)) { ConversationState conversationState = request.getConversationState(); tres.getContext().put(exports.getExportName(CONVERSATION_STATE), conversationState); } userFunctions.forEach((key, value) -> tres.getContext().put(key, templateEngine.createFunction(value))); render(tres); } return response; }