@Override public synchronized void dispose () { fireDiscoveryUpdate ( null, this.connections.toArray ( new ConnectionDescriptor[this.connections.size ()] ) ); this.listeners.clear (); this.connections.clear (); }
@Override public synchronized void dispose () { fireDiscoveryUpdate ( null, this.connections.toArray ( new ConnectionDescriptor[this.connections.size ()] ) ); this.listeners.clear (); this.connections.clear (); }
protected synchronized void setConnections ( final Set<ConnectionDescriptor> result ) { final Set<ConnectionDescriptor> added = new HashSet<ConnectionDescriptor> ( result ); added.removeAll ( this.connections ); final Set<ConnectionDescriptor> removed = new HashSet<ConnectionDescriptor> ( this.connections ); removed.removeAll ( result ); this.connections = result; fireDiscoveryUpdate ( added.toArray ( new ConnectionDescriptor[added.size ()] ), removed.toArray ( new ConnectionDescriptor[removed.size ()] ) ); }
protected synchronized void setConnections ( final Set<ConnectionDescriptor> result ) { final Set<ConnectionDescriptor> added = new HashSet<ConnectionDescriptor> ( result ); added.removeAll ( this.connections ); final Set<ConnectionDescriptor> removed = new HashSet<ConnectionDescriptor> ( this.connections ); removed.removeAll ( result ); this.connections = result; fireDiscoveryUpdate ( added.toArray ( new ConnectionDescriptor[added.size ()] ), removed.toArray ( new ConnectionDescriptor[removed.size ()] ) ); }
/** * Remove a connection * <p> * The connection can also be <code>null</code> in which the method will * return <code>false</code> * </p> * <p> * If the connection was not known, <code>false</code> will be returned and * no event will be emitted * </p> * * @param connectionInformation * the connection to remove * @return <code>true</code> if the connection was removed */ protected synchronized boolean removeConnection ( final ConnectionDescriptor connectionInformation ) { if ( connectionInformation == null ) { return false; } if ( this.connections.remove ( connectionInformation ) ) { fireDiscoveryUpdate ( null, new ConnectionDescriptor[] { connectionInformation } ); return true; } return false; }
/** * Add and announce a new connection * <p> * The connection can also be <code>null</code> in which the method will * return <code>false</code> * </p> * <p> * If the connection was already known, <code>false</code> will be returned * and no event will be emitted * </p> * * @param connectionInformation * a new connection * @return <code>true</code> if the new connection was added */ protected synchronized boolean addConnection ( final ConnectionDescriptor connectionInformation ) { if ( connectionInformation == null ) { return false; } if ( this.connections.add ( connectionInformation ) ) { fireDiscoveryUpdate ( new ConnectionDescriptor[] { connectionInformation }, null ); return true; } return false; }
/** * Remove a connection * <p> * The connection can also be <code>null</code> in which the method will * return <code>false</code> * </p> * <p> * If the connection was not known, <code>false</code> will be returned and * no event will be emitted * </p> * * @param connectionInformation * the connection to remove * @return <code>true</code> if the connection was removed */ protected synchronized boolean removeConnection ( final ConnectionDescriptor connectionInformation ) { if ( connectionInformation == null ) { return false; } if ( this.connections.remove ( connectionInformation ) ) { fireDiscoveryUpdate ( null, new ConnectionDescriptor[] { connectionInformation } ); return true; } return false; }
/** * Add and announce a new connection * <p> * The connection can also be <code>null</code> in which the method will * return <code>false</code> * </p> * <p> * If the connection was already known, <code>false</code> will be returned * and no event will be emitted * </p> * * @param connectionInformation * a new connection * @return <code>true</code> if the new connection was added */ protected synchronized boolean addConnection ( final ConnectionDescriptor connectionInformation ) { if ( connectionInformation == null ) { return false; } if ( this.connections.add ( connectionInformation ) ) { fireDiscoveryUpdate ( new ConnectionDescriptor[] { connectionInformation }, null ); return true; } return false; }