public void begin() {
   String id = contextManager.getThreadContextId();
   if (id != null) {
     log.debug("Begin conversation:  " + id);
     delegate.begin(id);
   } else {
     delegate.begin();
   }
 }
Esempio n. 2
0
  public String beginConversation() {
    conversation.begin();
    conversation.setTimeout(500);

    bean.setValue("foo");
    return conversation.getId();
  }
Esempio n. 3
0
 @Override
 protected void doGet(HttpServletRequest req, HttpServletResponse resp)
     throws ServletException, IOException {
   String uri = req.getRequestURI();
   if (uri.endsWith("/display")) {
     printInfo(resp.getWriter());
   } else if (uri.endsWith("/redirect")) {
     resp.sendRedirect("servlet/display"); // do a redirect, the cid is not propagated;
   } else if (uri.endsWith("/begin")) {
     conversation.begin();
     printInfo(resp.getWriter());
   } else if (uri.endsWith("/end")) {
     conversation.end();
     printInfo(resp.getWriter());
   } else if (uri.endsWith("/set")) {
     setMessage(req);
     printInfo(resp.getWriter());
   } else if (uri.endsWith("/invalidateSession")) {
     observer.reset();
     req.getSession().invalidate();
     printInfo(resp.getWriter());
   } else if (uri.endsWith("/listConversationsDestroyedWhileBeingAssociated")) {
     PrintWriter writer = resp.getWriter();
     writer.append("ConversationsDestroyedWhileBeingAssociated: ");
     printSessionIds(writer, observer.getAssociatedConversationIds());
   } else if (uri.endsWith("/listConversationsDestroyedWhileBeingDisassociated")) {
     PrintWriter writer = resp.getWriter();
     writer.append("ConversationsDestroyedWhileBeingDisassociated: ");
     printSessionIds(writer, observer.getDisassociatedConversationIds());
   } else {
     resp.setStatus(404);
   }
   resp.setContentType("text/plain");
 }
Esempio n. 4
0
 public String prepareCreate() {
   conversation.begin();
   if (address == null) {
     address = new Address();
   }
   return "prepare";
 }
 public void beginConversation() {
   if (conversation.isTransient()) {
     System.out.println("beginning conversation : " + this.conversation);
     conversation.begin();
     System.out.println("---> Init Conversation");
   }
 }
  /** Inicializa el bakend bean de control */
  public void initNewObject() {

    if (bandera == Boolean.FALSE) {
      if (conversation.isTransient()) {
        conversation.begin();
      }
      bandera = Boolean.TRUE;
      inicializarVariables();
    }
    busqueda();
  }
  public void setUsersId(Long usersId) {
    conversation.begin();
    if (usersId != null && usersId.longValue() > 0) { // Verifica que el id no sea vacío
      this.current =
          ejbFacade.find(usersId); // BUsca un paralelo de acuerdo al ID y lo asigna a current
      this.usersId = current.getId();
      System.out.println("Ingreso a editar users: " + current.getUsuario());

    } else {
      System.out.println("Ingreso a crear un nuevo users");
      this.current = new Users();
    }
  }
  public void retrieve() {

    if (FacesContext.getCurrentInstance().isPostback()) {
      return;
    }

    if (conversation.isTransient()) {
      conversation.begin();
    }

    if (id == null) {
      author = example;
    } else {
      author = findById(getId());
    }
  }
  /**
   * Prepares the DeleteCustomerBackingBean with data to show which customer the admin is deleting
   *
   * @param ae
   */
  public void actionListener(ActionEvent ae) {
    Customer customer = (Customer) ae.getComponent().getAttributes().get("customer");
    if (conv.isTransient()) {
      conv.begin();
      Logger.getAnonymousLogger()
          .log(Level.INFO, "CONVERSATION BEGINS: Got customer {0}", customer);
    } else {
    }

    deleteCustomerBackingBean.setFname(customer.getFname());
    deleteCustomerBackingBean.setLname(customer.getLname());
    deleteCustomerBackingBean.setEmail(customer.getEmail());
    deleteCustomerBackingBean.setUserName(customer.getUserName());
    Address address;
    address = customer.getAddress();
    deleteCustomerBackingBean.setAddress(address);
  }
  public String create() {

    conversation.begin();
    return "create?faces-redirect=true";
  }
Esempio n. 11
0
 public void beginConversation() {
   if (conversation.isTransient()) {
     conversation.begin();
     System.out.println("========> INICIANDO CONVERSACION: ");
   }
 }
Esempio n. 12
0
 public String load(Integer id) {
   conversation.begin();
   Long longId = new Long(id + "");
   address = findById(Address.class, longId);
   return "load";
 }
Esempio n. 13
0
 @WebRemote
 public void editPerson(Integer personId) {
   conversation.begin();
   person = entityManager.find(Person.class, personId);
 }
Esempio n. 14
0
 @WebRemote
 public void createPerson() {
   conversation.begin();
   person = new Person();
   person.setAddresses(new ArrayList<Address>());
 }
Esempio n. 15
0
  @Test(description = "A simple test to check conversation replication")
  public void testConversationReplication() throws Exception {

    TestContainer container1 = bootstrapContainer(1, Collections.singletonList(Baz.class));
    BeanManagerImpl beanManager1 = getBeanManager(container1);

    TestContainer container2 = bootstrapContainer(2, Collections.singletonList(Baz.class));
    BeanManagerImpl beanManager2 = getBeanManager(container2);

    use(1);

    // Set up the conversation context
    BoundRequest request1 = new BoundRequestImpl(container1.getSessionStore());
    BoundConversationContext conversationContext1 =
        Utils.getReference(beanManager1, BoundConversationContext.class);
    conversationContext1.associate(request1);
    conversationContext1.activate();

    // Set a value into Baz1
    Baz baz1 = Utils.getReference(beanManager1, Baz.class);
    baz1.setName("pete");

    // Begin the conversation
    Conversation conversation1 = Utils.getReference(beanManager1, Conversation.class);
    conversation1.begin();

    // refetch the test bean and check it has the right value
    baz1 = Utils.getReference(beanManager1, Baz.class);
    assert baz1.getName().equals("pete");

    // Simulate ending the request (from the POV of the conversation only!)
    assert !conversation1.isTransient();
    String cid = conversation1.getId();
    conversationContext1.invalidate();
    conversationContext1.deactivate();
    conversationContext1.dissociate(request1);

    // and start another, propagating the conversation
    request1 = new BoundRequestImpl(container1.getSessionStore());
    conversationContext1.associate(request1);
    conversationContext1.activate(cid);

    // refetch the test bean and check it has the right value
    baz1 = Utils.getReference(beanManager1, Baz.class);
    assert baz1.getName().equals("pete");
    assert !conversation1.isTransient();

    replicateSession(1, container1, 2, container2);

    use(2);

    // Set up the conversation context
    BoundRequest request2 = new BoundRequestImpl(container2.getSessionStore());
    BoundConversationContext conversationContext2 =
        Utils.getReference(beanManager2, BoundConversationContext.class);
    conversationContext2.associate(request2);
    conversationContext2.activate(cid);

    Baz baz2 = Utils.getReference(beanManager2, Baz.class);
    assert baz2.getName().equals("pete");

    Conversation conversation2 = Utils.getReference(beanManager2, Conversation.class);
    assert !conversation2.isTransient();

    use(2);
    container2.stopContainer();
    use(1);
    container1.stopContainer();
  }
Esempio n. 16
0
 public void setOfertante(Ofertante ofertante) {
   if (ofertante.getId() != null && conversation.isTransient()) {
     conversation.begin();
   }
   this.ofertante = ofertante;
 }
Esempio n. 17
0
 public void conversationBegin() {
   if (conversation.isTransient()) {
     conversation.begin();
   }
 }
 public void beginConversation() {
   if (conversation.isTransient()) {
     conversation.begin();
     System.out.println("Iniciando la conversación en users");
   }
 }