Java Naming and Directory Interface JNDI - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

Java Naming and Directory Interface JNDI

Description:

xmlns='http://java.sun.com/xml/ns/j2ee' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://java.sun.com/xml/ns/j2ee ... – PowerPoint PPT presentation

Number of Views:345
Avg rating:3.0/5.0
Slides: 32
Provided by: pier71
Category:

less

Transcript and Presenter's Notes

Title: Java Naming and Directory Interface JNDI


1
Java Naming and Directory Interface (JNDI)
Context jndiContext getInitialContext() Objec
t ref jndiContext.lookup(CabinHomeRemote) Cab
inHomeRemote home (CabinHomeRemote)
PortableRemoteObject.narrow(ref,
CabinHomeRemote.class) CabinRemote cabin_1
home.create(new Integer(1)) cabin_1.setName(Mast
er Suite) cabin_1.setDeckLevel(1)
2
Java Naming and Directory Interface (JNDI)
JNDI is a standard Java package that provides a
uniform API for accessing a wide range of
services.
  • virtual
  • dynamic.

3
The Remote Client API (Application Program
Interface)
client
EJB server
EJB server
EJB container
EJB container
4
The Remote Client API (Application Program
Interface)
client
EJB server
EJB server
EJB container
EJB container
5
The Remote Client API (Application Program
Interface)
Remote Client API
Java RMI-IIOP
Java RMI
CORBA
IDL
6
The Remote Client API (Application Program
Interface)
Remote Client API
Java RMI-IIOP
Java RMI
CORBA
IDL
7
Java RMI-IIOP return types and parameters
  • Return types and parameters
  • declared (checked by the compiler)
  • actual (checked at runtime).
  • primitives (byte, boolean, char, )
  • Java serializable types (java.io.Serializable)
  • Java RMI remote types (java.rmi.Remote).

8
Java RMI-IIOP return types and parameters
remote reference
client
original serializable object
EJB object
bean instance
before a serializable object is passed, one copy
resides on the client
9
Java RMI-IIOP return types and parameters
remote reference
client
original serializable object
EJB object
after a serializable object is passed, copies
reside on both the client and the bean instance.
Changes to one copy are not reflected in the
other.
bean instance
10
Java RMI-IIOP return types and parameters
client application
bean instance
EJB object
remote reference
A
Pass A to B
B
original remote reference
A
EJB object
bean instance
11
Java RMI-IIOP return types and parameters
client application
bean instance
EJB object
remote reference
A
B
original remote reference
A
copy of remote reference
EJB object
bean instance
12
Java RMI-IIOP overloading restrictions
Remote_interface_X
void bar(String s)
Remote_interface_Y
void bar(long l)
Remote_interface_Z
void bar(byte b)
13
Java RMI-IIOP overloading restrictions
Remote_interface_A
Remote_interface_B
void foo(int i)
void foo(double d)
Remote_interface_C
14
Java RMI-IIOP narrow
import javax.rmi.PortableRemoteObject javax.nam
ing.Context jndiContext Object ref
jndiContext.lookup(CabinHomeRemote) CabinHomeRe
mote home (CabinHomeRemote)
PortableRemoteObject.narrow(ref,
CabinHomeRemote.class)
15
The remote home interface
16
The remote home interface bean metadata
EJBHome.getEJBMetaData()
  • remote home interface
  • remote interface
  • primary key
  • entity/session bean.

17
The remote home interface creating and finding
beans
package com.titan.cabin import
java.rmi.RemoteException import
javax.ejb.CreateException import
javax.ejb.FinderException public interface
CabinHomeRemote extends javax.ejb.EJBHome
public CabinRemote create(Integer id)
throws CreateException, RemoteException
public CabinRemote findByPrimaryKey(Integer pk)
throws FinderException, RemoteException
18
The remote home interface (your own) home methods
but only for entity beans.
19
The remote interface
EJB home
20
The remote interface primary key
EJBObject.getPrimaryKey()
21
The remote interface comparing beans for identity
EJBObject.isIdentical() Object.equal()
22
The remote interface remove
EJBObject.remove()
23
The remote interface the enterprise bean handle
EJBObject.getHandle() returns javax.ejb.Handle
A Handle is a serializable reference to the
remote EJB object.
javax.ejb.HomeHandle
24
The local client API
client
EJB server
EJB server
EJB container
EJB container
25
The local client API
client
EJB server
EJB server
EJB container
EJB container
26
The local interface
getEJBLocalHome() returns a LocalHome object
getPrimaryKey() returns the primary key
isIdentical() compares two local EJB objects
remove() remove the EJB
27
The local home interface
create()
findByPrimaryKey()
remove()
28
Deployment descriptor
ltejb-jar xmlns"http//java.sun.com/xml/ns/j
2ee" xmlnsxsi"http//www.w3.org/2001/XMLSch
ema-instance" xsischemaLocation"http//java
.sun.com/xml/ns/j2ee
http//java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
version"2.1"gt ltenterprise-beansgt
ltentitygt ltejb-namegtCabinEJBlt/ejb-namegt
lthomegtcom.titan. CabinHomeRemotelt/homegt
ltremotegtcom.titan.CabinRemotelt/remotegt
ltlocal-homegtcom.titan.cabin.CabinHomeLocallt/local-
homegt ltlocalgtcom.titan.cabin.CabinLocallt/loc
algt ltejb-classgtcom.titan.CabinBeanlt/ejb-clas
sgt ltpersistence-typegtContainerlt/persistence-
typegt
29
Deployment descriptor
ltejb-jar xmlns"http//java.sun.com/xml/ns/j
2ee" xmlnsxsi"http//www.w3.org/2001/XMLSch
ema-instance" xsischemaLocation"http//java
.sun.com/xml/ns/j2ee
http//java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
version"2.1"gt ltenterprise-beansgt
ltentitygt ltejb-namegtCabinEJBlt/ejb-namegt
lthomegtcom.titan. CabinHomeRemotelt/homegt
ltremotegtcom.titan.CabinRemotelt/remotegt
ltlocal-homegtcom.titan.cabin.CabinHomeLocallt/local-
homegt ltlocalgtcom.titan.cabin.CabinLocallt/loc
algt ltejb-classgtcom.titan.CabinBeanlt/ejb-clas
sgt ltpersistence-typegtContainerlt/persistence-
typegt
30
Local vs. Remote
Local Remote
faster slower
(to other server without rewriting the code)
31
Local vs. Remote
Local Remote
faster slower
not movable movable
object arguments object arguments passed
by reference are copied
(dangerous!!!)
Write a Comment
User Comments (0)
About PowerShow.com