001/**
002 * Copyright (c) 2015-2022, Michael Yang 杨福海 (fuhai999@gmail.com).
003 * <p>
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * <p>
008 * http://www.apache.org/licenses/LICENSE-2.0
009 * <p>
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package io.jboot.aop.annotation;
017
018import java.lang.annotation.*;
019
020/**
021 * @author michael yang
022 */
023@Inherited
024@Retention(RetentionPolicy.RUNTIME)
025@Target({ElementType.METHOD})
026public @interface Transactional {
027
028    /**
029     * 使用哪个数据源
030     *
031     * @return
032     */
033    String config() default "";
034
035    /**
036     * 事务隔离级别
037     *
038     * @return
039     */
040    int transactionLevel() default -1;
041
042    /**
043     * return false 的时候,是否进行回滚
044     *
045     * @return
046     */
047    boolean rollbackForFalse() default false;
048
049    /**
050     * return ret.fail 的时候,是否进行回滚
051     *
052     * @return
053     */
054    boolean rollbackForRetFail() default false;
055
056
057    /**
058     * 返回 null 的时候,是否进行回滚
059     *
060     * @return
061     */
062    boolean rollbackForNull() default false;
063
064
065    /**
066     * 配置允许哪些异常不回滚
067     *
068     * @return
069     */
070    Class<? extends Throwable>[] noRollbackFor() default {};
071
072    /**
073     * 是否在新的线程里执行,在 Controller 的 Action 方法下配置无效
074     * 在 Controller 里,不能以新的线程在运行
075     *
076     * @return
077     */
078    boolean inNewThread() default false;
079
080    /**
081     * 使用哪个线程池来运行线程,需要在启动的时候,通过 TransactionalManager 来配置线程池及其名称
082     *
083     * @return
084     */
085    String threadPoolName() default "";
086
087    /**
088     * 是否以阻塞的方式运行线程,这个配置只有在返回值 void 情况下配置生效
089     * 有返回值的,此配置无效,默认都是阻塞运行线程的方式运行
090     *
091     * @return
092     */
093    boolean threadWithBlocked() default false;
094
095}