1 /***************************************************************************************
2 * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
3 * http://aspectwerkz.codehaus.org *
4 * ---------------------------------------------------------------------------------- *
5 * The software in this package is published under the terms of the LGPL license *
6 * a copy of which has been included with this distribution in the license.txt file. *
7 **************************************************************************************/
8 package org.codehaus.aspectwerkz.transform;
9
10 import org.objectweb.asm.Label;
11
12 import java.util.List;
13 import java.util.Set;
14
15 /***
16 * Interface for the different transformation context implementations. FIXME crap: abstract method on an interface.
17 * Refactor some in between if we are sure to keep the delegation model
18 *
19 * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
20 */
21 public interface Context {
22
23 public String getClassName();
24
25 /***
26 * Sets the current bytecode.
27 *
28 * @param bytecode
29 */
30 public abstract void setCurrentBytecode(final byte[] bytecode);
31
32 /***
33 * Returns the initial bytecode.
34 *
35 * @return bytecode
36 */
37 public abstract byte[] getInitialBytecode();
38
39 /***
40 * Returns the current bytecode.
41 *
42 * @return bytecode
43 */
44 public abstract byte[] getCurrentBytecode();
45
46 /***
47 * Returns the class loader.
48 *
49 * @return the class loader
50 */
51 public abstract ClassLoader getLoader();
52
53 /***
54 * The definitions context (with hierarchical structure)
55 *
56 * @return
57 */
58 public abstract Set getDefinitions();
59
60 /***
61 * Marks the class being transformed as advised. The marker can at most be set once per class per transformer
62 */
63 public abstract void markAsAdvised();
64
65 /***
66 * Resets the isAdviced flag.
67 */
68 public abstract void resetAdvised();
69
70 /***
71 * Checks if the class being transformed has been advised.
72 * This should only be used after ALL actual transformations.
73 *
74 * @return boolean
75 */
76 public abstract boolean isAdvised();
77
78 /***
79 * Marks the context as read-only.
80 */
81 public abstract void markAsReadOnly();
82
83 /***
84 * Checks if the context is read-only.
85 *
86 * @return boolean
87 */
88 public abstract boolean isReadOnly();
89
90 /***
91 * Returns meta-data for the transformation.
92 *
93 * @param key the key
94 * @return the value
95 */
96 public abstract Object getMetaData(final Object key);
97
98 /***
99 * Adds new meta-data for the transformation.
100 *
101 * @param key the key
102 * @param value the value
103 */
104 public abstract void addMetaData(final Object key, 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 }