[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Point Cut gambling
|
Ah... You args() pointcut usage isn't right for the nonmatching case.
Here is something that should work:
public pointcut remoteAuthOperations ( AddressBookManagerRemote iro,
AddressBookDO ado ) :
target ( AddressBookManagerRemote ) && target ( iro ) && args (
ado, * ) &&
(
call ( public void AddressBookManagerRemote.addParty (
AddressBookDO, PartyDO ) ) ||
call ( public void AddressBookManagerRemote.removeParty (
AddressBookDO, PartyDO ) )
);
Note the "*" in args() part of the pointcut. You have two arguments to
add/removeParty() and the original pointcut was trying to match the one
with only one argument of AddressBookDO type. Of course, using args (
ado, * ) is only one of the possibilities, you could use args(ado,
PartyDO) or args(ado, ..) and it should still work. The right choice
depends on what you are trying to express.
-Ramnivas
===
Ramnivas Laddad,
Author, AspectJ in Action
http://ramnivas.com
Franz Prilmeier wrote:
I am having troubles with pointcuts, yet again. It seems to me it lies
in the favour of the aspectj gods whether a point cut matches or not.
These are the participating files in my application (Packages and
irrelevant methods stripped away):
public interface IRemoteObject extends javax.ejb.EJBObject {
public boolean changeOperationAllowed ( AbstractDO ado ) throws
java.rmi.RemoteException;
}
public interface PersonManagerRemote extends IRemoteObject {
public PersonDO createPerson ( PersonDO p ) throws
java.rmi.RemoteException;
public void changePerson ( PersonDO p ) throws
java.rmi.RemoteException;
public void removePerson ( PersonDO p ) throws
java.rmi.RemoteException;
}
public interface AddressBookManagerRemote extends IRemoteObject {
public void addParty ( AddressBookDO ado, PartyDO pdo ) throws
java.rmi.RemoteException;
public void removeParty ( AddressBookDO ado, PartyDO pdo ) throws
java.rmi.RemoteException;
}
public class AbstractDO { /* ejb value object */ }
public class PartyDO extends AbstractDO { /* ejb value object */ }
public class AddressBookDO extends AbstractDO { /* ejb value object */ }
public class PersonDO extends PartyDO { /* ejb value object */ }
This point cut matches perfectly:
public pointcut remoteAuthOperations ( IRemoteObject iro, PersonDO
ado ) :
target ( PersonManagerRemote ) && target ( iro ) && args ( ado
) &&
(
call ( public void PersonManagerRemote.createPerson (
PersonDO ) ) ||
call ( public void PersonManagerRemote.changePerson (
PersonDO ) ) ||
call ( public void PersonManagerRemote.removePerson (
PersonDO ) )
);
This point cut doesn't match, but it isn't very different from the one
above:
public pointcut remoteAuthOperations ( AddressBookManagerRemote
iro, AddressBookDO ado ) :
target ( AddressBookManagerRemote ) && target ( iro ) && args (
ado ) &&
(
call ( public void AddressBookManagerRemote.addParty (
AddressBookDO, PartyDO ) ) ||
call ( public void AddressBookManagerRemote.removeParty (
AddressBookDO, PartyDO ) )
);
Where is the difference? Why doesn't it match?
I am now trying for two days to get this point cut to match. It's kind
of frustrating.
Franz
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users