/** * @since 2.0 */ public Connection attach(ConnectionData data) throws HL7Exception { try { Connection conn = null; // Disallow establishing same connection targets concurrently connectionMutexes.putIfAbsent(data.toString(), data.toString()); String mutex = connectionMutexes.get(data.toString()); synchronized (mutex) { discardConnectionIfStale(connections.get(data)); // Create connection or increase counter conn = connections.put(data); } return conn; } catch (Exception e) { log.debug("Failed to attach", e); throw new HL7Exception("Cannot open connection to " + data.getHost() + ":" + data.getPort() + "/" + data.getPort2(), e); } }
/** * @since 2.0 */ public Connection attach(ConnectionData data) throws HL7Exception { try { Connection conn = null; // Disallow establishing same connection targets concurrently connectionMutexes.putIfAbsent(data.toString(), data.toString()); String mutex = connectionMutexes.get(data.toString()); synchronized (mutex) { discardConnectionIfStale(connections.get(data)); // Create connection or increase counter conn = connections.put(data); } return conn; } catch (Exception e) { log.debug("Failed to attach", e); throw new HL7Exception("Cannot open connection to " + data.getHost() + ":" + data.getPort() + "/" + data.getPort2(), e); } }
public Connection getKnownConnection(ConnectionData key) { return connections.get(key); }
public Connection getKnownConnection(ConnectionData key) { return connections.get(key); }