FileDocCategorySizeDatePackage
Main.javaAPI DocAzureus 3.0.3.43921Fri Oct 01 08:55:32 BST 2004org.gudy.azureus2.ui.jws

Main

public class Main extends Object implements PluginEventListener, Plugin, PluginListener
author
parg

Fields Summary
protected static Main
singleton
protected static AESemaphore
init_sem
private static AEMonitor
class_mon
protected PluginInterface
plugin_interface
protected LoggerChannel
log
protected AESemaphore
ready_sem
Constructors Summary
Methods Summary
public voidclosedownComplete()

	
public voidclosedownInitiated()

	
public static org.gudy.azureus2.ui.jws.MaingetSingleton(java.lang.String[] args)


	  
	
		 	 
	
		try{
			class_mon.enter();
		
			if ( singleton == null ){
				
				new AEThread( "plugin initialiser ")
				{
					public void
					runSupport()
					{
						PluginManager.registerPlugin( Main.class );
						
						Properties props = new Properties();
						
						props.put( PluginManager.PR_MULTI_INSTANCE, "false" );
											
						PluginManager.startAzureus( PluginManager.UI_SWT, props );
					}
				}.start();
				
				init_sem.reserve();
			}
			
			return( singleton );
			
		}finally{
			
			class_mon.exit();
		}
	
public voidhandleEvent(PluginEvent ev)

		System.out.println( "PluginEvent:" + ev.getType());
		
		if ( ev.getType() == PluginEvent.PEV_CONFIGURATION_WIZARD_COMPLETES ){
			
			ready_sem.release();
		}
	
public voidinitializationComplete()

	
public voidinitialize(PluginInterface _pi)


	  
	
		  
		
		plugin_interface = _pi;

		singleton	= this;
		
		log = plugin_interface.getLogger().getChannel("JWS Launcher");
		
		log.addListener(
			new LoggerChannelListener()
			{
				public void
				messageLogged(
					int		type,
					String	content )
				{
					System.out.println( content );
				}
				
				public void
				messageLogged(
					String		str,
					Throwable	error )
				{
					System.out.println( str );
					
					Debug.printStackTrace( error );
				}
			});
		
		log.log(LoggerChannel.LT_INFORMATION, "Plugin Initialised");
		
		plugin_interface.addListener( this );
		
		plugin_interface.addEventListener( this );
		
		init_sem.release();
	
public static voidmain(java.lang.String[] args)

		getSingleton( args ).process();
	
protected voidprocess()

		ready_sem.reserve();
		
		log.log(LoggerChannel.LT_INFORMATION, "processing jws request" );
		
		Properties props = System.getProperties();
		
		Enumeration enumx = props.keys();
		
		while( enumx.hasMoreElements()){
		
			String	key = (String)enumx.nextElement();
			
			log.log(LoggerChannel.LT_INFORMATION, "\t" + key + " = '" + props.get(key) + "'");
		}
		
		String	torrent_url = (String)props.get( "azureus.javaws.torrent_url");
		
		log.log(LoggerChannel.LT_INFORMATION, "Torrent URL = " + torrent_url );
		
		if ( torrent_url != null ){
			
			try{
				plugin_interface.getDownloadManager().addDownload(new URL(torrent_url));
				
			}catch( Throwable e ){
							
				log.log( e );
			}
		}