JNDI » History » Version 1
Henning Blohm, 20.06.2015 20:37
1 | 1 | Henning Blohm | h1. JNDI Support |
---|---|---|---|
2 | |||
3 | Components in the z2-Environment may be looked up via the "Java Naming and Directory Interface":https://de.wikipedia.org/wiki/Java_Naming_and_Directory_Interface (JNDI). |
||
4 | |||
5 | The functionality is essentially equivalent to lookups via the IComponentsLookup (LINK) interface. |
||
6 | |||
7 | When looking up a component via z2, it is required to specify the expected return type. Using JNDI this can be accomplished by specifying a type query parameter in the JNDI URL. For example, when looking up a JDBC data source that is declared in a component repository as the component @mymodule/dataSource@, the call |
||
8 | |||
9 | <pre><code class="java"> |
||
10 | IComponentsLookup.INSTANCE.lookup("mymodule/dataSource",javax.sql.DataSource.class); |
||
11 | </code></pre> |
||
12 | |||
13 | is equivalent to |
||
14 | |||
15 | <pre><code class="java"> |
||
16 | new InitialContext().lookup("components:mymodule/dataSource?type=javax.sql.DataSource"); |
||
17 | </code></pre> |
||
18 | |||
19 | If no type parameter is specified, the JNDI lookup will be treated as a z2 component lookup for the type @java.lang.Object@. |