FieldModificationRequest.java :  » Byte-Code » PROSE » ch » ethz » prose » engine » Java Open Source

Java Open Source » Byte Code » PROSE 
PROSE » ch » ethz » prose » engine » FieldModificationRequest.java
//
//  This file is part of the prose package.
//
//  The contents of this file are subject to the Mozilla Public License
//  Version 1.1 (the "License"); you may not use this file except in
//  compliance with the License. You may obtain a copy of the License at
//  http://www.mozilla.org/MPL/
//
//  Software distributed under the License is distributed on an "AS IS" basis,
//  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
//  for the specific language governing rights and limitations under the
//  License.
//
//  The Original Code is prose.
//
//  The Initial Developer of the Original Code is Andrei Popovici. Portions
//  created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
//  All Rights Reserved.
//
//  Contributor(s):
// $Id: FieldModificationRequest.java,v 1.1.1.1 2003/07/02 15:30:51 apopovic Exp $
// =====================================================================
//
// (history at end)
//

package ch.ethz.prose.engine;

// used packages
import java.lang.reflect.Field;
import ch.ethz.jvmai.JoinPointKinds;
import ch.ethz.jvmai.ClassSpecific;

/**
 * Class FieldModificationRequest is a special kind of
 * <code>JoinPointRequest</code> which, when inserted into a
 * <code>JoinPointManager</code> will make the local virtual
 * machine to stop when it encounters a modification on the field
 * denoted by this request. A corresponding
 * <code>FieldModificationEvent</code> will be posted to the listeners
 * registered in the join point manager.
 *
 * @version  $Revision: 1.1.1.1 $
 * @author  Gerard Roos
 */
public class FieldModificationRequest extends JoinPointRequest implements JoinPointKinds,ClassSpecific {

  private final Field field;
  private final Class fieldClass;

  /** Constructor.
   * creates an empty field modification request. This constructor must
   * be used by subclasses, if the initialization shall not
   * go over the info interface.
   */
  protected FieldModificationRequest()
    {
      super(null);
      field      = null;
      fieldClass = null;
    }

    public String getKind()
    {
  return KIND_FIELD_MODIFICATION_JP;
    }

  public int getMask()
    {
      return MASK_FIELD_MODIFICATION_JP;
    }

  /**
   * Constructor.
   * @param f Field to set the watch at.
   * @param o Reference to the JoinPointManager to set and clear jvmai-watches.
   */
  public FieldModificationRequest(Field f,JoinPointManager o)
    {
      super(o);
      field = f;
      fieldClass = field.getDeclaringClass();
    }

  /**
   * Implements method of interface ClassSpecific.
   */
  public Class getTargetClass()
    {
      return fieldClass;
    }

  /**
   * Implements method of interface FieldSpecific.
   */
  public Field getField()
    {
      return field;
    }

  protected void setWatch(Object listeners)
    {
      owner.getAspectInterface().setFieldModificationWatch(field,listeners);
    }

  protected void clearWatch()
    {
      owner.getAspectInterface().clearFieldModificationWatch(field);
    }

  public boolean equals(Object other)
    {
      FieldModificationRequest otherReq;
      if (other instanceof FieldModificationRequest)
  otherReq = (FieldModificationRequest)other;
      else
  return false;
      return field.equals(otherReq.field);
    }

  public int hashCode()
    {
      return field.hashCode();
    }

  public String toString()
    {
      return "FieldModificationRequest on " + fieldClass.getName() + "." + field.getName();
    }

}


//======================================================================
//
// $Log: FieldModificationRequest.java,v $
// Revision 1.1.1.1  2003/07/02 15:30:51  apopovic
// Imported from ETH Zurich
//
// Revision 1.2  2003/05/20 16:05:03  popovici
//
// New QueryManager replaces functionality in AspectManager (better Soc)
// New 'Surrogate' classes for usage in the QueryManager
// The 'RemoteAspectManager' and tools modified to use the Surrogates and the QueryManager
//
// Revision 1.1  2003/05/05 13:58:27  popovici
// renaming from runes to prose
//
// Revision 1.10  2003/04/26 18:51:37  popovici
// 1 Bug fix which lead to a refactoring step:
//    1. the bug: 'JoinPointRequests' used to write to a static list, which survived a startup/teardown;
//                now this list belongs to the JoinPointManager;
//    2. the refactoring: the JoinPointManager now creates (and shares state) with join-points.
//
// Revision 1.9  2003/04/17 12:49:27  popovici
// Refactoring of the crosscut package
//  ExceptionCut renamed to ThrowCut
//  McutSignature is now SignaturePattern
//
// Revision 1.8  2003/04/17 08:47:57  popovici
// Important functionality additions
//  - Cflow specializers
//  - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
//  - Transactional capabilities
//  - Total refactoring of Specializer evaluation, which permits fine-grained distinction
//    between static and dynamic specializers.
//  - Functionality pulled up in abstract classes
//  - Uniformization of advice methods patterns and names
//
// Revision 1.7  2003/03/04 18:36:03  popovici
// Organization of imprts
//
// Revision 1.6  2003/03/04 11:27:29  popovici
// Important refactorization step (march):
// - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
// - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
//   structures
//
// Revision 1.5  2002/05/28 15:51:36  popovici
// parameterless contstructor created in FieldModificationRequest.
// Subclasses can now create Dummy field modification requests
//
// Revision 1.4  2002/03/28 13:48:48  popovici
// Mozilla-ified
//
// Revision 1.3  2002/02/21 12:44:30  popovici
// Dispatching efficiency issues:
//     - Hook methods in the join point manager are now inlined (they
//       do not use any more 'notifyListeners'
//     - Aop tags are now of type 'ListenerList' which allows efficient
//       array iteration
//     - 'setWatch' methods modifiy to accomodate ListenerLists on EventRequests
//
// Revision 1.2  2002/02/05 10:00:21  smarkwal
// JVMDI-specific code replaced by JVMAI. Prose-implementation classes and reflection package removed.
//
// Revision 1.1.1.1  2001/11/29 18:13:13  popovici
// Sources from runes
//
// Revision 1.1.2.4  2001/02/21 13:21:40  popovici
// method 'toString' change to be more executive
//
// Revision 1.1.2.3  2000/11/28 16:34:16  groos
// Interface FieldModificationRequest is now FieldSpecific. The methods provided in FieldSpecific are added and implemented.
//
// Revision 1.1.2.2  2000/11/22 16:49:01  groos
// Constructor not public anymore (now package scope).
// 'FieldSignature' interface is obsolete and has been removed. Uses 'FieldSignatureImpl' directly.
//
// Revision 1.1.2.1  2000/11/21 14:29:27  groos
// initial revision.
//
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.