Skip to content

Introduce @Spel annotation to denote which methods accept SpEL expressions #36922

Description

@kalgon

Would it be possible to annotate an annotation member which accepts a spel expression with @Spel to let IDEs know that this member can be evaluated? Maybe the @Spel annotation could indicate if expressions may reference beans, method parameters, etc.

If this mechanism is in place, third-party annotations could have their expressions validated by IDEs and it would simplify the IDEs' work by having a single general solution instead of implementing ad-hoc validations per annotation.

@interface Spel {
    enum Access {
        APPLICATION_CONTEXT, METHOD_PARAMETERS
    }
    Access[] access() default {};
}

@interface Locked {
    @Spel(access = {METHOD_PARAMETERS})
    String lockName(); 
}

class MyService {
    @Locked(lockName = "taskLock-#{#taskId}")
    void doSomethingThatMustBeLocked(long taskId, ...) { ... }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions