diff --git a/api/net/sf/briar/api/transport/TransportPlugin.java b/api/net/sf/briar/api/transport/TransportPlugin.java new file mode 100644 index 0000000000000000000000000000000000000000..d4e8948856460a0fd45c5da3d60899e83cf2f3c5 --- /dev/null +++ b/api/net/sf/briar/api/transport/TransportPlugin.java @@ -0,0 +1,49 @@ +package net.sf.briar.api.transport; + +import java.io.IOException; +import java.util.Map; + +import net.sf.briar.api.ContactId; +import net.sf.briar.api.TransportId; + +public interface TransportPlugin { + + /** Returns the plugin's transport identifier. */ + TransportId getId(); + + /** + * Stops the plugin. No further connections will be passed to the callback + * after this method has returned. + */ + void stop() throws IOException; + + /** Updates the plugin's local transport properties. */ + void setLocalProperties(Map<String, String> properties) + throws InvalidPropertiesException; + + /** Updates the plugin's transport properties for the given contact. */ + void setRemoteProperties(ContactId c, Map<String, String> properties) + throws InvalidPropertiesException; + + /** Updates the plugin's configuration properties. */ + void setConfig(Map<String, String> config) throws InvalidConfigException; + + /** + * Returns true if the plugin's poll() method should be called + * periodically to attempt to establish connections. + */ + boolean shouldPoll(); + + /** + * Returns the desired interval in milliseconds between calls to the + * plugin's poll() method. + */ + long getPollingInterval(); + + /** + * Attempts to establish connections using the current transport and + * configuration properties, and passes any created connections to the + * callback. + */ + void poll(); +} diff --git a/api/net/sf/briar/api/transport/batch/BatchTransportPlugin.java b/api/net/sf/briar/api/transport/batch/BatchTransportPlugin.java index 02141015bca831c2924a0d4e1310c97d3f12c063..b0457b30a1024858e20464ec80bda523be2f061a 100644 --- a/api/net/sf/briar/api/transport/batch/BatchTransportPlugin.java +++ b/api/net/sf/briar/api/transport/batch/BatchTransportPlugin.java @@ -4,18 +4,15 @@ import java.io.IOException; import java.util.Map; import net.sf.briar.api.ContactId; -import net.sf.briar.api.TransportId; import net.sf.briar.api.transport.InvalidConfigException; import net.sf.briar.api.transport.InvalidPropertiesException; +import net.sf.briar.api.transport.TransportPlugin; /** * An interface for transport plugins that do not support bidirectional, * reliable, ordered, timely delivery of data. */ -public interface BatchTransportPlugin { - - /** Returns the plugin's transport identifier. */ - TransportId getId(); +public interface BatchTransportPlugin extends TransportPlugin { /** * Starts the plugin. Any connections that are later initiated by contacts @@ -26,42 +23,6 @@ public interface BatchTransportPlugin { Map<String, String> config, BatchTransportCallback c) throws InvalidPropertiesException, InvalidConfigException, IOException; - /** - * Stops the plugin. No further connections will be passed to the callback - * after this method has returned. - */ - void stop() throws IOException; - - /** Updates the plugin's local transport properties. */ - void setLocalProperties(Map<String, String> properties) - throws InvalidPropertiesException; - - /** Updates the plugin's transport properties for the given contact. */ - void setRemoteProperties(ContactId c, Map<String, String> properties) - throws InvalidPropertiesException; - - /** Updates the plugin's configuration properties. */ - void setConfig(Map<String, String> config) throws InvalidConfigException; - - /** - * Returns true if the plugin's poll() method should be called - * periodically to attempt to establish connections. - */ - boolean shouldPoll(); - - /** - * Returns the desired interval in milliseconds between calls to the - * plugin's poll() method. - */ - long getPollingInterval(); - - /** - * Attempts to establish incoming and/or outgoing connections using the - * current transport and configuration properties, and passes any created - * readers and/or writers to the callback. - */ - void poll(); - /** * Attempts to create and return a BatchTransportReader for the given * contact using the current transport and configuration properties. diff --git a/api/net/sf/briar/api/transport/stream/StreamTransportPlugin.java b/api/net/sf/briar/api/transport/stream/StreamTransportPlugin.java index 1a2730ec9237e292b76e53a74619cab1a3ef0943..001cfe8d10bd617de8d0851d7e8d9c777411e111 100644 --- a/api/net/sf/briar/api/transport/stream/StreamTransportPlugin.java +++ b/api/net/sf/briar/api/transport/stream/StreamTransportPlugin.java @@ -1,20 +1,18 @@ package net.sf.briar.api.transport.stream; +import java.io.IOException; import java.util.Map; import net.sf.briar.api.ContactId; -import net.sf.briar.api.TransportId; import net.sf.briar.api.transport.InvalidConfigException; import net.sf.briar.api.transport.InvalidPropertiesException; +import net.sf.briar.api.transport.TransportPlugin; /** * An interface for transport plugins that support bidirectional, reliable, * ordered, timely delivery of data. */ -public interface StreamTransportPlugin { - - /** Returns the plugin's transport identifier. */ - TransportId getId(); +public interface StreamTransportPlugin extends TransportPlugin { /** * Starts the plugin. Any connections that are later initiated by contacts @@ -23,43 +21,7 @@ public interface StreamTransportPlugin { void start(Map<String, String> localProperties, Map<ContactId, Map<String, String>> remoteProperties, Map<String, String> config, StreamTransportCallback c) - throws InvalidPropertiesException, InvalidConfigException; - - /** - * Stops the plugin. No further connections will be passed to the callback - * after this method has returned. - */ - void stop(); - - /** Updates the plugin's local transport properties. */ - void setLocalProperties(Map<String, String> properties) - throws InvalidPropertiesException; - - /** Updates the plugin's transport properties for the given contact. */ - void setRemoteProperties(ContactId c, Map<String, String> properties) - throws InvalidPropertiesException; - - /** Updates the plugin's configuration properties. */ - void setConfig(Map<String, String> config) throws InvalidConfigException; - - /** - * Returns true if the plugin's poll() method should be called - * periodically to attempt to establish connections. - */ - boolean shouldPoll(); - - /** - * Returns the desired interval in milliseconds between calls to the - * plugin's poll() method. - */ - long getPollingInterval(); - - /** - * Attempts to establish connections using the current transport and - * configuration properties, and passes any created connections to the - * callback. - */ - void poll(); + throws InvalidPropertiesException, InvalidConfigException, IOException; /** * Attempts to create and return a StreamTransportConnection to the given