aop

How to change the buttons in a JOptionPane using AspectJ

I need to change the behavior of every JButton in an application (it's a research project). We felt that the best way to change all of the buttons using an aspect since it would keep it clean--we wouldn't have to change all 262 instances to a new type. We have run into a snag. The aspect that we have written does not modify the buttons i...

How can I get action name?

Hi folks, I replaced the ASP.NET ControllerFactory by a WindsorControllerFactory. And I registered all controllers and interceptors. Until here everything working well. Now when I am debuging my Interceptor I always get Execute from ControllerBase in invocation.Method.Name. I need to get the action name and the parameters of the acti...

Why does my Spring AOP aspect work in my unit test but not my webapp ?

I have an aspect working correctly in my unit tests, a log message is printed from the actual method, and afterwards from the aspect applied. When running my webapp though, I only see the result of the '@afterReturning' advice applied, my method does not execute first. My config: <beans xmlns="http://www.springframework.org/schema/be...

Can you call a class member from within a PostSharp advice?

So I'm working with PostSharp to pull out boilerplate logging/exception handling code so that this: public void doSomething() { Logger.Write("Entered doSomething"); try { // code } catch (Exception ex) { ExceptionPolicy.HandleException(ex, "Errors"); } Logger.Write("Exited doSomething");...

Aspect Orientated Programming in Qt

I'm trying to get my head around AOP and some Qt Code would really help. From wikipedia here is some sample code (easy for a Qt/C++ programmer to read): void transfer(Account fromAcc, Account toAcc, int amount, User user, Logger logger) throws Exception { logger.info("transferring money..."); if (! checkUserPermission(user)){ ...

My @Around advice is not being called for all the methods in the package

Hi, I have this code below in my LoggingAspect class and i am expect this to run for my methods like gov.ssa.rome.service.impl.save() gov.ssa.rome.dao.impl.save() but it is running only one time no matter what. i don't know why. i have used autowire to wire dao to servcice layer. I really appreciate your help. what should i do to mak...

How to catch the exception thrown from an advice

I have my own exeception "MyOwnExeception" and throw this exeception from my service class public void service() throws MyOwnExeception { // some code } Now I want to catch MyOwnExeception in an advice and rethrow a brand-new Exeception public class SimpleThrowsAdvice implements ThrowsAdvice { public void afterThrowing(Method ...

Spring MVC: Insert values into all my ModelAndView s

I have a mid-size Spring application and I want to insert key/value pairs into all my ModelAndViews in a cross cutting fashion (much like AOP). The motivation is to add all kind of data to all my pages (configuration values, build number, etc). What is the easiest way to have this done? I prefer without AOP but I am ready to use it if ...

Configuring Grails to use own DataSource implementation or to proxy the standard DataSource

In an application I want to use my own implementation of javax.sql.DataSource that extends the standard org.apache.commons.dbcp.BasicDataSource used by Grails and adds the functionality to set the client identifier based on the currently logged in user at the Grails application. What is the best way to change the underlying javax.sql.Da...

What Aspect-Oriented Programming (AOP) libraries for .NET are still actively developed?

I am trying to find a reasonably mature/stable and freely available (preferably open-source) library for doing AOP in .NET. I've been searching around a bit and found the products below; however, most of them seem dead: PostSharp this is the AOP solution usually recommended for .NET, however it's a commercial product and thus some use...

Is it possible to redefine Java methods from Clojure?

Using multimethods we are able to add methods to existing Java classes. My question is whether it is possible to redefine one specific method, and how, from Clojure code. For instance, if you have the following class, public class Shape { public void draw() { ... } } I'd like to be able to run something to add a before...

Spring Security and AOP

Is it possible to create a custom @Aspect and apply it to the Classes/Methods within Spring Security (3.0.3)? I'm trying to do some logging of logon/logoff requests and none of my Advices are being triggered. I'm using @AspectJ annotations and here is how I'm decorating my method: @After("execution (* org.springframework.security.aut...

PostSharp 1.5 and .Net 4

Postsharp is great, but only the 1.5 version is still opensource. Does it work with .net 4.0? If not, are there any other good AOP weavers out there? I'm not interested in the proxy type. ...

asp.net MVC 2 - most elegant way of isolating guard code - guarding against null controller parameters

Hi all I have a very simple problem, but I'm looking for the 'best' solution to the following: I have multiple controller actions something like this: public ActionResult DoSomething(PackageViewModel packageByName, DoSomethingInputModel inputModel) { if (packageByName == null) { Response.StatusCode = 404; Respon...

Crosscut concerns in middle of methods

it's convenient for AOP (e.g. AspectJ, SpringAOP) to deal with(advise on) crosscut concerns at pointcuts around methods below, "Sandwich" code methodA { crosscut code user code A crosscut code } methodB { crosscut code user code B crosscut code } Is AOP apt to crosscut concerns overlapped to user code below? ...

Intercepting child method calls using Unity

Using PIAB / Unity, is it possible to intercept "child" method calls ? e.g. the class has three methods ... DoSomething(), DoFirst(), DoSecond() The DoSomething() method calls DoFirst() which in turn calls DoSecond() I can get interception of DoSomething, but I can't get anything for DoFirst and DoSecond. I've tried various of the...

Spring logging by package name

I need to log many classes in some packages in a project which I can not change its source code. So I need a solution which I can specify package name, and with spring aop add logging to that package's classes without change them but I dont know how can I do that. How can I do that? ...

Pointcut matching methods with annotated parameters

I need to create an aspect with a pointcut matching a method if: it is annoted with MyAnnotationForMethod One of its parameters (can have many) is annotated with @MyAnnotationForParam (but can have other annotations as well). The aspect class look like this @Pointcut("execution(@MyAnnotationForMethod * *(..,@aspects.MyAnnotationForP...

Invoke proxy AOP by calling method within the bean

lets say the I have got a bean called with two methods 'foo' and 'goo' and 'goo' is marked with AOP interception call. is it possible to write any piece of code inside 'foo' in order to invoke 'goo' method not directly but through the proxy wrapper of the bean in order to activate the AOP part of it? public Class Pojo{ public void f...

ApplicationContext.getBean(Class clazz) doesn't go well with proxies

I have a bean definition in Spring and it's proxy counterpart which is meant to be used everywhere: <bean name="my.Bean" class="org.springframework.aop.framework.ProxyFactoryBean" scope="prototype"> <property name="proxyInterfaces" value="my.Interface"/> <property name="target" ref="my.BeanTarget"/> <property name="interceptorName...