des enterprise beans - Département Informatique
des enterprise beans - Département Informatique
des enterprise beans - Département Informatique
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Un bean session pour faire vos courses<br />
Descripteur de déploiement XML du bean session cart<br />
<br />
cart<br />
CartHome<br />
Cart<br />
CartBean<br />
Stateful<br />
Container<br />
<br />
<br />
<br />
<br />
<br />
cart<br />
*<br />
<br />
NotSupported<br />
<br />
<br />
<br />
cart<br />
purchase<br />
<br />
Required<br />
<br />
<br />
<br />
Le programme CartClient est l’application client qui utilise l’<strong>enterprise</strong><br />
bean Cart. Sa routine main() inclut tous les éléments que toutes les<br />
applications client d’<strong>enterprise</strong> bean doivent implémenter. Elle démontre<br />
comment<br />
• Utiliser JNDI pour localiser l’interface locale du bean.<br />
• Utiliser la méthode create() de l’interface locale pour créer un nouvel<br />
objet Cart distant.<br />
• Invoquer la méthode déclarée dans l’objet Cart.<br />
public static void main(String] args) throws Exception {<br />
// obtient un contexte JNDI en utilisant le service d’annuaire<br />
javax.naming.Context context = new javax.naming.InitialContext();<br />
Object objref = context.lookup("cart");<br />
CartHome home = (CartHome)javax.rmi.PortableRemoteObject.narrow(objref,<br />
CartHome.class);<br />
Cart cart;<br />
{<br />
String cardHolderName = "Jack B. Quick";<br />
String creditCardNumber = "1234-5678-9012-3456";<br />
Date expirationDate = new GregorianCalendar(2001,<br />
Calendar.JULY,1).getTime();<br />
cart = home home.create(cardHolderName, creditCardNumber, expirationDate);<br />
}<br />
D é veloppement <strong>des</strong> <strong>beans</strong> session 9-19