Merged common methods of BatchTransportPlugin and

StreamTransportPlugin into a superclass.
This commit is contained in:
akwizgran
2011-10-06 09:22:56 +01:00
parent b54668c50b
commit 6737e4ddfb
3 changed files with 55 additions and 83 deletions

View File

@@ -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();
}

View File

@@ -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.

View File

@@ -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