1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Properties connectionProperties = new Properties();
static{
connectionProperties.put("org.omg.CORBA.ORBInitialPort", "3700");
connectionProperties.put("org.omg.CORBA.ORBInitialHost","localhost");
try {
InitialContext ctx = new InitialContext(connectionProperties);
Object ref = ctx.lookup(classT.getName());
T service = (T) PortableRemoteObject.narrow(ref, classT);
System.out.println("got service "+classT.getName()+": "+service);
return service;
} catch (NamingException ex) {
throw new RuntimeException("unable to get service "+classT.getName(), ex);
} |
Partager