Questions tagged [aspect]

An aspect is a module implemented in an Aspect-Oriented Programming language that contains code for a cross-cutting concern, like logging or security. For questions about the aspect ratio of images, use the aspect-ratio tag.

This tag is for Aspect-Oriented Programming. For questions and answers about the aspect ratio of images, please use the tag.

A feature of a program, like logging, is usually spread throughout a program and is not related to that program's main function. Such a feature is called a cross-cutting concern. The aim of aspect-oriented software development (AOSD) (also called aspect-oriented programming or AOP) is to move a cross-cutting concerns into an aspect. This is called refactoring the code.

In AOSD, aspects are written separately from the main application, which can be written in any standard OOP language. An AOP compiler, like AspectJ, compiles the AOP code and object-oriented programming (OOP) code together in a process called weaving.

AOP is often used to enhance legacy applications or 3rd party libraries when the original source code is not available. It is also used to overcome the main weakness of OOP by collecting the cross-cutting concerns into aspects.

Wikis:

See also:

433 questions
0
votes
1 answer

Is there anything to add to java buildpath so that aspects be weaved when running the project?

I have a class MakeRedAspect in my project which makes red my messages: import java.awt.Color; import javax.swing.JLabel; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import…
user3777963
0
votes
1 answer

Spring aspect not working with identical configuration in similar project

I have 2 war project similar project which have common configuration:
hudi
  • 15,555
  • 47
  • 142
  • 246
0
votes
1 answer

PostSharp OnMethodBoundaryAspect - access parameters types from constructor

I have an OnMethodBoundaryAspect attribute (PostSharp), I want to be able to use expression from attribute constructor that gets uses the methods parameters Lets say something like this : [MyAttribute(p => p.SomeProperty)] public void…
Guy Levin
  • 1,230
  • 1
  • 10
  • 22
0
votes
2 answers

Is it safe to apply more than one aspects?

Assume that we have two aspects: public aspect TestAspect { pointcut publicMethodExecuted(): execution(public !static * *(..)); int around() : publicMethodExecuted() { System.out.println("Test string"); Object[] args =…
St.Antario
  • 26,175
  • 41
  • 130
  • 318
0
votes
0 answers

AspectJ: Accessing field defined in aspect (how to access inter-type member?)

I'm currently working with AspectJ the first time to get "my feet wet". I would like to add a new Button on my Main frame (class Main extends JFrame). This is what I have so far: public aspect MainWipe { public static final String Main.wipeText =…
Markus Weninger
  • 11,931
  • 7
  • 64
  • 137
0
votes
1 answer

Spring 4 AOP aspect is never being called?

I am using Spring 4 AOP and the aspect that i create is never being called and i cannot figure it out why is that. Look, i have this client class: package com.example.aspects; public class Client { public void talk(){ } } And my aspect:…
jscherman
  • 5,839
  • 14
  • 46
  • 88
0
votes
1 answer

In Spring Aspect programming how to differentiate a method call and Rest Call

I have a service using a method and I have actual method call also using it. can we differentiate between both in Aspect programming. for eg. public class AccountProcessorImpl implements AccountProcessor{ public Response calculateBalance(Account…
user1364861
  • 301
  • 1
  • 2
  • 16
0
votes
1 answer

BeanNameAutoProxyCreator setBeanNames regular expression not working?

This is my BeanNameAutoProxyCreator: @Bean public BeanNameAutoProxyCreator beanNameAutoProxyCreator() { BeanNameAutoProxyCreator beanNameAutoProxyCreator = new BeanNameAutoProxyCreator(); beanNameAutoProxyCreator.setBeanNames("*service"); //…
jscherman
  • 5,839
  • 14
  • 46
  • 88
0
votes
3 answers

how to set many targets to ProxyFactoryBean?

I am working with Spring 4 AOP and right now, i have my ProxyFactoryBean configured like this: @Bean @Primary public ProxyFactoryBean proxyFactoryBean() { ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean(); …
jscherman
  • 5,839
  • 14
  • 46
  • 88
0
votes
2 answers

Aspect weaving at compile-time doesn't work

I use Eclipse Kepler, Java 1.7. Part of my pom.xml is below. As I see during maven compile, no logs about weaving at all. Neither I have any errors. Aspect doesn't work neither. What am I doing wrong? As I see in some examples, this pom should…
Battle_Slug
  • 2,055
  • 1
  • 34
  • 60
0
votes
1 answer

Spring Aspect Logger

I have been creating a Annotation based aspect definition thus create @LogPerformance and put it on createuser() method. In that case it does not call the aspect method.But when I have moved @LogPerformance from createuser() to create() method…
Ahmet Karakaya
  • 9,899
  • 23
  • 86
  • 141
0
votes
1 answer

how to add annotations to method/constructor parameters without touching the source code?

I am trying to de/seralize framework objects (no source code access) into JSON using jackson 2. class Item { public Item(Long id) {} } I found this Add annotation to a parameter on a new method created with Javassist but this solution is based…
U.V.
  • 572
  • 4
  • 11
0
votes
1 answer

How to apply a postsharp aspect to just methods defined in child classes of a given class?

Can I specify that a PostSharp aspect will be applied just to all public methods of child classes of a given class? I mean, I have ClassA and want that an OnMethodBoundaryAspect be applied just to public methods defined in classes that inherited…
user1785721
0
votes
1 answer

Pointcut for a method injected with AspectJ

How can I define a pointcut for a method injected with ApsectJ? I have injected the method as follows and it works properly: public void com.moeActivity.onBackPressed() { super.onBackPressed(); Log.d("ATAG", "BACKK"); } Now am trying to…
0
votes
1 answer

error in aspectj Project as change the Compilation Level

I install eclipse_4.3, JDK_1.8.0, and I use ajdt_2.2.3 library for Aspect. until I don't change Compiler Compliance level, the default is 1.4, my project is OK. but when I write this code in my Project: List al = new…
Raha
  • 11
  • 2