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 java.util.List; 11 12 /*** 13 * Interface for the different transformation context implementations. FIXME crap: abstract method on an interface. 14 * Refactor some in between if we are sure to keep the delegation model 15 * 16 * @author <a href="mailto:jboner@codehaus.org">Jonas Bonér </a> 17 */ 18 public interface Context { 19 20 public String getClassName(); 21 22 /*** 23 * Sets the current bytecode. 24 * 25 * @param bytecode 26 */ 27 public abstract void setCurrentBytecode(final byte[] bytecode); 28 29 /*** 30 * Returns the initial bytecode. 31 * 32 * @return bytecode 33 */ 34 public abstract byte[] getInitialBytecode(); 35 36 /*** 37 * Returns the current bytecode. 38 * 39 * @return bytecode 40 */ 41 public abstract byte[] getCurrentBytecode(); 42 43 /*** 44 * Returns the class abstraction. 45 * 46 * @return clazz 47 */ 48 public abstract Object getClassAbstraction(); 49 50 /*** 51 * Returns the class loader. 52 * 53 * @return the class loader 54 */ 55 public abstract ClassLoader getLoader(); 56 57 /*** 58 * The definitions context (with hierarchical structure) 59 * 60 * @return 61 */ 62 public abstract List getDefinitions(); 63 64 /*** 65 * Marks the class being transformed as advised. The marker can at most be set once per class per transformer 66 */ 67 public abstract void markAsAdvised(); 68 69 /*** 70 * Marks the class as prepared. 71 */ 72 public abstract void markAsPrepared(); 73 74 /*** 75 * Resets the isAdviced flag. 76 */ 77 public abstract void resetAdvised(); 78 79 /*** 80 * Checks if the class being transformed has beed advised. 81 * 82 * @return boolean 83 */ 84 public abstract boolean isAdvised(); 85 86 /*** 87 * Checks if the class is prepared. 88 * 89 * @return 90 */ 91 public abstract boolean isPrepared(); 92 93 /*** 94 * Marks the context as read-only. 95 */ 96 public abstract void markAsReadOnly(); 97 98 /*** 99 * Checks if the context is read-only. 100 * 101 * @return boolean 102 */ 103 public abstract boolean isReadOnly(); 104 105 /*** 106 * Returns meta-data for the transformation. 107 * 108 * @param key the key 109 * @return the value 110 */ 111 public abstract Object getMetaData(final Object key); 112 113 /*** 114 * Adds new meta-data for the transformation. 115 * 116 * @param key the key 117 * @param value the value 118 */ 119 public abstract void addMetaData(final Object key, final Object value); 120 121 /*** 122 * Dump the class to specific directory. 123 * 124 * @param dir 125 */ 126 public abstract void dump(String dir); 127 }