salgmachine
salgmachine

Reputation: 529

Thoughts on framework architecture

now this is not directly a programming question, it's more a design question.

I am currently working on a cdi extension. this extension handles instances configured by

  1. a VM argument (-D parameter)
  2. a properties file from the classpath
  3. an annotation on the implementing class
  4. an annotation at injection point (e.g. @MyAnnotation(value ="text") private Object obj;)

Now I can't decide on how to prioritize multiple available configurations e.g. which argument overrides which one..

(as an example) when there is an annotation with value on classlevel and at injection point, which config should be used? does the "smallest" (at injection point) annotation always win or the "largest" (vm argument)?

as this is supposed to grow into a framework i want to get this right.

for the approach "the smallest one always wins" i could foresee use cases where the framework user gets confused because a class- or memberlevel annotation overrides the config of a properties file in the classpath. kinda the same picture (only reversed) is painted by the other approach..

so this would be a rule which the framework user has to learn. which of the approaches is more intuitive?

just brainstorming ;)

greetings from germany

Upvotes: 0

Views: 92

Answers (1)

LightGuard
LightGuard

Reputation: 5378

In DeltaSpike, and also CDI 1.1 (possibly more general in Java EE 7) the lowest number wins, at least from that standpoint it will be consistent.

Upvotes: 2

Related Questions