Accessing data with JNDI in Liberty
Use Java™ Directory Naming Interface APIs to access a data grid that runs with the Liberty server.
Before you begin
- Install the Liberty.
- Lesson 2.1: Define a server to run in the Liberty.
- Develop an application that you intend to access objects from the data grid. Depending on your method for configuring the data grid for JNDI, you might need a servlet; for example, when you use resource injection with the @Resource annotation.
About this task
Procedure
Example
xsGrid
tags
contain the JNDI information for the corresponding data grid. In this example, the default client
domain endpoint is dev
. If you do not want to use the default client domain
endpoint, then in the xsGrid
tag, you must specify which client domain to use to
connect to the data grid. In the following example, dev
is the default client
endpoint, which is used to connect to the data grid at wxs/myGrid2
, and
test
is the client endpoint for
wxs/myGrid2
.<server>
<featureManager>
<feature>jndi-1.0</feature>
<feature>eXtremeScale.client-1.1</feature>
</featureManager>
<xsBindings>
<xsGrid jndiName="wxs/myGrid" gridName="Grid" clientDomain="test"/>
<xsGrid jndiName="wxs/myGrid2" gridName="Grid" />
</xsBindings>
<xsClientDomain default="dev">
<endpointConfig> dev ; localhost:2809 </endpointConfig>
<endpointConfig> test ; testhost1:4444,testhost2:4444 </endpointConfig>
</xsClientDomain>
</server>