Smart props - DONE » History » Version 6
Henning Blohm, 27.11.2016 14:09
1 | 1 | Henning Blohm | h1. Smart Props |
---|---|---|---|
2 | |||
3 | The goal of this concept is to provide facilities to simplify sharing of component configuration while still being able to query resolved component configuration efficiently and with minimal resource usage. |
||
4 | |||
5 | h2. Design Draft |
||
6 | |||
7 | 6 | Henning Blohm | What we aim for is an extended _properties_ format that allows declarative inclusion of other component's configuration and the use of some expression language style substitution of variables. In other words, we strive for the use of a template processing language. |
8 | 1 | Henning Blohm | |
9 | 4 | Henning Blohm | The prospective candidate is the "Java Unified Expression Language":https://en.wikipedia.org/wiki/Unified_Expression_Language based on the implementation "JUEL":http://juel.sourceforge.net/ |
10 | 1 | Henning Blohm | |
11 | 6 | Henning Blohm | <b>Update:</b> As JUEL seems to be pretty dead and support is not clear, currently Java Expression Language ("JEXL":http://commons.apache.org/proper/commons-jexl/) is the preferred candidate. |
12 | |||
13 | 5 | Henning Blohm | Built-in implicit contexts include |
14 | |||
15 | * system properties, |
||
16 | * environment variables, |
||
17 | * other component properties (_lookup(<name>)_), |
||
18 | * the component name, |
||
19 | * the module name. |
||
20 | 4 | Henning Blohm | |
21 | Example: A repository declaration could look like this: |
||
22 | |||
23 | <pre> |
||
24 | com.zfabrik.component.type=com.zfabrik.svncr |
||
25 | |||
26 | svncr.url=${system['svn.repoBaseUrl']}${system.branch}/base |
||
27 | svncr.user=${system['svn.user']} |
||
28 | svncr.passwordr=${system['svn.password']} |
||
29 | </pre> |
||
30 | 1 | Henning Blohm | |
31 | 6 | Henning Blohm | h2. Resolution Flow |
32 | 1 | Henning Blohm | |
33 | 6 | Henning Blohm | In principle, expressions could be resolved early, during local component repository index load, or late, during component descriptor evaluation. |
34 | |||
35 | h3. Early Evaluation |
||
36 | |||
37 | This approach has the advantage that component queries would already take resolved component properties into account. Using this method, even system state participations or the visibility as component as such could be controlled via expressions. |
||
38 | |||
39 | We strive for early evaluation. |
||
40 | |||
41 | h2. Processing Scope |
||
42 | |||
43 | Allowing template processing means that we do not only process the value part of component properties, but instead the complete component descriptor as a text fragment. A sufficiently powerful expression language might as well introduce properties as desired. |
||
44 | 4 | Henning Blohm | |
45 | |||
46 | h2. Possible extensions |
||
47 | |||
48 | 2 | Henning Blohm | To extend this further, component declarations may indicate their template style via some "Shebang":http://de.wikipedia.org/wiki/Shebang, the default being *java.util.Properties*. |
49 | 1 | Henning Blohm | |
50 | For example: |
||
51 | |||
52 | <pre> |
||
53 | #!com.zfabrik.components/velocityConfig |
||
54 | # |
||
55 | 3 | Henning Blohm | com.zfabrik.component.type=com.zfabrik.java |
56 | 1 | Henning Blohm | |
57 | #parse('mymodule/spring_template') |
||
58 | |||
59 | java.privateReferences=,\ |
||
60 | ${java_private_references},\ |
||
61 | someotherref |
||
62 | </pre> |