📄 rmiconnection.java
字号:
connectLowlevel(this.clientAddress); try { return authServer.connect(connectQos); } catch(RemoteException e) { if (log.isLoggable(Level.FINE)) log.fine("Login failed"); throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME, "Login failed"); } } /** * @see I_XmlBlasterConnection#setConnectReturnQos(ConnectReturnQos) */ public void setConnectReturnQos(ConnectReturnQos connectReturnQos) { this.sessionId = connectReturnQos.getSecretSessionId(); this.ME = "RmiConnection-"+connectReturnQos.getSessionName().toString(); } /** * Logout from the server. * <p /> * The callback server is removed as well, releasing all RMI threads. * Note that this kills the server ping thread as well (if in failsafe mode) * @return true successfully logged out * false failure on gout */ public boolean disconnect(String disconnectQos) { if (log.isLoggable(Level.FINER)) log.finer("logout() ..."); try { if (authServer != null) { authServer.disconnect(this.sessionId, (disconnectQos==null)?"":disconnectQos); } shutdown(); resetConnection(); return true; } catch(XmlBlasterException e) { log.warning("XmlBlasterException: " + e.getMessage()); } catch(RemoteException e) { log.warning(e.toString()); e.printStackTrace(); } try { shutdown(); } catch (XmlBlasterException ex) { log.severe("disconnect: could not shutdown properly. " + ex.getMessage()); } resetConnection(); return false; } /** * Shut down. * Is called by logout() */ public void shutdown() throws XmlBlasterException { } /** * @return true if you are logged in */ public boolean isLoggedIn() { return this.blasterServer != null; } /** * Enforced by I_XmlBlasterConnection interface (failsafe mode). * see explanations of publish() method. * @see <a href="http://www.xmlBlaster.org/xmlBlaster/src/java/org/xmlBlaster/protocol/corba/xmlBlaster.idl" target="others">CORBA xmlBlaster.idl</a> */ public final String subscribe(String xmlKey, String qos) throws XmlBlasterException { if (log.isLoggable(Level.FINER)) log.finer("subscribe() ..."); try { return getXmlBlaster().subscribe(this.sessionId, xmlKey, qos); } catch(XmlBlasterException e) { throw e; } catch(Exception e) { throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME, "subscribe", e); } } /** * Enforced by I_XmlBlasterConnection interface (failsafe mode) * @see <a href="http://www.xmlBlaster.org/xmlBlaster/src/java/org/xmlBlaster/protocol/corba/xmlBlaster.idl" target="others">CORBA xmlBlaster.idl</a> */ public final String[] unSubscribe(String xmlKey, String qos) throws XmlBlasterException { if (log.isLoggable(Level.FINER)) log.finer("unSubscribe() ..."); try { return getXmlBlaster().unSubscribe(this.sessionId, xmlKey, qos); } catch(XmlBlasterException e) { throw e; } catch(Exception e) { throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME, "unSubscribe", e); } } /** * Publish fault-tolerant the given message. * <p /> * This is a wrapper around the raw RMI publish() method * If the server disappears you get an exception. * This call will not block. * <p /> * Enforced by I_XmlBlasterConnection interface (failsafe mode) * @see <a href="http://www.xmlBlaster.org/xmlBlaster/src/java/org/xmlBlaster/protocol/corba/xmlBlaster.idl" target="others">CORBA xmlBlaster.idl</a> */ public final String publish(MsgUnitRaw msgUnit) throws XmlBlasterException { if (log.isLoggable(Level.FINE)) log.fine("Publishing ..."); try { return getXmlBlaster().publish(this.sessionId, msgUnit); } catch(XmlBlasterException e) { if (log.isLoggable(Level.FINE)) log.fine("XmlBlasterException: " + e.getMessage()); throw e; } catch(Exception e) { throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME, "publish", e); } } /** * @see <a href="http://www.xmlBlaster.org/xmlBlaster/src/java/org/xmlBlaster/protocol/corba/xmlBlaster.idl" target="others">CORBA xmlBlaster.idl</a> */ public String[] publishArr(MsgUnitRaw [] msgUnitArr) throws XmlBlasterException { if (log.isLoggable(Level.FINER)) log.finer("publishArr() ..."); try { return getXmlBlaster().publishArr(this.sessionId, msgUnitArr); } catch(XmlBlasterException e) { if (log.isLoggable(Level.FINE)) log.fine("XmlBlasterException: " + e.getMessage()); throw e; } catch(Exception e) { throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME, "publishArr", e); } } /** * RMI does not support oneway messages. * @see <a href="http://www.xmlBlaster.org/xmlBlaster/src/java/org/xmlBlaster/protocol/corba/xmlBlaster.idl" target="others">CORBA xmlBlaster.idl</a> */ public void publishOneway(MsgUnitRaw [] msgUnitArr) throws XmlBlasterException { if (log.isLoggable(Level.FINER)) log.finer("publishOneway(), RMI does not support oneway, we switch to publishArr() ..."); publishArr(msgUnitArr); } /** * @see <a href="http://www.xmlBlaster.org/xmlBlaster/src/java/org/xmlBlaster/protocol/corba/xmlBlaster.idl" target="others">CORBA xmlBlaster.idl</a> */ public final String[] erase(String xmlKey, String qos) throws XmlBlasterException { if (log.isLoggable(Level.FINER)) log.finer("erase() ..."); try { return getXmlBlaster().erase(this.sessionId, xmlKey, qos); } catch(XmlBlasterException e) { throw e; } catch(Exception e) { throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME, "erase", e); } } /** * @see <a href="http://www.xmlBlaster.org/xmlBlaster/src/java/org/xmlBlaster/protocol/corba/xmlBlaster.idl" target="others">CORBA xmlBlaster.idl</a> */ public final MsgUnitRaw[] get(String xmlKey, String qos) throws XmlBlasterException { if (log.isLoggable(Level.FINER)) log.finer("get() ..."); try { return getXmlBlaster().get(this.sessionId, xmlKey, qos); } catch(XmlBlasterException e) { throw e; } catch(Exception e) { e.printStackTrace(); throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME, "get", e); } } /** * Register a listener for to receive information about the progress of incoming data. * Only one listener is supported, the last call overwrites older calls. This implementation * does nothing here, it just returns null. * * @param listener Your listener, pass 0 to unregister. * @return The previously registered listener or 0 */ public I_ProgressListener registerProgressListener(I_ProgressListener listener) { log.fine("This method is currently not implemeented."); return null; } /** * Check server. * @see <a href="http://www.xmlBlaster.org/xmlBlaster/src/java/org/xmlBlaster/protocol/corba/xmlBlaster.idl" target="others">CORBA xmlBlaster.idl</a> */ public String ping(String str) throws XmlBlasterException { try { return getXmlBlaster().ping(str); } catch(Exception e) { throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME, "ping", e); } } /** * Command line usage. * <p /> * These variables may be set in xmlBlaster.properties as well. * Don't use the "-" prefix there. */ public static String usage() { String text = "\n"; text += "RmiConnection 'RMI' options:\n"; text += " -dispatch/connection/plugin/rmi/registryPort\n"; text += " Specify a port number where rmiregistry of the xmlBlaster server listens.\n"; text += " Default is port "+DEFAULT_REGISTRY_PORT+", the port 0 switches this feature off.\n"; text += " -dispatch/connection/plugin/rmi/hostname\n"; text += " Specify a hostname where rmiregistry of the xmlBlaster server runs.\n"; text += " Default is the localhost.\n"; text += " -dispatch/callback/plugin/rmi/registryPort\n"; text += " Specify a port number where rmiregistry for the callback server listens.\n"; text += " Default is port "+DEFAULT_REGISTRY_PORT+", the port 0 switches this feature off.\n"; text += " -dispatch/callback/plugin/rmi/hostname\n"; text += " Specify a hostname where rmiregistry for the callback server runs.\n"; text += " Default is the localhost (useful for multi homed hosts).\n"; text += "\n"; return text; }} // class RmiConnection
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -