Java 未从服务类调用方面
我有一个服务类,它有一个方法:Java 未从服务类调用方面,java,spring,aop,Java,Spring,Aop,我有一个服务类,它有一个方法: public void setDataSource(DynaFormReportFilterBean filterBean,Map parameterValues,List<Map<String,Object>> dynaFormStatusList) 调用方法 public void afterReportAction(JoinPoint jp, final AbstractBean bean, final Map parame
public void setDataSource(DynaFormReportFilterBean filterBean,Map parameterValues,List<Map<String,Object>> dynaFormStatusList)
调用方法
public void afterReportAction(JoinPoint jp,
final AbstractBean bean, final Map parameterValues,
final List<Map<String, Object>> dynaFormStatusList) {//----Code here------//}`
public void afterReportAction(JoinPoint jp,
最终AbstractBean,最终Map参数值,
最终列表(dynaFormStatusList){/----此处代码------/}`
当我运行代码时,不会调用Aspect类
以下是应用程序上下文条目:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- The below configuration is used to enable AspectJ support -->
<aop:aspectj-autoproxy>
<aop:include name="addressBookAuditLogAspect" />
<aop:include name="inventoryAuditLogAspect" />
<!-- aop:include name="shipmentAuditLogAspect" / -->
<aop:include name="dynaAuditLogAspect" />
<aop:include name="questionAuditLogAspect" />
<aop:include name="reportAuditLogAspect" />
</aop:aspectj-autoproxy>
<!-- This bean defines the details about the TaskExecutor used for asynchronous invocation of method/s
The values 3 properties mentioned can be changed as per the requirement
Currently the values are specified for testing purpose -->
<bean id="businessLogExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="10" />
<property name="maxPoolSize" value="25" />
<property name="queueCapacity" value="100" />
</bean>
<!-- The below bean defines the 'DynaAuditLogAspect' class which will act as a bridge between Bio4D and Auditing utility -->
<bean id="dynaAuditLogAspect" class="org.bio.audit.dynaforms.DynaAuditLogAspect">
<property name="taskExecutor" ref="businessLogExecutor" />
<property name="bioExtensionDataDAO" ref="bioExtensionDataDAO" />
</bean>
<!-- The below bean defines the 'ReportAuditLogAspect' class which will act as a bridge between Bio4D and Auditing utility -->
<bean id="reportAuditLogAspect" class="org.bio.audit.reports.ReportAuditLogAspect">
<property name="taskExecutor1" ref="businessLogExecutor" />
<property name="usersDAO" ref="usersDAO" />
</bean>
<bean id="questionAuditLogAspect" class="org.bio.audit.dynaforms.QuestionAuditLogAspect">
</bean>
<!-- The below bean defines the 'ShipmentAuditLogAspect' class which will act as a bridge between Bio4D and Auditing utility -->
<bean id="shipmentAuditLogAspect" class="org.bio.audit.bms.ShipmentAuditLogAspect">
<property name="bmsTaskExecutor" ref="businessLogExecutor" />
<property name="shipmentDAO" ref="shipmentDAO" />
</bean>
<bean id="inventoryAuditLogAspect" class="org.bio.audit.bms.InventoryAuditLogAspect">
</bean>
<!-- The below bean defines the 'AddressBookAuditLogAspect' class which will act as a bridge between Bio4D and Auditing utility -->
<bean id="addressBookAuditLogAspect" class="org.bio.audit.administration.AddressBookAuditLogAspect"/>
</beans>
如您需要在配置中声明的注释中所述。
此外,由于您正在使用@AfterReturning advice,因此只有当目标方法在运行时未引发任何异常时,才会执行此建议。切入点中的
*
和org
之间是否需要一个空格?@sp00m是的,*和org之间有一个空格仍然面对问题,它为什么要工作。我在您的配置中没有看到
。您还需要意识到这样一个事实,即SpringAOP只适用于Spring定义和控制的bean。如果您有一个非托管实例(例如由Jasper创建的实例),它将无法工作。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- The below configuration is used to enable AspectJ support -->
<aop:aspectj-autoproxy>
<aop:include name="addressBookAuditLogAspect" />
<aop:include name="inventoryAuditLogAspect" />
<!-- aop:include name="shipmentAuditLogAspect" / -->
<aop:include name="dynaAuditLogAspect" />
<aop:include name="questionAuditLogAspect" />
<aop:include name="reportAuditLogAspect" />
</aop:aspectj-autoproxy>
<!-- This bean defines the details about the TaskExecutor used for asynchronous invocation of method/s
The values 3 properties mentioned can be changed as per the requirement
Currently the values are specified for testing purpose -->
<bean id="businessLogExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="10" />
<property name="maxPoolSize" value="25" />
<property name="queueCapacity" value="100" />
</bean>
<!-- The below bean defines the 'DynaAuditLogAspect' class which will act as a bridge between Bio4D and Auditing utility -->
<bean id="dynaAuditLogAspect" class="org.bio.audit.dynaforms.DynaAuditLogAspect">
<property name="taskExecutor" ref="businessLogExecutor" />
<property name="bioExtensionDataDAO" ref="bioExtensionDataDAO" />
</bean>
<!-- The below bean defines the 'ReportAuditLogAspect' class which will act as a bridge between Bio4D and Auditing utility -->
<bean id="reportAuditLogAspect" class="org.bio.audit.reports.ReportAuditLogAspect">
<property name="taskExecutor1" ref="businessLogExecutor" />
<property name="usersDAO" ref="usersDAO" />
</bean>
<bean id="questionAuditLogAspect" class="org.bio.audit.dynaforms.QuestionAuditLogAspect">
</bean>
<!-- The below bean defines the 'ShipmentAuditLogAspect' class which will act as a bridge between Bio4D and Auditing utility -->
<bean id="shipmentAuditLogAspect" class="org.bio.audit.bms.ShipmentAuditLogAspect">
<property name="bmsTaskExecutor" ref="businessLogExecutor" />
<property name="shipmentDAO" ref="shipmentDAO" />
</bean>
<bean id="inventoryAuditLogAspect" class="org.bio.audit.bms.InventoryAuditLogAspect">
</bean>
<!-- The below bean defines the 'AddressBookAuditLogAspect' class which will act as a bridge between Bio4D and Auditing utility -->
<bean id="addressBookAuditLogAspect" class="org.bio.audit.administration.AddressBookAuditLogAspect"/>
</beans>