How to Spring » History » Version 5
Henning Blohm, 05.09.2012 17:58
1 | 2 | Henning Blohm | h1. How to Use the Spring Framework in Z2 |
---|---|---|---|
2 | |||
3 | There is actually nothing sooo particular about using Spring in Z2. But when knowing how Z2 modularity works, there is much to gain by spending a few minutes reading this How-To. However it is required that you are familiar with the Spring framework as such. |
||
4 | |||
5 | h2. Pre-Requisites |
||
6 | |||
7 | 3 | Henning Blohm | In order to have the Spring libraries available you need to add the repository _z2-addons.spring_ to your environment. Some samples, for example the z2-samples.jta-spring sample explained in [[How to TransactionManager]] does so. To use the master branch version, add a *springRepository.properties* component descriptor to your *environment* module saying |
8 | |||
9 | <pre> |
||
10 | com.zfabrik.systemStates.participation=com.zfabrik.boot.main/sysrepo_up |
||
11 | |||
12 | # git stored component repository |
||
13 | com.zfabrik.component.type=com.zfabrik.gitcr |
||
14 | |||
15 | # true <=> optional repository. If gitcr.uri is invalid, then this gitcr will be ignore silently |
||
16 | gitcr.optional=true |
||
17 | |||
18 | # this can also point to a remote repository like |
||
19 | # ssh://myserver/some/git/repo |
||
20 | gitcr.uri=http://git.z2-environment.net/z2-addons.spring |
||
21 | |||
22 | # the git branch to use (e.g. 'master') |
||
23 | gitcr.branch=master |
||
24 | </pre> |
||
25 | |||
26 | For your own system, you may need to adapt the repository URL and the branch selection accordingly. |
||
27 | |||
28 | If that sounds like meaningless gibberish to you - sorry please consult the documentation at http://www.z2-environment.eu/v20doc and go back to [[First_steps_with_z2]]. |
||
29 | |||
30 | 4 | Henning Blohm | When you added that repository the following modules are available: |
31 | |||
32 | * org.springframework.orm |
||
33 | * org.springframework.security |
||
34 | * org.springframework.foundation |
||
35 | * org.springframework.transaction |
||
36 | * org.springframework.jdbc |
||
37 | * org.springframework.web |
||
38 | * com.zfabrik.springframework |
||
39 | * com.zfabrik.springframework.web |
||
40 | |||
41 | |||
42 | With the exception of those starting with "com.zfabrik", these do, more or less, correspond to the typical Spring modules found out there. |
||
43 | |||
44 | 2 | Henning Blohm | h2. Using Spring in Web Applications |
45 | |||
46 | 5 | Henning Blohm | This is the simplest and really just the standard case. If you do not strive for re-use across modules that use Spring, then there is not much to worry about. |
47 | |||
48 | As usual, you define an application context in the WEB-INF folder of the Web application and set up a context listener in WEB-INF/web.xml to have the application |
||
49 | context initialized as the Web app is started. |
||
50 | |||
51 | In order to have the minimal set of dependencies satisfied - i.e. not assuming you want to use the (very cool) AspectJ based Spring configuration, you should _add_ (i.e. augment whatever refs you already have) |
||
52 | the following references to *java/z.properties*: |
||
53 | |||
54 | <pre> |
||
55 | java.privateReferences=\ |
||
56 | com.zfabrik.springframework.web,\ |
||
57 | org.springframework.foundation,\ |
||
58 | org.springframework.web |
||
59 | |||
60 | </pre> |
||
61 | |||
62 | The reference to *com.zfabrik.springframework.web* is not strictly needed but adds the following capabilities: |
||
63 | |||
64 | |||
65 | 2 | Henning Blohm | h2. Using Spring in Re-use Modules |
66 | |||
67 | h2. Using Spring's Aspect/J Configuration |