1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package clientejb3;
import buss.SnBeanRemote;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import mapped.Customer;
import mapped.Dept;
import mapped.Product;
/**
*
* @author liquideshark
*/
public class Scott {
/**
* @param args the command line arguments
*/
public static List getCustom(){
Properties props = new Properties();
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
SnBeanRemote rcom =null;
try {
InitialContext ic = new InitialContext(props);
rcom = (SnBeanRemote) ic.lookup("buss.SnBeanRemote");
//List allCust = rcom.getCustomers();
} catch (NamingException ex) {
Logger.getLogger(Exemple2.class.getName()).log(Level.SEVERE, null, ex);
}
return rcom.getCustomers();
}
public static void main(String[] args) {
// TODO code application logic here
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");
// props.setProperty("java.naming.factory.state","com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
// optional. Defaults to localhost. Only needed if web server is running
// on a different host than the appserver
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
// optional. Defaults to 3700. Only needed if target orb port is not 3700.
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
try {
InitialContext ic = new InitialContext(props);
SnBeanRemote rcom = (SnBeanRemote) ic.lookup("buss.SnBeanRemote");
List allCust = rcom.getCustomers();
List allDept = rcom.getDepartement();
List allProduct = rcom.getProduit();
System.out.println("*********** Customer **************\n\n");
for (Iterator iter = allCust.iterator(); iter.hasNext();) {
Customer cust = (Customer) iter.next();
System.out.println(":Addre:"+cust.getAddress()+":City:"+cust.getCity()+":Name:"+cust.getName()+":Phone:"+cust.getPhone());
}
System.out.println("*********** Departement **************\n\n");
for (Iterator iter = allDept.iterator(); iter.hasNext();) {
Dept dep = (Dept) iter.next();
System.out.println(":Name :"+dep.getDname()+":Localisation: "+dep.getLoc()+":Depnumer: "+dep.getDeptno());
}
System.out.println("*********** Produits ************** \n\n");
for (Iterator iter = allProduct.iterator(); iter.hasNext();) {
Product prod = (Product) iter.next();
System.out.println("Description "+prod.getDescrip()+"ID produit: "+prod.getProdid());
}
} catch (NamingException ex) {
Logger.getLogger(Exemple2.class.getName()).log(Level.SEVERE, null, ex);
}
List lilo = getCustom();
System.out.println("*********** %%%%%%%%%Customer LILO%%%%%%% **************\n\n");
for (Iterator iter = lilo.iterator(); iter.hasNext();) {
Customer cust = (Customer) iter.next();
System.out.println(":Addre:"+cust.getAddress()+":City:"+cust.getCity()+":Name:"+cust.getName()+":Phone:"+cust.getPhone());
}
}
} |
Partager