Object process( JobContext jobContext );我使用名为 JobProcessImpl 的 impl 的方法定义 JobProcess 。每当执行此 JobProcessImpl.process 方法时,我都想监视多个子类。我希望所有这些子类都被执行。
间谍类被定义为基类Task来查找 JobProcessImpl.process 调用。
在输出中,我总是看到仅从 AnnotationTask 记录,而不从 ReviewTask 记录。
请告诉我,如果可能的话,问题是什么。
我尝试了两天通过关注各种帖子来解决这个问题。
package com.spring.aspect.dynamicflow.activity;
import com.spring.aspect.dynamicflow.entity.JobContext;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Component
@Aspect
public abstract class Task {
private static final Logger log = LoggerFactory.getLogger( Task.class );
@Around ( "execution(public java.lang.Object com.spring.aspect.dynamicflow.process.JobProcessImpl.process(..)) " + "&& args(context)" )
public Object task( JobContext context ) {
log.info( "This is the base task and needs to overridden by the derived task for the job id: {} ", context.getJobId() );
return context;
}
}
基类:AnnotationTask
package com.spring.aspect.dynamicflow.activity;
import com.spring.aspect.dynamicflow.entity.JobContext;
import com.spring.aspect.dynamicflow.entity.TaskStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Component
public class AnnotationTask extends Task {
private static final Logger log = LoggerFactory.getLogger( AnnotationTask.class );
@Override
public Object task( JobContext context ) {
log.info( "AnnotationTask's task" );
/*
* do some validation if annotation is completed or not
*/
log.info( "Setting that the annotation is done." );
context.setAnnotationTaskStatus( TaskStatus.COMPLETED );
return "AnnotationTask Completed";
}
倚天杖
温温酱
相关分类