mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +01:00
Merged common methods of BatchTransportPlugin and
StreamTransportPlugin into a superclass.
This commit is contained in:
49
api/net/sf/briar/api/transport/TransportPlugin.java
Normal file
49
api/net/sf/briar/api/transport/TransportPlugin.java
Normal 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();
|
||||||
|
}
|
||||||
@@ -4,18 +4,15 @@ import java.io.IOException;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.sf.briar.api.ContactId;
|
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.InvalidConfigException;
|
||||||
import net.sf.briar.api.transport.InvalidPropertiesException;
|
import net.sf.briar.api.transport.InvalidPropertiesException;
|
||||||
|
import net.sf.briar.api.transport.TransportPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface for transport plugins that do not support bidirectional,
|
* An interface for transport plugins that do not support bidirectional,
|
||||||
* reliable, ordered, timely delivery of data.
|
* reliable, ordered, timely delivery of data.
|
||||||
*/
|
*/
|
||||||
public interface BatchTransportPlugin {
|
public interface BatchTransportPlugin extends TransportPlugin {
|
||||||
|
|
||||||
/** Returns the plugin's transport identifier. */
|
|
||||||
TransportId getId();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the plugin. Any connections that are later initiated by contacts
|
* Starts the plugin. Any connections that are later initiated by contacts
|
||||||
@@ -26,42 +23,6 @@ public interface BatchTransportPlugin {
|
|||||||
Map<String, String> config, BatchTransportCallback c)
|
Map<String, String> config, BatchTransportCallback c)
|
||||||
throws InvalidPropertiesException, InvalidConfigException, IOException;
|
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
|
* Attempts to create and return a BatchTransportReader for the given
|
||||||
* contact using the current transport and configuration properties.
|
* contact using the current transport and configuration properties.
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
package net.sf.briar.api.transport.stream;
|
package net.sf.briar.api.transport.stream;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.sf.briar.api.ContactId;
|
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.InvalidConfigException;
|
||||||
import net.sf.briar.api.transport.InvalidPropertiesException;
|
import net.sf.briar.api.transport.InvalidPropertiesException;
|
||||||
|
import net.sf.briar.api.transport.TransportPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface for transport plugins that support bidirectional, reliable,
|
* An interface for transport plugins that support bidirectional, reliable,
|
||||||
* ordered, timely delivery of data.
|
* ordered, timely delivery of data.
|
||||||
*/
|
*/
|
||||||
public interface StreamTransportPlugin {
|
public interface StreamTransportPlugin extends TransportPlugin {
|
||||||
|
|
||||||
/** Returns the plugin's transport identifier. */
|
|
||||||
TransportId getId();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the plugin. Any connections that are later initiated by contacts
|
* Starts the plugin. Any connections that are later initiated by contacts
|
||||||
@@ -23,43 +21,7 @@ public interface StreamTransportPlugin {
|
|||||||
void start(Map<String, String> localProperties,
|
void start(Map<String, String> localProperties,
|
||||||
Map<ContactId, Map<String, String>> remoteProperties,
|
Map<ContactId, Map<String, String>> remoteProperties,
|
||||||
Map<String, String> config, StreamTransportCallback c)
|
Map<String, String> config, StreamTransportCallback c)
|
||||||
throws InvalidPropertiesException, InvalidConfigException;
|
throws InvalidPropertiesException, InvalidConfigException, IOException;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to create and return a StreamTransportConnection to the given
|
* Attempts to create and return a StreamTransportConnection to the given
|
||||||
|
|||||||
Reference in New Issue
Block a user