Methods Summary |
---|
public java.nio.ByteBuffer | allocateDirectByteBuffer(int size)
return( DirectByteBufferPool.getBuffer( DirectByteBuffer.AL_EXTERNAL,size ).getBuffer(DirectByteBuffer.SS_EXTERNAL));
|
public PooledByteBuffer | allocatePooledByteBuffer(int length)
return( new PooledByteBufferImpl( length ));
|
public PooledByteBuffer | allocatePooledByteBuffer(byte[] data)
return( new PooledByteBufferImpl( data ));
|
public PooledByteBuffer | allocatePooledByteBuffer(java.util.Map map)
return( new PooledByteBufferImpl( BEncoder.encode( map )));
|
public int | compareVersions(java.lang.String v1, java.lang.String v2)
return Constants.compareVersions( v1, v2 );
|
public AggregatedDispatcher | createAggregatedDispatcher(long idle_dispatch_time, long max_queue_size)
return(
new AggregatedDispatcher()
{
private AggregatedList list =
createAggregatedList(
new AggregatedListAcceptor()
{
public void
accept(
List l )
{
for (int i=0;i<l.size();i++){
try{
((Runnable)l.get(i)).run();
}catch( Throwable e ){
Debug.printStackTrace(e);
}
}
}
},
idle_dispatch_time,
max_queue_size );
public void
add(
Runnable runnable )
{
list.add( runnable );
}
public Runnable
remove(
Runnable runnable )
{
return((Runnable)list.remove( runnable ));
}
public void
destroy()
{
list.destroy();
}
});
|
public AggregatedList | createAggregatedList(AggregatedListAcceptor acceptor, long idle_dispatch_time, long max_queue_size)
return(
new AggregatedList()
{
AEMonitor timer_mon = new AEMonitor( "aggregatedList" );
Timer timer = new Timer( "AggregatedList" );
TimerEvent event;
List list = new ArrayList();
public void
add(
Object obj )
{
List dispatch_now = null;
try{
timer_mon.enter();
// if the list is full kick off a dispatch and reset the list
if ( max_queue_size > 0 &&
max_queue_size == list.size()){
dispatch_now = list;
list = new ArrayList();
}
list.add( obj );
// set up a timer to wakeup in required time period
long now = SystemTime.getCurrentTime();
if ( event != null ){
event.cancel();
}
event =
timer.addEvent(
now + idle_dispatch_time,
new TimerEventPerformer()
{
public void
perform(
TimerEvent event )
{
dispatch();
}
});
}finally{
timer_mon.exit();
}
if ( dispatch_now != null ){
dispatch( dispatch_now );
}
}
public Object
remove(
Object obj )
{
Object res = null;
try{
timer_mon.enter();
res = list.remove( obj )?obj:null;
if ( res != null ){
long now = SystemTime.getCurrentTime();
if ( event != null ){
event.cancel();
}
if ( list.size() == 0 ){
event = null;
}else{
event =
timer.addEvent(
now + idle_dispatch_time,
new TimerEventPerformer()
{
public void
perform(
TimerEvent event )
{
dispatch();
}
});
}
}
}finally{
timer_mon.exit();
}
return( res );
}
protected void
dispatch()
{
List dispatch_list;
try{
timer_mon.enter();
dispatch_list = list;
list = new ArrayList();
}finally{
timer_mon.exit();
}
dispatch( dispatch_list );
}
protected void
dispatch(
List l )
{
if ( l.size() > 0 ){
try{
acceptor.accept( l );
}catch( Throwable e ){
Debug.printStackTrace(e);
}
}
}
public void
destroy()
{
dispatch();
timer.destroy();
}
});
|
public void | createProcess(java.lang.String command_line)
try{
// we need to spawn without inheriting handles
PlatformManager pm = PlatformManagerFactory.getPlatformManager();
pm.createProcess( command_line, false );
}catch(Throwable e) {
Debug.printStackTrace(e);
try{
Runtime.getRuntime().exec( command_line );
}catch( Throwable f ){
throw( new PluginException("Failed to create process", f ));
}
}
|
public void | createThread(java.lang.String name, java.lang.Runnable target)
Thread t =
new AEThread( pi.getPluginName() + "::" + name )
{
public void
runSupport()
{
setPluginThreadContext( pi );
target.run();
}
};
t.setDaemon(true);
t.start();
|
public UTTimer | createTimer(java.lang.String name)
return( new UTTimerImpl( pi, name, false ));
|
public UTTimer | createTimer(java.lang.String name, boolean lightweight)
return( new UTTimerImpl( pi, name, lightweight ));
|
public UTTimer | createTimer(java.lang.String name, int priority)
return( new UTTimerImpl( pi, name, priority ));
|
public ByteArrayWrapper | createWrapper(byte[] data)
return( new HashWrapper( data ));
|
public void | freeDirectByteBuffer(java.nio.ByteBuffer buffer)
//DirectByteBufferPool.freeBuffer( buffer );
|
public java.lang.String | getAzureusProgramDir()
String res = SystemProperties.getApplicationPath();
if ( res.endsWith(File.separator )){
res = res.substring(0,res.length()-1);
}
return( res );
|
public java.lang.String | getAzureusUserDir()
String res = SystemProperties.getUserPath();
if ( res.endsWith(File.separator )){
res = res.substring(0,res.length()-1);
}
return( res );
|
public long | getCurrentSystemTime()
return SystemTime.getCurrentTime();
|
public Formatters | getFormatters()
return( new FormattersImpl());
|
public java.io.InputStream | getImageAsStream(java.lang.String image_name)
return( UtilitiesImpl.class.getClassLoader().getResourceAsStream("org/gudy/azureus2/ui/icons/" + image_name));
|
public LocaleUtilities | getLocaleUtilities()
return( new LocaleUtilitiesImpl( pi ));
|
public Monitor | getMonitor()
return new MonitorImpl( pi );
|
public static PluginInterface | getPluginThreadContext()
return((PluginInterface)tls.get());
|
public java.net.InetAddress | getPublicAddress(boolean v6)
if ( v6 ){
String vc_ip = VersionCheckClient.getSingleton().getExternalIpAddress( false, true );
if ( vc_ip != null && vc_ip.length() > 0 ){
try{
return( InetAddress.getByName( vc_ip ));
}catch( Throwable e ){
Debug.printStackTrace( e );
}
}
return( null );
}else{
return( getPublicAddress());
}
|
public java.net.InetAddress | getPublicAddress()
long now = SystemTime.getCurrentTime();
if ( now < last_public_ip_address_time ){
last_public_ip_address_time = now;
}else{
if ( last_public_ip_address != null && now - last_public_ip_address_time < 15*60*1000 ){
return( last_public_ip_address );
}
}
InetAddress res = null;
try{
String vc_ip = VersionCheckClient.getSingleton().getExternalIpAddress( false, false );
if ( vc_ip != null && vc_ip.length() > 0 ){
res = InetAddress.getByName( vc_ip );
}else{
ExternalIPChecker checker = ExternalIPCheckerFactory.create();
ExternalIPCheckerService[] services = checker.getServices();
final String[] ip = new String[]{ null };
for (int i=0;i<services.length && ip[0] == null;i++){
final ExternalIPCheckerService service = services[i];
if ( service.supportsCheck()){
final AESemaphore sem = new AESemaphore("Utilities:getExtIP");
ExternalIPCheckerServiceListener listener =
new ExternalIPCheckerServiceListener()
{
public void
checkComplete(
ExternalIPCheckerService _service,
String _ip )
{
ip[0] = _ip;
sem.release();
}
public void
checkFailed(
ExternalIPCheckerService _service,
String _reason )
{
sem.release();
}
public void
reportProgress(
ExternalIPCheckerService _service,
String _message )
{
}
};
services[i].addListener( listener );
try{
services[i].initiateCheck( 60000 );
sem.reserve( 60000 );
}finally{
services[i].removeListener( listener );
}
}
if ( ip[0] != null ){
res = InetAddress.getByName( ip[0] );
break;
}
}
}
}catch( Throwable e ){
Debug.printStackTrace( e );
}
if ( res == null ){
// if we failed then use any prior value if we've got one
res = last_public_ip_address;
}else{
last_public_ip_address = res;
last_public_ip_address_time = now;
}
return( res );
|
public org.gudy.azureus2.plugins.utils.xml.rss.RSSFeed | getRSSFeed(java.net.URL feed_location)
return( getRSSFeed( getResourceDownloaderFactory().create( feed_location )));
|
public org.gudy.azureus2.plugins.utils.xml.rss.RSSFeed | getRSSFeed(ResourceDownloader feed_location)
return( new RSSFeedImpl( this, feed_location ));
|
public ResourceDownloaderFactory | getResourceDownloaderFactory()
return( ResourceDownloaderFactoryImpl.getSingleton());
|
public org.gudy.azureus2.plugins.utils.resourceuploader.ResourceUploaderFactory | getResourceUploaderFactory()
return( ResourceUploaderFactoryImpl.getSingleton());
|
public org.gudy.azureus2.plugins.utils.security.SESecurityManager | getSecurityManager()
return( new SESecurityManagerImpl( core ));
|
public Semaphore | getSemaphore()
return( new SemaphoreImpl( pi ));
|
public org.gudy.azureus2.plugins.utils.xml.simpleparser.SimpleXMLParserDocumentFactory | getSimpleXMLParserDocumentFactory()
return( new SimpleXMLParserDocumentFactoryImpl());
|
public boolean | isCVSVersion()
return( Constants.isCVSVersion());
|
public boolean | isFreeBSD()
return( Constants.isFreeBSD );
|
public boolean | isLinux()
return( Constants.isLinux );
|
public boolean | isOSX()
return( Constants.isOSX );
|
public boolean | isSolaris()
return( Constants.isSolaris );
|
public boolean | isUnix()
return( Constants.isUnix );
|
public boolean | isWindows()
return( Constants.isWindows );
|
public java.lang.String | normaliseFileName(java.lang.String f_name)
return FileUtil.convertOSSpecificChars(f_name);
|
public java.util.Map | readResilientBEncodedFile(java.io.File parent_dir, java.lang.String file_name, boolean use_backup)
return( FileUtil.readResilientFile( parent_dir, file_name, use_backup ));
|
public java.lang.String | reverseDNSLookup(java.net.InetAddress address)
final AESemaphore sem = new AESemaphore("Utilities:reverseDNS");
final String[] res = { null };
IPToHostNameResolver.addResolverRequest(
address.getHostAddress(),
new IPToHostNameResolverListener()
{
public void
IPResolutionComplete(
String result,
boolean succeeded )
{
if ( succeeded ){
res[0] = result;
}
sem.release();
}
});
sem.reserve( 60000 );
return( res[0] );
|
public static final void | setPluginThreadContext(PluginInterface pi)
tls.set( pi );
|
public void | writeResilientBEncodedFile(java.io.File parent_dir, java.lang.String file_name, java.util.Map data, boolean use_backup)
FileUtil.writeResilientFile( parent_dir, file_name, data, use_backup );
|