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.inlining.spi;
008:
009: import org.codehaus.aspectwerkz.reflect.ClassInfo;
010: import org.codehaus.aspectwerkz.definition.AspectDefinition;
011: import org.codehaus.aspectwerkz.transform.inlining.AdviceMethodInfo;
012: import org.codehaus.aspectwerkz.transform.inlining.AspectInfo;
013: import org.objectweb.asm.CodeVisitor;
014: import org.objectweb.asm.ClassWriter;
015:
016: /**
017: * TODO document
018: *
019: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
020: */
021: public interface AspectModel {
022: /**
023: * Returns the aspect model type, which is an id for the the special aspect model, can be anything as long
024: * as it is unique.
025: *
026: * @return the aspect model type id
027: */
028: String getAspectModelType();
029:
030: /**
031: * Defines the aspect and adds definition to the aspect definition.
032: *
033: * @param aspectClassInfo
034: * @param aspectDef
035: * @param loader
036: */
037: void defineAspect(ClassInfo aspectClassInfo,
038: AspectDefinition aspectDef, ClassLoader loader);
039:
040: /**
041: * Returns info about the closure class, name and type (interface or class).
042: *
043: * @return the closure class info
044: */
045: AroundClosureClassInfo getAroundClosureClassInfo();
046:
047: /**
048: * Creates the methods required to implement or extend to implement the closure for the specific aspect model type.
049: *
050: * @param cw
051: * @param className
052: */
053: void createMandatoryMethods(ClassWriter cw, String className);
054:
055: /**
056: * Creates invocation of the super class for the around closure.
057: * <p/>
058: * E.g. the invocation of super(..) in the constructor.
059: * <p/>
060: * Only needed to be implemented if the around closure base class is really a base class and not an interface.
061: *
062: * @param cv
063: */
064: void createInvocationOfAroundClosureSuperClass(CodeVisitor cv);
065:
066: /**
067: * Creates aspect reference field (field in the jit jointpoint class f.e.) for an aspect instance.
068: *
069: * @param cw
070: * @param aspectInfo
071: * @param joinPointClassName
072: */
073: void createAspectReferenceField(ClassWriter cw,
074: AspectInfo aspectInfo, String joinPointClassName);
075:
076: /**
077: * Creates instantiation of an aspect instance.
078: *
079: * @param cv
080: * @param aspectInfo
081: * @param joinPointClassName
082: */
083: void createAspectInstantiation(CodeVisitor cv,
084: AspectInfo aspectInfo, String joinPointClassName);
085:
086: /**
087: * Handles the arguments to the around advice.
088: *
089: * @param cv
090: * @param adviceMethodInfo
091: */
092: void createAroundAdviceArgumentHandling(CodeVisitor cv,
093: AdviceMethodInfo adviceMethodInfo);
094:
095: /**
096: * Handles the arguments to the after advice.
097: *
098: * @param cv
099: * @param adviceMethodInfo
100: */
101: void createBeforeAdviceArgumentHandling(CodeVisitor cv,
102: AdviceMethodInfo adviceMethodInfo);
103:
104: /**
105: * Handles the arguments to the after advice.
106: *
107: * @param cv
108: * @param adviceMethodInfo
109: */
110: void createAfterAdviceArgumentHandling(CodeVisitor cv,
111: AdviceMethodInfo adviceMethodInfo);
112:
113: /**
114: * Should return true if the aspect model requires that Runtime Type Information (RTTI) is build up
115: * for the join point. Needed for reflective systems and systems that does not support f.e. args() binding.
116: *
117: * @return
118: */
119: boolean requiresReflectiveInfo();
120:
121: /**
122: * Info about the around closure class or interface for this specific aspect model.
123: *
124: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
125: */
126: public static class AroundClosureClassInfo {
127: private final String m_super ClassName;
128: private final String[] m_interfaceNames;
129:
130: public AroundClosureClassInfo(final String super ClassName,
131: final String[] interfaceNames) {
132: m_super ClassName = super ClassName;
133: m_interfaceNames = interfaceNames;
134: }
135:
136: public String getSuperClassName() {
137: return m_super ClassName;
138: }
139:
140: public String[] getInterfaceNames() {
141: return m_interfaceNames;
142: }
143:
144: /**
145: * Type safe enum for the around closure class type.
146: */
147: public static class Type {
148: public static final Type INTERFACE = new Type("INTERFACE");
149: public static final Type CLASS = new Type("CLASS");
150: private final String m_name;
151:
152: private Type(String name) {
153: m_name = name;
154: }
155:
156: public String toString() {
157: return m_name;
158: }
159: }
160:
161: }
162: }
|