private void handleException(Exception e) throws CorbaHostException { // The cause of the Exception is JDK specific if (e instanceof NotFound) { throw new CorbaHostException(CorbaHostException.NO_SUCH_OBJECT, e); } else if (e instanceof InvalidName) { throw new CorbaHostException(e); } else { throw new CorbaHostException(e); } }
protected CorbaHost getCorbaHost() throws CorbaHostException { if (hosts.getCorbaHosts().isEmpty()) { throw new CorbaHostException("No registered CORBA hosts"); } return hosts.getCorbaHosts().get(0); }
protected CorbaHost getCorbaHost() throws CorbaHostException { if (hosts.getCorbaHosts().isEmpty()) { throw new CorbaHostException("No registered CORBA hosts"); } return hosts.getCorbaHosts().get(0); }
/** * Starts transient name server under given port. If TNS was previously * spawned it increments clients counter. */ synchronized private void createLocalNameServer(int port) throws CorbaHostException { int useCount = clientsCount.containsKey(port) ? clientsCount.get(port) : 0; // no server previously spawned if (useCount == 0) { TransientNameServer server = new TransientNameServer("localhost", port, TransientNameService.DEFAULT_SERVICE_NAME); Thread thread = server.start(); if (thread == null) { throw new CorbaHostException("TransientNameServer couldn't be started"); } else { localServers.put(port, server); } } clientsCount.put(port, ++useCount); }
public void registerServant(String uri, Object servantObject) throws CorbaHostException { CorbanameURL details = CorbaHostUtils.getServiceDetails(uri); ORB orb = createORB(details.getHost(), details.getPort(), false); try { NamingContext namingCtx = getNamingContext(orb, details.getNameService()); for (int i = 0; i < details.getNamePath().size() - 1; i++) { NameComponent nc = new NameComponent(details.getNamePath().get(i), ""); NameComponent[] path = new NameComponent[] {nc}; try { namingCtx = NamingContextHelper.narrow(namingCtx.resolve(path)); } catch (Exception e) { namingCtx = namingCtx.bind_new_context(path); } } NameComponent finalName = new NameComponent(details.getNamePath().get(details.getNamePath().size() - 1), ""); try { namingCtx.resolve(new NameComponent[] {finalName}); // no exception means that some object is already registered // under this name, we need to crash here throw new CorbaHostException(CorbaHostException.BINDING_IN_USE); } catch (NotFound e) { namingCtx.bind(new NameComponent[] {finalName}, servantObject); } } catch (CorbaHostException e) { throw e; } catch (Exception e) { handleException(e); } }
public Object lookup(String uri) throws CorbaHostException { Object result = null; try { CorbanameURL url = new CorbanameURL(uri); ORB orb = createORB(url.getHost(), url.getPort(), false); NamingContextExt context = getNamingContext(orb, url.getNameService()); result = context.resolve_str(url.getName()); } catch (Exception e) { handleException(e); } if (result == null) { throw new CorbaHostException(CorbaHostException.NO_SUCH_OBJECT); } return result; }