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
4
votes
1 answer

Applying aspect on constructor in c# using PostSharp

I am working on various concepts in PostSharp. Updated: This is my program class as namespace myconstructor { class Program { static void Main(string[] args) { createfolder(); streamfolder(); …
GowthamanSS
  • 1,434
  • 4
  • 33
  • 58
3
votes
1 answer

How to labeling text based on aspect term and sentiment

I have coded to label text data by term aspect then sentiment with vader lexicon. But the result is only output -1 which means negative and 1 which means positive, where there should be 3 classes of positive, negative and neutral. Here is the code…
3
votes
1 answer

Lombok extension methods: Prevalence/priority?

First off: I absolutely LOVE Project Lombok. Awesome tool! There's so many excellent aspects to this 'compile time' library. Loving the @ExtensionMethods, I have already hit this 'feature' a few times, so now it's time for me to ask this…
JayC667
  • 2,418
  • 2
  • 17
  • 31
3
votes
1 answer

How to call Postsharp Aspect in Unit Test?

I have an aspect sorting list. public override void OnInvoke(MethodInterceptionArgs args) { args.Proceed(); var string_list = (args.ReturnValue as List); string_list.Sort(); Console.WriteLine("Postsharp Aspect içerisinde…
ImC0der
  • 308
  • 2
  • 18
3
votes
1 answer

@Around annotation : Make variable available to joinpoint without changing method signature and use it later

While using @Around aspect and Spring boot. What would be the best approach to create a variable before joinPoint execution, make it available during joinPoint execution to collect data in it and after joinPoint execution use the data collected in…
nash
  • 105
  • 1
  • 10
3
votes
1 answer

How inject a Spring-boot service into a aspectj class?

I'm with a problem.. I'm creating a aspectj class and into my class I need to access a spring-boot service, but when I try use @Autowired or inject it through a constructor I have an error: "Could not autowire. No beans of 'UserService' type…
Eduardo Cintra
  • 101
  • 1
  • 11
3
votes
1 answer

@Around @Aspect in the same package only works with @DependsOn

Please see the updates below. I have a Spring Boot application where I accept TCP/IP connections: public MyClass implements InitializingBean { @Override public void afterPropertiesSet() throws Exception { try (ServerSocket…
Hasan Can Saral
  • 2,950
  • 5
  • 43
  • 78
3
votes
1 answer

AspectJ AOP LTW not working with dynamic loading of javaagent

Here is my sample non-working project. It contains 2 modules: aop-lib - Aspects used as lib. It contains the following classes Wrap.java - It's the annotation used to attach advice WrapDef.java - It is the definition of the above mentioned Wrap…
Pankaj Singhal
  • 15,283
  • 9
  • 47
  • 86
3
votes
1 answer

Advices aren't woven into class files across modules

I have problem with AspectJ, I wanted to create 2 jar files. One is file with aspects and logic, while second is with MVC service. I have two modules: logger-client logger-service inside module client @Aspect public class AspectTesting { …
Hunteerq
  • 250
  • 1
  • 4
  • 15
3
votes
1 answer

Spring CGLib proxy - class variables become null

I have a filter service whose methods are profiled through the aspect. As an example I will give you a piece of code where I have a problem @Service public class FilterService extends AbstractService { private static final Logger log…
Peter Kozlovsky
  • 633
  • 2
  • 10
  • 28
3
votes
1 answer

How to make Spring @Cacheable work on top of AspectJ aspect?

I created an AspectJ aspect which runs fine within a spring application. Now I want to add caching, using springs Cacheable annotation. To check that @Cacheable gets picked up, I'm using the name of a non-existing cache manager. The regular run-time…
manonthemat
  • 6,101
  • 1
  • 24
  • 49
3
votes
2 answers

AOP - Error: java.lang.StackOverflowError at org.aspectj.runtime.internal.AroundClosure

I am trying to use Aspect Oriented Programming to execute a simple Fibonacci function and trace all calls to any method apart from the ones in Java and also display the nesting level of them. Java Code: package tracing; public class Test { …
Marialena
  • 817
  • 8
  • 31
3
votes
1 answer

@Async @Aspect @AfterReturnung. My method has HttpServletRequest object as method argument, but able to access it my aop method

I am trying to log HttpServletRequest content through aop in async mode. The method on which pointcut in implement has HttpServletRequest as method argument. I am not able to access it in async mode, though the code works fine without the @Async…
3
votes
1 answer

aspect c++ tracing function control flow and input output parameters

I am using aspectc++ to generate control flow of the program. trace.ah: #ifndef __trace_ah__ #define __trace_ah__ #include // Control flow tracing example aspect trace { // print the function name before…
Step
  • 307
  • 3
  • 11
3
votes
1 answer

AspectJ is giving error for tracing annotations in source files

I have an aspect code like this: package aspects; import java.util.logging.Level; import java.util.logging.Logger; import org.aspectj.lang.Signature; import org.junit.Test; public aspect TestCaseTrace{ // pointcut traceTestCase() :…
batman
  • 3,565
  • 5
  • 20
  • 41
1 2
3
28 29