Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] How can I exclude class's in aspectJ pointcuts

Well to send compile code sample going to be abit of a problem because
its 
Part of our application and I don't know about the security isshoes here
but I will try to send the aspect code changed abit . about the test its
a problem its involved the application .

The problematic point is the method is : 
MethodsActionsMap = securityManager.checkAccess(ClassName,MethodeName);
This inner method of the application it is inside the
com.foo.test.security.securityManager.checkAccess (...)
If I remove it there is no error .

public aspect AspectSecurity {
		
		private  SecurityManager securityManager  =  new
SecurityManager();  
		private  String	    ClassName   = "" ;
		private  String     MethodeName = "";
		private  Hashtable<Integer,Integer> MethodsActionsMap;
		private  Integer iWRITE = null;
		private  Integer iREAD  = null;
		
		private final static Log log =
LogFactory.getLog(AspectSecurity.class);
		
		pointcut aspectCheckAccess():
			(execution(* get*(..)) || execution(* set*(..)))

			&& within(com.foo.test..*) 
			&& !within(com.foo.test.security.*) 
			&& !within(AspectSecurity);
                        && !within(com.foo.helpers.*)
                        && !within(com.foo.config.*)
                        && !within(com.foo.someOtherStuff.*);
		 
		@SuppressWarnings("unchecked")
		before(): aspectCheckAccess(){
			Signature sig = thisJoinPoint.getSignature();
			ClassName  	   =
sig.getDeclaringType().getName() ;
			MethodeName	   = sig.getName();
			System.out.println("Checking method Privilege ["
+ sig.getDeclaringType().getName() + "|"+ sig.getName() + "]");
			try{
				System.out.println("after matching
here:"+thisJoinPoint.getSourceLocation());

			MethodsActionsMap =
securityManager.checkAccess(ClassName,MethodeName);

			if (MethodsActionsMap==null)
				System.err.println("Null after matching
here:"+thisJoinPoint.getSourceLocation());

			}catch(Exception e){
				e.printStackTrace();
			}
			                    
		}
		
	} 

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Ron DiFrango
Sent: Tuesday, November 27, 2007 10:27 PM
To: aspectj-users@xxxxxxxxxxx; aspectj-users@xxxxxxxxxxx
Subject: RE: [aspectj-users] How can I exclude class's in aspectJ
pointcuts

Can you send a code sample plus your aspect at this point?  And maybe a
small test case to demonstrate the problem.

Ron DiFrango


-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx on behalf of Meir Yanovich
Sent: Tue 11/27/2007 3:17 PM
To: aspectj-users@xxxxxxxxxxx
Subject: RE: [aspectj-users] How can I exclude class's in aspectJ
pointcuts
 
Thanks but im getting back this java.lang.NullPointerException 
Whit the same print error.. what else I can do ? Please help 
Thanks 

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy Clement
Sent: Tuesday, November 27, 2007 7:02 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] How can I exclude class's in aspectJ
pointcuts

You need brackets around the execution || execution piece, like I
specified in my pointcut. Otherwise none of the within stuff is
applying to the execution(* get*(..)) clause)

  (  execution(* get*(..)) || execution(* set*(..)) )
 && within(com.foo.test..*)
                         && !within(com.foo.test.security.*)
                         && !within(com.foo.helpers.*)
                         && !within(com.foo.config.*)
                         && !within(com.foo.someOtherStuff.*)
                         &&
!within(fts.crm.core.config.AspectSecurity.*)
                         && !within(AspectSecurity);


On 27/11/2007, Meir Yanovich <meiry@xxxxxxxxxxxx> wrote:
> Ok in the places I see the advises the ounces it shouldn't be I don't
> see ant '?' just the simple arrow icon.
> Here is how my pointcut looks like :
>
> pointcut aspectCheckAccess():
>                         execution(* get*(..)) || execution(* set*(..))
> && within(com.foo.test..*)
>                         && !within(com.foo.test.security.*)
>                         && !within(com.foo.helpers.*)
>                         && !within(com.foo.config.*)
>                         && !within(com.foo.someOtherStuff.*)
>                         &&
!within(fts.crm.core.config.AspectSecurity.*)
>                         && !within(AspectSecurity);
>
> What else can I do here ?
>
>
> -----Original Message-----
> From: aspectj-users-bounces@xxxxxxxxxxx
> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy Clement
> Sent: Tuesday, November 27, 2007 6:48 PM
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] How can I exclude class's in aspectJ
> pointcuts
>
> Which ones is it touching that it should not? and what exactly is your
> pointcut?
>
> The use of two dots, as in a.b..* causes us to include everying in
> package a.b and all sub-packages.  This is different to just using a
> single dot which would mean we only include everything in a.b and
> ignore the sub packages.  I just thought this might be impacting you.
>
> if you use a pointcut that cannot be fully statically resolved then it
> may insert some runtime checks to fully determine the match and they
> will execute when the program runs.  Runtime checks are shown in
> eclipse as advise errors with a small '?' on them.  If you are just
> using execution and within, you should not be seeing any runtime
> checks.  If you are seeing advice applying to locations you dont think
> it should, see if they have a '?' on the icon in the eclipse border.
> A '?' does not mean the advice will definetly execute, it means a
> further test will execute at runtime and that will determine whether
> your advice will run.
>
> Andy.
>
> On 27/11/2007, Meir Yanovich <meiry@xxxxxxxxxxxx> wrote:
> > But I added to the pointcut to exclude the aspect class
> >
> > -----Original Message-----
> > From: aspectj-users-bounces@xxxxxxxxxxx
> > [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy Clement
> > Sent: Tuesday, November 27, 2007 6:12 PM
> > To: aspectj-users@xxxxxxxxxxx
> > Subject: Re: [aspectj-users] How can I exclude class's in aspectJ
> > pointcuts
> >
> > I presume you are getting a repeating stack trace out?  You should
> > look at the code mentioned in the repeating stack trace line and see
> > where it leads - if you keep your aspects in mind you will discover
it
> > takes you round in a circle.  Sometimes it can be as simple as using
> > toString() on an object in your advice, forgetting that toString()
is
> > using getXXX to fetch some data to include in the string, the call
to
> > getXXX is advised and you go back round to the advice again, which
> > calls toString() again.
> >
> > On 27/11/2007, Meir Yanovich <meiry@xxxxxxxxxxxx> wrote:
> > > Ok the aspect file is in other package in com.foo.config
> > > I added also the
> > > && !within(AspectSecurity)
> > > && !within(com.foo.config.*);
> > >
> > > And still getting StackOverflowError
> > > Im testing the methods with junit tester that using one of the
get's
> > > What else can it be ?
> > >
> > > Thanks allot for your help
> > >
> > > -----Original Message-----
> > > From: aspectj-users-bounces@xxxxxxxxxxx
> > > [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy
Clement
> > > Sent: Tuesday, November 27, 2007 6:01 PM
> > > To: aspectj-users@xxxxxxxxxxx
> > > Subject: Re: [aspectj-users] How can I exclude class's in aspectJ
> > > pointcuts
> > >
> > > StackOverflowError usually means you are advising yourself.  What
> > > package is your aspect in?
> > > Is it in a package you are excluding with your within clauses?  If
> you
> > > don't exclude the aspect and it contains methods called get* or
set*
> > > then you will self-advise and crash.
> > >
> > > Andy.
> > >
> > > On 27/11/2007, Meir Yanovich <meiry@xxxxxxxxxxxx> wrote:
> > > > Ok im getting somewhere now .. im not getting the exception
> > > > But it seams there is somewhere recursion happening.. and im
> getting
> > > > java.lang.StackOverflowError
> > > > >From different package from com.foo.helpers.queryHelper it
keeps
> > > > visiting it.
> > > > Even if I add to your pointcut something like this :
> > > > execution(* get*(..)) || execution(* set*(..))) &&
> > > > within(com.foo.test..*) && !within(com.foo.test.security.*)&&
> > > > !within(com.foo.helpers.queryHelper.*)
> > > >
> > > >
> > > > -----Original Message-----
> > > > From: aspectj-users-bounces@xxxxxxxxxxx
> > > > [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy
> Clement
> > > > Sent: Tuesday, November 27, 2007 5:41 PM
> > > > To: aspectj-users@xxxxxxxxxxx
> > > > Subject: Re: [aspectj-users] How can I exclude class's in
aspectJ
> > > > pointcuts
> > > >
> > > > (execution(* get*(..)) || execution(* set*(..))) &&
> > > > within(com.foo.test..*) && !within(com.foo.test.security.*)
> > > >
> > > > On 27/11/2007, Meir Yanovich <meiry@xxxxxxxxxxxx> wrote:
> > > > > Ok maybe I will try different approaches...
> > > > > How can I write pointcut pattern that matches this :
> > > > > Only watch methods that are starting with get or set only
under
> > the
> > > > > package:
> > > > > com.foo.test.* AND exclude (don't watch) the package
> > > > > com.foo.test.security.* and all its methods.
> > > > >
> > > > > Thanks for the help
> > > > >
> > > > > -----Original Message-----
> > > > > From: aspectj-users-bounces@xxxxxxxxxxx
> > > > > [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy
> > Clement
> > > > > Sent: Tuesday, November 27, 2007 5:13 PM
> > > > > To: aspectj-users@xxxxxxxxxxx
> > > > > Subject: Re: [aspectj-users] How can I exclude class's in
> aspectJ
> > > > > pointcuts
> > > > >
> > > > > So the NPE is occurring at line 54 in your aspect? Without
> seeing
> > > the
> > > > > code, it sounds like you need to either guard the line that is
> > > > > suffering from a null or find the place that is getting
matched
> > > which
> > > > > leads to the null occurring in your advice.  you could do that
> > with
> > > > > something like this in your advice:
> > > > >
> > > > > if (whateverItIs==null) System.err.println("Null after
matching
> > > here:
> > > > > "+thisJoinPoint.getSourceLocation());
> > > > >
> > > > > Andy.
> > > > >
> > > > > On 27/11/2007, Meir Yanovich <meiry@xxxxxxxxxxxx> wrote:
> > > > > > Well yes from the what I see I have something like 600+
> methods
> > > that
> > > > I
> > > > > > expected , and I don't see any ajcore file...
> > > > > > Also this is java.lang.NullPointerException im getting ..
> > > > > >
> > > > > > -----Original Message-----
> > > > > > From: aspectj-users-bounces@xxxxxxxxxxx
> > > > > > [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy
> > > Clement
> > > > > > Sent: Tuesday, November 27, 2007 4:38 PM
> > > > > > To: aspectj-users@xxxxxxxxxxx
> > > > > > Subject: Re: [aspectj-users] How can I exclude class's in
> > aspectJ
> > > > > > pointcuts
> > > > > >
> > > > > > what do you mean by stuck trace? is that the only line of
> output
> > > you
> > > > > > see?  Did weaving all go OK?
> > > > > > If AspectJ crashed during weaving you might see an ajcore
file
> > on
> > > > the
> > > > > > disk which would give details of the problem.  If you
compile
> > with
> > > > > > -showWeaveInfo are you definetly seeing that it advices only
> > where
> > > > you
> > > > > > expect?
> > > > > >
> > > > > > Andy
> > > > > >
> > > > > > On 27/11/2007, Meir Yanovich <meiry@xxxxxxxxxxxx> wrote:
> > > > > > > No just one time , not recursion . this is stuck trace
> > > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: aspectj-users-bounces@xxxxxxxxxxx
> > > > > > > [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of
Andy
> > > > Clement
> > > > > > > Sent: Tuesday, November 27, 2007 3:44 PM
> > > > > > > To: aspectj-users@xxxxxxxxxxx
> > > > > > > Subject: Re: [aspectj-users] How can I exclude class's in
> > > aspectJ
> > > > > > > pointcuts
> > > > > > >
> > > > > > > that looks just like one line of a Java stack trace?  Are
> you
> > > > > getting
> > > > > > > that over and over?  If so that could indicate you have
> > advised
> > > > > > > yourself by accident and are recursing...
> > > > > > >
> > > > > > > Andy.
> > > > > > >
> > > > > > > On 27/11/2007, Meir Yanovich <meiry@xxxxxxxxxxxx> wrote:
> > > > > > > > Hello and thanks for the fast reply I added this.
> > > > > > > > But I still getting error ..
> > > > > > > > My real case is bit more complex then the example I
gave.
> > > > > > > > How can I get some kind of error checking from aspectJ
or
> > > > somekind
> > > > > > of
> > > > > > > > debug info from aspectJ ?
> > > > > > > > All im getting is :
> > > > > > > > at
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
com.foo.configuration.AspectSecurity.ajc$before$com_foo_configuration_As
> > > > > > > > pectSecurity$1$dbea9d15(AspectSecurity.aj:54)
> > > > > > > >
> > > > > > > > in line 54 I have called method from within my
application
> .
> > > > > > > >
> > > > > > > > -----Original Message-----
> > > > > > > > From: aspectj-users-bounces@xxxxxxxxxxx
> > > > > > > > [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of
> > > > > > > > hermod.opstvedt@xxxxxxxxx
> > > > > > > > Sent: Tuesday, November 27, 2007 2:37 PM
> > > > > > > > To: aspectj-users@xxxxxxxxxxx
> > > > > > > > Subject: RE: [aspectj-users] How can I exclude class's
in
> > > > aspectJ
> > > > > > > > pointcuts
> > > > > > > >
> > > > > > > > Hi
> > > > > > > >
> > > > > > > > ...... && !within(com.fo.test.security.*)
> > > > > > > >
> > > > > > > > Hermod
> > > > > > > >
> > > > > > > > -----Original Message-----
> > > > > > > > From: aspectj-users-bounces@xxxxxxxxxxx
> > > > > > > > [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of
> Meir
> > > > > > Yanovich
> > > > > > > > Sent: Tuesday, November 27, 2007 1:25 PM
> > > > > > > > To: aspectj-users@xxxxxxxxxxx
> > > > > > > > Subject: [aspectj-users] How can I exclude class's in
> > aspectJ
> > > > > > > pointcuts
> > > > > > > >
> > > > > > > >
> > > > > > > > Hello all
> > > > > > > > I like to advice all the class's under :
> > > > > > > > com.foo.test.* but NOT the classes under
> > > com.fo.test.security.*
> > > > > How
> > > > > > > can
> > > > > > > > I represent that with aspectJ pointcuts ?
> > > > > > > > _______________________________________________
> > > > > > > > aspectj-users mailing list
> > > > > > > > aspectj-users@xxxxxxxxxxx
> > > > > > > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > > > > > > * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
> *
> > *
> > > *
> > > > *
> > > > > *
> > > > > > *
> > > > > > > *
> > > > > > > > * *
> > > > > > > >
> > > > > > > > This email with attachments is solely for the use of the
> > > > > individual
> > > > > > or
> > > > > > > > entity to whom it is addressed. Please also be aware
that
> > the
> > > > DnB
> > > > > > NOR
> > > > > > > > Group
> > > > > > > > cannot accept any payment orders or other legally
binding
> > > > > > > correspondence
> > > > > > > > with
> > > > > > > > customers as a part of an email.
> > > > > > > >
> > > > > > > > This email message has been virus checked by the anti
> virus
> > > > > programs
> > > > > > > > used
> > > > > > > > in the DnB NOR Group.
> > > > > > > >
> > > > > > > > * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
> *
> > *
> > > *
> > > > *
> > > > > *
> > > > > > *
> > > > > > > *
> > > > > > > > * *
> > > > > > > > _______________________________________________
> > > > > > > > aspectj-users mailing list
> > > > > > > > aspectj-users@xxxxxxxxxxx
> > > > > > > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > > > > > >
> > > > > > > > _______________________________________________
> > > > > > > > aspectj-users mailing list
> > > > > > > > aspectj-users@xxxxxxxxxxx
> > > > > > > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > > > > > >
> > > > > > > _______________________________________________
> > > > > > > aspectj-users mailing list
> > > > > > > aspectj-users@xxxxxxxxxxx
> > > > > > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > > > > > _______________________________________________
> > > > > > > aspectj-users mailing list
> > > > > > > aspectj-users@xxxxxxxxxxx
> > > > > > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > > > > >
> > > > > > _______________________________________________
> > > > > > aspectj-users mailing list
> > > > > > aspectj-users@xxxxxxxxxxx
> > > > > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > > > > _______________________________________________
> > > > > > aspectj-users mailing list
> > > > > > aspectj-users@xxxxxxxxxxx
> > > > > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > > > >
> > > > > _______________________________________________
> > > > > aspectj-users mailing list
> > > > > aspectj-users@xxxxxxxxxxx
> > > > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > > > _______________________________________________
> > > > > aspectj-users mailing list
> > > > > aspectj-users@xxxxxxxxxxx
> > > > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > > >
> > > > _______________________________________________
> > > > aspectj-users mailing list
> > > > aspectj-users@xxxxxxxxxxx
> > > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > > _______________________________________________
> > > > aspectj-users mailing list
> > > > aspectj-users@xxxxxxxxxxx
> > > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > >
> > > _______________________________________________
> > > aspectj-users mailing list
> > > aspectj-users@xxxxxxxxxxx
> > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > _______________________________________________
> > > aspectj-users mailing list
> > > aspectj-users@xxxxxxxxxxx
> > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top