private ClassDescriptor toClassDescriptor(ClassFile classFile, ArchiveEntry entry) { ClassDescriptor.Categorization categorization = ClassDescriptor.Categorization.OTHER;; final AnnotationsAttribute visibleAnnotations = (AnnotationsAttribute) classFile.getAttribute( AnnotationsAttribute.visibleTag ); if ( visibleAnnotations != null ) { if ( visibleAnnotations.getAnnotation( Entity.class.getName() ) != null || visibleAnnotations.getAnnotation( MappedSuperclass.class.getName() ) != null || visibleAnnotations.getAnnotation( Embeddable.class.getName() ) != null ) { categorization = ClassDescriptor.Categorization.MODEL; } else if ( visibleAnnotations.getAnnotation( Converter.class.getName() ) != null ) { categorization = ClassDescriptor.Categorization.CONVERTER; } } return new ClassDescriptorImpl( classFile.getName(), categorization, entry.getStreamAccess() ); } }
private static boolean isAnnotated(ClassFile cfile, Class<? extends Annotation>[] annotated) { List attributes = U.safe(cfile.getAttributes()); for (Object attribute : attributes) { if (attribute instanceof AnnotationsAttribute) { AnnotationsAttribute annotations = (AnnotationsAttribute) attribute; for (Class<? extends Annotation> ann : annotated) { if (annotations.getAnnotation(ann.getName()) != null) { return true; } } } } return false; }
public boolean hasAnnotation(String annotationType) { if (visible != null && visible.getAnnotation(annotationType) != null) { return true; } if (invisible != null && invisible.getAnnotation(annotationType) != null) { return true; } return false; }
public static boolean isStatefulSession(AnnotationsAttribute group) { return group.getAnnotation(javax.ejb.Stateful.class.getName()) != null; }
public static boolean isEntity(AnnotationsAttribute group) { return group.getAnnotation(javax.persistence.Entity.class.getName()) != null; }
/** * Test if a field has the provided annotation */ static boolean hasAnnotation(CtField ctField, Class<? extends java.lang.annotation.Annotation> annotationType) throws ClassNotFoundException { return getAnnotations(ctField).getAnnotation(annotationType.getName()) != null; }
/** * Test if a field has the provided annotation */ static boolean hasAnnotation(CtField ctField, Class<? extends java.lang.annotation.Annotation> annotationType) throws ClassNotFoundException { return getAnnotations(ctField).getAnnotation(annotationType.getName()) != null; }
/** * Test if a class has the provided annotation */ static boolean hasAnnotation(CtClass ctClass, Class<? extends java.lang.annotation.Annotation> annotationType) throws ClassNotFoundException { return getAnnotations(ctClass).getAnnotation(annotationType.getName()) != null; }
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); }
private void undeployPrecedence(AnnotationsAttribute visible, ClassFile cf)throws Exception { javassist.bytecode.annotation.Annotation info = visible.getAnnotation(Precedence.class.getName()); if (info != null) { loaderStrategy.undeployPrecedence(this, cf.getName()); } }
private void undeployInterceptorBindings(AnnotationsAttribute visible, ClassFile cf) throws Exception { javassist.bytecode.annotation.Annotation binfo = visible.getAnnotation(Bind.class.getName()); if (binfo == null) return; loaderStrategy.undeployInterceptorBinding(this, cf.getName()); }
public static boolean isVisibleAnnotationPresent(CtConstructor ctMethod, String annotation) { if (closingDownManager) { return false; } MethodInfo mi = ctMethod.getMethodInfo2(); AnnotationsAttribute visible = (AnnotationsAttribute) mi.getAttribute(AnnotationsAttribute.visibleTag); if (visible == null) return false; return visible.getAnnotation(annotation) != null; }
private MemberValue getMemberValue(final ClassFile classFile, final String annotationType, final String memberName) { final AnnotationsAttribute annotations = (AnnotationsAttribute) classFile.getAttribute(AnnotationsAttribute.visibleTag); final Annotation annotation = annotations.getAnnotation(annotationType); return annotation == null ? null : annotation.getMemberValue(memberName); }
public static boolean isVisibleAnnotationPresent(CtField field, String annotation) { if (closingDownManager) { return false; } FieldInfo mi = field.getFieldInfo2(); AnnotationsAttribute visible = (AnnotationsAttribute) mi.getAttribute(AnnotationsAttribute.visibleTag); if (visible == null) return false; return visible.getAnnotation(annotation) != null; }
private void undeployPointcuts(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; loaderStrategy.undeployPointcut(this, getPointcutName(cf, finfo)); } }
private void undeployPreparedClass(AnnotationsAttribute visible, ClassFile cf) throws Exception { //Check for Aspect javassist.bytecode.annotation.Annotation info = visible.getAnnotation(Prepare.class.getName()); if (info != null) { String name = cf.getName() + "." + visible.getName(); loaderStrategy.undeployPointcut(this, name); } }
private void undeployDynamicCFlow(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("Undeploying @DynamicCFlowDef in: " + cf.getName()); String name = cf.getName(); loaderStrategy.undeployDynamicCFlow(this, name); } }
private void undeployAspect(AnnotationsAttribute visible, ClassFile cf) throws Exception { //Check for Aspect javassist.bytecode.annotation.Annotation info = visible.getAnnotation(Aspect.class.getName()); if (info != null) { if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("Undeploying @Aspect in: " + cf.getName()); loaderStrategy.undeployAspect(this, cf.getName()); undeployAspectMethodBindings(cf); } }
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); } }
static private void updatePropOrder(CtClass ctClass, String name){ ClassFile classFile = ctClass.getClassFile(); AnnotationsAttribute annotations = (AnnotationsAttribute)classFile.getAttribute(AnnotationsAttribute.visibleTag); Annotation xmlTypeAnnotation = annotations.getAnnotation("javax.xml.bind.annotation.XmlType"); ArrayMemberValue propOrderValue = (ArrayMemberValue)xmlTypeAnnotation.getMemberValue("propOrder"); removeValue(propOrderValue, name); annotations.addAnnotation(xmlTypeAnnotation); }