User development,
A new message was posted in the thread "Problem with AOP arond advice in JBoss
trunk":
http://community.jboss.org/message/522280#522280
Author : Andrew Dinn
Profile :
http://community.jboss.org/people/adinn
Message:
--------------------------------------------------------------
I have been trying to revive on AS trunk the Web Service Transactions BAFramework demo
which we last had working on AS 4.2.3. In doing so have come across what appears to be a
problem with AOP. I don't have a _simple_ test case yet but by playing around with the
code I have pinned the problem down.
My AOP advice binding is not being applied in a specific circumstance. This happens when
the method belongs to an EJB and is annotated with a WebMethod annotation. In this case if
I annotate the method with the BAMethod annotation AOP fails to apply the advice binding
it. However, if I move the BAMethod annotation to a submethod called by the WebMethod then
AOP respects the binding. Here, in brief, are the details of the failing and working
cases:
This is the jboss-aop.xml
<aop xmlns="urn:jboss:aop-beans:1.0">
<!-- BA Processing Aspect -->
<aspect
class="org.jboss.jbossts.baframework.aspect.TransactionProcessingAspect"
scope="PER_INSTANCE"/>
<pointcut name="baMethodAnnotation" expr="execution(*
*->@org.jboss.jbossts.baframework.annotation.BAMethod(..))"/>
<pointcut name="baDataManagementAnnotation"
expr="field(org.jboss.jbossts.baframework.datamgmt.DataManager
*->(a)org.jboss.jbossts.baframework.annotation.BADataManagement)"/>
<bind pointcut="baMethodAnnotation">
<advice name="process"
aspect="org.jboss.jbossts.baframework.aspect.TransactionProcessingAspect"/>
</bind>
<bind pointcut="baDataManagementAnnotation">
<advice name="access"
aspect="org.jboss.jbossts.baframework.aspect.TransactionProcessingAspect"/>
</bind>
</aop>
n.b. teh aspect class, TransactionProcessingAspect, implements methdos with the following
signatures:
public Object process(MethodInvocation invocation) throws Throwable;
public Object access(FieldReadInvocation invocation) throws Throwable;
public Object access(FieldWriteInvocation invocation) throws Throwable;
Here is the web service implementation class te aspect should be applied to
@Stateless
@Remote(Hotel.class)
@WebService(name="Hotel")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@HandlerChain(file = "jaxws-handlers-server.xml")
@BAService(serviceClass=HotelImpl.class,ejbInterface=Hotel.class,jndiName="bademo/HotelImpl/remote")
public class HotelImpl implements Hotel
{
. . .
@WebMethod
@BAMethod(agreement=AgreementType.PARTICIPANT_COMPLETION)
@BACompensatedBy(value="cancelRoom",type=DataMatch.CUSTOM)
@BAResult("reservationNumber")
public Integer bookRoom(@BAParam("username")String
username,@BAParam("password")String password, Integer roomNumber)
throws HotelCustomException, RoomAlreadyOccupiedException
{
log.info("bookRoom()");
hotelView.newMethod("bookRoom()");
hotelView.addMessage("Username: " + username);
. . .
This version of the code builds and boots up ok but AOP fails to call the aspect
class's advice method, process(MethodInvocation invocation)
However, if I introduce an auxiliary method so that the web service target method becomes
a wrapper and then split the annotations, applying the @WebMethod to the wrapper and the
@BAMethod annotation to the auxiliary method, then my advice method does get called.
@WebMethod
public Integer bookRoom(String username, String password, Integer roomNumber)
throws HotelCustomException, RoomAlreadyOccupiedException
{
return bookRoomInternal(username, password, roomNumber);
}
@BAMethod(agreement=AgreementType.PARTICIPANT_COMPLETION)
@BACompensatedBy(value="cancelRoom",type=DataMatch.CUSTOM)
@BAResult("reservationNumber")
public Integer bookRoomInternal(@BAParam("username")String
username,@BAParam("password")String password, Integer roomNumber)
throws HotelCustomException, RoomAlreadyOccupiedException
{
log.info("bookRoom()");
hotelView.newMethod("bookRoom()");
hotelView.addMessage("Username: " + username);
. . .
Any idea why AOP does not call process when both annotations are applied tot he service
method?
If you need the full source I can provide it but it's a bit large and messy as it
involves EJB, Web Servces and XTS (BA) code as well as the aspect code sketched above. I
was hoping this description might be enough to allow you to identify what is wrong.
n.b. I am doing the AOP transform offline but I encountered the same failure using dynamic
AOP. I have not yet seen whether inserting the auxiliary method fixes the dynamic AOP
case.
regards,
Andrew Dinn
--------------------------------------------------------------
To reply to this message visit the message page:
http://community.jboss.org/message/522280#522280