Thank you for your quick answer. the SimpleInterceptor class is exactly the same one as the injboss-annotation example, excpet the fact that i change his package name to aop,
the intercepted class is the same as the example except the fact that i change his package name to aop. again thank you package aop; | | import org.jboss.aop.joinpoint.ConstructorInvocation; | import org.jboss.aop.joinpoint.FieldReadInvocation; | import org.jboss.aop.joinpoint.FieldWriteInvocation; | import org.jboss.aop.joinpoint.Invocation; | import org.jboss.aop.joinpoint.MethodInvocation; | import org.jboss.aop.advice.Interceptor; | import org.jboss.aop.PointcutDef; | import org.jboss.aop.TypeDef; | import org.jboss.aop.Bind; | import org.jboss.aop.InterceptorDef; | import org.jboss.aop.pointcut.Pointcut; | import org.jboss.aop.pointcut.Typedef; | | /** | * | * @author <a href="mailto:[EMAIL PROTECTED]">Bill Burke</a> | * @version $Revision: 37406 $ | */ | @InterceptorDef | @Bind (pointcut="aop.SimpleInterceptor.valueConstructors OR aop.SimpleInterceptor.valueMessage OR aop.SimpleInterceptor.service OR aop.SimpleInterceptor.sessionValue OR aop.SimpleInterceptor.mbeans") | public class SimpleInterceptor implements Interceptor | { | @PointcutDef ("execution(aop.ExampleValue->new(..))") | public static Pointcut valueConstructors; | | @PointcutDef ("execution(* aop.ExampleValue->getMessage())") | public static Pointcut valueMessage; | | // @PointcutDef ("execution(* aop.ExampleValue->getBla())") | // public static Pointcut valueBla; | | @TypeDef ("class($instanceof{javax.servlet.http.HttpServlet}) AND class(org.jboss.injbossaop.web.*)") | public static Typedef servlets; | | @PointcutDef ("execution(* $typedef{aop.SimpleInterceptor.servlets}->service(..))") | public static Pointcut service; | | @TypeDef ("class($instanceof{javax.ejb.SessionBean}) AND class(org.jboss.injbossaop.ejb.*)") | public static Typedef sessionBeans; | | @PointcutDef ("execution(* $typedef{aop.SimpleInterceptor.sessionBeans}->getValue(..))") | public static Pointcut sessionValue; | | @PointcutDef ("all(org.jboss.injbossaop.mbean.*)") | public static Pointcut mbeans; | | public String getName() { return "SimpleInterceptor"; } | | public Object invoke(Invocation invocation) throws Throwable | { | try | { | System.out.println("<<< Entering SimpleInterceptor: " + invocationInfo(invocation)); | return invocation.invokeNext(); | } | finally | { | System.out.println(">>> Leaving SimpleInterceptor"); | } | } | | private String invocationInfo(Invocation invocation) | { | StringBuffer info = new StringBuffer("\n\tinvocation class: " + invocation.getClass().getName()); | | if (invocation instanceof MethodInvocation) | { | MethodInvocation mi = (MethodInvocation)invocation; | info.append("\n\ttype: Method Invocation"); | info.append("\n\tmethod: " + mi.getMethod().getName()); | info.append("\n\tClass containing method: " + mi.getTargetObject().getClass().getName()); | } | else if (invocation instanceof ConstructorInvocation) | { | ConstructorInvocation ci = (ConstructorInvocation)invocation; | info.append("\n\ttype: Constructor Invocation"); | info.append("\n\tconstructor: " + ci.getConstructor()); | } | else if (invocation instanceof FieldWriteInvocation) | { | FieldWriteInvocation fi = (FieldWriteInvocation)invocation; | info.append("\n\ttype: Field Write Invocation"); | info.append("\n\tfield: " + fi.getField()); | | } | else if (invocation instanceof FieldReadInvocation) | { | FieldReadInvocation fi = (FieldReadInvocation)invocation; | info.append("\n\ttype: Field Write Invocation"); | info.append("\n\tfield: " + fi.getField()); | } | | return info.toString(); | } | } /* | * JBoss, Home of Professional Open Source | * Copyright 2005, JBoss Inc., and individual contributors as indicated | * by the @authors tag. See the copyright.txt in the distribution for a | * full listing of individual contributors. | * | * This is free software; you can redistribute it and/or modify it | * under the terms of the GNU Lesser General Public License as | * published by the Free Software Foundation; either version 2.1 of | * the License, or (at your option) any later version. | * | * This software is distributed in the hope that it will be useful, | * but WITHOUT ANY WARRANTY; without even the implied warranty of | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | * Lesser General Public License for more details. | * | * You should have received a copy of the GNU Lesser General Public | * License along with this software; if not, write to the Free | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | */ | package aop; | | import java.io.Serializable; | | /** | * | * @author <a href="mailto:[EMAIL PROTECTED]">Kabir Khan</a> | * | */ | public class ExampleValue implements Serializable{ | String message = ""; | | public ExampleValue() | { | } | | public ExampleValue(String msg) | { | message = msg; | } | | public String getMessage() | { | return message; | } | | public String getBla() | { | return message; | } | } View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4049107#4049107 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4049107 _______________________________________________ jboss-user mailing list [email protected] https://lists.jboss.org/mailman/listinfo/jboss-user
