FileDocCategorySizeDatePackage
UpdateCheckerImpl.javaAPI DocAzureus 3.0.3.45364Thu Jan 11 10:15:18 GMT 2007org.gudy.azureus2.pluginsimpl.local.update

UpdateCheckerImpl

public class UpdateCheckerImpl extends Object implements UpdateChecker
author
parg

Fields Summary
protected UpdateCheckInstanceImpl
check_instance
protected UpdatableComponentImpl
component
protected AESemaphore
semaphore
protected boolean
completed
protected boolean
failed
protected boolean
cancelled
protected boolean
sem_released
protected List
listeners
protected List
progress_listeners
protected AEMonitor
this_mon
Constructors Summary
protected UpdateCheckerImpl(UpdateCheckInstanceImpl _check_instance, UpdatableComponentImpl _component, AESemaphore _sem)


	
	
			
			
						 
	
		check_instance		= _check_instance;
		component			= _component;
		semaphore			= _sem;
	
Methods Summary
public voidaddListener(UpdateCheckerListener l)

		try{
			this_mon.enter();
		
			listeners.add( l );
			
			if ( failed ){
				
				l.failed( this );
				
			}else if ( completed ){
				
				l.completed( this );
			}
			
			if ( cancelled ){
				
				l.cancelled( this );
				
			}
		}finally{
			
			this_mon.exit();
		}
	
public voidaddProgressListener(UpdateProgressListener l)

		try{
			this_mon.enter();
		
			List	new_l = new ArrayList( progress_listeners );
			
			new_l.add( l );
			
			progress_listeners	= new_l;
			
		}finally{
			
			this_mon.exit();
		}
	
public UpdateaddUpdate(java.lang.String name, java.lang.String[] description, java.lang.String new_version, ResourceDownloader downloader, int restart_required)

		return(	addUpdate(
					name, description, new_version,
					new ResourceDownloader[]{ downloader },
					restart_required ));
	
public UpdateaddUpdate(java.lang.String name, java.lang.String[] description, java.lang.String new_version, ResourceDownloader[] downloaders, int restart_required)

		reportProgress( "Adding update: " + name );
		
		return( check_instance.addUpdate( 
					component, name, description, new_version,
					downloaders, restart_required ));
	
protected voidcancel()

		cancelled	= true;
		
		for (int i=0;i<listeners.size();i++){
			
			try{
				((UpdateCheckerListener)listeners.get(i)).cancelled( this );
				
			}catch( Throwable e ){
				
				Debug.printStackTrace(e);
			}
		}
	
public voidcompleted()

		try{
			this_mon.enter();
		
			if ( !sem_released ){
				
				completed	= true;
				
				for (int i=0;i<listeners.size();i++){
					
					try{
						((UpdateCheckerListener)listeners.get(i)).completed( this );
						
					}catch( Throwable e ){
						
						Debug.printStackTrace( e );
					}
				}
				
				sem_released	= true;
				
				semaphore.release();
			}
		}finally{
			
			this_mon.exit();
		}
	
public UpdateInstallercreateInstaller()

		return( check_instance.createInstaller());
	
public voidfailed()

		try{
			this_mon.enter();
		
			if ( !sem_released ){
				
				failed	= true;
	
				for (int i=0;i<listeners.size();i++){
					
					try{
						((UpdateCheckerListener)listeners.get(i)).failed( this );
						
					}catch( Throwable e ){
						
						Debug.printStackTrace( e );
					}
				}
	
				sem_released	= true;
				
				semaphore.release();
			}	
		}finally{
			
			this_mon.exit();
		}
	
public UpdateCheckInstancegetCheckInstance()

		return( check_instance );
	
public UpdatableComponentgetComponent()

		return( component.getComponent());
	
protected booleangetFailed()

		return( failed );
	
public voidremoveListener(UpdateCheckerListener l)

		try{
			this_mon.enter();
		
			listeners.remove(l);
			
		}finally{
			
			this_mon.exit();
		}
	
public voidremoveProgressListener(UpdateProgressListener l)

		try{
			this_mon.enter();
		
			List	new_l = new ArrayList( progress_listeners );
			
			new_l.remove( l );
			
			progress_listeners	= new_l;
				
		}finally{
			
			this_mon.exit();
		}
	
public voidreportProgress(java.lang.String str)

		List	ref = progress_listeners;
		
		for (int i=0;i<ref.size();i++){
			
			try{
				((UpdateProgressListener)ref.get(i)).reportProgress( str );
				
			}catch( Throwable e ){
				
				Debug.printStackTrace(e);
			}
		}