[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Question re: declare error


I'd like to declare an error if my @Transactional attributed instance variables are being set outside of the context of a Change object.  In other words, I'd like to have an error in this case:

public class Foo
{
    @Transactional
     String name

      public void setName(String newName)
      {
            name = newName;
      }
}

But not in this case:

public class Foo
{
    @Transactional
     String name

      public void setName(String newName)
      {
            new ValueChange<String>(name, newName)
            {
                 public void set(String value)
                  {
                        name = value;
                  }
             }.post();
      }
}

It seems like this kind of aspect should do that:

public aspect FieldChangeAspect
{
    declare error :
        set(@Transactional * *) &&
        !this(Change)  : "Set of @Transactional variable not in Change object";
}

But this gives me an error saying "this() pointcut designator cannot be used in declare statements."  BTW,  target(), and args() also give the same error for declare statements i guess, so you can't filter on types of this, target, or args in declares.

Am I missing something?  Is there a reason for this or could these be enhancements?

Cheers,
--
-pete
peter m. murray
pete@xxxxxxxxxxxx