Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] AspectJ in WAR files

The throws clause in the pointcut must match the throws clause in the method
you are trying to intercept.  addSomething() throws ModelException and
AppliationException while doPrint() throws Exception.

From the docs:

Type patterns may be used to pick out methods and constructors based on
their throws clauses. This allows the following two kinds of extremely
wildcarded pointcuts: 

  pointcut throwsMathlike():
      // each call to a method with a throws clause containing at least
      // one exception exception with "Math" in its name.
      call(* *(..) throws *..*Math*);

  pointcut doesNotThrowMathlike():
      // each call to a method with a throws clause containing no
      // exceptions with "Math" in its name.
      call(* *(..) throws !*..*Math*);

A ThrowsClausePattern is a comma-separated list of ThrowsClausePatternItems,
where 

ThrowsClausePatternItem :
[ ! ] TypeNamePattern

A ThrowsClausePattern matches the throws clause of any code member
signature. To match, each ThrowsClausePatternItem must match the throws
clause of the member in question. If any item doesn't match, then the whole
pattern doesn't match. 


-----Original Message-----
From: qqasim@xxxxxxxxxxxxxx [mailto:qqasim@xxxxxxxxxxxxxx]
Sent: Friday, August 22, 2003 9:17 AM
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] AspectJ in WAR files


Hi I am try to do one thing for a log time but without any success.

I am trying to write some aspects, create a war file and deploy them on
Jboss.
Everyting works apart from the aspects.

I have 1 java fils: com.person.Person
1 aspect file: com.person.PersonAspect

Person class includes following methods:

public Vector addSomething(String name, String[] books) 
            throws ModelException, ApplicationException 
{...}

I want to catch the above method, so I wrote following in PersonAspect:
"
import  org.apache.log4j.Logger;

public aspect PersonAspect {
	
	static Logger logger;

pointcut doPrint(): execution(* PersonAspect.*(..) throws Exception);

before (): doPrint()
	{
		String classname =
thisJoinPoint.getSignature().getDeclaringType
().getName()+".class";
		
		logger = Logger.getLogger(classname);
		logger.error("LOGGER == aspect b4 " + thisJoinPoint );
		
		System.out.println("aspect b4 a ");
}
}

However, when I call addSomething(..) no statement is printed onto the
console.

I am wondering if there is something wrong woth my code or is it that JBoss 
would not print the logging statements.

regards

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



Back to the top