Package org.springframework.transaction.support

Examples of org.springframework.transaction.support.TransactionTemplate


     * entity
     */
    @Converter
    public static CustomerEntity toCustomer(PersonDocument doc, Exchange exchange) throws Exception {
        EntityManager entityManager = exchange.getProperty(JpaConstants.ENTITY_MANAGER, EntityManager.class);
        TransactionTemplate transactionTemplate = exchange.getContext().getRegistry().lookupByNameAndType("transactionTemplate", TransactionTemplate.class);

        String user = doc.getUser();
        CustomerEntity customer = findCustomerByName(transactionTemplate, entityManager, user);

        // let's convert information from the document into the entity bean
View Full Code Here


    protected EntityManager createEntityManager() {
        return getEntityManagerFactory().createEntityManager();
    }

    protected TransactionTemplate createTransactionTemplate() {
        TransactionTemplate transactionTemplate = new TransactionTemplate(getTransactionManager());
        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
        transactionTemplate.afterPropertiesSet();
        return transactionTemplate;
    }
View Full Code Here

    sfControl.replay();
    sessionControl.replay();
    xaResControl.replay();

    PlatformTransactionManager tm = new LocalTransactionManager(sf);
    TransactionTemplate tt = new TransactionTemplate(tm);
    final List l = new ArrayList();
    l.add("test");
    assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
    assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());

    tt.execute(new TransactionCallbackWithoutResult() {
      protected void doInTransactionWithoutResult(TransactionStatus status) {
        assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
        JcrTemplate template = new JcrTemplate(sf);
        template.save();
      }
View Full Code Here

    sessionControl.replay();
    xaResControl.replay();
    final SessionHolderProviderManager providerManager = new ListSessionHolderProviderManager();

    PlatformTransactionManager tm = new LocalTransactionManager(sf);
    TransactionTemplate tt = new TransactionTemplate(tm);
    final List l = new ArrayList();
    l.add("test");
    assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
    assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());

    try {
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
          JcrTemplate template = new JcrTemplate(sf);
          template.execute(new JcrCallback() {
            public Object doInJcr(Session se) throws RepositoryException {
View Full Code Here

    sessionControl.replay();
    xaResControl.replay();
    final SessionHolderProviderManager providerManager = new ListSessionHolderProviderManager();

    PlatformTransactionManager tm = new LocalTransactionManager(sf);
    TransactionTemplate tt = new TransactionTemplate(tm);
    final List l = new ArrayList();
    l.add("test");
    assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
    assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());

    tt.execute(new TransactionCallbackWithoutResult() {
      protected void doInTransactionWithoutResult(TransactionStatus status) {
        assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
        JcrTemplate template = new JcrTemplate(sf);
        template.execute(new JcrCallback() {
          public Object doInJcr(Session se) throws RepositoryException {
View Full Code Here

    final SessionFactory sf = (SessionFactory) sfControl.getMock();

    sfControl.replay();

    PlatformTransactionManager tm = new LocalTransactionManager(sf);
    TransactionTemplate tt = new TransactionTemplate(tm);

    assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
    assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());

    tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);
    try {
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
          JcrTemplate template = new JcrTemplate(sf);
          template.execute(new JcrCallback() {
            public Object doInJcr(Session session) throws RepositoryException {
View Full Code Here

    sessionControl.replay();
    xaResControl.replay();
    final SessionHolderProviderManager providerManager = new ListSessionHolderProviderManager();

    PlatformTransactionManager tm = new LocalTransactionManager(sf);
    TransactionTemplate tt = new TransactionTemplate(tm);
    UserTxSessionHolder uTx = new UserTxSessionHolder(session);
    TransactionSynchronizationManager.bindResource(sf, uTx);

    assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));

    tt.execute(new TransactionCallbackWithoutResult() {
      protected void doInTransactionWithoutResult(TransactionStatus status) {
        assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
        JcrTemplate template = new JcrTemplate(sf);
        template.save();
      }
View Full Code Here

    sfControl.replay();
    sessionControl.replay();
    xaResControl.replay();

    PlatformTransactionManager tm = new LocalTransactionManager(sf);
    TransactionTemplate tt = new TransactionTemplate(tm);
    UserTxSessionHolder uTx = new UserTxSessionHolder(session);
    TransactionSynchronizationManager.bindResource(sf, uTx);

    assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
    uTx.setRollbackOnly();

    try {
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
          JcrTemplate template = new JcrTemplate(sf);
          template.save();
        }
View Full Code Here

   */
  public void testStatefulInTransaction() {
    final Jsr94Template template = getTemplate("ruleSource");
    final Jsr94TransactionManager transactionManager = new Jsr94TransactionManager();
    transactionManager.setRuleSource(template.getRuleSource());
    final TransactionTemplate txTemplate = new TransactionTemplate(transactionManager);
    List result = (List) txTemplate.execute(new TransactionCallback() {

          /* (non-Javadoc)
           * @see org.springframework.transaction.support.TransactionCallback#doInTransaction(org.springframework.transaction.TransactionStatus)
           */
          public Object doInTransaction(TransactionStatus status) {
View Full Code Here

    spaceCtrl.setMatcher(MockControl.ALWAYS_MATCHER);
    spaceCtrl.setReturnValue(lease);

    mockReplay();

    TransactionTemplate tt = new TransactionTemplate(jiniTM);

    assertSynchronizationManager();
   
    tt.execute(new TransactionCallbackWithoutResult() {
      protected void doInTransactionWithoutResult(TransactionStatus status) {
        assertTrue("Has thread session",
            TransactionSynchronizationManager.hasResource(space));

        spaceTemplate.write(entry, Lease.FOREVER);
View Full Code Here

TOP

Related Classes of org.springframework.transaction.support.TransactionTemplate

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.