Package org.jbpm.db

Examples of org.jbpm.db.JbpmSession


  public void setHibernateSessionFactory(SessionFactory hibernateSessionFactory) {
    this.hibernateSessionFactory = hibernateSessionFactory;
  }

  public void testGetSession() {
    JbpmSession session = this.jbpmSessionFactory.openJbpmSession();
    assertNotNull("JbpmSession should not be null", session);

    Session hibernateSession = session.getSession();
    Session springSuppliedHibernateSession = SessionFactoryUtils.getSession(this.hibernateSessionFactory,
        false);

    assertSame("JbpmSession not using Spring-supplied Hibernate session", hibernateSession,
        springSuppliedHibernateSession);

    hibernateSession = null;
    session.close();

  }
View Full Code Here


  }

  public void testJbpmCloseSession() throws Exception {
    log.debug("start testJbpmCloseSession");
    // save reference to current Session (in case there is one existing already)
    JbpmSession currentSession = JbpmSession.getCurrentJbpmSession();

    JbpmSession jbpmSession = this.jbpmSessionFactory.openJbpmSession();

    Session springSession = SessionFactoryUtils.getSession(hibernateSessionFactory, false);
    // session is opened
    assertTrue(jbpmSession.getSession().isOpen());
    // same session returned by current jbpm session
    assertSame(jbpmSession.getSession(), JbpmSession.getCurrentJbpmSession().getSession());
    // same session as the one thread-bounded by Spring
    assertSame(springSession, jbpmSession.getSession());

    // close jbpm session
    jbpmSession.close();

    // jbpm session nullified
    assertNull(jbpmSession.getSession());
    assertSame(currentSession, JbpmSession.getCurrentJbpmSession());

    // thread-bound session not null and opened
    assertTrue(springSession.isOpen());
    log.debug("end testJbpmCloseSession");
View Full Code Here

   *
   * @param callback
   * @return
   */
  public Object execute(final JbpmCallback callback) {
    final JbpmSession jbpmSession = getSession();
    boolean existingTransaction = JbpmSessionFactoryUtils.isTransactional(jbpmSession,
        this.jbpmSessionFactory);

    if (existingTransaction) {
      logger.debug("Found thread-bound Session for JbpmTemplate");
View Full Code Here

    if (jbpmSessionHolder != null && jbpmSessionHolder.getJbpmSession() != null) {
      return jbpmSessionHolder.getJbpmSession();
    }

    JbpmSession jbpmSession = sessionFactory.openJbpmSession();
    jbpmSessionHolder = new JbpmSessionHolder(jbpmSession);

    if (TransactionSynchronizationManager.isSynchronizationActive()) {
      TransactionSynchronizationManager.registerSynchronization(new SpringJbpmSessionSynchronization(
          jbpmSessionHolder, sessionFactory));
View Full Code Here

  }

  public void testGetSessionOutsideTransaction() {
    log.info("getSessionOutsideTransaction");
   
    JbpmSession firstJbpmSession = JbpmSessionFactoryUtils.getSession(this.jbpmSessionFactory);
    assertNotNull(firstJbpmSession);

    JbpmSession secondJbpmSession = JbpmSessionFactoryUtils.getSession(this.jbpmSessionFactory);

    assertNotNull(secondJbpmSession);

    assertNotSame(firstJbpmSession, secondJbpmSession);
   
View Full Code Here

    final Map sessionMap = new HashMap();

    TransactionTemplate transactionTemplate = new TransactionTemplate(this.transactionManager);
    transactionTemplate.execute(new TransactionCallback() {
      public Object doInTransaction(TransactionStatus status) {
        JbpmSession firstSession = JbpmSessionFactoryUtils.getSession(jbpmSessionFactory);
        JbpmSession secondSession = JbpmSessionFactoryUtils.getSession(jbpmSessionFactory);
        sessionMap.put("first", firstSession);
        sessionMap.put("second", secondSession);

        // try to close inside a transaction
        JbpmSessionFactoryUtils.releaseSession(firstSession, jbpmSessionFactory);
        assertTrue("Should not close session inside a transaction.",
            firstSession.getSession().isOpen());
        return null;
      }
    });

    JbpmSession first = (JbpmSession) sessionMap.get("first");
    JbpmSession second = (JbpmSession) sessionMap.get("second");

    assertSame("Should've got the same session twice inside the transaction", first, second);
    assertNull("Hibernate session should be closed", first.getSession());
    assertNull("no current session", JbpmSession.getCurrentJbpmSession());
View Full Code Here

    sessionMap.clear();
  }

  public void testReleaseOutsideTransaction() {
    log.info("ReleaseOutsideTransaction");
    JbpmSession jbpmSession = JbpmSessionFactoryUtils.getSession(this.jbpmSessionFactory);
    JbpmSessionFactoryUtils.releaseSession(jbpmSession, this.jbpmSessionFactory);
    assertNull("Session should be closed", jbpmSession.getSession());
  }
View Full Code Here

  public void testMultipleJBmpInvocations() {

    log.info("multipleJbpmInvocation");
   
    //     Get Sessions
    JbpmSession jbpmSession = JbpmSessionFactoryUtils.getSession(this.jbpmSessionFactory);
    GraphSession graphSession = jbpmSession.getGraphSession();

    graphSession.saveProcessDefinition(processDefinition);
    //     Get All Process Definitions
    List l = graphSession.findLatestProcessDefinitions();
View Full Code Here

  public IdentitySession(Session session) {
    this.session = session;
  }

  public IdentitySession() {
    JbpmSession currentJbpmSession = JbpmSession.getCurrentJbpmSession();
    if ( (currentJbpmSession==null)
         || (currentJbpmSession.getSession()==null)
         || (! currentJbpmSession.getSession().isOpen())
       ) {
      throw new RuntimeException("no active JbpmSession to create an identity session");
    }
    session = currentJbpmSession.getSession();
  }
View Full Code Here

  public IdentitySession(Session session) {
    this.session = session;
  }

  public IdentitySession() {
    JbpmSession currentJbpmSession = JbpmSession.getCurrentJbpmSession();
    if ( (currentJbpmSession==null)
         || (currentJbpmSession.getSession()==null)
         || (! currentJbpmSession.getSession().isOpen())
       ) {
      throw new RuntimeException("no active JbpmSession to create an identity session");
    }
    session = currentJbpmSession.getSession();
  }
View Full Code Here

TOP

Related Classes of org.jbpm.db.JbpmSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.