Hi,

Yes that was my wery wery first attemt but something is wrong since it will always end 
up in a exception (see below). That is why i started to try out interception of the 
proxy itself (but failed). At last I did generate my own proxy over the JBOSS proxy 
and tried to advice such but failed as well (see below for code snippets).

I know you do not have much time but please could you bring some light on my other 
questions as well. There's a question below within the code as well.

Many Regards,
 Mario





--------------------- call pointcut exception --------------------------
BeanIf:
package se.dataductus.aopdemo.security;

public interface Dummy extends javax.ejb.EJBObject
{
        public void DummyMethod() throws java.rmi.RemoteException;
}


This is the pointcut:
        
                
        



....and the Exception:

test-security:
     [java] java.lang.ExceptionInInitializerError
     [java] Caused by: java.lang.RuntimeException: java.lang.RuntimeException: 
java.lang.NullPointerException
     [java] at org.jboss.aop.ClassAdvisor.attachClass(ClassAdvisor.java:207)
     [java] at org.jboss.aop.AspectManager.getAdvisor(AspectManager.java:351)
     [java] at se.dataductus.aopdemo.security.TestSecurity.(TestSecurity.java)
     [java] Caused by: java.lang.RuntimeException: java.lang.NullPointerException
     [java] at org.jboss.aop.pointcut.MethodMatcher.visit(MethodMatcher.java:189)
     [java] at org.jboss.aop.pointcut.ast.ASTAll.jjtAccept(ASTAll.java:21)
     [java] at org.jboss.aop.pointcut.MatcherHelper.visit(MatcherHelper.java:70)
     [java] at org.jboss.aop.pointcut.MatcherHelper.matches(MatcherHelper.java:65)
     [java] at 
org.jboss.aop.pointcut.PointcutExpression.matchesExecution(PointcutExpression.java:80)
     [java] at org.jboss.aop.ClassAdvisor.resolveMethodPointcut(ClassAdvisor.java:264)
     [java] at 
org.jboss.aop.ClassAdvisor.createInterceptorChains(ClassAdvisor.java:432)
     [java] at org.jboss.aop.ClassAdvisor.attachClass(ClassAdvisor.java:202)
     [java] ... 2 more
     [java] Caused by: java.lang.NullPointerException
     [java] at 
org.jboss.aop.annotation.PortableAnnotationElement.isAnyAnnotationPresent(PortableAnnotationElement.java:112)
     [java] at 
org.jboss.aop.annotation.PortableAnnotationElement.isAnyAnnotationPresent(PortableAnnotationElement.java:105)
     [java] at org.jboss.aop.pointcut.MethodMatcher.visit(MethodMatcher.java:185)
     [java] ... 9 more
     [java] Exception in thread "main"
BUILD FAILED: C:\progs\java\workspace\aopdemo\build.xml:45: Java returned: 1



------------------------- Intercepting a created subclass   ------------------
Advising and adding instance interceptor:

AdviceBinding binding = new AdviceBinding("execution(* $instanceof{" + csBeanIf + 
"}->*(..))",null);
    binding.addInterceptor(ClientCLSBMethodInvokerInterceptor.class);
    AspectManager.instance().addBinding(binding);

>
> When adding the binding it will do a softmatch and in the
> private Object matchClass(ClassExpression classExpression)
> the clazz is not the generated subtype instead it is the pure class
> of which i've done a copy from (and derived). It will fail to add
> the new interceptor.
>
> I must admit that I do not understand how to add a instance advisor
> and trigger it by an expression since the AdvisorBinding is taking the
> interceptor class. On the instance I can get the instance advisor to
> add a interceptor instance to the interceptor stack...
>
> The question is how do I add a interceptor instance that gets invoked
> by an advise?
>



Advised advised = (Advised)obj;      
advised._getInstanceAdvisor().insertInterceptor(new 
ClientCLSBMethodInvokerInterceptor());


Code to write subclass with ejbIf:

                CtClass cls     = 
cp.makeClass(csClassName,cp.get("se.dataductus.aopdemo.util.ClientSLSB"));
                CtClass clsIf = cp.get(csBeanIf);
                cls.addInterface(clsIf);
                cls.makeClassInitializer();

                CtField  fld  = CtField.make("private " + csBeanIf + " _bean = null; 
",cls);
                cls.addField(fld);
                String csMeth = "private " + csBeanIf + " _resolveBean() { if ( null 
== this._bean) { this._bean = super.resolve(); } return this._bean; }";
                
                CtMethod meth = CtNewMethod.make(csMeth,cls);
                cls.addMethod(meth);
                
                CtMethod []m = clsIf.getDeclaredMethods();
                for(int i = 0;i < m.length;i++)
                {                               
                        meth = 
CtNewMethod.make(m.getReturnType(),m.getName(),m.getParameterTypes(),m.getExceptionTypes(),this.writeMethod(m),cls);
                        cls.addMethod(meth);
                }
                
                cls.writeFile();
                return cls;             



View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3839497#3839497

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3839497


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to