FAQ Database Discussion Community


spring autowired aop circular dependency

spring,aop,spring-java-config,spring-aspects
I'm using java config with @ComponentScanin order to initialize my beans and @EnableAspectJAutoProxy(proxyTargetClass=true)to use cglib proxies. In this project we have a lots of generated services autowired between them using @Autowired. It works pretty well. But, for some of these services I've added @Async (I've also added @EnableAsync(proxyTargetClass = true)on...

Difference between call and execution pointcuts in PHP?

java,php,aop,aspectj
In AOP in Java (AspectJ) when we talk about method pointcuts, we can differentiate them into two different sets: method call pointcuts and method execution pointcuts. Basing on these resources here on SO: execution Vs. call Join point Difference between call and execution in AOP And some AspectJ background, we...

How do I access parameters specified in a Java Aspect?

java,reflection,annotations,aop
I have an annotation called "@ProgressCheck" that we can put on a controller to check the progress of an application. If the application is already submitted or late, then it throws the user to a page appropriate for that situation. The annotation interface is: @Retention(RetentionPolicy.RUNTIME) public @interface ProgressCheck { }...

Is it mandatory to implement concrete aspect in aspectJ

java,aop,aspectj
I am running a HelloWorld project using load time weaving (LTW) in aspectJ. I had defined abstract aspect only. I had not defined concrete aspect but mentioned "name" attribute of <concrete-aspect> as main.java.aop.helloworld.MyHelloWorldAspect in the aop.xml as below: <concrete-aspect name="main.java.aop.helloworld.MyHelloWorldAspect" extends="main.java.aop.helloworld.HelloWorldAspect"> <pointcut name="helloWorld" expression="execution(public static void HelloWorld.say*(..))" /> </concrete-aspect> I...

pointcut execution for specific class constructor

java,aop,aspectj,pointcut
I'm trying to create specific class constructor pointcut execution but I get the following marker: Aspect code: public aspect CarLogger { private Logger logger; pointcut instantiate() : execution (Car.new(..)); after() : instantiate(){ logger.log(Level.INFO, "In Car::Car()", thisJoinPoint.getThis()); } this code returns no match for this type name Car. But if I...

How to use AspectJ for Loggin in a maven project?

java,maven,jboss,aop,aspectj
I have a maven Java EE 6 project and I have into every methods a Logger information to show in the console the beginning with parameters and the end too. In some methods i forgot the make that so i want to use aspectJ to manage the beginning and the...

AspectJ: List pointcut args aop,aspectj
I have this class: public class MyClass { public void updatePeople(List<Person> people) { //DO STUFF } } I want to log the size of people when updatePeople is called by AOP. This is my aspect: @Aspect public class MyAspect { @Pointcut("execution(void com.bla.bla.MyClass.updatePeople(List<Person>)) && args(people)") public void updatePeople(List<Person> people) {} @Before("updatePeople(people)")...

Spring AOP use AspectJ to works or what?

java,spring,aop,aspectj,spring-aop
I am studying Spring AOP and I have the following doubt. From what I know there are 2 ways to implement AOP behavior into a Java application that are: AspectJ: that is the first original AOP technology that uses byte code modification for aspect weaving. Spring AOP: Java-based AOP framework...

How can I configure AOP in Liferay Service Builder?

liferay,aop
I want to to intercept a method in Service Builder, for example: XXXLocalService.update(). But I don't know the correct way to do this. I have done some research but I haven't found a clear way to do this. Any help will be greatly appreciated....

C# Attributes and Aop paradigm

c#,aop
I want to know the difference between the use of the C# custom Attributes and an AOP framework (like PostSharp). How to choose between them ?

Spring AOP with groovy: get called method

spring,groovy,aop,spring-aop
I'm using spring aop with groovy and have a monitoring aspect that should log each method's execution time. The problem is groovy calls are not the same as java calls so the following code always prints "getMetaClass()" as method name. @Before("execution(* mypackage.MyService.*(..))") void beforeMethod(JoinPoint joinPoint) { logger.info(joinPoint.signature.name + " called")...

AspectJ annotations: Pointcut params

annotations,aop,aspectj
I'm trying to log a login action with AspectJ. I need to obtain the logged user. I tried this but it doesn't work. The joinpoint is never executed. @Aspect public class LoginActivityAspect { @Pointcut(value = "call(void com.android.project.activities.LoginActivity.loginSuccess(String)) && this(username)", argNames = "username") public void loginSuccess(String username) {} @Before(value = "loginSuccess(username)")...

Field read field write access in aspectJ

java,aop,aspectj
I am new to aspectJ. I would like to understand field read access and field write access pointcuts. Assume I have a private static string variable "name" in my class "Field". private static String name; I need to assign a value when name is read and throw exception when it...

Intercept Exceptions for logging with CDI's AOP on Java EE 7

exception,logging,cdi,aop,java-ee-7
I have the following class snippet, from which I'd like to remove the repetitive logging code and move it to an Interceptor using CDI's AOP. /** * Javadoc omitted */ public abstract class JpaDao<T extends LongIdentifiable> implements GenericDao<T> { @Override @Transactional public Long persist(T type) throws GeneralPersistenceException { if (type...

AttributeTargetElements = MulticastTargets.Method isn't respected?

c#,aop,postsharp,aspect-oriented
I applied this aspect: [Serializable] [MulticastAttributeUsage(MulticastTargets.Method)] // regular methods, excluding ctors! public class WmiClassMethodAspect : OnMethodBoundaryAspect { public WmiClassMethodAspect() { ApplyToStateMachine = false; } // PostSharp Express edition... public override void OnEntry(MethodExecutionArgs args) { //base.OnEntry(args); } public override void OnExit(MethodExecutionArgs args) { //base.OnExit(args); } } over certain namespace's class: [assembly:...

AOP (without Spring) not working on Tomcat but Eclipse

java,tomcat,aop,aspectj
Implemented AOP using AspectJ without Spring. It works perfectly fine when running in Eclipse (Tomcat server) but not when run directly in Tomcat. Have added required dependencies in the pom but of no use. Not able to figure out the issue. Aspect class: @Aspect public class FeatureAOP { private static...

Create Spring @Service instance with @Transactional methods manually from Java

java,spring,transactions,aop,spring-aop
Let's say there are @Service and @Repository interfaces like the following: @Repository public interface OrderDao extends JpaRepository<Order, Integer> { } public interface OrderService { void saveOrder(Order order); } @Service public class OrderServiceImpl implements OrderService { @Autowired private OrderDao orderDao; @Override @Transactional public void saveOrder(Order order) { orderDao.save(order); } } This...

Using compile-time aspects to implement abstract interfaces

.net,mvvm,aop,fody
As I understand it, all compile-time .NET aspect-oriented-programming frameworks (such as PostSharp or Fody) can only process code that has already successfully compiled. This presents an obstacle if you want to use an aspect from these frameworks to implement members of an abstract interface, because the class being modified would...

Spring Boot Logger Aspects

java,spring,logging,aop,aspect
I'm having problems getting my logging aspect to log information when methods from classes of a particular package are accessed. In other words, "no" logging occurs. I even got desperate and added System.out.println statements, with no luck. All of my classes are located under the org.my.package package, i.e. org.my.package.controller, org.my.package.model,...

INotifyPropertyChanged-Feature on Auto-Properties

c#,mvvm,compiler-construction,aop,postsharp
I have many Model-Classes which implement the INotifyPropertyChanged-Interface in order to update the UI when value changed. Sadly the properties must be written fully to support this feature. I decreased my code already by using the 'SetPropertyValue'-Method() in BaseClass. private string _title; public string Title { get { return title;...

AOP pointcut expression for specific annotated variable

java,spring,aop
I have a scenario like this.. A custom annotation definition... @Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface CacheMe{ String node(); } User details class... class User { String name; String ssn; } And a class with "User" object as variable and uses @CacheMe annotation Class Test{ @CacheMe(node="user") User user; public User getUser(Long id){...

ApsectJ is throwing exception while adding @Transactional annotation

java,spring,aop,aspectj,spring-transactions
We are using AOP and everything works fine, I have added @Transactional. This is happening when i move from one method to another and i can't find any connection!! !!!! annotation and the application is not starting and throwing exception: Reason: Expected stackmap frame at this location. Bytecode: 0000000: 014e...