2

I have a annotation that does include several other annotations, pretty much like this one here:

@Component // Spring Component
@Interface OsgiService { boolean isFactory() }

meaning that all classes annotated with @OsgiService shall automatically also be annotated as @Component. Which works fine.

Now however, I'd like to add another annotation, that has a parameter which is dependent of the isFactory parameter of @OsgiService.

@Component // Spring Component
@Scope(isFactory() ? "prototype" : "singleton")
@Interface OsgiService { boolean isFactory() }

Which does not work. However, as isFactory property of an annotation requires to be a static value, shouldn't it be possible to have something like this?

1 Answer 1

3

I don't think this is possible.

You can create two annotations: @OsgiService and @OsgiServiceFactory

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.