]> git.argeo.org Git - gpl/argeo-slc.git/blob - src/site/apt/howtos/howto-executionResources.apt
Improve provisioning via OSGiBoot
[gpl/argeo-slc.git] / src / site / apt / howtos / howto-executionResources.apt
1 Management of writable files within tests
2
3 This provides an abstraction for files generated by the test.
4
5 The files are stored in the standard osgi instance area (argument -data <my data area> to an OSGi launch, default is a ./data directory in the execution directory) under a ${osgi.instance.area}/executionResources directory.
6
7 A subdirectory is created for each execution, thus avoiding that the files override each other.
8
9 The format of this directory is yyyyMMdd_HHmmss_<execution context uuid>
10
11 In order to use it:
12
13 [[1]] First declare a ResourcesManager in your application context. It has to reference the SLC Execution Context (always available):
14
15 +-------------------------------+
16 <bean id="basic.resourcesManager" parent="slcTemplate.fileResources">
17 <property name="executionContext" ref="executionContext" />
18 </bean>
19 +-------------------------------+
20
21 [[1]] Then you can retrieve Spring Resources via a call to this manager. For example (it could also be an inner bean):
22
23 +-------------------------------+
24 <bean id="basic.writeTo" factory-bean="basic.resourcesManager"
25 factory-method="getWritableResource" scope="execution">
26 <constructor-arg value="subdir/writeTo" />
27 <aop:scoped-proxy />
28 </bean>
29 +-------------------------------+
30
31 The "constructor argument" (just a Spring notation in this case) is a relative path that you want to give to this file.
32 Within a given execution, repeated calls on the manager with the same relative path will always point to the same file.
33
34 [[1]] Then simply use this standard Spring Resource where required:
35
36 +-------------------------------+
37 <bean parent="task.echo">
38 <property name="message" value="DATA" />
39 <property name="writeTo" ref="basic.writeTo" />
40 </bean>
41 +-------------------------------+
42
43 Underlying calls to the getFile() method of this resource won't fail (since they are writable).
44
45 Factory bean for execution resources
46
47 Here is an enhancement to declare execution resources:
48
49 +-------------------------------+
50 <bean id="executionResources.placeholderPass" parent="slcTemplate.simpleFlow">
51 <constructor-arg ref="executionResources.spec" />
52 <property name="executables">
53 <list>
54 <bean parent="task.echo">
55 <property name="message" value="DATA" />
56 <property name="writeTo">
57 <bean parent="slcTemplate.resourcesFactoryBean" scope="execution">
58 <property name="executionResources" ref="executionResources" />
59 <property name="relativePath" value="subdir/@{var}" />
60 <aop:scoped-proxy />
61 </bean>
62 </property>
63 </bean>
64 </list>
65 </property>
66 </bean>
67 +-------------------------------+
68
69 This allows to pass @{} execution parameters.
70
71 The other form WON'T WORK if you try to passe @{} in the constructor-arg tag (but still works if the relative path does not contain a @{}):
72
73 +-------------------------------+
74 <bean id="executionResources.placeholderFail" parent="slcTemplate.simpleFlow">
75 <constructor-arg ref="executionResources.spec" />
76 <property name="executables">
77 <list>
78 <bean parent="task.echo">
79 <property name="message" value="DATA" />
80 <property name="writeTo">
81 <bean factory-bean="executionResources" factory-method="getWritableResource"
82 scope="execution">
83 <constructor-arg value="subdir/@{var}" />
84 <aop:scoped-proxy />
85 </bean>
86 </property>
87 </bean>
88 </list>
89 </property>
90 </bean>
91 +-------------------------------+
92