protected static Object create(AnnotationsAttribute group, Class<? extends Annotation> annotation) throws Exception { if (group == null) return null; javassist.bytecode.annotation.Annotation info = group.getAnnotation(annotation.getName()); if (info == null) return null; return AnnotationProxy.createProxy(info, annotation); }
public void visitAnnotationMemberValue(AnnotationMemberValue annotationMemberValue) { try { value = AnnotationProxy.createProxy(annotationMemberValue.getValue()); } catch (Exception e) { throw new RuntimeException(e); } }
public void visitAnnotationMemberValue(AnnotationMemberValue annotationMemberValue) { try { value = AnnotationProxy.createProxy(annotationMemberValue.getValue()); } catch (Exception e) { throw new RuntimeException(e); } }
public static Object createProxy(javassist.bytecode.annotation.Annotation info) throws Exception { Class<?> annotation = Thread.currentThread().getContextClassLoader().loadClass(info.getTypeName()); return createProxy(info, annotation); }
public void visitAnnotationMemberValue(AnnotationMemberValue node) { try { Annotation ann = node.getValue(); value = AnnotationProxy.createProxy(ann); } catch (Exception e) { throw new RuntimeException(e); } }
public static Object createProxy(javassist.bytecode.annotation.Annotation info) throws Exception { Class annotation = Thread.currentThread().getContextClassLoader().loadClass(info.getTypeName()); return createProxy(info, annotation); }
public void visitAnnotationMemberValue(AnnotationMemberValue node) { try { Annotation ann = node.getValue(); value = AnnotationProxy.createProxy(ann); } catch (Exception e) { throw new RuntimeException(e); } }
private void undeployPrepares(ClassFile cf) throws Exception { Iterator<FieldInfo> fields = cf.getFields().iterator(); while (fields.hasNext()) { FieldInfo finfo = fields.next(); AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag); if (mgroup == null) continue; javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(Prepare.class.getName()); if (binfo == null) continue; AnnotationProxy.createProxy(binfo, Prepare.class); loaderStrategy.undeployPointcut(this, getPrepareName(cf, finfo)); } }
private void undeployTypedefs(ClassFile cf) throws Exception { Iterator<FieldInfo> fields = cf.getFields().iterator(); while (fields.hasNext()) { FieldInfo finfo = fields.next(); AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag); if (mgroup == null) continue; javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(TypeDef.class.getName()); if (binfo == null) continue; AnnotationProxy.createProxy(binfo, TypeDef.class); loaderStrategy.undeployTypedef(this, getTypedefName(cf, finfo)); } }
private void undeployCFlowStackDefs(ClassFile cf) throws Exception { Iterator<FieldInfo> fields = cf.getFields().iterator(); while (fields.hasNext()) { FieldInfo finfo = fields.next(); AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag); if (mgroup == null) continue; javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(CFlowStackDef.class.getName()); if (binfo == null) continue; AnnotationProxy.createProxy(binfo, CFlowStackDef.class); loaderStrategy.undeployCFlow(this, getStackDefName(cf, finfo)); } }
private void deployPointcuts(ClassFile cf) throws Exception { Iterator<FieldInfo> fields = cf.getFields().iterator(); while (fields.hasNext()) { FieldInfo finfo = fields.next(); AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag); if (mgroup == null) continue; javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(PointcutDef.class.getName()); if (binfo == null) continue; PointcutDef pdef = (PointcutDef) AnnotationProxy.createProxy(binfo, PointcutDef.class); loaderStrategy.deployPointcut(this, getPointcutName(cf, finfo), pdef.value()); } }
private void deployTypedefs(ClassFile cf) throws Exception { Iterator<FieldInfo> fields = cf.getFields().iterator(); while (fields.hasNext()) { FieldInfo finfo = fields.next(); AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag); if (mgroup == null) continue; javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(TypeDef.class.getName()); if (binfo == null) continue; TypeDef typeDefinition = (TypeDef) AnnotationProxy.createProxy(binfo, TypeDef.class); String name = getTypedefName(cf, finfo); String expr = typeDefinition.value(); loaderStrategy.deployTypedef(this, name, expr); } }
private void deployPrepares(ClassFile cf) throws Exception { Iterator<FieldInfo> fields = cf.getFields().iterator(); while (fields.hasNext()) { FieldInfo finfo = fields.next(); AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag); if (mgroup == null) continue; javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(Prepare.class.getName()); if (binfo == null) continue; Prepare prepare = (Prepare) AnnotationProxy.createProxy(binfo, Prepare.class); String name = getPrepareName(cf, finfo); String expr = prepare.value(); loaderStrategy.deployPointcut(this, name, expr); } }
private void deployAnnotationIntroductions(ClassFile cf) throws Exception { Iterator<FieldInfo> fields = cf.getFields().iterator(); while (fields.hasNext()) { FieldInfo finfo = fields.next(); AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag); if (mgroup == null) continue; javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(AnnotationIntroductionDef.class.getName()); if (binfo == null) continue; AnnotationIntroductionDef intro = (AnnotationIntroductionDef) AnnotationProxy.createProxy(binfo, AnnotationIntroductionDef.class); String expr = intro.expr(); boolean invisible = intro.invisible(); String annotation = intro.annotation(); annotation = annotation.replace('\'', '"'); loaderStrategy.deployAnnotationIntroduction(this, expr, annotation, invisible); } }
private void undeployAnnotationIntroductions(ClassFile cf) throws Exception { Iterator<FieldInfo> fields = cf.getFields().iterator(); while (fields.hasNext()) { FieldInfo finfo = fields.next(); AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag); if (mgroup == null) continue; javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(AnnotationIntroductionDef.class.getName()); if (binfo == null) continue; AnnotationIntroductionDef intro = (AnnotationIntroductionDef) AnnotationProxy.createProxy(binfo, AnnotationIntroductionDef.class); String expr = intro.expr(); boolean invisible = intro.invisible(); String annotation = intro.annotation(); annotation = annotation.replace('\'', '"'); loaderStrategy.undeployAnnotationIntroduction(this, expr, annotation, invisible); } }
private void undeployInterceptor(AnnotationsAttribute visible, ClassFile cf) throws Exception { //Check for InterceptorDef javassist.bytecode.annotation.Annotation info = visible.getAnnotation(InterceptorDef.class.getName()); if (info != null) { if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("Undeploying @InterceptorDef in: " + cf.getName()); AnnotationProxy.createProxy(info, Aspect.class); loaderStrategy.undeployInterceptor(this, cf.getName()); undeployInterceptorBindings(visible, cf); } }
private void deployDynamicCFlow(AnnotationsAttribute visible, ClassFile cf) throws Exception { javassist.bytecode.annotation.Annotation info = visible.getAnnotation(DynamicCFlowDef.class.getName()); if (info != null) { if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("Found @DynamicCFlowDef in: " + cf.getName()); AnnotationProxy.createProxy(info, DynamicCFlowDef.class); String name = cf.getName(); String clazz = cf.getName(); String[] interfaces = cf.getInterfaces(); boolean foundDCFlow = false; for (int i = 0; i < interfaces.length; i++) { if (interfaces[i].equals(DynamicCFlow.class.getName())) { foundDCFlow = true; break; } } if (!foundDCFlow) throw new RuntimeException("@DynamicCFlow annotated class: " + clazz + " must implement " + DynamicCFlow.class.getName()); loaderStrategy.deployDynamicCFlow(this, clazz, name); } }
private void deployInterceptorBindings(AnnotationsAttribute visible, ClassFile cf, String name) throws Exception { javassist.bytecode.annotation.Annotation binfo = visible.getAnnotation(Bind.class.getName()); if (binfo == null) return; Bind bind = (Bind) AnnotationProxy.createProxy(binfo, Bind.class); String pointcutString = replaceThisInExpr(bind.pointcut(), cf.getName()); String cflow = replaceThisInExpr(bind.cflow(), cf.getName()); if (cflow == null || cflow.trim().equals("")) cflow = null; ASTCFlowExpression cflowExpression = null; if (cflow != null) { cflowExpression = new PointcutExpressionParser(new StringReader(cflow)).CFlowExpression(); } loaderStrategy.deployInterceptorBinding(this, name, pointcutString, cflow, cflowExpression); }
private boolean deployPreparedClass(AnnotationsAttribute visible, ClassFile cf) throws Exception { //Check for Aspect javassist.bytecode.annotation.Annotation info = visible.getAnnotation(Prepare.class.getName()); if (info != null) { if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("Found top-level @Prepare in: " + cf.getName()); Prepare prepare = (Prepare) AnnotationProxy.createProxy(info, Prepare.class); String name = cf.getName() + "." + visible.getName(); String expr = replaceThisInExpr(prepare.value(), cf.getName()); loaderStrategy.deployPointcut(this, name, expr); return true; } return false; }
private void deployCFlowStackDefs(ClassFile cf) throws Exception { Iterator<FieldInfo> fields = cf.getFields().iterator(); while (fields.hasNext()) { FieldInfo finfo = fields.next(); AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag); if (mgroup == null) continue; javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(CFlowStackDef.class.getName()); if (binfo == null) continue; CFlowStackDef stackDef = (CFlowStackDef) AnnotationProxy.createProxy(binfo, CFlowStackDef.class); String name = getStackDefName(cf, finfo); CFlowDef[] cflows = stackDef.cflows(); AspectAnnotationLoaderStrategy.CFlowStackInfo stack = new AspectAnnotationLoaderStrategy.CFlowStackInfo(name); for (int i = 0; i < cflows.length; i++) { CFlowDef cflow = cflows[i]; boolean not = !cflow.called(); stack.addCFlow(new AspectAnnotationLoaderStrategy.CFlowInfo(cflow.expr(), not)); } loaderStrategy.deployCFlow(this, stack); } }