【发布时间】:2015-10-02 00:11:40
【问题描述】:
我是 spring 的新手,我发现了一个有趣的行为,但不知道如何解决它...我有一个类如下:
@组件 公共类 ScheduleService {
/** The Constant log. */
private static final Logger log = LoggerFactory.getLogger(ScheduleService.class);
/** The schedule repository. */
@Autowired
private ScheduleRepository scheduleRepository;
@Autowired
private PipelineService pipelineService;
private AtomicReference atomic_scheduler = new AtomicReference();
/**
* Instantiates a new schedule service.
*/
public ScheduleService() {
}
/**
* Starts the quarts scheduler instance
*
*/
public synchronized void start() {
....
}
public Scheduler getScheduler() {
start();
return (Scheduler) atomic_scheduler.get();
}
/**
* Creates the schedule.
*
* @param session the session
* @param schedule the Schedule
* @return the Schedule
*/
public Schedule createSchedule(Session session, Schedule schedule) throws Exception {
....... }
/**
* Gets the Schedule.
*
* @param session the session
* @param id the id
* @return the Schedule
*/
@Transactional(propagation=Propagation.REQUIRES_NEW, isolation=Isolation.READ_COMMITTED)
public Schedule getSchedule(Session session, String id) throws Exception {
..... }
/**
* Gets the Schedule given the Schedule name.
*
* @param session the session
* @param name the name of the Schedule to return
* @return the Schedule
*/
@Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
public Schedule getScheduleByName(Session session, String name) throws Exception {
........
}
/**
*/
public Schedule updateSchedule(Session session, Schedule sch) throws Exception {
....... } }
我发现这个类中的所有方法都是由代理调用的,但我不知道为什么...... APO 代理应该只调用“事务”方法吗?我该如何解决这个问题?我希望通过直接调用线程而不通过代理来调用非事务性方法。
感谢大家的建议。
【问题讨论】:
-
否...为整个对象创建一个代理,而不是该对象的子集(这也不可能)。但只有事务方法会应用建议,其他方法不会。
-
为什么不希望通过代理调用方法?
标签: java spring spring-boot aspectj spring-aop