001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.spring.transaction;
016    
017    import org.springframework.transaction.TransactionException;
018    import org.springframework.transaction.TransactionStatus;
019    import org.springframework.transaction.support.DefaultTransactionStatus;
020    
021    /**
022     * @author Shuyang Zhou
023     */
024    public class TransactionStatusAdapter
025            extends DefaultTransactionStatus
026            implements com.liferay.portal.kernel.transaction.TransactionStatus {
027    
028            public TransactionStatusAdapter(TransactionStatus transactionStatus) {
029                    super(null, false, false, false, false, null);
030    
031                    _transactionStatus = transactionStatus;
032            }
033    
034            @Override
035            public Object createSavepoint() throws TransactionException {
036                    return _transactionStatus.createSavepoint();
037            }
038    
039            @Override
040            public void flush() {
041                    _transactionStatus.flush();
042            }
043    
044            public TransactionStatus getTransactionStatus() {
045                    return _transactionStatus;
046            }
047    
048            @Override
049            public boolean hasSavepoint() {
050                    return _transactionStatus.hasSavepoint();
051            }
052    
053            @Override
054            public boolean isCompleted() {
055                    return _transactionStatus.isCompleted();
056            }
057    
058            @Override
059            public boolean isNewTransaction() {
060                    return _transactionStatus.isNewTransaction();
061            }
062    
063            @Override
064            public boolean isRollbackOnly() {
065                    return _transactionStatus.isRollbackOnly();
066            }
067    
068            @Override
069            public void releaseSavepoint(Object savepoint) throws TransactionException {
070                    _transactionStatus.releaseSavepoint(savepoint);
071            }
072    
073            @Override
074            public void rollbackToSavepoint(Object savepoint)
075                    throws TransactionException {
076    
077                    _transactionStatus.rollbackToSavepoint(savepoint);
078            }
079    
080            @Override
081            public void setRollbackOnly() {
082                    _transactionStatus.setRollbackOnly();
083            }
084    
085            private final TransactionStatus _transactionStatus;
086    
087    }