/** * @param connection if not <code>null</code>, the link object will close this resource as last * action before returning from {@link #close()}, relinquishing any underlying resources * @param name the link name * @param settings medium settings of the accessed KNX network */ protected AbstractLink( final AutoCloseable connection, final String name, final KNXMediumSettings settings) { conn = connection; this.name = name; logger = LogService.getLogger("calimero.link." + getName()); notifier = new LinkNotifier(); setKNXMedium(settings); notifier.start(); }
@Override public final void close() { synchronized (this) { if (closed) return; closed = true; } onClose(); notifier.quit(); try { if (conn != null) conn.close(); } catch (final Exception ignore) { } }
@Override public void removeLinkListener(final NetworkLinkListener l) { notifier.removeListener(l); }
@Override public void addLinkListener(final NetworkLinkListener l) { notifier.addListener(l); }
@Override public void connectionClosed(final CloseEvent e) { ((AbstractLink) source).closed = true; super.connectionClosed(e); logger.info("link closed"); }
public void connectionClosed(final CloseEvent e) { ((AbstractMonitor) source).closed = true; super.connectionClosed(e); logger.info("monitor closed"); LogManager.getManager().removeLogService(logger.getName()); }