SlideShare une entreprise Scribd logo
1  sur  27
SCOT




         Java Naming and Directory
              Interface (JNDI)
                   Vijay Bhatt
              NCST Juhu, Mumbai




                (c)CDAC(Formerly NCST)
  JNDI                                1
SCOT


                     Agenda
  •    What is JNDI?
  •    Naming and Directory Services
  •    Naming Concepts
  •    Issues
  •    JNDI Architecture
  •    Programming with JNDI
  •    Role of JNDI in J2EE

                   (c)CDAC(Formerly NCST)
  JNDI                                   2
SCOT




  • Class.forName("com.microsoft.jdbc.
    sqlserver.SQLServerDriver");

  • cnn = DriverManager.getConnection
    ("jdbc:microsoft:sqlserver://siddh
     ant:1433",“username",“password");

                (c)CDAC(Formerly NCST)
  JNDI                                3
SCOT




  • Context ctx = new InitialContext();
  • DataSource ds =
     (DataSource)ctx.lookup(“myname”);
  • Connection con =
    ds.getConnection(“abc”,”***”);



                (c)CDAC(Formerly NCST)
  JNDI                                4
SCOT


                    JNDI

   Java Naming and Directory Interface
   (JNDI) provides a standard interface for
   Java applications to access naming and
   directory services.



                (c)CDAC(Formerly NCST)
  JNDI                                5
SCOT


             Naming Service
  • Naming Service performs:
    – Binding: Associating names with objects
    – Lookup: Find an object based on a name.
        • Examples: DNS and File systems
  • Examples:
    – DNS
    – Filesystems
                (c)CDAC(Formerly NCST)
  JNDI                                6
SCOT


             Directory Service
  • Directory is a naming service that stores
    objects with attributes.
    – Usernames and passwords etc stored in
    attrs.
  • Tree like structure



                 (c)CDAC(Formerly NCST)
  JNDI                                 7
SCOT


                   Names
  • Atomic name is a indivisible component of
    a
    name
   – in /etc/fstab, etc and fstab are atomic
    names.
  • Compound name is zero or more atomic
    names put together.
    – /etc/fstab is a compound name
                (c)CDAC(Formerly NCST)
  JNDI                                8
SCOT

                      Binding
  • Binding is an association of a name with an object.
    – Filename “autoexec.bat” has a binding to some
         file data on the disk.
    – “c:windows” foldername is bound to a folder on
    your drive.
  • Compound name such as /usr/people/ed/.cshrc
    consists of multiple bindings, one to usr, one to
    people, one to ed, and one to .cshrc.


                   (c)CDAC(Formerly NCST)
  JNDI                                   9
SCOT

                      Context
  • Contains zero or more bindings.
    – Each binding has a distinct atomic name.
  • /etc contains files named mtab and exports.
  • The /etc folder is a context containing bindings
    with atomic names mtab and exports.
  • mtab and exports are each bound to a file on
    the disk.



                   (c)CDAC(Formerly NCST)
  JNDI                                   10
SCOT

                 Sub-Context

  • /usr – CONTEXT
     – /usr/people – SUB-CONTEXT
     – /usr/bin – SUB-CONTEXT
     – /usr/local – SUB-CONTEXT
  • Each atomic name is bound to a sub-context the
    subfolder.
  • Subcontext are full-fledged contexts
  • Can contain more name-object bindings, such as
    other files or other folders.
                  (c)CDAC(Formerly NCST)
  JNDI                                  11
SCOT


  Naming System and Namespaces
  • Naming system: A connected set of
    contexts.
  • Namespace: all the names contained within
    that naming system.




                (c)CDAC(Formerly NCST)
  JNDI                                12
SCOT


               InitialContext
  • Starting point for exploring a namespace.
  • Starting point for performing all naming
    and
    directory operations.




                 (c)CDAC(Formerly NCST)
  JNDI                                 13
SCOT


                      Issues
  • Many naming and directory products.
    – Netscape Directory Server
    – MicrosoftActiveDirectory
  • Various naming and directory protocols: Each
    directory standard has a different protocol for
    accessing the directory.
    – Lightweight Directory Access Protocol (LDAP)
    – Network Information System (NIS)
    – Novell’s Network Directory System (NDS)
  • EveryDS has it’s ownAPI.
                  (c)CDAC(Formerly NCST)
  JNDI                                  14
SCOT


               Introducing JNDI
  • Standard interface to interact with naming and
    directory systems.
  • For Java programs.
  • Provides common interface to disparate
    directories: Same API for LDAP and NIS NDS.
  • Used in EJB, RMI-IIOP, JDBC for operations like
    locating entities i.e. Users, Machines (e.g. printer),
    Objects, Services (e.g. datasource) etc.
                    (c)CDAC(Formerly NCST)
  JNDI                                    15
SCOT


             JNDI Architecture
  • The client API
     – Allow Java code to perform directory
       operations.
  • The Service Provider: Driver
  • The Service Provider Interface (SPI)
    – An interface to which naming and directory
      service vendors can plug in.

                   (c)CDAC(Formerly NCST)
  JNDI                                   16
SCOT




         (c)CDAC(Formerly NCST)
  JNDI                         17
SCOT


               JNDI Packages
  The JNDI comprises of 5 packages
  • javax.naming – Contains classes and interfaces
    for accessing naming services
  • javax.naming.directory – Extends javax.naming
    and provides functionality to access directory
    services in addition to naming services



                  (c)CDAC(Formerly NCST)
  JNDI                                  18
SCOT


                JNDI Packages
  • javax.naming.event – Classes and interfaces for
    supporting event notification in naming and
    directory services
  • javax.naming.ldap – Classes and interfaces for
    using features that are specific to LDAP v3 that
    are not already covered by the more generic
    javax.naming.directory
  • javax.naming.spi – Vendors develop their
    naming/directory services conforming to SPI.
    Applications can then access these services
    through the JNDI API
                   (c)CDAC(Formerly NCST)
  JNDI                                   19
SCOT
           InitialContextFactory
  • Used to acquire an initial context
  • Implementation of the JNDI driver: Knows the
     specific semantics of a particular directory
    structure.
  • bootstrapping.
  • Necessary information for JNDI to acquire that
     initial context.
     – The IP address of the J2EE server
     – The port number that the J2EE server accepts
     – Any username/password necessary to use the
     J2EE server. (c)CDAC(Formerly NCST)
  JNDI                                    20
SCOT
    javax.naming.Context ctx =
   new javax.naming.InitialContext
  (System.getProperties());

 java
   -Djava.naming.factory.initial=
   com.sun.jndi.fscontext.RefFSContextFactory
  -Djava.naming.provider.url=
   file:c:examples.InitCtx
 class of the JNDI driver
 • provider URL: URL that the service provider
   accepts for bootstrapping.
                  (c)CDAC(Formerly NCST)
  JNDI                                  21
SCOT

          Other JNDI operations
            Methods invoked on a Context
  • list() - list of contents available at the context.
    – names of objects bound to the JNDI tree
    – subcontexts.
  • lookup() - look up objects bound to the JNDI tree
    – Return type is driver specific
          • RMI-IIOP java.rmi.Remote
          • file system java.io.File

                    (c)CDAC(Formerly NCST)
  JNDI                                    22
SCOT
• rename() - give a new name to a context
   – c:temp to c:tmp
• createSubcontext() - create a subcontext at the
  context
   – c:foobar at the folder c:foo.
• destroySubcontext() - destroy a subcontext of the
   context
   – Destroy c:foobar from the folder c:foo.
• bind() – associates a name to a content and stores
   it at the Context
   – JNDI drivers accept different parameters to bind()
• rebind() - forces a bind even if some object is
   already bound to (c)CDAC(Formerly NCST)
                      the name.
  JNDI                                     23
SCOT


                Binding
  import javax.naming.*;
       public class Startup {
       public static void main(String
    args[]) throws Exception {
       AccountImpl acct_impl = new
    AccountImpl();
       Context ctx = new
    InitialContext
    (System.getProperties());
       ctx.rebind(“myname",
    acct_impl);(c)CDAC(Formerly NCST)
  JNDI                               24
       }
SCOT


             Looking Up
  import javax.naming.*;
   import java.rmi.*;
   public class Client {
   public static void main (String[]
    args) throws Exception { Context
    ctx = new InitialContext
    (System.getProperties());
   Object remoteObject =
    ctx.lookup(“myname");
    Account account = (Account)
              (c)CDAC(Formerly NCST)
  JNDI                              25
    javax.rmi.PortableRemoteObject.na
SCOT

          Role of JNDI in J2EE
  • J2EE servers have a JNDI implementation.
  • Used to Look up beans.
  • Connect to resource factories
     – JDBC DataSource
     – Java Message Service (JMS) drivers
  • Acquiring a reference to the Java
    Transaction API’s (JTA) UserTransaction
    interface.
                  (c)CDAC(Formerly NCST)
  JNDI                                  26
SCOT


                References
  • Mastering Enterprise JavaBeans by Ed
    Roman et. al. (Wiley)
  • JNDI Tutorial on java.sun.com
  • Java Server Programming J2EE Edition –
    Volume 1 – Wrox.
  • Java Enterprise in a nutshell – David
    Flanagan et. Al. – O’reilly
                (c)CDAC(Formerly NCST)
  JNDI                                27

Contenu connexe

Tendances

Android styles and themes
Android   styles and themesAndroid   styles and themes
Android styles and themesDeepa Rani
 
Angular 8
Angular 8 Angular 8
Angular 8 Sunil OS
 
Developing an ASP.NET Web Application
Developing an ASP.NET Web ApplicationDeveloping an ASP.NET Web Application
Developing an ASP.NET Web ApplicationRishi Kothari
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net frameworkArun Prasad
 
Collections - Lists, Sets
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets Hitesh-Java
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepGuo Albert
 
Java Threads Tutorial | Multithreading In Java Tutorial | Java Tutorial For B...
Java Threads Tutorial | Multithreading In Java Tutorial | Java Tutorial For B...Java Threads Tutorial | Multithreading In Java Tutorial | Java Tutorial For B...
Java Threads Tutorial | Multithreading In Java Tutorial | Java Tutorial For B...Edureka!
 
Types of Drivers in JDBC
Types of Drivers in JDBCTypes of Drivers in JDBC
Types of Drivers in JDBCHemant Sharma
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentationguest11106b
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate pptAneega
 
Data Persistence in Android with Room Library
Data Persistence in Android with Room LibraryData Persistence in Android with Room Library
Data Persistence in Android with Room LibraryReinvently
 
JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART IOXUS 20
 

Tendances (20)

Android styles and themes
Android   styles and themesAndroid   styles and themes
Android styles and themes
 
Angular 8
Angular 8 Angular 8
Angular 8
 
Developing an ASP.NET Web Application
Developing an ASP.NET Web ApplicationDeveloping an ASP.NET Web Application
Developing an ASP.NET Web Application
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
 
History of java'
History of java'History of java'
History of java'
 
Collections - Lists, Sets
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
 
Java Threads Tutorial | Multithreading In Java Tutorial | Java Tutorial For B...
Java Threads Tutorial | Multithreading In Java Tutorial | Java Tutorial For B...Java Threads Tutorial | Multithreading In Java Tutorial | Java Tutorial For B...
Java Threads Tutorial | Multithreading In Java Tutorial | Java Tutorial For B...
 
Java awt
Java awtJava awt
Java awt
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Types of Drivers in JDBC
Types of Drivers in JDBCTypes of Drivers in JDBC
Types of Drivers in JDBC
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
Data Persistence in Android with Room Library
Data Persistence in Android with Room LibraryData Persistence in Android with Room Library
Data Persistence in Android with Room Library
 
JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART I
 
Maven ppt
Maven pptMaven ppt
Maven ppt
 

Similaire à Jndi

2001: JNDI Its all in the Context
2001:  JNDI Its all in the Context2001:  JNDI Its all in the Context
2001: JNDI Its all in the ContextRussell Castagnaro
 
Java Future S Ritter
Java Future S RitterJava Future S Ritter
Java Future S Rittercatherinewall
 
Memory Analysis of the Dalvik (Android) Virtual Machine
Memory Analysis of the Dalvik (Android) Virtual MachineMemory Analysis of the Dalvik (Android) Virtual Machine
Memory Analysis of the Dalvik (Android) Virtual MachineAndrew Case
 
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 3IMC Institute
 
Jump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on DatabricksJump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on DatabricksDatabricks
 
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 AdvancedIMC Institute
 
Cassandra Java APIs Old and New – A Comparison
Cassandra Java APIs Old and New – A ComparisonCassandra Java APIs Old and New – A Comparison
Cassandra Java APIs Old and New – A Comparisonshsedghi
 
Oracle RAC and Docker: The Why and How
Oracle RAC and Docker: The Why and HowOracle RAC and Docker: The Why and How
Oracle RAC and Docker: The Why and HowSeth Miller
 
Data Types/Structures in DivConq
Data Types/Structures in DivConqData Types/Structures in DivConq
Data Types/Structures in DivConqeTimeline, LLC
 
.NET Cloud-Native Bootcamp Minneapolis
.NET Cloud-Native Bootcamp Minneapolis.NET Cloud-Native Bootcamp Minneapolis
.NET Cloud-Native Bootcamp MinneapolisVMware Tanzu
 
Docker 1.11 Presentation
Docker 1.11 PresentationDocker 1.11 Presentation
Docker 1.11 PresentationSreenivas Makam
 
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtugVk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtugketan_patel25
 
Introduction to Apache Cassandra
Introduction to Apache CassandraIntroduction to Apache Cassandra
Introduction to Apache CassandraRobert Stupp
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetesDongwon Kim
 
Vijfhart thema-avond-oracle-12c-new-features
Vijfhart thema-avond-oracle-12c-new-featuresVijfhart thema-avond-oracle-12c-new-features
Vijfhart thema-avond-oracle-12c-new-featuresmkorremans
 
Introduction into Docker Containers, the Oracle Platform and the Oracle (Nati...
Introduction into Docker Containers, the Oracle Platform and the Oracle (Nati...Introduction into Docker Containers, the Oracle Platform and the Oracle (Nati...
Introduction into Docker Containers, the Oracle Platform and the Oracle (Nati...Lucas Jellema
 

Similaire à Jndi (20)

Jdbc
JdbcJdbc
Jdbc
 
2001: JNDI Its all in the Context
2001:  JNDI Its all in the Context2001:  JNDI Its all in the Context
2001: JNDI Its all in the Context
 
Java Future S Ritter
Java Future S RitterJava Future S Ritter
Java Future S Ritter
 
Memory Analysis of the Dalvik (Android) Virtual Machine
Memory Analysis of the Dalvik (Android) Virtual MachineMemory Analysis of the Dalvik (Android) Virtual Machine
Memory Analysis of the Dalvik (Android) Virtual Machine
 
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
 
Jump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on DatabricksJump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on Databricks
 
Intro to Apache Spark
Intro to Apache SparkIntro to Apache Spark
Intro to Apache Spark
 
Intro to Apache Spark
Intro to Apache SparkIntro to Apache Spark
Intro to Apache Spark
 
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
 
Cassandra Java APIs Old and New – A Comparison
Cassandra Java APIs Old and New – A ComparisonCassandra Java APIs Old and New – A Comparison
Cassandra Java APIs Old and New – A Comparison
 
Oracle RAC and Docker: The Why and How
Oracle RAC and Docker: The Why and HowOracle RAC and Docker: The Why and How
Oracle RAC and Docker: The Why and How
 
20170126 big data processing
20170126 big data processing20170126 big data processing
20170126 big data processing
 
Data Types/Structures in DivConq
Data Types/Structures in DivConqData Types/Structures in DivConq
Data Types/Structures in DivConq
 
.NET Cloud-Native Bootcamp Minneapolis
.NET Cloud-Native Bootcamp Minneapolis.NET Cloud-Native Bootcamp Minneapolis
.NET Cloud-Native Bootcamp Minneapolis
 
Docker 1.11 Presentation
Docker 1.11 PresentationDocker 1.11 Presentation
Docker 1.11 Presentation
 
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtugVk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtug
 
Introduction to Apache Cassandra
Introduction to Apache CassandraIntroduction to Apache Cassandra
Introduction to Apache Cassandra
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetes
 
Vijfhart thema-avond-oracle-12c-new-features
Vijfhart thema-avond-oracle-12c-new-featuresVijfhart thema-avond-oracle-12c-new-features
Vijfhart thema-avond-oracle-12c-new-features
 
Introduction into Docker Containers, the Oracle Platform and the Oracle (Nati...
Introduction into Docker Containers, the Oracle Platform and the Oracle (Nati...Introduction into Docker Containers, the Oracle Platform and the Oracle (Nati...
Introduction into Docker Containers, the Oracle Platform and the Oracle (Nati...
 

Dernier

Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptxDhatriParmar
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptxJonalynLegaspi2
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleCeline George
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptxmary850239
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 

Dernier (20)

prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptx
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP Module
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 

Jndi

  • 1. SCOT Java Naming and Directory Interface (JNDI) Vijay Bhatt NCST Juhu, Mumbai (c)CDAC(Formerly NCST) JNDI 1
  • 2. SCOT Agenda • What is JNDI? • Naming and Directory Services • Naming Concepts • Issues • JNDI Architecture • Programming with JNDI • Role of JNDI in J2EE (c)CDAC(Formerly NCST) JNDI 2
  • 3. SCOT • Class.forName("com.microsoft.jdbc. sqlserver.SQLServerDriver"); • cnn = DriverManager.getConnection ("jdbc:microsoft:sqlserver://siddh ant:1433",“username",“password"); (c)CDAC(Formerly NCST) JNDI 3
  • 4. SCOT • Context ctx = new InitialContext(); • DataSource ds = (DataSource)ctx.lookup(“myname”); • Connection con = ds.getConnection(“abc”,”***”); (c)CDAC(Formerly NCST) JNDI 4
  • 5. SCOT JNDI Java Naming and Directory Interface (JNDI) provides a standard interface for Java applications to access naming and directory services. (c)CDAC(Formerly NCST) JNDI 5
  • 6. SCOT Naming Service • Naming Service performs: – Binding: Associating names with objects – Lookup: Find an object based on a name. • Examples: DNS and File systems • Examples: – DNS – Filesystems (c)CDAC(Formerly NCST) JNDI 6
  • 7. SCOT Directory Service • Directory is a naming service that stores objects with attributes. – Usernames and passwords etc stored in attrs. • Tree like structure (c)CDAC(Formerly NCST) JNDI 7
  • 8. SCOT Names • Atomic name is a indivisible component of a name – in /etc/fstab, etc and fstab are atomic names. • Compound name is zero or more atomic names put together. – /etc/fstab is a compound name (c)CDAC(Formerly NCST) JNDI 8
  • 9. SCOT Binding • Binding is an association of a name with an object. – Filename “autoexec.bat” has a binding to some file data on the disk. – “c:windows” foldername is bound to a folder on your drive. • Compound name such as /usr/people/ed/.cshrc consists of multiple bindings, one to usr, one to people, one to ed, and one to .cshrc. (c)CDAC(Formerly NCST) JNDI 9
  • 10. SCOT Context • Contains zero or more bindings. – Each binding has a distinct atomic name. • /etc contains files named mtab and exports. • The /etc folder is a context containing bindings with atomic names mtab and exports. • mtab and exports are each bound to a file on the disk. (c)CDAC(Formerly NCST) JNDI 10
  • 11. SCOT Sub-Context • /usr – CONTEXT – /usr/people – SUB-CONTEXT – /usr/bin – SUB-CONTEXT – /usr/local – SUB-CONTEXT • Each atomic name is bound to a sub-context the subfolder. • Subcontext are full-fledged contexts • Can contain more name-object bindings, such as other files or other folders. (c)CDAC(Formerly NCST) JNDI 11
  • 12. SCOT Naming System and Namespaces • Naming system: A connected set of contexts. • Namespace: all the names contained within that naming system. (c)CDAC(Formerly NCST) JNDI 12
  • 13. SCOT InitialContext • Starting point for exploring a namespace. • Starting point for performing all naming and directory operations. (c)CDAC(Formerly NCST) JNDI 13
  • 14. SCOT Issues • Many naming and directory products. – Netscape Directory Server – MicrosoftActiveDirectory • Various naming and directory protocols: Each directory standard has a different protocol for accessing the directory. – Lightweight Directory Access Protocol (LDAP) – Network Information System (NIS) – Novell’s Network Directory System (NDS) • EveryDS has it’s ownAPI. (c)CDAC(Formerly NCST) JNDI 14
  • 15. SCOT Introducing JNDI • Standard interface to interact with naming and directory systems. • For Java programs. • Provides common interface to disparate directories: Same API for LDAP and NIS NDS. • Used in EJB, RMI-IIOP, JDBC for operations like locating entities i.e. Users, Machines (e.g. printer), Objects, Services (e.g. datasource) etc. (c)CDAC(Formerly NCST) JNDI 15
  • 16. SCOT JNDI Architecture • The client API – Allow Java code to perform directory operations. • The Service Provider: Driver • The Service Provider Interface (SPI) – An interface to which naming and directory service vendors can plug in. (c)CDAC(Formerly NCST) JNDI 16
  • 17. SCOT (c)CDAC(Formerly NCST) JNDI 17
  • 18. SCOT JNDI Packages The JNDI comprises of 5 packages • javax.naming – Contains classes and interfaces for accessing naming services • javax.naming.directory – Extends javax.naming and provides functionality to access directory services in addition to naming services (c)CDAC(Formerly NCST) JNDI 18
  • 19. SCOT JNDI Packages • javax.naming.event – Classes and interfaces for supporting event notification in naming and directory services • javax.naming.ldap – Classes and interfaces for using features that are specific to LDAP v3 that are not already covered by the more generic javax.naming.directory • javax.naming.spi – Vendors develop their naming/directory services conforming to SPI. Applications can then access these services through the JNDI API (c)CDAC(Formerly NCST) JNDI 19
  • 20. SCOT InitialContextFactory • Used to acquire an initial context • Implementation of the JNDI driver: Knows the specific semantics of a particular directory structure. • bootstrapping. • Necessary information for JNDI to acquire that initial context. – The IP address of the J2EE server – The port number that the J2EE server accepts – Any username/password necessary to use the J2EE server. (c)CDAC(Formerly NCST) JNDI 20
  • 21. SCOT javax.naming.Context ctx = new javax.naming.InitialContext (System.getProperties()); java -Djava.naming.factory.initial= com.sun.jndi.fscontext.RefFSContextFactory -Djava.naming.provider.url= file:c:examples.InitCtx class of the JNDI driver • provider URL: URL that the service provider accepts for bootstrapping. (c)CDAC(Formerly NCST) JNDI 21
  • 22. SCOT Other JNDI operations Methods invoked on a Context • list() - list of contents available at the context. – names of objects bound to the JNDI tree – subcontexts. • lookup() - look up objects bound to the JNDI tree – Return type is driver specific • RMI-IIOP java.rmi.Remote • file system java.io.File (c)CDAC(Formerly NCST) JNDI 22
  • 23. SCOT • rename() - give a new name to a context – c:temp to c:tmp • createSubcontext() - create a subcontext at the context – c:foobar at the folder c:foo. • destroySubcontext() - destroy a subcontext of the context – Destroy c:foobar from the folder c:foo. • bind() – associates a name to a content and stores it at the Context – JNDI drivers accept different parameters to bind() • rebind() - forces a bind even if some object is already bound to (c)CDAC(Formerly NCST) the name. JNDI 23
  • 24. SCOT Binding import javax.naming.*; public class Startup { public static void main(String args[]) throws Exception { AccountImpl acct_impl = new AccountImpl(); Context ctx = new InitialContext (System.getProperties()); ctx.rebind(“myname", acct_impl);(c)CDAC(Formerly NCST) JNDI 24 }
  • 25. SCOT Looking Up import javax.naming.*; import java.rmi.*; public class Client { public static void main (String[] args) throws Exception { Context ctx = new InitialContext (System.getProperties()); Object remoteObject = ctx.lookup(“myname"); Account account = (Account) (c)CDAC(Formerly NCST) JNDI 25 javax.rmi.PortableRemoteObject.na
  • 26. SCOT Role of JNDI in J2EE • J2EE servers have a JNDI implementation. • Used to Look up beans. • Connect to resource factories – JDBC DataSource – Java Message Service (JMS) drivers • Acquiring a reference to the Java Transaction API’s (JTA) UserTransaction interface. (c)CDAC(Formerly NCST) JNDI 26
  • 27. SCOT References • Mastering Enterprise JavaBeans by Ed Roman et. al. (Wiley) • JNDI Tutorial on java.sun.com • Java Server Programming J2EE Edition – Volume 1 – Wrox. • Java Enterprise in a nutshell – David Flanagan et. Al. – O’reilly (c)CDAC(Formerly NCST) JNDI 27