Java 类javax.enterprise.context.Conversation 实例源码

项目:Mastering-Java-EE-Development-with-WildFly    文件:ContextSPITestCase.java   
/**
 * Tests simple conversation in a jar archive
 */
@Test
public void testConversation() {
    logger.info("start conversation test");
    Conversation conversation = conversationBean.getConversation();
    assertEquals("deafult timeout is 600000 millis", 600000, conversation.getTimeout());
    assertEquals("when the conversation is not started it is transient", true, conversation.isTransient());
    assertNull("I have not started the conversation so the id will be null", conversation.getId());
    conversationBean.initConversation();
    assertEquals("verifiing the openeded conversation", "1", conversation.getId());
    assertEquals("when the conversation is started it is not transient", false, conversation.isTransient());
    conversationBean.endConversation();
    assertNull("when I close the conversation the id will be null", conversation.getId());
    assertEquals("when the conversation is ended it is transient again", true, conversation.isTransient());
    logger.info("end conversation test");
}
项目:oscm    文件:SubscriptionWizardConversationTest.java   
@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();

}
项目:development    文件:SubscriptionWizardConversationTest.java   
@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();

}
项目:church-management-jee    文件:PersonHome.java   
@Inject
@Valid
public PersonHome(@NotNull PersistenceService persistenceService,
                  @NotNull Conversation conversation,
                  @NotNull Messages messages,
                  @NotNull Logger logger,
                  @NotNull ValidatorFactory validatorFactory) {
    this.persistenceService = persistenceService;
    this.conversation = conversation;
    this.messages = messages;
    this.logger = logger;
    this.validatorFactory = validatorFactory;

    discipleshipStatusValues = new LinkedHashMap<>();
    discipleshipStatusValues.put(messages.getMessageFor("enumerations.DiscipleshipStatus.DISCIPLE_CANDIDATE"), DiscipleshipStatus.DISCIPLE_CANDIDATE.toString());
    discipleshipStatusValues.put(messages.getMessageFor("enumerations.DiscipleshipStatus.NOT_INTERESTED"), DiscipleshipStatus.NOT_INTERESTED.toString());
    discipleshipStatusValues.put(messages.getMessageFor("enumerations.DiscipleshipStatus.TEACHING_CANDIDATE"), DiscipleshipStatus.TEACHING_CANDIDATE.toString());
}
项目:enkan    文件:ParameterUtils.java   
public static boolean isReservedType(Class<?> type) {
    return HttpRequest.class.isAssignableFrom(type)
            || Session.class.isAssignableFrom(type)
            || Flash.class.isAssignableFrom(type)
            || Conversation.class.isAssignableFrom(type)
            || ConversationState.class.isAssignableFrom(type)
            || UserPrincipal.class.isAssignableFrom(type)
            || Map.class.isAssignableFrom(type);
}
项目:enkan    文件:LoginController.java   
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();
    }
}
项目:enkan    文件:GuestbookController.java   
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);
}
项目:enkan    文件:GuestbookController.java   
@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);
}
项目:enkan    文件:ConversationStateController.java   
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();
}
项目:enkan    文件:ConversationMiddleware.java   
@Override
public HttpResponse handle(HttpRequest request, MiddlewareChain 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;
}
项目:flowable-engine    文件:BusinessProcess.java   
/**
 * @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);
}
项目:SecureBPMN    文件:BusinessProcess.java   
/**
 * @see #startTask(String) 
 * 
 * this method allows to start a conversation if no conversation is active
 */
public Task startTask(String taskId, boolean beginConversation) {
  Conversation conversation = conversationInstance.get();
  if(conversation.isTransient()) {
   conversation.begin(); 
  }    
  return startTask(taskId);
}
项目:FiWare-Template-Handler    文件:BusinessProcess.java   
/**
 * @see #startTask(String) 
 * 
 * this method allows to start a conversation if no conversation is active
 */
public Task startTask(String taskId, boolean beginConversation) {
  Conversation conversation = conversationInstance.get();
  if(conversation.isTransient()) {
   conversation.begin(); 
  }    
  return startTask(taskId);
}
项目:camunda-bpm-platform    文件:BusinessProcess.java   
/**
 * @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);
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:ConversationBean.java   
public Conversation getConversation() {
    return conversation;
}
项目:oscm    文件:UpgradeWizardConversation.java   
public Conversation getConversation() {
    return conversation;
}
项目:oscm    文件:UpgradeWizardConversation.java   
public void setConversation(Conversation conversation) {
    this.conversation = conversation;
}
项目:oscm    文件:SubscriptionWizardConversation.java   
/**
 * Getters and setters part
 */

public void setConversation(Conversation conversation) {
    this.conversation = conversation;
}
项目:enkan    文件:RenderTemplateMiddleware.java   
@Override
public HttpResponse handle(HttpRequest request, MiddlewareChain 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(PrincipalAvailable.class::isInstance)
                    .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.entrySet().stream()
                .forEach(e -> tres.getContext().put(e.getKey(), templateEngine.createFunction(e.getValue())));
        render(tres);
    }
    return response;
}
项目:enkan    文件:ConversationInjector.java   
@Override
public boolean isApplicable(Class<?> type, HttpRequest request) {
    return Conversation.class.isAssignableFrom(type);
}
项目:enkan    文件:ConversationInjector.java   
@Override
public Conversation getInjectObject(HttpRequest request) {
    return request.getConversation();
}
项目:enkan    文件:LoginController.java   
public HttpResponse loginForm(Parameters params, Conversation conversation) {
    if (conversation.isTransient()) conversation.begin();
    return templateEngine.render("guestbook/login",
            "url", params.get("url"));
}
项目:enkan    文件:ConversationStateController.java   
public HttpResponse page3(Conversation conversation) {
    if (!conversation.isTransient()) conversation.end();
    return templateEngine.render("conversationState/page3");
}
项目:enkan    文件:DefaultConversation.java   
@Override
public boolean equals(Object another) {
    return another != null && Conversation.class.isInstance(another) && Objects.equals(getId(), Conversation.class.cast(another).getId());
}
项目:enkan    文件:ConversationAvailable.java   
default Conversation getConversation() {
    return (Conversation) getExtension("conversation");
}
项目:enkan    文件:ConversationAvailable.java   
default void setConversation(Conversation conversation) {
    setExtension("conversation", conversation);
}
项目:development    文件:UpgradeWizardConversation.java   
public Conversation getConversation() {
    return conversation;
}
项目:development    文件:UpgradeWizardConversation.java   
public void setConversation(Conversation conversation) {
    this.conversation = conversation;
}
项目:development    文件:SubscriptionWizardConversation.java   
/**
 * Getters and setters part
 */

public void setConversation(Conversation conversation) {
    this.conversation = conversation;
}
项目:facshop    文件:ShoppingCart.java   
public Conversation getConversation() {
    return conversation;
}
项目:iclos    文件:Navigator.java   
public Conversation getConversation() {
    return this.conversation;
}
项目:iclos    文件:Navigator.java   
public void setConversation(final Conversation conversation) {
    this.conversation = conversation;
}
项目:ServisTakip    文件:WPHomeBean.java   
public Conversation getConversation() {
    return conversation;
}
项目:ServisTakip    文件:WPHomeBean.java   
public void setConversation(Conversation conversation) {
    this.conversation = conversation;
}
项目:ServisTakip    文件:HomeBean.java   
public Conversation getConversation() {
    return conversation;
}
项目:ServisTakip    文件:HomeBean.java   
public void setConversation(Conversation conversation) {
    this.conversation = conversation;
}
项目:oracle-samples    文件:ShoppingCart.java   
public Conversation getConversation() {
    return conversation;
}
项目:cursosandroid    文件:GenericMB.java   
/**
 * @return a conversa atual
 */
public Conversation getConversa() {
    return conversa;
}
项目:Pingeso    文件:CourseMaintainerConversationalMB.java   
public Conversation getConversation() {
    return conversation;
}
项目:Pingeso    文件:CourseMaintainerOfTeacherConversationalMB.java   
public Conversation getConversation() {
    return conversation;
}