[JBoss AOP] - Constructor Advice
by David Tucker
David Tucker [http://community.jboss.org/people/codefox] created the discussion
"Constructor Advice"
To view the discussion, visit: http://community.jboss.org/message/626443#626443
--------------------------------------------------------------
I've been writing AOP against actions in my ESB pipeline (as we all now know :) ) and while writing pointcuts against the process methods works fine, I have a need to have advice around the constructors of the actions so that I can populate some metadata. The problem is that none of the pointcuts I've written seem to do anything. I've tried various things since it seemed that the ESB might be instantiating the actions via reflection but that didn't seem to work either. When I wrote advice against the class ActionProcessingPipeline just to see if it would grab any constructor, I got no output from my constructor advice. Here is my current code:
jboss-aop.xml:
<pointcut expr="execution(public com.amentra.*->new(..)) name=NewInstancePC"/>
<aspect name="ConstructorAdvice" class="com.amentra.aop.advice.ConstructorAdvice" scope="PER_VM"/>
<bind pointcut="NewInstancePC">
<before aspect="ConstructorAdvice" name="interceptConstructor"/>
</bind>
I've also tried doing this via reflection though and extended the appropriate class in my ConstructorAdvice and that also didn't result in anything. The reflection I tried this way:
jboss-aop.xml:
<pointcut expr="call(* java.lang.reflect.Constructor->newInstance()) name=NewInstancePC/>
<pointcut expr="call(* java.lang.Class->newInstance()) name=ClassNewInstancePC/>
<aspect name="ConstructorAdvice" class="com.amentra.aop.advice.ConstructorAdvice" scope="PER_VM"/>
<bind pointcut="NewInstancePC OR ClassNewInstancePC">
<before aspect="ConstructorAdvice" name="interceptConstructor"/>
</bind>
ConstructorAdvice.java:
package com.amentra.aop.advice;
import java.lang.reflect.Constructor;
import org.apache.log4j.Logger;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.reflection.ReflectionAspect;
public class ConstructorAdvice extends ReflectionAspect {
Logger LOG = Logger.getLogger(this.getClass());
@Override
protected Object interceptConstructor(Invocation invocation, Constructor<?> constructor, Object[] args) throws Throwable
{
LOG.info("****************CONSTRUCTOR ADVICE****************");
return super.interceptConstructor(invocation, constructor, args);
}
}
Thanks for any help on getting AOP to recognize my constructors.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/626443#626443]
Start a new discussion in JBoss AOP at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 3 months
[JBoss Tools] - Running JBoss Developer Studio 4.x with JRE/JDK 7
by Isaac Rooskov
Isaac Rooskov [http://community.jboss.org/people/irooskov] created the document:
"Running JBoss Developer Studio 4.x with JRE/JDK 7"
To view the document, visit: http://community.jboss.org/docs/DOC-17191
--------------------------------------------------------------
When installing JBoss Developer Studio 4.x, if you attempt to set JRE/JDK 7 as the Java version to be used you will encounter an error and installation will not complete.
JBoss Developer Studio 4.x is not supported with Java 7, however you can complete installation with Java 6 and then follow a few steps to allow it to work with version 7; though it must be stressed that this is not supported. Java 7 will be supported for JBoss Developer Studio 5.
To use Java 7 with JBoss Developer Studio 4.x:
- Install JBoss Developer Studio using Java 6
- After installation, navigate to the /studio/ folder of your installation.
- Open the jbdevstudio.ini file in a text editor
- Add the following lines to the end of the file:
-vm
JAVA_7_FOLDER/bin/java
- Replace JAVA_7_FOLDER with the path to your Java 7 installation
- Save the file and exit your text editor
When you next launch JBoss Developer Studio 4.x it will use Java 7
--------------------------------------------------------------
Comment by going to Community
[http://community.jboss.org/docs/DOC-17191]
Create a new document in JBoss Tools at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=102&co...]
13 years, 3 months