FileDocCategorySizeDatePackage
SubjectInterceptor.javaAPI DocJBoss 4.2.12065Fri Jul 13 21:02:26 BST 2007org.jboss.aspects.patterns.observable

SubjectInterceptor

public class SubjectInterceptor extends Object implements org.jboss.aop.advice.Interceptor
A Subject Interceptor. Traps changes to the object and fires change notifications.
author
Adrian Brock
version
$Revision: 57186 $

Fields Summary
Constructors Summary
Methods Summary
public java.lang.StringgetName()

      return "Observerable";
   
public java.lang.Objectinvoke(org.jboss.aop.joinpoint.Invocation invocation)

      FieldInvocation fi = (FieldInvocation) invocation;
      Object before = fi.getField().get(fi.getTargetObject());
      Object result = invocation.invokeNext();
      Object after = fi.getField().get(fi.getTargetObject());
      if ((before == null && after != null) || (before != null && before.equals(after) == false))
      {
         Subject observable = (Subject) fi.getTargetObject();
         observable.notifyObservers();
      }
      return result;