Java 如何使用SpringAOP为struts应用程序中的Thread类编写BeforeAdvice?
我有一个struts应用程序,使用Spring AOP和IoC,通过ClassPathXmlApplicationContext()加载applicationContext.xml 现在我有一个Mailer.java,它扩展了一个线程,如下所示Java 如何使用SpringAOP为struts应用程序中的Thread类编写BeforeAdvice?,java,spring,multithreading,struts,aop,Java,Spring,Multithreading,Struts,Aop,我有一个struts应用程序,使用Spring AOP和IoC,通过ClassPathXmlApplicationContext()加载applicationContext.xml 现在我有一个Mailer.java,它扩展了一个线程,如下所示 public class Mailer extends Thread { public static void sendMessage(String to, String cc, String from, String subject, Str
public class Mailer extends Thread
{
public static void sendMessage(String to, String cc, String from, String subject, String message) throws MessagingException
{
//sending e-mails, returning nothing
}
}
在上面的类中,sendMessage()是一个静态方法,调用方式如下
Mailer.sendMessage()
在应用程序的服务类中
现在我想为sendMessage()方法创建MethodBeforeAdvice。我该怎么做呢?Spring AOP是基于代理的-因此您需要使用如果您使用
@Aspect
作为建议,该方法应该使用注释进行注释
@Before("execution(* com.package.Mailer.sendMessage(..))")
public void aMethodBeforeAdvice(JoinPoint jp) {}