Package org.springframework.transaction.support

Examples of org.springframework.transaction.support.TransactionCallback


        TransactionTemplate transactionTemplate = new TransactionTemplate();
        transactionTemplate.setTransactionManager(new JpaTransactionManager(jpaTemplate.getEntityManagerFactory()));
        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);

        transactionTemplate.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus arg0) {
                List list = jpaTemplate.find(SELECT_ALL_STRING);
                for (Object item : list) {
                    jpaTemplate.remove(item);
                }
View Full Code Here


                } catch (InterruptedException e) {
                    LOG.debug("Caught: " + e, e);
                }
            }
            try {
                transactionTemplate.execute(new TransactionCallback() {
                    public Object doInTransaction(TransactionStatus status) {
                        try {
                            Object key = getCorrelationKey(exchange);

                            T entity = loadEntity(exchange, key);
View Full Code Here

    @ManagedOperation(description = "Adds the key to the store")
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public boolean add(final String messageId) {
        // Run this in single transaction.
        Boolean rc = (Boolean)transactionTemplate.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus status) {
                int count = jdbcTemplate.queryForInt(QUERY_STRING, processorName, messageId);
                if (count == 0) {
                    jdbcTemplate.update(INSERT_STRING, processorName, messageId);
                    return Boolean.TRUE;
View Full Code Here

    @ManagedOperation(description = "Does the store contain the given key")
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public boolean contains(final String messageId) {
        // Run this in single transaction.
        Boolean rc = (Boolean)transactionTemplate.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus status) {
                int count = jdbcTemplate.queryForInt(QUERY_STRING, processorName, messageId);
                if (count == 0) {
                    return Boolean.FALSE;
                } else {
View Full Code Here

    }

    @ManagedOperation(description = "Remove the key from the store")
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public boolean remove(final String messageId) {
        Boolean rc = (Boolean)transactionTemplate.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus status) {
                int updateCount = jdbcTemplate.update(DELETE_STRING, processorName, messageId);
                if (updateCount == 0) {
                    return Boolean.FALSE;
                } else {
View Full Code Here

        jdbcTemplate = new JdbcTemplate(dataSource);
    }

    @SuppressWarnings("unchecked")
    public Exchange add(final CamelContext camelContext, final String correlationId, final Exchange exchange) {
        return (Exchange) transactionTemplate.execute(new TransactionCallback() {

            public Exchange doInTransaction(TransactionStatus status) {
                String sql;
                Exchange result = null;
                final String key = correlationId;
View Full Code Here

        return result;
    }

    @SuppressWarnings("unchecked")
    private Exchange get(final String key, final String repositoryName, final CamelContext camelContext) {
        return (Exchange) transactionTemplateReadOnly.execute(new TransactionCallback() {
            public Exchange doInTransaction(TransactionStatus status) {
                try {
                    final byte[] data = jdbcTemplate.queryForObject(
                            "SELECT " + EXCHANGE + " FROM " + repositoryName + " WHERE " + ID + " = ?",
                            new Object[]{key}, byte[].class);
View Full Code Here

        });
    }

    @SuppressWarnings("unchecked")
    public Set<String> getKeys() {
        return (LinkedHashSet<String>) transactionTemplateReadOnly.execute(new TransactionCallback() {
            public LinkedHashSet<String> doInTransaction(TransactionStatus status) {
                List<String> keys = jdbcTemplate.query("SELECT " + ID + " FROM " + getRepositoryName(),
                        new RowMapper<String>() {
                            public String mapRow(ResultSet rs, int rowNum) throws SQLException {
                                String id = rs.getString(ID);
View Full Code Here

        });
    }

    @SuppressWarnings("unchecked")
    public Set<String> scan(CamelContext camelContext) {
        return (LinkedHashSet<String>) transactionTemplateReadOnly.execute(new TransactionCallback() {
            public LinkedHashSet<String> doInTransaction(TransactionStatus status) {
                List<String> keys = jdbcTemplate.query("SELECT " + ID + " FROM " + getRepositoryNameCompleted(),
                        new RowMapper<String>() {
                            public String mapRow(ResultSet rs, int rowNum) throws SQLException {
                                String id = rs.getString(ID);
View Full Code Here

        TransactionTemplate transactionTemplate = new TransactionTemplate();
        transactionTemplate.setTransactionManager(new JpaTransactionManager(jpaTemplate.getEntityManagerFactory()));
        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);

        transactionTemplate.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus arg0) {
                List list = jpaTemplate.find(SELECT_ALL_STRING);
                for (Object item : list) {
                    jpaTemplate.remove(item);
                }
View Full Code Here

TOP

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

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.