public static String computeActivityName(String prefix, String interfaceName, ExecutableElement activity) { assert(activity != null); String activityName = null; Activity activityAnnotation = activity.getAnnotation(Activity.class); if (activityAnnotation != null && !activityAnnotation.name().isEmpty()) { activityName = activityAnnotation.name(); } else { if (prefix == null || prefix.isEmpty()) { activityName = interfaceName + "." + activity.getSimpleName().toString(); } else { activityName = prefix + activity.getSimpleName().toString(); } } return activityName; }
@Override public Boolean visitExecutable(ExecutableElement e, ProcessingEnvironment p) { TypeMirror returnType = e.getReturnType(); if (!ProcessorUtils.isVoidType(returnType) && ProcessorUtils.isPromiseType(returnType)) { reportError(p, "Activity methods are not allowed to have Promise return type.", e); } for (VariableElement parameter: e.getParameters()) { TypeMirror parameterType = parameter.asType(); if (ProcessorUtils.isPromiseType(parameterType)) { reportError(p, "Activity methods are not allowed to have Promise parameter type.", parameter); } } if ((version == null || version.isEmpty()) && (parentVersion == null || parentVersion.isEmpty())) { Activity activityAnnotation = e.getAnnotation(Activity.class); if (activityAnnotation == null || activityAnnotation.name().isEmpty()) { reportError(p, "Activity version not specified.", e); } } return super.visitExecutable(e, p); }
public static String computeActivityVersion(String version, ExecutableElement activity) { Activity activityAnnotation = activity.getAnnotation(Activity.class); if (activityAnnotation != null && !activityAnnotation.version().isEmpty()) { version = activityAnnotation.version(); } return version; }
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 ); }
@Activity(name = "computeDataSize") int computeDataSizeForInputData(String bucketName, String filename);