[Ubermq-commits] jms/src/com/ubermq/jms/server MessageServer.java,1.38,1.39
Brought to you by:
jimmyp
From: <ji...@us...> - 2003-01-31 23:21:19
|
Update of /cvsroot/ubermq/jms/src/com/ubermq/jms/server In directory sc8-pr-cvs1:/tmp/cvs-serv10549/src/com/ubermq/jms/server Modified Files: MessageServer.java Log Message: clustering Index: MessageServer.java =================================================================== RCS file: /cvsroot/ubermq/jms/src/com/ubermq/jms/server/MessageServer.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** MessageServer.java 30 Jan 2003 14:42:21 -0000 1.38 --- MessageServer.java 31 Jan 2003 23:21:15 -0000 1.39 *************** *** 1,5 **** package com.ubermq.jms.server; ! import com.ubermq.jms.server.ssl.*; ! import com.ubermq.jms.client.unicast.*; import com.ubermq.jms.server.admin.*; --- 1,4 ---- package com.ubermq.jms.server; ! import com.ubermq.jms.client.*; import com.ubermq.jms.client.unicast.*; import com.ubermq.jms.server.admin.*; *************** *** 10,13 **** --- 9,13 ---- import com.ubermq.jms.server.journal.impl.*; import com.ubermq.jms.server.proc.*; + import com.ubermq.jms.server.ssl.*; import com.ubermq.kernel.*; import java.io.*; *************** *** 74,80 **** --- 74,110 ---- public interface Protocol { + /** + * Returns the service URI for this protocol. This may only + * be called after the start method has successfully completed. + * + * @return an URI describing how to connect to + * this protocol, or null if a URI cannot be used. + */ + public URI getServiceURI(); + + /** + * Indicates if the protocol is enabled. + * + * @return true indicates enabled. + */ public boolean isEnabled(); + + /** + * Starts the protocol. This method should + * not return until the protocol is started. + * + * @param dp an IMessageProcessor + * @param lists a ConnectionList[] that + * can be used to receive incoming IO connections for servicing. + * + * @throws IOException if the protocol could not be started. + */ public void start(IMessageProcessor dp, ConnectionList[] lists) throws IOException; + + /** + * Stops the protocol. If the protocol has not been started, + * this call must not fail. + */ public void stop(); } *************** *** 122,127 **** * channel based I/O on behalf of connected clients. */ ! protected void exec() { try { // open journal --- 152,159 ---- * channel based I/O on behalf of connected clients. */ ! protected URI exec() { + URI serviceURI = null; + try { // open journal *************** *** 155,158 **** --- 187,193 ---- p.start(datagramProcessor, lists); com.ubermq.Utility.getLogger().info("Protocol " + p.toString() + " started"); + + if (serviceURI == null) + serviceURI = p.getServiceURI(); } } *************** *** 162,167 **** } catch(Exception x) { ! com.ubermq.Utility.getLogger().throwing("", "", x); } } --- 197,209 ---- } catch(Exception x) { ! x.printStackTrace(); } + + // set server name and return URi + if (datagramProcessor instanceof DatagramProc) + { + ((DatagramProc)datagramProcessor).setServerName(serviceURI.toString()); + } + return serviceURI; } *************** *** 193,204 **** protected void onClusterAnnouncement(String url) { ! com.ubermq.Utility.getLogger().fine("cluster notification for " + url); ! if (started && ! clusterCxnCount < CLUSTER_MAX_CXNS) { // we'll try to actually connect to the other guy. clusterCxn[clusterCxnCount++] = ! new ClusterPropagation(getServiceUrl(), ! url); } } --- 235,245 ---- protected void onClusterAnnouncement(String url) { ! com.ubermq.Utility.getLogger().info("joining cluster member at " + url); ! if (clusterCxnCount < CLUSTER_MAX_CXNS) { // we'll try to actually connect to the other guy. clusterCxn[clusterCxnCount++] = ! new ClusterPropagation(new PipeConnectionFactory(this), ! new URLConnectionFactory(url)); } } *************** *** 208,212 **** { DatagramProc dp = new DatagramProc(settings, getDatagramFactoryHolder()); - dp.setServerName(getServiceUrl()); return dp; } --- 249,252 ---- *************** *** 348,351 **** --- 388,413 ---- return port == DEFAULT_PORT ? "UberMQ" : ("UberMQ (" + port + ")"); } + + /** + * Returns the service URI for this protocol. + * + * @return an URI describing how to connect to + * this protocol, or null if a URI cannot be used. + */ + public URI getServiceURI() + { + try + { + if (port == DEFAULT_PORT) + return URI.create("ubermq://" + InetAddress.getLocalHost()); + else + return URI.create("ubermq://" + InetAddress.getLocalHost() + ":" + port); + } + catch (UnknownHostException e) { + return URI.create("ubermq://localhost"); + } + } + + } *************** *** 363,366 **** --- 425,430 ---- Configurator.getProperty(ServerConfig.ADMIN_SERVICE_NAME, "UberMQAdmin"); + private URI serviceURI; + public boolean isEnabled() { *************** *** 380,386 **** registry.rebind(ADMIN_SERVICE_NAME, admin); ! com.ubermq.Utility.getLogger().info("Administrative service running at //" + ! InetAddress.getLocalHost().getHostName() + ! ":" + ADMIN_PORT + "/" + ADMIN_SERVICE_NAME); } catch (java.rmi.RemoteException e) { --- 444,450 ---- registry.rebind(ADMIN_SERVICE_NAME, admin); ! serviceURI = URI.create("//" + InetAddress.getLocalHost().getHostName() + ! ":" + ADMIN_PORT + "/" + ADMIN_SERVICE_NAME); ! com.ubermq.Utility.getLogger().info("Administrative service running at " + serviceURI.toString()); } catch (java.rmi.RemoteException e) { *************** *** 398,401 **** --- 462,478 ---- return "UberMQAdmin"; } + + /** + * Returns the service URI for this protocol. + * + * @return an URI describing how to connect to + * this protocol, or null if a URI cannot be used. + */ + public URI getServiceURI() + { + return serviceURI; + } + + } |