0

Configuring AOP with ZK to intercept methods.

asked 2012-03-19 09:37:04 +0800

javaenthu gravatar image javaenthu
141 2

Hi,
Before certain methods (or as of now all the methods) I have written an Aspect. All my other application is functioning correctly.
But none of the methods is getting called in the aspect class. I have modified my application-context.xml to support AOP.

The same cutpoint I tried in same folder structure in my local application but with ZK i am having issues. Am i missing something?


My Apect class is like this :

package com.mypckg.services.impl;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class MyIntercpeter {

	@Pointcut("execution(* com.mypckg.services.impl.MyService.getStudents(..))")
	public void performance() {
	}

	@Before("performance()")
	public void doSomethingBeforeExecution() {
 		System.out.println("Before execution method called...");

		 
	}

	@AfterReturning("performance()")
	public void doSomethingAfterExecution() {
 		System.out.println("After execution method called...");
		 
	}
}

The modifications I made in the application-context.xml are

<beans  .........
	 
	xmlns:aop="http://www.springframework.org/schema/aop"

	xsi:schemaLocation="
           ..........
             http://www.springframework.org/schema/aop
  http://www.springframework.org/schema/aop/spring-aop.xsd">


.....

<aop:aspectj-autoproxy />
<context:annotation-config />

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2012-03-19 10:36:41 +0800

TonyQ gravatar image TonyQ
642
https://www.masterbranch....

Which class you are going to do AOP ?

Is that a composer or ?

link publish delete flag offensive edit

answered 2012-03-19 10:42:27 +0800

javaenthu gravatar image javaenthu
141 2

updated 2012-03-19 10:42:54 +0800

I want to intercept all the methods of the application including Composer.
May be first to start with we shall go ahead with non -composer classes.
Thanks for showing interest and replying :)

And do you think what configurations I have added are correct?

link publish delete flag offensive edit

answered 2012-03-19 10:56:19 +0800

TonyQ gravatar image TonyQ
642
https://www.masterbranch....

updated 2012-03-19 10:56:39 +0800

The keypoint is , as what I know, the AOP only work for those classes which is created by Spring .

If you are using apply="mypackage.MyComposrt" definition in your zul page,
it's created by ZK, so it might not work with your configurationm .

Usually if I have to work with Spring and Composers,
I will setup spring variable resolver and make sure there's a definition apply="${myComposerBean}" in the zul page.

I didn't see your usage , so I might be wrong , just a quick guess. ;)

link publish delete flag offensive edit

answered 2012-03-19 11:09:07 +0800

javaenthu gravatar image javaenthu
141 2

Thanks Tony.
I have 3 layers. (zk, composer, and DAO)
At the start of the each method and and at the return of the each method I want to do some logging.
And from zk i am calling directly composer methods, and in the composers DAO's are autowired.
Hope it helps to understand my scenario.

I didn't understand about variable resolver thing.

link publish delete flag offensive edit

answered 2012-03-19 11:38:06 +0800

TonyQ gravatar image TonyQ
642
https://www.masterbranch....

Would you mind to provide some code snippets for your zul and composer code ?

That would make things more clear. ;)

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-03-19 09:37:04 +0800

Seen: 120 times

Last updated: Mar 19 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More