com.coherentlogic.coherent.data.adapter.aop.aspects.AbstractPropertyChangeGenerator Maven / Gradle / Ivy
package com.coherentlogic.coherent.data.adapter.aop.aspects;
import java.beans.PropertyChangeEvent;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.CodeSignature;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.coherentlogic.coherent.data.adapter.aop.exceptions.PropertyChangeGeneratorException;
import com.coherentlogic.coherent.data.model.core.annotations.Changeable;
import com.coherentlogic.coherent.data.model.core.domain.SerializableBean;
import com.coherentlogic.coherent.data.model.core.exceptions.MisconfiguredException;
/**
* Base class that is used for intercepting setter method calls from either AspectJ (where code is augmented
* outside of the Spring container), or for use within the Spring container, using Spring AOP.
*
* PropertyChangeGenerator implementation that uses the AspectJ ProceedingJoinPoint in order to execute the
* property change event notification in the {@link AbstractPropertyChangeGenerator}. Classes that extend
* this class must be annotated as an Aspect and also include the specific advice on the
* {@link #onSetterMethodCalled(ProceedingJoinPoint)}.
*
* Note that the org.codehaus.mojo:aspectj-maven-plugin plugin must be added to the Maven pom, similar to
* what's included below.
*
*
*
*
*
*
* org.codehaus.mojo
* aspectj-maven-plugin
* 1.10
*
* 1.8
*
* 1.8
*
* ...
*
*
* true
*
*
*
*
* compile
* test-compile
*
*
*
*
*
*
*
* @TODO Move this class into src and force developers to extend from this.
*
* @see {@link DefaultPropertyChangeGeneratorAspect}
* @see /src/test/java/com.coherentlogic.coherent.data.adapter.aop.aspects.PropertyChangeGeneratorAspect
*
* @author Thomas P. Fuller
* @author Support
*/
public abstract class AbstractPropertyChangeGenerator {
private static final Logger log = LoggerFactory.getLogger(AbstractPropertyChangeGenerator.class);
static final String FIRE_PROPERTY_CHANGE = "firePropertyChange";
/**
* @see {@link SerializableBean#firePropertyChange}
*/
private final Method firePropertyChangeMethod;
public AbstractPropertyChangeGenerator() {
try {
firePropertyChangeMethod = SerializableBean.class.getDeclaredMethod(
FIRE_PROPERTY_CHANGE, PropertyChangeEvent.class);
} catch (Exception e) {
throw new RuntimeException ("An exception was thrown when attempting to get the method named " +
FIRE_PROPERTY_CHANGE + ".", e);
}
}
/*
* See if you can use method overloading instead of a closure.
*
* Object result = joinPoint.proceed ()
*
* or
*
* Object result = invocation.proceed();
*/
public Object invoke(
Object targetObject,
Method method,
ProceedClosure
© 2015 - 2025 Weber Informatics LLC | Privacy Policy