FITECH Laboratories spacer
graphic Company graphic Products graphic Support graphic Customers graphic Partners
The Power of Choice
spacer » Buy graphic » Try graphic » Map graphic » Contact graphic
spacer
spacer
xTier™
Overview
xTier Services
Business Case
Documentation
F.A.Q.
Buy xTier™
Try xTier™
Professional Services
graphic
spacer xTier
spacer
jndi
Product: xTier™/LWC 2.3
Whitepaper: n/a
spacer
 support@fitechlabs.com
 Download
 Buy
 Depends: log
 Related: jmx
xTier™ Navigator:
cache cluster config email i18n
ioc info jmx jndi security
log marshal objpool os fs
tx uidgen workflow jobs
db startup jms grid

Description
The 'jndi' service provides an "umbrella" API and uniform configuration for any native JNDI implementation. This service provides implementation for some well-known JNDI usage patterns. Note that the JNDI kernel service does not implement the JNDI SPI directly but rather provides a vendor-independent configuration and access API, as well as additional utility methods on top of Context APIs. This, among other things, greatly benefits code portability with the ability to redeploy code utilizing the 'jndi' service with different underlying JNDI implementations with no code changes.

 Top

Configuration
Configuration of the service is specified in the xtier_jndi.xml xTier™ configuration file. This file follows the standard xTier™ service configuration pattern and is illustrated by the following complete example of these object definition:

1<xtier-jndi>
2    <region name="examples">
3        <!--
4            Specifyes the authoritativeness of 
5            the service requested. 
6        -->
7        <authoritative>true</authoritative>
8
9        <!--
10            Batch size to use when returning data via 
11            the service's protocol. 
12        -->
13        <batchsize>50</batchsize>
14
15        <!-- 
16            DNS host and domain names to use for 
17            the JNDI URL context. 
18        -->
19        <dns-url>dns://somehost/wiz.com</dns-url>
20
21        <!-- Initial context factory. -->
22        <init-context-factory>
23            com.sun.jndi.rmi.registry.RegistryContextFactory
24        </init-context-factory>
25
26        <!--
27            Preferred language to use with the service.
28        -->
29        <language>en:de:ru</language>
30
31        <!-- List of object factories to use. -->
32        <obj-factories>
33            com.foo.someFactory:com.foo.anotherFactory
34        </obj-factories>
35
36        <!-- Information for the service provider to use. -->
37        <provider-url>rmi://localhost:1099</provider-url>
38
39        <!--
40            Specifyes how referrals encountered by the service 
41            provider are to be processed.
42        -->
43        <referral>follow</referral>
44
45        <!-- 
46            Security level to use. Its value is one of the 
47            following strings: "none", "simple", "strong". 
48        -->
49        <authentication>simple</authentication>
50
51        <!--
52            Identity of the principal for authenticating the 
53            caller to the service. The format of the principal 
54            depends on the authentication scheme.
55        -->
56        <credentials>777</credentials>
57
58        <!-- Security protocol to use. -->
59        <protocol>ssl</protocol>
60
61        <!--
62            List of state factories to use.
63        -->
64        <factories>com.foo.stateFactory</factories>
65
66        <!--
67            List of package prefixes to use when loading 
68            in URL context factories. 
69        -->
70        <url-pkg-prefixes>com.foo</url-pkg-prefixes>
71    </region>
72</xtier-jndi>

Formal specification for this configuration file can be found in the xtier_jndi.dtd DTD file in the ${XTIER_ROOT}/config/dtd folder. The following table provides explanations for the configuration elements:

authentication Corresponds to Context.SECURITY_AUTHENTICATION.
authoritative Corresponds to Context.AUTHORITATIVE.
batchsize Corresponds to Context.BATCHSIZE.
credentials Corresponds to Context.SECURITY_PRINCIPAL.
dns-url Corresponds to Context.DNS_URL.
factories Corresponds to Context.STATE_FACTORIES.
init-context-factory Corresponds to Context.INITIAL_CONTEXT_FACTORY.
language Corresponds to Context.LANGUAGE.
obj-factories Corresponds to Context.OBJECT_FACTORIES.
protocol Corresponds to Context.SECURITY_PROTOCOL.
provider-url Corresponds to Context.PROVIDER_URL.
referral Corresponds to Context.REFERRAL.
url-pkg-prefixes Corresponds to Context.URL_PKG_PREFIXES.

 Top

Examples
The usage of the 'jndi' service follows the standard pattern of using an xTier™ service: you need to obtain an instance of the xTier™ kernel that serves as a service registry. Once you have the xTier™ kernel you can get an instance of any service, in our case the 'jndi' service.

1// Get the instance of xTier kernel.
2XtierKernel xtier = XtierKernel.getInstance();
3 
4// Get the instance of 'jndi' service. 
5JndiService jndi = xtier.jndi();
6 
7InitialContext ctx = jndi.getInitialContext();
8 
9Hashtable env = ctx.getEnvironment();
10 
11// Print out the JNDI settings.
12for (Enumeration enum = env.keys(); enum.hasMoreElements() == true;) {
13    Object key = enum.nextElement();
14 
15    System.out.println(key + " = " + env.get(key));
16} 
17 
18try {
19    jndi.bindEx(JNDI_NAME, new RefObj(), true);
20    
21    jndi.unbindEx(JNDI_NAME);        
22}
23catch (NamingException e) {
24    // ...
25}
26 
27// Stop the xTier kernel.
28xtier.stop();

Note also that every utility method comes in four versions:

  • Method that takes Context and JNDI name as a String
  • Method that does not take Context and takes JNDI name as a String
  • Method that takes Context and JNDI name as a Name
  • Method that does not take Context and takes JNDI name as a Name

 Download xTier™ for full examples and documentation.

 Top

spacer