/** * Visits the class. * * @param access * @param name * @param signature * @param superName * @param interfaces */ public void visit( final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { ExpressionContext ctx = new ExpressionContext(PointcutType.WITHIN, m_classInfo, m_classInfo); if (!classFilter(m_classInfo, ctx, m_ctx.getDefinitions())) { m_declaringTypeName = name; m_mixinFields = new HashMap(); // populate with fields already present for mixins from previous weaving for (int i = 0; i < m_classInfo.getFields().length; i++) { FieldInfo fieldInfo = m_classInfo.getFields()[i]; if (fieldInfo.getName().startsWith(MIXIN_FIELD_NAME)) { m_mixinFields.put(fieldInfo.getType(), fieldInfo); } } // add fields and method for (not already there) mixins addMixinMembers(); } super.visit(version, access, name, signature, superName, interfaces); }
/** * Defines the aspect. * * @param classInfo * @param aspectDef * @param loader */ public void defineAspect( final ClassInfo classInfo, final AspectDefinition aspectDef, final ClassLoader loader) { ClassInfo[] interfaces = classInfo.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { ClassInfo anInterface = interfaces[i]; if (anInterface.getName().equals(MethodInterceptor.class.getName()) || anInterface.getName().equals(MethodBeforeAdvice.class.getName()) || anInterface.getName().equals(AfterReturningAdvice.class.getName()) || anInterface.getName().equals(ThrowsAdvice.class.getName())) { aspectDef.setAspectModel(ASPECT_MODEL_TYPE); aspectDef.setContainerClassName(null); return; } } }
/** * Filters the classes to be transformed. * * @param classInfo the class to filter * @param ctx the context * @param definitions a set with the definitions * @return boolean true if the method should be filtered away */ public static boolean classFilter( final ClassInfo classInfo, final ExpressionContext ctx, final Set definitions) { for (Iterator it = definitions.iterator(); it.hasNext(); ) { SystemDefinition systemDef = (SystemDefinition) it.next(); if (classInfo.isInterface()) { return true; } String className = classInfo.getName().replace('/', '.'); if (systemDef.inExcludePackage(className)) { return true; } if (!systemDef.inIncludePackage(className)) { return true; } if (systemDef.hasMixin(ctx)) { return false; } } return true; }