001: //
002: // This file is part of the prose package.
003: //
004: // The contents of this file are subject to the Mozilla Public License
005: // Version 1.1 (the "License"); you may not use this file except in
006: // compliance with the License. You may obtain a copy of the License at
007: // http://www.mozilla.org/MPL/
008: //
009: // Software distributed under the License is distributed on an "AS IS" basis,
010: // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
011: // for the specific language governing rights and limitations under the
012: // License.
013: //
014: // The Original Code is prose.
015: //
016: // The Initial Developers of the Original Code are Angela Nicoara and Gerald Linhofer.
017: // All Rights Reserved.
018: //
019: // Contributor(s):
020: // $Id$
021: // =====================================================================
022: //
023: // (history at end)
024: //
025:
026: package ch.ethz.prose.engine;
027:
028: // used packages
029: import java.lang.reflect.Constructor;
030:
031: import ch.ethz.jvmai.JoinPointKinds;
032: import ch.ethz.jvmai.ClassSpecific;
033:
034: /**
035: * Class ConstructorRequest.
036: *
037: * @version $Revision$
038: * @author Angela Nicoara
039: * @author Gerald Linhofer
040: */
041: public class ConstructorRequest extends JoinPointRequest implements
042: JoinPointKinds, ClassSpecific {
043:
044: private final Constructor constructor;
045: private final Class constructorClass;
046:
047: public int getMask() {
048: return MASK_CONSTRUCTOR_JP | MASK_CODE_JP;
049: }
050:
051: public String getKind() {
052: return KIND_CONSTRUCTOR_JP;
053: }
054:
055: /**
056: * Constructor.
057: * @param m Method to set the watch at.
058: * @param o Reference to the JoinPointManager to set and clear jvmai-watches.
059: */
060: public ConstructorRequest(Constructor m, JoinPointManager o) {
061: super (o);
062: constructor = m;
063: constructorClass = constructor.getDeclaringClass();
064: }
065:
066: /**
067: * Implements method from ClassSpecific
068: */
069: public Class getTargetClass() {
070: return constructorClass;
071: }
072:
073: /**
074: * Implements method from MethodSpecific
075: */
076: public Constructor getConstructor() {
077: return constructor;
078: }
079:
080: protected void setWatch(Object listeners) {
081: owner.getAspectInterface().setConstructorWatch(constructor,
082: listeners);
083: }
084:
085: protected void clearWatch() {
086: owner.getAspectInterface().clearConstructorWatch(constructor);
087: }
088:
089: public boolean equals(Object other) {
090: ConstructorRequest otherReq;
091: if (other instanceof ConstructorRequest)
092: otherReq = (ConstructorRequest) other;
093: else
094: return false;
095: return constructor.equals(otherReq.constructor);
096: }
097:
098: // the plus 1 guarantees,
099: // that a MethodExitRequest and MethodEntryRequest on the same Method don't have the same hashCode.
100: public int hashCode() {
101: return (getConstructor().hashCode() + 1);
102: }
103:
104: public String toString() {
105: return "ConstructorRequest on " + constructorClass.getName()
106: + "." + constructor.getName();
107: }
108:
109: }
110:
111: //======================================================================
112: //
113: // $Log$
114: //
|