2011-10-14 34 views
1

我正在使用JSF1.2框架。 我沒有將我的應用程序與Spring集成。我想執行對方法調用的分析。我的應用程序文件是EAR(EJB + WAR)。我可以在攔截器的幫助下獲得會話bean方法的執行時間,但對於WAR模塊,我建議在此博客中使用AspectJ。所以我寫了一些代碼。有什麼我需要做的事情就像配置細節。我添加了所需的jar文件AspectJJSF支持AspectJ與任何配置?我的代碼是:AspectJ與JSF1.2

import org.aopalliance.intercept.MethodInterceptor; 
import org.aopalliance.intercept.MethodInvocation; 
import org.aspectj.lang.annotation.Around; 
import org.aspectj.lang.annotation.Aspect; 
@Aspect 
public class AopInterceptor implements MethodInterceptor{ 

public AopInterceptor() { 
} 

@Pointcut("execution (* *.*(..))") 
public void profile(){} 

@Around("profile()") 
public Object invoke(MethodInvocation mi) throws Throwable { 
    System.out.println("test start"); 
    Object obj=mi.proceed(); 
    System.out.println("test end"); 
    return obj; 
} 
} 
+0

請不要放''中[關閉]你的問題標題。謝謝。 –

+0

我已經在WAR build.xml文件中創建了一個目標,並添加了AspectJ jar文件。現在我正在獲取所有調用的方法。這裏是targer代碼: –

回答

0

我在WAR build.xml文件中創建了一個目標,並添加了AspectJ jar文件。現在我正在獲取所有調用的方法。這裏是targer代碼:

<taskdef classpath="C:/Users/s.kosna/Downloads/aspectj-1.6.11/lib/aspectjtools.jar" 
resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"/> 
<target name="aspectj"> 
<echo level="info">--- aspectj (start) ---</echo> 
<condition property="targetos" value="windows" else="unix"> 
    <os family="windows"/> 
</condition> 
<pathconvert targetos="${targetos}" property="javac.convertedClasspath" > 
    <path path="${javac.classpath}" /> 
</pathconvert> 
<iajc source="1.6" target="1.6" showweaveinfo="true" verbose="true" destdir="${build.classes.dir}" > 
    <inpath> 
     <pathelement location="${build.classes.dir}"/> 
    </inpath> 
    <classpath> 
     <pathelement location="${javac.convertedClasspath}" /> 
    </classpath> 
</iajc> 
<echo level="info">LORDDOSKIAS BRUTAL TEST ---</echo> 
</target> 

<target name="-post-compile" depends="aspectj"></target> 

把上面的代碼在一個封裝和你戰的build.xml這就是添加上面的Ant腳本它會工作

+0

任何人都可以關閉這個問題 –