FileDocCategorySizeDatePackage
TRTrackerServerFactoryImpl.javaAPI DocAzureus 3.0.3.45273Thu Sep 06 21:10:58 BST 2007org.gudy.azureus2.core3.tracker.server.impl

TRTrackerServerFactoryImpl

public class TRTrackerServerFactoryImpl extends Object
author
parg

Fields Summary
protected static List
servers
protected static List
listeners
protected static org.gudy.azureus2.core3.util.AEMonitor
class_mon
Constructors Summary
Methods Summary
public static voidaddListener(TRTrackerServerFactoryListener l)

		try{
			class_mon.enter();
		
			listeners.add( l );
			
			for (int i=0;i<servers.size();i++){
				
				l.serverCreated((TRTrackerServer)servers.get(i));
			}
		}finally{
			
			class_mon.exit();
		}
	
protected static voidclose(TRTrackerServerImpl server)

		try{
			class_mon.enter();
		
			server.closeSupport();
			
			if ( servers.remove( server )){
			
				for (int i=0;i<listeners.size();i++){
					
					((TRTrackerServerFactoryListener)listeners.get(i)).serverDestroyed( server );
				}	
			}
		}finally{
			
			class_mon.exit();
		}
	
public static TRTrackerServercreate(java.lang.String name, int protocol, int port, java.net.InetAddress bind_ip, boolean ssl, boolean apply_ip_filter, boolean main_tracker, boolean start_up_ready)


	  
	
				
					
					
			
				
				
				
				 
	
		 
	
		try{
			class_mon.enter();
		
			TRTrackerServerImpl	server;
			
			if ( protocol == TRTrackerServerFactory.PR_TCP ){
				
				if ( COConfigurationManager.getBooleanParameter( "Tracker TCP NonBlocking" ) && main_tracker && !ssl ){
					
					server = 
						new TRNonBlockingServer( 
							name, 
							port, 
							bind_ip, 
							apply_ip_filter,
							start_up_ready,
							new TRNonBlockingServerProcessorFactory()
							{
								public TRNonBlockingServerProcessor
								create(	
									TRTrackerServerTCP		_server,
									SocketChannel			_socket )
								{
									return( new NonBlockingProcessor( _server, _socket ));

								}
							});
				}else{
					
					server = new TRBlockingServer( name, port, bind_ip, ssl, apply_ip_filter, start_up_ready );
				}
				
			}else if ( protocol == TRTrackerServerFactory.PR_UDP ){
				
				if ( ssl ){
					
					throw( new TRTrackerServerException( "TRTrackerServerFactory: UDP doesn't support SSL"));
				}
				
				server = new TRTrackerServerUDP( name, port, start_up_ready );
				
			}else{
				
				server = new TRTrackerServerDHT( name, start_up_ready );
			}
			
			servers.add( server );
			
			for (int i=0;i<listeners.size();i++){
				
				((TRTrackerServerFactoryListener)listeners.get(i)).serverCreated( server );
			}
			
			return( server );
			
		}finally{
			
			class_mon.exit();
		}
	
public static voidremoveListener(TRTrackerServerFactoryListener l)

		try{
			class_mon.enter();
		
			listeners.remove( l );
			
		}finally{
			
			class_mon.exit();
		}