This is an automated email from the ASF dual-hosted git repository. tabish pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git
The following commit(s) were added to refs/heads/main by this push: new 1e75712 Add more Javadocs to engine and client API classes 1e75712 is described below commit 1e757123ae2c87383df71a177e4b122ff1a0f622 Author: Timothy Bish <tabish...@gmail.com> AuthorDate: Wed Apr 28 14:28:30 2021 -0400 Add more Javadocs to engine and client API classes --- .../qpid/protonj2/client/ReconnectLocation.java | 8 ++ .../qpid/protonj2/client/SessionOptions.java | 9 +- .../apache/qpid/protonj2/client/SourceOptions.java | 3 + .../apache/qpid/protonj2/client/SslOptions.java | 31 ++++++- .../qpid/protonj2/client/TransportOptions.java | 97 +++++++++++++++++++++- .../protonj2/client/impl/ClientDeliveryState.java | 63 +++++++++++++- .../client/transport/X509AliasKeyManager.java | 11 +++ .../client/util/ReconnectLocationPool.java | 9 ++ .../qpid/protonj2/engine/IncomingAMQPEnvelope.java | 13 +++ .../org/apache/qpid/protonj2/engine/LinkState.java | 21 ++++- .../qpid/protonj2/engine/OutgoingAMQPEnvelope.java | 27 ++++++ .../apache/qpid/protonj2/engine/SessionState.java | 15 +++- 12 files changed, 294 insertions(+), 13 deletions(-) diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/ReconnectLocation.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/ReconnectLocation.java index 20b9a74..e876523 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/ReconnectLocation.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/ReconnectLocation.java @@ -29,6 +29,14 @@ public class ReconnectLocation { private final String host; private final int port; + /** + * Creates a new {@link ReconnectLocation} instance with the fixed host and port values. + * + * @param host + * The remote host where the connection will be made + * @param port + * The port on the remote where the connection attempt will be made. + */ public ReconnectLocation(String host, int port) { Objects.requireNonNull(host, "Cannot create a reconnect entry with a null host value"); diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/SessionOptions.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/SessionOptions.java index bab793f..e65a131 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/SessionOptions.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/SessionOptions.java @@ -24,11 +24,18 @@ import org.apache.qpid.protonj2.client.exceptions.ClientOperationTimedOutExcepti import org.apache.qpid.protonj2.client.exceptions.ClientSendTimedOutException; /** - * Options that control the behaviour of the {@link Session} created from them. + * Options that control the behavior of the {@link Session} created from them. */ public class SessionOptions { + /** + * The default Session configured incoming capacity limit to provide to the remote + */ public static final int DEFAULT_SESSION_INCOMING_CAPACITY = 100 * 1024 * 1024; + + /** + * The default Session configured outgoing capacity to apply to local pending writes. + */ public static final int DEFAULT_SESSION_OUTGOING_CAPACITY = 100 * 1024 * 1024; private long sendTimeout = ConnectionOptions.DEFAULT_SEND_TIMEOUT; diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/SourceOptions.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/SourceOptions.java index e96a337..c9005c2 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/SourceOptions.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/SourceOptions.java @@ -31,6 +31,9 @@ public final class SourceOptions extends TerminusOptions<SourceOptions> { DeliveryState.Type.ACCEPTED, DeliveryState.Type.REJECTED, DeliveryState.Type.RELEASED, DeliveryState.Type.MODIFIED }; + /** + * The default AMQP Outcome that will be specified for all new {@link Receiver} instances. + */ public static final ClientDeliveryState DEFAULT_RECEIVER_OUTCOME = new ClientDeliveryState.ClientModified(true, false); private DistributionMode distributionMode; diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/SslOptions.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/SslOptions.java index dedef84..144f870 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/SslOptions.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/SslOptions.java @@ -358,24 +358,47 @@ public class SslOptions implements Cloneable { return this; } + /** + * @return the currently configured default SSL port. + */ public int defaultSslPort() { return defaultSslPort; } + /** + * Sets the default AMQP SSL port that should be used if the user did not provide a port value. + * + * @param defaultSslPort + * the default AMQP SSL port to use when none provided by the user. + * + * @return this {@link SslOptions} instance. + */ public SslOptions defaultSslPort(int defaultSslPort) { this.defaultSslPort = defaultSslPort; return this; } + /** + * @return the currently configured {@link SSLContext} override or null if none set. + */ + public SSLContext sslContextOverride() { + return sslContextOverride; + } + + /** + * Provides a user configured {@link SSLContext} that should be used when performing the + * SSL handshake with the remote. + * + * @param sslContextOverride + * User defined {@link SSLContext} used for authentication. + * + * @return this {@link SslOptions} instance. + */ public SslOptions sslContextOverride(SSLContext sslContextOverride) { this.sslContextOverride = sslContextOverride; return this; } - public SSLContext sslContextOverride() { - return sslContextOverride; - } - /** * @return true if the an native SSL based encryption layer is allowed to be used instead of the JDK. */ diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/TransportOptions.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/TransportOptions.java index c911f87..f2624dc 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/TransportOptions.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/TransportOptions.java @@ -173,6 +173,14 @@ public class TransportOptions implements Cloneable { return tcpNoDelay; } + /** + * Configure the underlying connection to use the tcpNoDelay option. + * + * @param tcpNoDelay + * controls if the underlying connection configures tcpNoDelay. + * + * @return this {@link TransportOptions} instance. + */ public TransportOptions tcpNoDelay(boolean tcpNoDelay) { this.tcpNoDelay = tcpNoDelay; return this; @@ -185,6 +193,14 @@ public class TransportOptions implements Cloneable { return soLinger; } + /** + * Configures the soLinger value that should be configured on the connection socket. + * + * @param soLinger + * The soLinger value to use for the underlying socket. + * + * @return this {@link TransportOptions} instance. + */ public TransportOptions soLinger(int soLinger) { this.soLinger = soLinger; return this; @@ -197,6 +213,14 @@ public class TransportOptions implements Cloneable { return tcpKeepAlive; } + /** + * Configures the TCP socket keep-alive value that should be used for a connection. + * + * @param keepAlive + * The TCP/IP keep-alive value to use for the connection. + * + * @return this {@link TransportOptions} instance. + */ public TransportOptions tcpKeepAlive(boolean keepAlive) { this.tcpKeepAlive = keepAlive; return this; @@ -209,6 +233,15 @@ public class TransportOptions implements Cloneable { return connectTimeout; } + /** + * A transport layer connection timeout value that controls how long a connection attempt can block + * before giving up and throwing a connection error. + * + * @param connectTimeout + * connection timeout in milliseconds. + * + * @return this {@link TransportOptions} instance. + */ public TransportOptions connectTimeout(int connectTimeout) { this.connectTimeout = connectTimeout; return this; @@ -221,6 +254,14 @@ public class TransportOptions implements Cloneable { return defaultTcpPort; } + /** + * The default unsecured connection port to use when none has been specified by the user. + * + * @param defaultTcpPort + * the default port to use for non-SSL connection if none provided. + * + * @return this {@link TransportOptions} instance. + */ public TransportOptions defaultTcpPort(int defaultTcpPort) { this.defaultTcpPort = defaultTcpPort; return this; @@ -233,6 +274,14 @@ public class TransportOptions implements Cloneable { return localAddress; } + /** + * The local address to bind to when attempting a remote connection. + * + * @param localAddress + * the local address to bind to. + * + * @return this {@link TransportOptions} instance. + */ public TransportOptions localAddress(String localAddress) { this.localAddress = localAddress; return this; @@ -245,6 +294,15 @@ public class TransportOptions implements Cloneable { return localPort; } + /** + * Configures the local port value to bind to when connecting to the remote, if that port is + * already in use this can lead to a connection error. + * + * @param localPort + * local port value to use when making a remote connection. + * + * @return this {@link TransportOptions} instance. + */ public TransportOptions localPort(int localPort) { this.localPort = localPort; return this; @@ -263,7 +321,7 @@ public class TransportOptions implements Cloneable { * @param allowNativeIO * should use of available native transport be allowed if one is available. * - * @return this options instance. + * @return this {@link TransportOptions} instance. */ public TransportOptions allowNativeIO(boolean allowNativeIO) { this.allowNativeIO = allowNativeIO; @@ -301,7 +359,7 @@ public class TransportOptions implements Cloneable { * @param traceBytes * should the transport log the bytes in and out. * - * @return this options instance. + * @return this {@link TransportOptions} instance. */ public TransportOptions traceBytes(boolean traceBytes) { this.traceBytes = traceBytes; @@ -315,6 +373,14 @@ public class TransportOptions implements Cloneable { return useWebSockets; } + /** + * Set to true to configure the transport layer as a WebSocket based connection. + * + * @param webSockets + * should the transport attempt connection using a WebSocket. + * + * @return this {@link TransportOptions} instance. + */ public TransportOptions useWebSockets(boolean webSockets) { this.useWebSockets = webSockets; return this; @@ -327,6 +393,14 @@ public class TransportOptions implements Cloneable { return webSocketPath; } + /** + * The optional path element to provide when connecting via a WebSocket. + * + * @param webSocketPath + * path value to use for WebSocket connections. + * + * @return this {@link TransportOptions} instance. + */ public TransportOptions webSocketPath(String webSocketPath) { this.webSocketPath = webSocketPath; return this; @@ -339,6 +413,16 @@ public class TransportOptions implements Cloneable { return webSocketHeaders; } + /** + * Additional headers to be passed along to the remote when performing a WebSocket based connect. + * + * @param key + * the header key to use with the provided value. + * @param value + * the value to store under the provided key. + * + * @return this {@link TransportOptions} instance. + */ public TransportOptions addWebSocketHeader(String key, String value) { this.webSocketHeaders.put(key, value); return this; @@ -351,6 +435,15 @@ public class TransportOptions implements Cloneable { return webSocketMaxFrameSize; } + /** + * Configures the maximum size of each WebSocket frame, payloads larger than the max frame size are + * split into multiple frames during transmission. + * + * @param maxFrameSize + * the maximum WebSocket frame size before payloads are split. + * + * @return this {@link TransportOptions} instance. + */ public TransportOptions webSocketMaxFrameSize(int maxFrameSize) { this.webSocketMaxFrameSize = maxFrameSize; return this; diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientDeliveryState.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientDeliveryState.java index a9e0d90..6a724d3 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientDeliveryState.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientDeliveryState.java @@ -121,6 +121,9 @@ public abstract class ClientDeliveryState implements DeliveryState { //----- Delivery State implementations + /** + * Client defined {@link Accepted} delivery state definition + */ public static class ClientAccepted extends ClientDeliveryState { private static final ClientAccepted INSTANCE = new ClientAccepted(); @@ -135,11 +138,17 @@ public abstract class ClientDeliveryState implements DeliveryState { return Accepted.getInstance(); } + /** + * @return a singleton instance of the accepted type. + */ public static ClientAccepted getInstance() { return INSTANCE; } } + /** + * Client defined {@link Released} delivery state definition + */ public static class ClientReleased extends ClientDeliveryState { private static final ClientReleased INSTANCE = new ClientReleased(); @@ -154,11 +163,17 @@ public abstract class ClientDeliveryState implements DeliveryState { return Released.getInstance(); } + /** + * @return a singleton instance of the released type. + */ public static ClientReleased getInstance() { return INSTANCE; } } + /** + * Client defined {@link Rejected} delivery state definition + */ public static class ClientRejected extends ClientDeliveryState { private final Rejected rejected = new Rejected(); @@ -169,12 +184,30 @@ public abstract class ClientDeliveryState implements DeliveryState { } } + /** + * Create a new Rejected outcome with the given description of the rejection cause. + * + * @param condition + * the condition that defines the rejection outcome. + * @param description + * the description of the underlying cause of the rejection. + */ public ClientRejected(String condition, String description) { if (condition != null || description != null) { rejected.setError(new ErrorCondition(Symbol.valueOf(condition), description)); } } + /** + * Create a new Rejected outcome with the given description of the rejection cause. + * + * @param condition + * the condition that defines the rejection outcome. + * @param description + * the description of the underlying cause of the rejection. + * @param info + * additional information to be provide to the remote about the rejection. + */ public ClientRejected(String condition, String description, Map<String, Object> info) { if (condition != null || description != null) { rejected.setError(new ErrorCondition( @@ -192,11 +225,14 @@ public abstract class ClientDeliveryState implements DeliveryState { return rejected; } - public static ClientRejected fromProtonType(Rejected rejected) { + static ClientRejected fromProtonType(Rejected rejected) { return new ClientRejected(rejected); } } + /** + * Client defined {@link Modified} delivery state definition + */ public static class ClientModified extends ClientDeliveryState { private final Modified modified = new Modified(); @@ -207,11 +243,29 @@ public abstract class ClientDeliveryState implements DeliveryState { this.modified.setMessageAnnotations(new LinkedHashMap<>(modified.getMessageAnnotations())); } + /** + * Create a new instance with the given outcome values. + * + * @param failed + * has the delivery failed + * @param undeliverable + * is the delivery no longer deliverable to this client. + */ public ClientModified(boolean failed, boolean undeliverable) { modified.setDeliveryFailed(failed); modified.setUndeliverableHere(undeliverable); } + /** + * Create a new instance with the given outcome values. + * + * @param failed + * has the delivery failed + * @param undeliverable + * is the delivery no longer deliverable to this client. + * @param annotations + * updated annotation values to provide to the remote. + */ public ClientModified(boolean failed, boolean undeliverable, Map<String, Object> annotations) { modified.setDeliveryFailed(failed); modified.setUndeliverableHere(undeliverable); @@ -228,11 +282,14 @@ public abstract class ClientDeliveryState implements DeliveryState { return modified; } - public static ClientModified fromProtonType(Modified modified) { + static ClientModified fromProtonType(Modified modified) { return new ClientModified(modified); } } + /** + * Client defined {@link TransactionalState} delivery state definition + */ public static class ClientTransactional extends ClientDeliveryState { private final TransactionalState txnState = new TransactionalState(); @@ -252,7 +309,7 @@ public abstract class ClientDeliveryState implements DeliveryState { return txnState; } - public static ClientTransactional fromProtonType(TransactionalState txnState) { + static ClientTransactional fromProtonType(TransactionalState txnState) { return new ClientTransactional(txnState); } } diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/transport/X509AliasKeyManager.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/transport/X509AliasKeyManager.java index 6fad74b..12b240b 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/transport/X509AliasKeyManager.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/transport/X509AliasKeyManager.java @@ -32,9 +32,20 @@ import javax.net.ssl.X509ExtendedKeyManager; * key manager. */ public class X509AliasKeyManager extends X509ExtendedKeyManager { + private X509ExtendedKeyManager delegate; private String alias; + /** + * Creates a new alias manager with the provided configuration + * + * @param alias + * The alias value to be used. + * @param delegate + * A delegate that will be used by this manager instance. + * + * @throws IllegalArgumentException if no alias is provided for this manager. + */ public X509AliasKeyManager(String alias, X509ExtendedKeyManager delegate) throws IllegalArgumentException { if (alias == null) { throw new IllegalArgumentException("The given key alias must not be null."); diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/util/ReconnectLocationPool.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/util/ReconnectLocationPool.java index 49d06be..d4d5d3d 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/util/ReconnectLocationPool.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/util/ReconnectLocationPool.java @@ -31,10 +31,19 @@ public class ReconnectLocationPool { private final LinkedList<ReconnectLocation> entries; + /** + * Creates an empty {@link ReconnectLocationPool}. + */ public ReconnectLocationPool() { this.entries = new LinkedList<ReconnectLocation>(); } + /** + * Creates a new {@link ReconnectLocationPool} with the provided {@link ReconnectLocation} values. + * + * @param backups + * a list of location where a reconnection attempt should be made. + */ public ReconnectLocationPool(List<ReconnectLocation> backups) { this.entries = new LinkedList<ReconnectLocation>(); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/IncomingAMQPEnvelope.java b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/IncomingAMQPEnvelope.java index 1693e60..b141454 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/IncomingAMQPEnvelope.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/IncomingAMQPEnvelope.java @@ -24,6 +24,9 @@ import org.apache.qpid.protonj2.types.transport.Performative.PerformativeHandler */ public class IncomingAMQPEnvelope extends PerformativeEnvelope<Performative> { + /** + * The AMQP Frame type marker value used when processing incoming frames. + */ public static final byte AMQP_FRAME_TYPE = (byte) 0; private AMQPPerformativeEnvelopePool<IncomingAMQPEnvelope> pool; @@ -52,6 +55,16 @@ public class IncomingAMQPEnvelope extends PerformativeEnvelope<Performative> { } } + /** + * Invoke the correct PerformativeHandler event based on the body of this {@link IncomingAMQPEnvelope} + * + * @param <E> + * The type that the {@link Performative} handler expects for the context value. + * @param handler + * The handler that should be used to process the current body value. + * @param context + * The context that should be passed along for the current event. + */ public <E> void invoke(PerformativeHandler<E> handler, E context) { getBody().invoke(handler, getPayload(), getChannel(), context); } diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/LinkState.java b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/LinkState.java index ac839f6..a4a3409 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/LinkState.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/LinkState.java @@ -20,8 +20,25 @@ package org.apache.qpid.protonj2.engine; * Represents the state of an AMQP Link. */ public enum LinkState { - IDLE, + + /** + * Indicates that the targeted end of the Link (local or remote) has not yet been opened. + */ + IDLE, + + /** + * Indicates that the targeted end of the Link (local or remote) is currently open. + */ ACTIVE, + + /** + * Indicates that the targeted end of the Link (local or remote) has been detached. + */ DETACHED, - CLOSED, + + /** + * Indicates that the targeted end of the Link (local or remote) has been closed. + */ + CLOSED + } diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/OutgoingAMQPEnvelope.java b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/OutgoingAMQPEnvelope.java index 6616976..1e825ba 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/OutgoingAMQPEnvelope.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/OutgoingAMQPEnvelope.java @@ -26,6 +26,9 @@ import org.apache.qpid.protonj2.types.transport.Performative.PerformativeHandler */ public class OutgoingAMQPEnvelope extends PerformativeEnvelope<Performative> { + /** + * The frame type value to used when encoding the outgoing AMQP frame. + */ public static final byte AMQP_FRAME_TYPE = (byte) 0; private AMQPPerformativeEnvelopePool<OutgoingAMQPEnvelope> pool; @@ -63,6 +66,13 @@ public class OutgoingAMQPEnvelope extends PerformativeEnvelope<Performative> { return this; } + /** + * Called when the encoder determines that the encoding of the {@link Performative} plus any + * payload value is to large for a single AMQP frame. The configured handler should update + * the {@link Performative} in preparation for encoding as a split framed AMQP transfer. + * + * @return this {@link OutgoingAMQPEnvelope} instance + */ public OutgoingAMQPEnvelope handlePayloadToLarge() { payloadToLargeHandler.accept(getBody()); return this; @@ -82,6 +92,13 @@ public class OutgoingAMQPEnvelope extends PerformativeEnvelope<Performative> { return this; } + /** + * Called by the encoder when the write of a frame that comprises the transfer of the AMQP {@link Performative} + * plus any assigned payload has completed. If the transfer comprises multiple frame writes this handler should + * be invoked as each frame is successfully written by the IO layer. + * + * @return this {@link OutgoingAMQPEnvelope} instance. + */ public OutgoingAMQPEnvelope handleOutgoingFrameWriteComplete() { if (frameWriteCompleteHandler != null) { frameWriteCompleteHandler.run(); @@ -109,6 +126,16 @@ public class OutgoingAMQPEnvelope extends PerformativeEnvelope<Performative> { } } + /** + * Invoke the correct PerformativeHandler event based on the body of this {@link OutgoingAMQPEnvelope} + * + * @param <E> + * The type that the {@link Performative} handler expects for the context value. + * @param handler + * The handler that should be used to process the current body value. + * @param context + * The context that should be passed along for the current event. + */ public <E> void invoke(PerformativeHandler<E> handler, E context) { getBody().invoke(handler, getPayload(), getChannel(), context); } diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/SessionState.java b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/SessionState.java index 17e7cb5..874c4ef 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/SessionState.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/SessionState.java @@ -20,7 +20,20 @@ package org.apache.qpid.protonj2.engine; * Represents the state of an AMQP Session. */ public enum SessionState { + + /** + * Indicates that the targeted end of the Session (local or remote) has not yet been opened. + */ IDLE, + + /** + * Indicates that the targeted end of the Session (local or remote) is currently open. + */ ACTIVE, - CLOSED, + + /** + * Indicates that the targeted end of the Session (local or remote) has been closed. + */ + CLOSED + } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org