Java Naming and Directory Interface

25 750 8
Java Naming and Directory Interface

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Java Naming and Directory Interface

JNDIJNDIthangld@uit.edu.vnthangld@uit.edu.vnKhoa Mạng máy tính và Truyền thôngKhoa Mạng máy tính và Truyền thôngĐại học Công nghệ Thông tinĐại học Công nghệ Thông tinJava Naming and Directory Interface Java Naming and Directory Interface 2 Nội dungNội dungJNDIDịch vụ Naming và DirectoryKiến trúc JNDILập trình với JNDIJNDI trong J2EE/JavaEE JNDIJNDI Java Naming and Directory Interface 4 Đặt vấn đềĐặt vấn đềKết nối với CSDL (MySQL)Class.forName(“com.mysql.jdbc.Driver”);Connection conn = DriverManager.getConnection (“jdbc:mysql://localhost:3306/database”,“username”,“password”); Java Naming and Directory Interface 5 JNDIJNDIJNDI cung cấp một giao tiếp chuẩn thống nhất cho các ứng dụng Java truy cập các dịch vụ tên và thư mụcCung cấp giao tiếp chung cho các hệ thống naming/directory khác nhau: API chung cho LDAP, NIS, …Được sử dụng để thực hiện các thao tác trên hệ thống naming/directory. Ví dụ: định vị các thực thể: Users, Machines, Objects, Services (JDBC Data source, JMS), … Java Naming and Directory Interface 6 Dịch vụ NamingDịch vụ NamingDịch vụ Naming thực hiện các thao tác:Binding: liên kết một tên với một đối tượngLookup: tìm kiếm một đối tượng dựa vào tênMột số dịch vụ NamingRMI RegistryCORBA Naming ServiceDNS Java Naming and Directory Interface 7 Dịch vụ DirectoryDịch vụ DirectoryĐối tượng directory bao gồm nhiều thuộc tínhCho phép truy vấn các thuộc tính của một đối tượng Directory và tìm kiếm đối tượng dựa trên tập thuộc tínhMột số dịch vụ DirectoryLDAP - Lightweight Directory Access ProtocolNDS - Novell Directory ServiceNIS - Network Information System: directory service for SolarisMicrosoft Active Directory Kiến trúc JNDIKiến trúc JNDI Java Naming and Directory Interface 9 Kiến trúc JNDIKiến trúc JNDI Java Naming and Directory Interface 10 Kiến trúc JNDIKiến trúc JNDIApplication Programming Interface (API)API để chương trình truy xuất dịch vụ naming/directoryHệ thống các interface thống nhấtService Provider Interface (SPI)Được cung cấp bởi các nhà sản xuất nhằm hỗ trợ truy xuất dịch vụ naming/directory [...]... JNDI Java Naming and Directory Interface 11 Naming System Naming System  Naming System: là hệ thống liên kết các context  Namespace: chứa tất cả các tên trong hệ thống Naming System đó JNDI JNDI InitialContext InitialContext Java Naming and Directory Interface 16 InitialContext: Java Parameters InitialContext: Java Parameters #java -Djava .naming. factory.initial= com.sun.enterprise .naming. SerialInitContextFactory -Djava .naming. provider.url=jnp://193.205.194.162:1099 -Djava .naming. factory.url.pkgs=com.sun.enterprise .naming -Djava .naming. factory.state= com.sun.corba.ee.impl.presentation.rmi. ... ds.getConnection(“username”, “password”); conn.close(); Java Naming and Directory Interface 18 Các thao tác trên JNDI context Các thao tác trên JNDI context  bind() / rebind()  list()  lookup()  rename() JNDI & JavaEE JNDI & JavaEE Java Naming and Directory Interface 9 Kiến trúc JNDI Kiến trúc JNDI Java Naming and Directory Interface 13 InitialContext InitialContext  Vị trí bắt... RMIInterface t = (RMIInterface) ctx.lookup(“JndiName”); Java Naming and Directory Interface 14 InitialContext: Java Code InitialContext: Java Code Properties props = new Properties(); props.setProperty(" ;java. naming. factory.initial", "com.sun.enterprise .naming. SerialInitContextFactory"); props.setProperty(" ;java. naming. factory.url.pkgs", "com.sun.enterprise .naming& quot;); props.setProperty(" ;java. naming. factory.state",.. .Java Naming and Directory Interface 2 Nội dung Nội dung  JNDI  Dịch vụ Naming Directory  Kiến trúc JNDI  Lập trình với JNDI  JNDI trong J2EE/JavaEE Java Naming and Directory Interface 20 JNDI và RMI JNDI và RMI Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY,... -Djava .naming. factory.initial= com.sun.enterprise .naming. SerialInitContextFactory -Djava .naming. provider.url=jnp://193.205.194.162:1099 -Djava .naming. factory.url.pkgs=com.sun.enterprise .naming -Djava .naming. factory.state= com.sun.corba.ee.impl.presentation.rmi. JNDIStateFactoryImpl <file.class> Java Naming and Directory Interface 21 JNDI và JDBC JNDI và JDBC  JDBC Data source  Hỗ trợ connection... thao tác trên naming directory  Để có thể định vị sử dụng một InitialContext, cần cung cấp một số thông tin JNDI  Địa chỉ IP của server  Cổng dịch vụ  Vị trí bắt đầu trên JNDI tree  Có thể phải cung cấp thêm username/password đối với các dịch vụ naming/ directory cần chứng thực Java Naming and Directory Interface 24 JNDI trong J2EE/JavaEE JNDI trong J2EE/JavaEE  Các J2EE/JavaEE servers... "com.sun.enterprise .naming& quot;); props.setProperty(" ;java. naming. factory.state", "com.sun.corba.ee.impl.presentation.rmi. JNDIStateFactoryImpl"); props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost"); props.setProperty("org.omg.CORBA.ORBInitialPort", "3700"); InitialContext ic = new InitialContext(props); Q&A Q&A Java Naming and Directory Interface 7 Dịch vụ Directory Dịch... vụ Directory Dịch vụ Directory  Đối tượng directory bao gồm nhiều thuộc tính  Cho phép truy vấn các thuộc tính của một đối tượng Directory và tìm kiếm đối tượng dựa trên tập thuộc tính  Một số dịch vụ Directory  LDAP - Lightweight Directory Access Protocol  NDS - Novell Directory Service  NIS - Network Information System: directory service for Solaris  Microsoft Active Directory Lập trình... Naming and Directory Interface 24 JNDI trong J2EE/JavaEE JNDI trong J2EE/JavaEE  Các J2EE/JavaEE servers đều cài đặt JNDI  Hỗ trợ:  Tìm kiếm các EJB.  Kết nối đến các tài nguyên  JDBC DataSource  Java Message Service (JMS) objects  Xác định và truy xuất các đối tượng transaction (JTS) . Công nghệ Thông tinJava Naming and Directory Interface Java Naming and Directory Interface 2 Nội dungNội dungJNDIDịch vụ Naming và Directory Kiến trúc. số dịch vụ Naming RMI RegistryCORBA Naming ServiceDNS Java Naming and Directory Interface 7 Dịch vụ DirectoryDịch vụ Directory Đối tượng directory bao

Ngày đăng: 13/09/2012, 11:16

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan