git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@646803 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2008-04-10 13:43:46 +00:00
parent acf453b46a
commit 520a2ded04
5 changed files with 40 additions and 17 deletions

View File

@ -202,7 +202,13 @@ public class DiscoveryNetworkConnector extends NetworkConnector implements Disco
} }
public String getName() { public String getName() {
return discoveryAgent.toString(); String name = super.getName();
if (name == null) {
name = discoveryAgent.toString();
;
super.setName(name);
}
return name;
} }
} }

View File

@ -88,6 +88,8 @@ public class LdapNetworkConnector
// local context // local context
private DirContext context = null; private DirContext context = null;
//currently in use URI
private URI ldapURI = null;
/** /**
* returns the next URI from the configured list * returns the next URI from the configured list
@ -195,9 +197,9 @@ public class LdapNetworkConnector
LOG.info("connecting..."); LOG.info("connecting...");
Hashtable<String, String> env = new Hashtable(); Hashtable<String, String> env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
URI uri = getUri(); this.ldapURI = getUri();
LOG.debug(" URI [" + uri + "]"); LOG.debug(" URI [" + this.ldapURI + "]");
env.put(Context.PROVIDER_URL, uri.toString()); env.put(Context.PROVIDER_URL, this.ldapURI.toString());
if(anonymousAuthentication) if(anonymousAuthentication)
{ {
LOG.debug(" login credentials [anonymous]"); LOG.debug(" login credentials [anonymous]");
@ -221,9 +223,9 @@ public class LdapNetworkConnector
{ {
if(failover) if(failover)
{ {
uri = getUri(); this.ldapURI = getUri();
LOG.error("connection error [" + env.get(Context.PROVIDER_URL) + "], failover connection to [" + uri.toString() + "]"); LOG.error("connection error [" + env.get(Context.PROVIDER_URL) + "], failover connection to [" + this.ldapURI.toString() + "]");
env.put(Context.PROVIDER_URL, uri.toString()); env.put(Context.PROVIDER_URL, this.ldapURI.toString());
Thread.sleep(curReconnectDelay); Thread.sleep(curReconnectDelay);
curReconnectDelay = Math.min(curReconnectDelay * 2, maxReconnectDelay); curReconnectDelay = Math.min(curReconnectDelay * 2, maxReconnectDelay);
} }
@ -272,13 +274,21 @@ public class LdapNetworkConnector
* *
* @return connector name * @return connector name
*/ */
public String getName() public String getName() {
{ return toString(); }
String name = super.getName();
if (name == null) {
name = this.getClass().getName() + " [" + ldapURI.toString() + "]";
super.setName(name);
}
return name;
}
/** /**
* add connector of the given URI * add connector of the given URI
* *
* @param result search result of connector to add * @param result
* search result of connector to add
*/ */
protected synchronized void addConnector(SearchResult result) protected synchronized void addConnector(SearchResult result)
throws Exception throws Exception

View File

@ -142,7 +142,12 @@ public class MulticastNetworkConnector extends NetworkConnector {
} }
public String getName() { public String getName() {
return remoteTransport.toString(); String name = super.getName();
if(name == null) {
name = remoteTransport.toString();
super.setName(name);
}
return name;
} }
protected DemandForwardingBridgeSupport createBridge(Transport local, Transport remote) { protected DemandForwardingBridgeSupport createBridge(Transport local, Transport remote) {

View File

@ -35,7 +35,7 @@ public class NetworkBridgeConfiguration {
private String userName; private String userName;
private String password; private String password;
private String destinationFilter = ">"; private String destinationFilter = ">";
private String name = "localhost"; private String name = null;
/** /**
* @return the conduitSubscriptions * @return the conduitSubscriptions
@ -210,6 +210,9 @@ public class NetworkBridgeConfiguration {
* @return the name * @return the name
*/ */
public String getName() { public String getName() {
if(this.name == null) {
this.name = "localhost";
}
return this.name; return this.name;
} }

View File

@ -201,8 +201,6 @@ public abstract class NetworkConnector extends NetworkBridgeConfiguration implem
serviceSupport.stop(); serviceSupport.stop();
} }
public abstract String getName();
protected void handleStart() throws Exception { protected void handleStart() throws Exception {
if (localURI == null) { if (localURI == null) {
throw new IllegalStateException("You must configure the 'localURI' property"); throw new IllegalStateException("You must configure the 'localURI' property");
@ -263,6 +261,7 @@ public abstract class NetworkConnector extends NetworkBridgeConfiguration implem
} }
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected ObjectName createNetworkBridgeObjectName(NetworkBridge bridge) throws MalformedObjectNameException { protected ObjectName createNetworkBridgeObjectName(NetworkBridge bridge) throws MalformedObjectNameException {
ObjectName connectorName = getObjectName(); ObjectName connectorName = getObjectName();