public static List<com.amazonaws.eclipse.simpleworkflow.asynchrony.objectmodel.Activities> getAllSuperActivities( ProcessingEnvironment processingEnv, TypeElement activities, DeclaredType activitiesAnnotationType, Set<DeclaredType> annotationsToExcludeFromCopying) { List<com.amazonaws.eclipse.simpleworkflow.asynchrony.objectmodel.Activities> superActivities = new ArrayList<com.amazonaws.eclipse.simpleworkflow.asynchrony.objectmodel.Activities>(); for (TypeMirror superInterfaceType : activities.getInterfaces()) { Element superInterfaceDeclaration = processingEnv.getTypeUtils().asElement(superInterfaceType); Activities annotation = superInterfaceDeclaration != null ? superInterfaceDeclaration.getAnnotation(Activities.class) : null; if (annotation != null) { superActivities.add(getActivitiesModel(processingEnv, (TypeElement) superInterfaceDeclaration, activitiesAnnotationType, annotationsToExcludeFromCopying)); } } return superActivities; }
@Override public Boolean visitType(TypeElement e, ProcessingEnvironment p) { if (e.getAnnotation(Activities.class) != null) { if (e.getKind().isClass()) { reportError(p, "@Activities can only be used on an interface.", e); } if (e.getNestingKind().isNested()) { reportError(p, "@Activities not allowed on inner or nested types.", e); } version = ProcessorUtils.getActivitiesVersion(e); parentVersion = ProcessorUtils.getParentActivitiesVersion(p, e); } return super.visitType(e, p); }
public static String getActivitiesNamePrefix(TypeElement activitiesElement) { if (activitiesElement == null) { return ""; } Activities annotation = activitiesElement.getAnnotation(Activities.class); String activityPrefix = annotation.activityNamePrefix(); if (activityPrefix == null) { activityPrefix = activitiesElement.getSimpleName().toString(); } return activityPrefix; }
public static String getActivitiesVersion(TypeElement activitiesElement) { if (activitiesElement == null) return null; Activities annotation = activitiesElement.getAnnotation(Activities.class); if (annotation == null) return null; return annotation.version(); }
public static com.amazonaws.eclipse.simpleworkflow.asynchrony.objectmodel.Activities getActivitiesModel( ProcessingEnvironment processingEnv, TypeElement activities, DeclaredType activitiesAnnotationType, Set<DeclaredType> annotationsToExcludeFromCopying) { ActivitiesDeclarationVisitor visitor = new ActivitiesDeclarationVisitor(processingEnv, (TypeElement) activities, activitiesAnnotationType, annotationsToExcludeFromCopying); visitor.scan(activities, processingEnv); return visitor.getActivitiesDefinition(); }
ActivityInvocationDescriber( Class<?>... activityTypes ) { Map<String, Invocation> map = new HashMap<String, Invocation>(); for ( Class<?> activityType : activityTypes ) { Activities activities = activityType.getAnnotation( Activities.class ); if ( activities == null ) { throw new IllegalArgumentException( "Type " + activityType + " is not annotated with " + Activities.class ); } String prefix = StringUtils.isBlank( activities.activityNamePrefix() ) ? ( activityType.getSimpleName() + "." ) : activities.activityNamePrefix(); for ( Method method : activityType.getMethods() ) { Description desc = method.getAnnotation( Description.class ); if ( desc == null ) { continue; } String name = method.getName(); Activity activity = method.getAnnotation( Activity.class ); if ( activity != null && StringUtils.isNotBlank( activity.name() ) ) { name = activity.name(); } map.put( prefix + name, new Invocation( method ) ); } } this.invocationMap = Collections.unmodifiableMap( map ); }