Is there a way to execute actions in some order if one of them is parametrized (doesn't extend Action.Simple)?
I've tried to use @With like this:
Controller
@With(AnnotationAction.class)
public Result indexWith() {
return ok();
}
AnnotationAction
public final class AnnotationAction extends Action<Annotation> {
private static final Logger.ALogger log = Logger.of(AnnotationAction.class);
@Override
public CompletionStage<Result> call(Request request) {
log.info(String.valueOf(configuration.skip()));
return delegate.call(request);
}
}
Annotation
@With(AnnotationAction.class)
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Annotation {
boolean skip() default false;
}
After executing the request, I get the following error from AnnotationAction on the line where the configuration variable resides:
java.lang.ClassCastException: class jdk.proxy4.$Proxy24 cannot be cast to class controllers.Annotation (jdk.proxy4.$Proxy24 is in module jdk.proxy4 of loader play.runsupport.NamedURLClassLoader @462f781a; controllers.Annotation is in unnamed module of loader play.runsupport.DelegatedResourcesClassLoader @417ee5ee)
at controllers.AnnotationAction.call(AnnotationAction.java:14)
at play.core.j.JavaAction.$anonfun$apply$8(JavaAction.scala:192)
at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:687)
at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:467)
at play.core.j.ClassLoaderExecutionContext.$anonfun$execute$1(ClassLoaderExecutionContext.scala:64)
at play.api.libs.streams.Execution$trampoline$.execute(Execution.scala:65)
at play.core.j.ClassLoaderExecutionContext.execute(ClassLoaderExecutionContext.scala:59)
at scala.concurrent.impl.Promise$Transformation.submitWithValue(Promise.scala:429)
I'm okay with using the default skip value.
Is there any workaround for that? May I create another Action that wraps the initial and apply(and optionally configure) the Annotation there?
The reproducer is in the annotations branch here
Is there a way to execute actions in some order if one of them is parametrized (doesn't extend
Action.Simple)?I've tried to use
@Withlike this:Controller
AnnotationAction
Annotation
After executing the request, I get the following error from
AnnotationActionon the line where theconfigurationvariable resides:I'm okay with using the default
skipvalue.Is there any workaround for that? May I create another Action that wraps the initial and apply(and optionally configure) the
Annotationthere?The reproducer is in the
annotationsbranch here