Smart props - DONE » History » Version 7
Henning Blohm, 05.03.2017 20:01
1 | 1 | Henning Blohm | h1. Smart Props |
---|---|---|---|
2 | |||
3 | 7 | Henning Blohm | The goal of this concept is to provide facilities to simplify sharing of component configuration, making use of system and environment variables while still being able to query resolved component configuration efficiently and with minimal resource usage. |
4 | 1 | Henning Blohm | |
5 | 7 | Henning Blohm | h2. Latest Design |
6 | |||
7 | In order to maximize compatibility and flexibility the following design has been chosen: |
||
8 | |||
9 | Component properties can be marked with a processing style. To do so, the property name is qualified with an appended, colon separated style descriptor. For example, |
||
10 | |||
11 | <pre> |
||
12 | someProp\:JEXL3="This is a JEXL3 string" |
||
13 | </pre> |
||
14 | |||
15 | marks the property "someProp" as being of style <em>JEXL3</em>. Note that colons need to be escaped using a backslash to be part of the name. |
||
16 | |||
17 | When |
||
18 | |||
19 | ---- |
||
20 | |||
21 | |||
22 | h2. Previous Design Draft |
||
23 | 1 | Henning Blohm | |
24 | 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. |
25 | 1 | Henning Blohm | |
26 | 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/ |
27 | 1 | Henning Blohm | |
28 | 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. |
29 | |||
30 | 5 | Henning Blohm | Built-in implicit contexts include |
31 | |||
32 | * system properties, |
||
33 | * environment variables, |
||
34 | * other component properties (_lookup(<name>)_), |
||
35 | * the component name, |
||
36 | * the module name. |
||
37 | 4 | Henning Blohm | |
38 | Example: A repository declaration could look like this: |
||
39 | |||
40 | <pre> |
||
41 | com.zfabrik.component.type=com.zfabrik.svncr |
||
42 | |||
43 | svncr.url=${system['svn.repoBaseUrl']}${system.branch}/base |
||
44 | svncr.user=${system['svn.user']} |
||
45 | svncr.passwordr=${system['svn.password']} |
||
46 | </pre> |
||
47 | 1 | Henning Blohm | |
48 | 6 | Henning Blohm | h2. Resolution Flow |
49 | 1 | Henning Blohm | |
50 | 6 | Henning Blohm | In principle, expressions could be resolved early, during local component repository index load, or late, during component descriptor evaluation. |
51 | |||
52 | h3. Early Evaluation |
||
53 | |||
54 | 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. |
||
55 | |||
56 | We strive for early evaluation. |
||
57 | |||
58 | h2. Processing Scope |
||
59 | |||
60 | 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. |
||
61 | 4 | Henning Blohm | |
62 | |||
63 | h2. Possible extensions |
||
64 | |||
65 | 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*. |
66 | 1 | Henning Blohm | |
67 | For example: |
||
68 | |||
69 | <pre> |
||
70 | #!com.zfabrik.components/velocityConfig |
||
71 | # |
||
72 | 3 | Henning Blohm | com.zfabrik.component.type=com.zfabrik.java |
73 | 1 | Henning Blohm | |
74 | #parse('mymodule/spring_template') |
||
75 | |||
76 | java.privateReferences=,\ |
||
77 | ${java_private_references},\ |
||
78 | someotherref |
||
79 | </pre> |