001: /**************************************************************************************
002: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
003: * http://aspectwerkz.codehaus.org *
004: * ---------------------------------------------------------------------------------- *
005: * The software in this package is published under the terms of the LGPL license *
006: * a copy of which has been included with this distribution in the license.txt file. *
007: **************************************************************************************/package org.codehaus.aspectwerkz.transform;
008:
009: import org.objectweb.asm.Label;
010:
011: import java.util.List;
012: import java.util.Set;
013:
014: /**
015: * Interface for the different transformation context implementations. FIXME crap: abstract method on an interface.
016: * Refactor some in between if we are sure to keep the delegation model
017: *
018: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
019: */
020: public interface Context {
021:
022: public String getClassName();
023:
024: /**
025: * Sets the current bytecode.
026: *
027: * @param bytecode
028: */
029: public abstract void setCurrentBytecode(final byte[] bytecode);
030:
031: /**
032: * Returns the initial bytecode.
033: *
034: * @return bytecode
035: */
036: public abstract byte[] getInitialBytecode();
037:
038: /**
039: * Returns the current bytecode.
040: *
041: * @return bytecode
042: */
043: public abstract byte[] getCurrentBytecode();
044:
045: /**
046: * Returns the class loader.
047: *
048: * @return the class loader
049: */
050: public abstract ClassLoader getLoader();
051:
052: /**
053: * The definitions context (with hierarchical structure)
054: *
055: * @return
056: */
057: public abstract Set getDefinitions();
058:
059: /**
060: * Marks the class being transformed as advised. The marker can at most be set once per class per transformer
061: */
062: public abstract void markAsAdvised();
063:
064: /**
065: * Resets the isAdviced flag.
066: */
067: public abstract void resetAdvised();
068:
069: /**
070: * Checks if the class being transformed has been advised.
071: * This should only be used after ALL actual transformations.
072: *
073: * @return boolean
074: */
075: public abstract boolean isAdvised();
076:
077: /**
078: * Marks the context as read-only.
079: */
080: public abstract void markAsReadOnly();
081:
082: /**
083: * Checks if the context is read-only.
084: *
085: * @return boolean
086: */
087: public abstract boolean isReadOnly();
088:
089: /**
090: * Returns meta-data for the transformation.
091: *
092: * @param key the key
093: * @return the value
094: */
095: public abstract Object getMetaData(final Object key);
096:
097: /**
098: * Adds new meta-data for the transformation.
099: *
100: * @param key the key
101: * @param value the value
102: */
103: public abstract void addMetaData(final Object key,
104: final Object value);
105:
106: /**
107: * Dump the class to specific directory.
108: *
109: * @param dir
110: */
111: public abstract void dump(String dir);
112:
113: /**
114: * Tries to resolve the line number from the given label
115: *
116: * @param label
117: * @return
118: */
119: abstract int resolveLineNumberInfo(Label label);
120:
121: }
|