SlideShare une entreprise Scribd logo
JNDI:
Java Naming & Directory
Services
D. C. Sherman 1
Rationale
A fundamental element in every application is the capability to find and
locate components and services.
A client looking for a component service usually knows its name, but not its
physical location.
The component name corresponds to the actual name, typically much
more difficult to remember and manage.
A well-known naming service is provided in the Internet by DNS
For applications, a naming directory service is the way to refer to a required
service (e.g. a JDBC data source, a JMS connection factory, an EJB
home interface, etc.)
Terms
A naming service is an application tht contains a set of objects, or
references to objects, with corresponding names (usually easy to
remember). Such correspondences a recalled bindings.
A directory service allows for the association of attributes to a binding.
Some popular directory implementations:
LDAP (Lightweight Directory Access Protocol)
NDS (Network Directory Service)
AD (Active Directory)
NIS+ (Network Information Service Plus)
Overview
JNDI (Java naming Directory Interface) provides Java clients with the
capacity to access naming and directory services.
JNDI is subdivided in the following packages:
javax.naming
javax.naming.directory
javax.naming.event
javax.naming.ldap
javax.naming.spi
Configuration
 JNDI configuration can be quite a difficult task
 Whenever we use an EJB server, JNDB is started automatically at he
same time as the server itself. Such a server is usually already
configured for the specific server.
 Also the client applications using JNDI must be configured, which task is
up to the programmer.
Properties
A client (object) uses JNDI to locate remote services, but JNDI might be a
remote service as well. How, then, to locate a naming service without
using a naming service?
This can be done using environment properties.
Some standard JNDI properties:
 java.naming.factory.initial
 java.naming.provider.url
 java.naming.security.authorization
etc.
Context
Context (interface) is used to deal with objects that have been bound to a
JNDI name.
javax.naming.Context contains methods to put objects in the naming
service, and retrieve them.
All the naming services have an access point, referenced as *InitalContext*
in the JNDI (not thread-safe!):
Select th eservice providerspecify requried configuration
call the *InitialContext* constructor, with teh environment properties
InitialContext
InitialContext must be closed after its usage, as it happens for any
resource, e.g. a JDBC connection. The best way to do it is to insert the
invocation of the close method inside a finally block.
The method getEnvironment of Context returns an Hashtable with all the
active properties for the context.
The method lookup(name) returns a reference to the Object corresponding
to name. This way, also EJB "home factories" are looked up.
Access
As an EJB usually must not access files, how can an EJB access its
configuration properties?
A smart way to pass a configuration value to a bean is through its
deployment descriptor, adding an env-entry tag, e.g.
 <env-entry>
 <description>what a beautiful entry!</description>
 <env-entry-name>theNicestGirl</env-entry-name>
 <env-entry-type>java.lang.String</env-entry-type>
 <env-entry-value>”Anne”</env-entry-value>
 </env-entry>
An EJB accesses environment properties using an InitialContext object, and
looking up the desired property by its name.

Contenu connexe

Tendances

Easy data-with-spring-data-jpa
Easy data-with-spring-data-jpaEasy data-with-spring-data-jpa
Easy data-with-spring-data-jpa
Staples
 
JDBC Basics (In 20 Minutes Flat)
JDBC Basics (In 20 Minutes Flat)JDBC Basics (In 20 Minutes Flat)
JDBC Basics (In 20 Minutes Flat)
Craig Dickson
 
ZODB, the Zope Object Database (May 2003)
ZODB, the Zope Object Database (May 2003)ZODB, the Zope Object Database (May 2003)
ZODB, the Zope Object Database (May 2003)
Kiran Jonnalagadda
 
Entity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsEntity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic Unicorns
Richie Rump
 
Dev Cast Dependency Injection
Dev Cast Dependency InjectionDev Cast Dependency Injection
Dev Cast Dependency Injection
Dylan Thomas
 
NoSQL Endgame JCON Conference 2020
NoSQL Endgame JCON Conference 2020NoSQL Endgame JCON Conference 2020
NoSQL Endgame JCON Conference 2020
Thodoris Bais
 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code First
James Johnson
 
Cloud computing 21 concept of wsdl modeling
Cloud computing 21 concept of wsdl modelingCloud computing 21 concept of wsdl modeling
Cloud computing 21 concept of wsdl modeling
Vaibhav Khanna
 
Кирилл Латыш "ERP on Websockets"
Кирилл Латыш "ERP on Websockets"Кирилл Латыш "ERP on Websockets"
Кирилл Латыш "ERP on Websockets"
Fwdays
 
Spring Test DBUnit
Spring Test DBUnitSpring Test DBUnit
Spring Test DBUnit
Jaran Flaath
 
Introduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC DriversIntroduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC Drivers
Kumar
 
NoSQL Endgame LWJUG 2021
NoSQL Endgame LWJUG 2021NoSQL Endgame LWJUG 2021
NoSQL Endgame LWJUG 2021
Thodoris Bais
 
Introduction to Hibernate Framework
Introduction to Hibernate FrameworkIntroduction to Hibernate Framework
Introduction to Hibernate Framework
Raveendra R
 
Apply hibernate to model and persist associations mappings in document versio...
Apply hibernate to model and persist associations mappings in document versio...Apply hibernate to model and persist associations mappings in document versio...
Apply hibernate to model and persist associations mappings in document versio...
csandit
 
Hibernate Session 1
Hibernate Session 1Hibernate Session 1
Hibernate Session 1
b_kathir
 
Getting started with entity framework
Getting started with entity framework Getting started with entity framework
Getting started with entity framework
Lushanthan Sivaneasharajah
 

Tendances (16)

Easy data-with-spring-data-jpa
Easy data-with-spring-data-jpaEasy data-with-spring-data-jpa
Easy data-with-spring-data-jpa
 
JDBC Basics (In 20 Minutes Flat)
JDBC Basics (In 20 Minutes Flat)JDBC Basics (In 20 Minutes Flat)
JDBC Basics (In 20 Minutes Flat)
 
ZODB, the Zope Object Database (May 2003)
ZODB, the Zope Object Database (May 2003)ZODB, the Zope Object Database (May 2003)
ZODB, the Zope Object Database (May 2003)
 
Entity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsEntity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic Unicorns
 
Dev Cast Dependency Injection
Dev Cast Dependency InjectionDev Cast Dependency Injection
Dev Cast Dependency Injection
 
NoSQL Endgame JCON Conference 2020
NoSQL Endgame JCON Conference 2020NoSQL Endgame JCON Conference 2020
NoSQL Endgame JCON Conference 2020
 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code First
 
Cloud computing 21 concept of wsdl modeling
Cloud computing 21 concept of wsdl modelingCloud computing 21 concept of wsdl modeling
Cloud computing 21 concept of wsdl modeling
 
Кирилл Латыш "ERP on Websockets"
Кирилл Латыш "ERP on Websockets"Кирилл Латыш "ERP on Websockets"
Кирилл Латыш "ERP on Websockets"
 
Spring Test DBUnit
Spring Test DBUnitSpring Test DBUnit
Spring Test DBUnit
 
Introduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC DriversIntroduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC Drivers
 
NoSQL Endgame LWJUG 2021
NoSQL Endgame LWJUG 2021NoSQL Endgame LWJUG 2021
NoSQL Endgame LWJUG 2021
 
Introduction to Hibernate Framework
Introduction to Hibernate FrameworkIntroduction to Hibernate Framework
Introduction to Hibernate Framework
 
Apply hibernate to model and persist associations mappings in document versio...
Apply hibernate to model and persist associations mappings in document versio...Apply hibernate to model and persist associations mappings in document versio...
Apply hibernate to model and persist associations mappings in document versio...
 
Hibernate Session 1
Hibernate Session 1Hibernate Session 1
Hibernate Session 1
 
Getting started with entity framework
Getting started with entity framework Getting started with entity framework
Getting started with entity framework
 

Similaire à Java Naming & Directory Services

Jndi (1)
Jndi (1)Jndi (1)
Jndi (1)
laraibnaeem
 
Name Services
Name Services Name Services
Name Services
_AmmarAjmal_
 
Name services
Name servicesName services
Name services
Rajendran N
 
JNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLJNDI, JMS, JPA, XML
JNDI, JMS, JPA, XML
Kumar
 
JNDI
JNDIJNDI
Free Hibernate Tutorial | VirtualNuggets
Free Hibernate Tutorial  | VirtualNuggetsFree Hibernate Tutorial  | VirtualNuggets
Free Hibernate Tutorial | VirtualNuggets
Virtual Nuggets
 
Java Web Programming Using Cloud Platform: Module 3
Java Web Programming Using Cloud Platform: Module 3Java Web Programming Using Cloud Platform: Module 3
Java Web Programming Using Cloud Platform: Module 3
IMC Institute
 
Java Web Programming [3/9] : Servlet Advanced
Java Web Programming [3/9] : Servlet AdvancedJava Web Programming [3/9] : Servlet Advanced
Java Web Programming [3/9] : Servlet Advanced
IMC Institute
 
Session 1 Tp1
Session 1 Tp1Session 1 Tp1
Session 1 Tp1
phanleson
 
Collaborative Cuisine's 1 Hour JNDI Cookbook
Collaborative Cuisine's 1 Hour JNDI CookbookCollaborative Cuisine's 1 Hour JNDI Cookbook
Collaborative Cuisine's 1 Hour JNDI Cookbook
Ken Lin
 
Final Database Connectivity in JAVA.ppt
Final Database Connectivity in JAVA.pptFinal Database Connectivity in JAVA.ppt
Final Database Connectivity in JAVA.ppt
TabassumMaktum
 
jdbc_presentation.ppt
jdbc_presentation.pptjdbc_presentation.ppt
jdbc_presentation.ppt
DrMeenakshiS
 
Hibernate training at HarshithaTechnologySolutions @ Nizampet
Hibernate training at HarshithaTechnologySolutions @ NizampetHibernate training at HarshithaTechnologySolutions @ Nizampet
Hibernate training at HarshithaTechnologySolutions @ Nizampet
Jayarajus
 
Jdbc Lecture5
Jdbc Lecture5Jdbc Lecture5
Jdbc Lecture5
phanleson
 
Overview Of JDBC
Overview Of JDBCOverview Of JDBC
Overview Of JDBC
Mindfire Solutions
 
Enterprise Spring
Enterprise SpringEnterprise Spring
Enterprise Spring
Emprovise
 
Spring jdbc dao
Spring jdbc daoSpring jdbc dao
Spring jdbc dao
Anuj Singh Rajput
 
SHOW104: Practical Java
SHOW104: Practical JavaSHOW104: Practical Java
SHOW104: Practical Java
Mark Myers
 
Jdbc introduction
Jdbc introductionJdbc introduction
Jdbc introduction
Rakesh Kumar Ray
 
JDBC.ppt
JDBC.pptJDBC.ppt
JDBC.ppt
ChagantiSahith
 

Similaire à Java Naming & Directory Services (20)

Jndi (1)
Jndi (1)Jndi (1)
Jndi (1)
 
Name Services
Name Services Name Services
Name Services
 
Name services
Name servicesName services
Name services
 
JNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLJNDI, JMS, JPA, XML
JNDI, JMS, JPA, XML
 
JNDI
JNDIJNDI
JNDI
 
Free Hibernate Tutorial | VirtualNuggets
Free Hibernate Tutorial  | VirtualNuggetsFree Hibernate Tutorial  | VirtualNuggets
Free Hibernate Tutorial | VirtualNuggets
 
Java Web Programming Using Cloud Platform: Module 3
Java Web Programming Using Cloud Platform: Module 3Java Web Programming Using Cloud Platform: Module 3
Java Web Programming Using Cloud Platform: Module 3
 
Java Web Programming [3/9] : Servlet Advanced
Java Web Programming [3/9] : Servlet AdvancedJava Web Programming [3/9] : Servlet Advanced
Java Web Programming [3/9] : Servlet Advanced
 
Session 1 Tp1
Session 1 Tp1Session 1 Tp1
Session 1 Tp1
 
Collaborative Cuisine's 1 Hour JNDI Cookbook
Collaborative Cuisine's 1 Hour JNDI CookbookCollaborative Cuisine's 1 Hour JNDI Cookbook
Collaborative Cuisine's 1 Hour JNDI Cookbook
 
Final Database Connectivity in JAVA.ppt
Final Database Connectivity in JAVA.pptFinal Database Connectivity in JAVA.ppt
Final Database Connectivity in JAVA.ppt
 
jdbc_presentation.ppt
jdbc_presentation.pptjdbc_presentation.ppt
jdbc_presentation.ppt
 
Hibernate training at HarshithaTechnologySolutions @ Nizampet
Hibernate training at HarshithaTechnologySolutions @ NizampetHibernate training at HarshithaTechnologySolutions @ Nizampet
Hibernate training at HarshithaTechnologySolutions @ Nizampet
 
Jdbc Lecture5
Jdbc Lecture5Jdbc Lecture5
Jdbc Lecture5
 
Overview Of JDBC
Overview Of JDBCOverview Of JDBC
Overview Of JDBC
 
Enterprise Spring
Enterprise SpringEnterprise Spring
Enterprise Spring
 
Spring jdbc dao
Spring jdbc daoSpring jdbc dao
Spring jdbc dao
 
SHOW104: Practical Java
SHOW104: Practical JavaSHOW104: Practical Java
SHOW104: Practical Java
 
Jdbc introduction
Jdbc introductionJdbc introduction
Jdbc introduction
 
JDBC.ppt
JDBC.pptJDBC.ppt
JDBC.ppt
 

Plus de Darryl Sherman

Il 01-search engines
Il 01-search enginesIl 01-search engines
Il 01-search engines
Darryl Sherman
 
Il 02-search requeststrings
Il 02-search requeststringsIl 02-search requeststrings
Il 02-search requeststrings
Darryl Sherman
 
Python unit testing
Python unit testingPython unit testing
Python unit testing
Darryl Sherman
 
PSD to HTML Conversion
PSD to HTML ConversionPSD to HTML Conversion
PSD to HTML Conversion
Darryl Sherman
 
Angular js filters and directives
Angular js filters and directivesAngular js filters and directives
Angular js filters and directives
Darryl Sherman
 
Node js lecture
Node js lectureNode js lecture
Node js lecture
Darryl Sherman
 

Plus de Darryl Sherman (6)

Il 01-search engines
Il 01-search enginesIl 01-search engines
Il 01-search engines
 
Il 02-search requeststrings
Il 02-search requeststringsIl 02-search requeststrings
Il 02-search requeststrings
 
Python unit testing
Python unit testingPython unit testing
Python unit testing
 
PSD to HTML Conversion
PSD to HTML ConversionPSD to HTML Conversion
PSD to HTML Conversion
 
Angular js filters and directives
Angular js filters and directivesAngular js filters and directives
Angular js filters and directives
 
Node js lecture
Node js lectureNode js lecture
Node js lecture
 

Dernier

BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 

Dernier (20)

BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 

Java Naming & Directory Services

  • 1. JNDI: Java Naming & Directory Services D. C. Sherman 1
  • 2. Rationale A fundamental element in every application is the capability to find and locate components and services. A client looking for a component service usually knows its name, but not its physical location. The component name corresponds to the actual name, typically much more difficult to remember and manage. A well-known naming service is provided in the Internet by DNS For applications, a naming directory service is the way to refer to a required service (e.g. a JDBC data source, a JMS connection factory, an EJB home interface, etc.)
  • 3. Terms A naming service is an application tht contains a set of objects, or references to objects, with corresponding names (usually easy to remember). Such correspondences a recalled bindings. A directory service allows for the association of attributes to a binding. Some popular directory implementations: LDAP (Lightweight Directory Access Protocol) NDS (Network Directory Service) AD (Active Directory) NIS+ (Network Information Service Plus)
  • 4. Overview JNDI (Java naming Directory Interface) provides Java clients with the capacity to access naming and directory services. JNDI is subdivided in the following packages: javax.naming javax.naming.directory javax.naming.event javax.naming.ldap javax.naming.spi
  • 5. Configuration  JNDI configuration can be quite a difficult task  Whenever we use an EJB server, JNDB is started automatically at he same time as the server itself. Such a server is usually already configured for the specific server.  Also the client applications using JNDI must be configured, which task is up to the programmer.
  • 6. Properties A client (object) uses JNDI to locate remote services, but JNDI might be a remote service as well. How, then, to locate a naming service without using a naming service? This can be done using environment properties. Some standard JNDI properties:  java.naming.factory.initial  java.naming.provider.url  java.naming.security.authorization etc.
  • 7. Context Context (interface) is used to deal with objects that have been bound to a JNDI name. javax.naming.Context contains methods to put objects in the naming service, and retrieve them. All the naming services have an access point, referenced as *InitalContext* in the JNDI (not thread-safe!): Select th eservice providerspecify requried configuration call the *InitialContext* constructor, with teh environment properties
  • 8. InitialContext InitialContext must be closed after its usage, as it happens for any resource, e.g. a JDBC connection. The best way to do it is to insert the invocation of the close method inside a finally block. The method getEnvironment of Context returns an Hashtable with all the active properties for the context. The method lookup(name) returns a reference to the Object corresponding to name. This way, also EJB "home factories" are looked up.
  • 9. Access As an EJB usually must not access files, how can an EJB access its configuration properties? A smart way to pass a configuration value to a bean is through its deployment descriptor, adding an env-entry tag, e.g.  <env-entry>  <description>what a beautiful entry!</description>  <env-entry-name>theNicestGirl</env-entry-name>  <env-entry-type>java.lang.String</env-entry-type>  <env-entry-value>”Anne”</env-entry-value>  </env-entry> An EJB accesses environment properties using an InitialContext object, and looking up the desired property by its name.