minor logic fix; added javaagent to README
This commit is contained in:
@@ -26,6 +26,12 @@ This library will handle nearly all the requirements to get AspectJ working in A
|
||||
|
||||
You can use the `@Aspect` annotation as you would think. However, you cannot add a `@Component` or similar annotation to the class. The class must NOT be defined as a Spring bean. We need to let AspectJ instantiate the class; not Spring. This module will side-load the instance as a Spring bean, including any use of @PostConstruct or @Autowired as one would expect.
|
||||
|
||||
You will also need to specify the base packages to scan for `@Aspect` classes. You can do that with any unique property in `alfresco-global.properties` (environment or module) or in the Java `-D` arguments. Here is an example:
|
||||
|
||||
```ini
|
||||
inteligr8.mymodule.aspectj.basePackages=com.myco.alfresco.mymodule.aspect
|
||||
```
|
||||
|
||||
### `aop.xml`
|
||||
|
||||
AspectJ without Spring AOP requires you to define your aspects. This module includes an `aop.xml` that deals with excluding ACS libraries. You just need to define your aspects and maybe exclude some more libraries to prevent them from being picked up.
|
||||
|
@@ -11,6 +11,7 @@ import java.util.Set;
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.aspectj.lang.Aspects;
|
||||
import org.aspectj.lang.NoAspectBoundException;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -51,8 +52,10 @@ public class AspectJSpringAdapter {
|
||||
Object bean = this.applicationContext.getAutowireCapableBeanFactory().initializeBean(aspect, beanName);
|
||||
this.applicationContext.getAutowireCapableBeanFactory().autowireBean(bean);
|
||||
this.logger.debug("Wrapped aspect in bean: {} => {}", beanName, aspectBeanDef.getBeanClassName());
|
||||
} catch (NoAspectBoundException nabe) {
|
||||
this.logger.warn("An @Aspect was found that is not defined in `aop.xml`: " + aspectBeanDef.getBeanClassName(), nabe);
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
this.logger.warn("Failed to properly register aspect: " + aspectBeanDef.getBeanClassName(), cnfe);
|
||||
this.logger.warn("Failed to Springify aspect: " + aspectBeanDef.getBeanClassName(), cnfe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user