/** * Acquires a lock describing the entire contents of <code>station</code>. This * method is intended in situations where the layout of <code>station</code> gets * modified and this modification must not be interrupted. * @param station the station for which a lock is requested * @return the acquired token to release the lock * @throws IllegalStateException if the lock is already acquired */ public synchronized Token acquire( DockStation station ){ if( isConcurrent() ){ return new Token( this, station ); } if( token != null ){ throwException( new IllegalStateException( defaultMessage() ) ); } token = new Token( this, station ); return token; }
/** * Allows <code>station</code> to become the new parent of <code>dockable</code>. * @param station the station which wants to be the new parent of <code>dockable</code> * @param dockable a dockable with no parent * @return the acquired token to release the lock * @throws IllegalStateException if <code>dockable</code> has a parent or <code>station</code> * thinks that <code>dockable</code> is one of its children */ public synchronized Token acquireLink( DockStation station, Dockable dockable ){ if( station == null ){ throw new IllegalArgumentException( "station is null" ); } if( dockable == null ){ throw new IllegalArgumentException( "dockable is null" ); } ensureUnlinked( station, dockable ); if( isConcurrent() ){ return new Token( this, station, dockable, true ); } if( token != null ){ throwException( new IllegalStateException( defaultMessage() ) ); } token = new Token( this, station, dockable, true ); return token; }
/** * Allows <code>station</code> to remove itself as parent from <code>dockable</code>. * @param station the current parent of <code>dockable</code> * @param dockable a dockable with <code>station</code> as parent * @return the acquired token to release the lock * @throws IllegalStateException if <code>dockable</code> is not a child of * <code>station</code> */ public synchronized Token acquireUnlink( DockStation station, Dockable dockable ){ if( station == null ){ throw new IllegalArgumentException( "station is null" ); } if( dockable == null ){ throw new IllegalArgumentException( "dockable is null" ); } ensureLinked( station, dockable ); if( isConcurrent() ){ return new Token( this, station, dockable, false ); } if( token != null ){ throwException( new IllegalStateException( defaultMessage() ) ); } token = new Token( this, station, dockable, false ); return token; }
/** * Allows <code>station</code> to remove itself as parent from <code>dockable</code>. * @param station the current parent of <code>dockable</code> * @param dockable a dockable with <code>station</code> as parent * @return the acquired token to release the lock * @throws IllegalStateException if <code>dockable</code> is not a child of * <code>station</code> */ public synchronized Token acquireUnlink( DockStation station, Dockable dockable ){ if( station == null ){ throw new IllegalArgumentException( "station is null" ); } if( dockable == null ){ throw new IllegalArgumentException( "dockable is null" ); } ensureLinked( station, dockable ); if( isConcurrent() ){ return new Token( this, station, dockable, false ); } if( token != null ){ throwException( new IllegalStateException( defaultMessage() ) ); } token = new Token( this, station, dockable, false ); return token; }
/** * Acquires a lock describing the entire contents of <code>station</code>. This * method is intended in situations where the layout of <code>station</code> gets * modified and this modification must not be interrupted. * @param station the station for which a lock is requested * @return the acquired token to release the lock * @throws IllegalStateException if the lock is already acquired */ public synchronized Token acquire( DockStation station ){ if( isConcurrent() ){ return new Token( this, station ); } if( token != null ){ throwException( new IllegalStateException( defaultMessage() ) ); } token = new Token( this, station ); return token; }
/** * Allows <code>station</code> to become the new parent of <code>dockable</code>. * @param station the station which wants to be the new parent of <code>dockable</code> * @param dockable a dockable with no parent * @return the acquired token to release the lock * @throws IllegalStateException if <code>dockable</code> has a parent or <code>station</code> * thinks that <code>dockable</code> is one of its children */ public synchronized Token acquireLink( DockStation station, Dockable dockable ){ if( station == null ){ throw new IllegalArgumentException( "station is null" ); } if( dockable == null ){ throw new IllegalArgumentException( "dockable is null" ); } ensureUnlinked( station, dockable ); if( isConcurrent() ){ return new Token( this, station, dockable, true ); } if( token != null ){ throwException( new IllegalStateException( defaultMessage() ) ); } token = new Token( this, station, dockable, true ); return token; }