共用方式為


OperationContext Class

  • java.lang.Object
    • com.microsoft.azure.storage.OperationContext

public class OperationContext

Represents the current logical operation. A logical operation may have a one-to-many relationship with multiple individual physical requests.

Field Summary

Modifier and Type Field and Description
final String defaultLoggerName

Name of the org.slf4j.Logger that will be created by default if logging is enabled and a org.slf4j.Logger has not been specified.

Constructor Summary

Constructor Description
OperationContext()

Creates an instance of the class.

Method Summary

Modifier and Type Method and Description
synchronized void appendRequestResult(RequestResult requestResult)

Reserved for internal use. Appends a RequestResult object to the internal collection in a synchronized manner.

String getClientRequestID()

Gets the client side trace ID.

long getClientTimeInMs()

Gets the operation latency, in milliseconds, from the client's perspective. This may include any potential retries.

Proxy getDefaultProxy()

Gets the default proxy used by the client library if enabled. The default can be overridden to enable a proxy for an individual operation context instance by using setProxy(Proxy proxy).

String getDefaultProxyPassword()

Gets the default password for the authenticated proxy which will be used when making a request. Default is . To set a password to use setProxyPassword(final String password)

String getDefaultProxyUsername()

Gets a default username for the authenticated proxy which will be used when making a request. Default is . To set a username use setDefaultProxyUsername(final String username)

StorageEventMultiCaster<ErrorReceivingResponseEvent, StorageEvent<ErrorReceivingResponseEvent>> getErrorReceivingResponseEventHandler()

Gets an event multi-caster that is triggered when a network error occurs before the HTTP response status and headers are received. It allows event listeners to be dynamically added and removed.

StorageEventMultiCaster<ErrorReceivingResponseEvent, StorageEvent<ErrorReceivingResponseEvent>> getGlobalErrorReceivingResponseEventHandler()

Gets a global event multi-caster that is triggered when a network error occurs before the HTTP response status and headers are received. It allows event listeners to be dynamically added and removed.

StorageEventMultiCaster<RequestCompletedEvent, StorageEvent<RequestCompletedEvent>> getGlobalRequestCompletedEventHandler()

Gets a global event multi-caster that is triggered when a request is completed. It allows event listeners to be dynamically added and removed.

StorageEventMultiCaster<ResponseReceivedEvent, StorageEvent<ResponseReceivedEvent>> getGlobalResponseReceivedEventHandler()

Gets a global event multi-caster that is triggered when a response is received. It allows event listeners to be dynamically added and removed.

StorageEventMultiCaster<RetryingEvent, StorageEvent<RetryingEvent>> getGlobalRetryingEventHandler()

Gets a global event multi-caster that is triggered when a request is retried. It allows event listeners to be dynamically added and removed.

StorageEventMultiCaster<SendingRequestEvent, StorageEvent<SendingRequestEvent>> getGlobalSendingRequestEventHandler()

Gets a global event multi-caster that is triggered before sending a request. It allows event listeners to be dynamically added and removed.

synchronized RequestResult getLastResult()

Gets the last request result encountered for the operation.

org.slf4j.Logger getLogger()

Gets the org.slf4j.Logger associated with this operation. If the org.slf4j.Logger object associated with this operation is null, this will return the class's default org.slf4j.Logger object.

Proxy getProxy()

Gets a proxy which will be used when making a request. Default is . To set a proxy to use by default, use setDefaultProxy(Proxy defaultProxy)

String getProxyPassword()

Gets the password for the authenticated proxy which will be used when making a request. Default is . To set a password to use setProxyPassword(final String password)

String getProxyUsername()

Gets a username for the authenticated proxy which will be used when making a request. Default is . To set a username use setProxyUsername(final String username)

StorageEventMultiCaster<RequestCompletedEvent, StorageEvent<RequestCompletedEvent>> getRequestCompletedEventHandler()

Gets an event multi-caster that is triggered when a request is completed. It allows event listeners to be dynamically added and removed.

ArrayList<RequestResult> getRequestResults()

Returns the set of request results that the current operation has created.

StorageEventMultiCaster<ResponseReceivedEvent, StorageEvent<ResponseReceivedEvent>> getResponseReceivedEventHandler()

Gets an event multi-caster that is triggered when a response is received. It allows event listeners to be dynamically added and removed.

StorageEventMultiCaster<RetryingEvent, StorageEvent<RetryingEvent>> getRetryingEventHandler()

Gets an event multi-caster that is triggered when a request is retried. It allows event listeners to be dynamically added and removed.

StorageEventMultiCaster<SendingRequestEvent, StorageEvent<SendingRequestEvent>> getSendingRequestEventHandler()

Gets an event multi-caster that is triggered before sending a request. It allows event listeners to be dynamically added and removed.

HashMap<String, String> getUserHeaders()

Gets any additional headers for the request, for example, for proxy or logging information.

void initialize()

Reserved for internal use. Initializes the in order to begin processing a new operation. All operation specific information is erased.

boolean isLoggingEnabled()

Indicates whether log entries will be produced for this request.

boolean isLoggingEnabledByDefault()

Indicates whether the client library should produce log entries by default. The default can be overridden to enable logging for an individual operation context instance by using setLoggingEnabled(boolean loggingEnabled).

void setClientRequestID(final String clientRequestID)

Sets the client side request ID.

void setClientTimeInMs(final long clientTimeInMs)

Reserved for internal use. Represents the operation latency, in milliseconds, from the client's perspective. This may include any potential retries.

void setDefaultProxy(Proxy defaultProxy)

Specifies the proxy the client library should use by default. The default can be overridden to turn on a proxy for an individual operation context instance by using setProxy(Proxy proxy).

void setDefaultProxyPassword(final String password)

Sets a default password for an authenticated proxy which will be used when making a request. Default is .

void setDefaultProxyUsername(final String username)

Sets a default username for an authenticated proxy which will be used when making a request. Default is .

void setErrorReceivingResponseEventHandler(final StorageEventMultiCaster<ErrorReceivingResponseEvent, StorageEvent<ErrorReceivingResponseEvent>> errorReceivingResponseEventHandler)

Sets an event multi-caster that is triggered when a network error occurs before the HTTP response status and headers are received.

void setGlobalErrorReceivingResponseEventHandler(final StorageEventMultiCaster<ErrorReceivingResponseEvent, StorageEvent<ErrorReceivingResponseEvent>> globalErrorReceivingResponseEventHandler)

Sets a global event multi-caster that is triggered when a network error occurs before the HTTP response status and headers are received.

void setGlobalRequestCompletedEventHandler(final StorageEventMultiCaster<RequestCompletedEvent, StorageEvent<RequestCompletedEvent>> globalRequestCompletedEventHandler)

Sets a global event multi-caster that is triggered when a request is completed.

void setGlobalResponseReceivedEventHandler(final StorageEventMultiCaster<ResponseReceivedEvent, StorageEvent<ResponseReceivedEvent>> globalResponseReceivedEventHandler)

Sets a global event multi-caster that is triggered when a response is received.

void setGlobalRetryingEventHandler(final StorageEventMultiCaster<RetryingEvent, StorageEvent<RetryingEvent>> globalRetryingEventHandler)

Sets a global event multi-caster that is triggered when a request is retried.

void setGlobalSendingRequestEventHandler(final StorageEventMultiCaster<SendingRequestEvent, StorageEvent<SendingRequestEvent>> globalSendingRequestEventHandler)

Sets a global event multi-caster that is triggered before sending a request.

void setLogger(final org.slf4j.Logger logger)

Sets the org.slf4j.Logger for this operation.

void setLoggingEnabled(boolean loggingEnabled)

Specifies whether log entries will be produced for this request.

void setLoggingEnabledByDefault(boolean enableLoggingByDefault)

Specifies whether the client library should produce log entries by default. The default can be overridden to turn on logging for an individual operation context instance by using setLoggingEnabled(boolean loggingEnabled).

void setProxy(Proxy proxy)

Sets a proxy which will be used when making a request. Default is . To set a proxy to use by default, use setDefaultProxy(Proxy defaultProxy)

void setProxyPassword(final String password)

Sets a password for an authenticated proxy which will be used when making a request. Default is .

void setProxyUsername(final String username)

Sets a username for an authenticated proxy which will be used when making a request. Default is .

void setRequestCompletedEventHandler(final StorageEventMultiCaster<RequestCompletedEvent, StorageEvent<RequestCompletedEvent>> requestCompletedEventHandler)

Sets an event multi-caster that is triggered when a request is completed.

void setResponseReceivedEventHandler(final StorageEventMultiCaster<ResponseReceivedEvent, StorageEvent<ResponseReceivedEvent>> responseReceivedEventHandler)

Sets an event multi-caster that is triggered when a response is received.

void setRetryingEventHandler(final StorageEventMultiCaster<RetryingEvent, StorageEvent<RetryingEvent>> retryingEventHandler)

Sets an event multi-caster that is triggered when a request is retried.

void setSendingRequestEventHandler(final StorageEventMultiCaster<SendingRequestEvent, StorageEvent<SendingRequestEvent>> sendingRequestEventHandler)

Sets an event multi-caster that is triggered before sending a request.

void setUserHeaders(final HashMap<String, String> userHeaders)

Sets any additional headers for the request, for example, for proxy or logging information.

Field Details

defaultLoggerName

public static final String defaultLoggerName= Logger.ROOT_LOGGER_NAME

Name of the org.slf4j.Logger that will be created by default if logging is enabled and a org.slf4j.Logger has not been specified.

Constructor Details

OperationContext

public OperationContext()

Creates an instance of the class.

Method Details

appendRequestResult

public synchronized void appendRequestResult(RequestResult requestResult)

Reserved for internal use. Appends a RequestResult object to the internal collection in a synchronized manner.

Parameters:

requestResult - A RequestResult to append.

getClientRequestID

public String getClientRequestID()

Gets the client side trace ID.

Returns:

A String which represents the client request ID.

getClientTimeInMs

public long getClientTimeInMs()

Gets the operation latency, in milliseconds, from the client's perspective. This may include any potential retries.

Returns:

A long which contains the client latency time in milliseconds.

getDefaultProxy

public static Proxy getDefaultProxy()

Gets the default proxy used by the client library if enabled. The default can be overridden to enable a proxy for an individual operation context instance by using setProxy(Proxy proxy).

Returns:

The default java.net.Proxy if set; otherwise null

getDefaultProxyPassword

public static String getDefaultProxyPassword()

Gets the default password for the authenticated proxy which will be used when making a request. Default is . To set a password to use setProxyPassword(final String password)

Returns:

A String to use when making a request.

getDefaultProxyUsername

public static String getDefaultProxyUsername()

Gets a default username for the authenticated proxy which will be used when making a request. Default is . To set a username use setDefaultProxyUsername(final String username)

Returns:

A String to use when making a request.

getErrorReceivingResponseEventHandler

public StorageEventMultiCaster> getErrorReceivingResponseEventHandler()

Gets an event multi-caster that is triggered when a network error occurs before the HTTP response status and headers are received. It allows event listeners to be dynamically added and removed.

Returns:

A StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object for the errorReceivingResponseEventHandler.

getGlobalErrorReceivingResponseEventHandler

public static StorageEventMultiCaster> getGlobalErrorReceivingResponseEventHandler()

Gets a global event multi-caster that is triggered when a network error occurs before the HTTP response status and headers are received. It allows event listeners to be dynamically added and removed.

Returns:

A StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object for the globabErrorReceivingResponseEventHandler.

getGlobalRequestCompletedEventHandler

public static StorageEventMultiCaster> getGlobalRequestCompletedEventHandler()

Gets a global event multi-caster that is triggered when a request is completed. It allows event listeners to be dynamically added and removed.

Returns:

A StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object for the globalRequestCompletedEventHandler.

getGlobalResponseReceivedEventHandler

public static StorageEventMultiCaster> getGlobalResponseReceivedEventHandler()

Gets a global event multi-caster that is triggered when a response is received. It allows event listeners to be dynamically added and removed.

Returns:

A StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object for the globalResponseReceivedEventHandler.

getGlobalRetryingEventHandler

public static StorageEventMultiCaster> getGlobalRetryingEventHandler()

Gets a global event multi-caster that is triggered when a request is retried. It allows event listeners to be dynamically added and removed.

Returns:

A StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object for the globalRetryingEventHandler.

getGlobalSendingRequestEventHandler

public static StorageEventMultiCaster> getGlobalSendingRequestEventHandler()

Gets a global event multi-caster that is triggered before sending a request. It allows event listeners to be dynamically added and removed.

Returns:

A StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object for the globalSendingRequestEventHandler.

getLastResult

public synchronized RequestResult getLastResult()

Gets the last request result encountered for the operation.

Returns:

A RequestResult object which represents the last request result.

getLogger

public org.slf4j.Logger getLogger()

Gets the org.slf4j.Logger associated with this operation. If the org.slf4j.Logger object associated with this operation is null, this will return the class's default org.slf4j.Logger object.

Returns:

The org.slf4j.Logger object associated with this operation, or the class's default org.slf4j.Logger if null.

getProxy

public Proxy getProxy()

Gets a proxy which will be used when making a request. Default is . To set a proxy to use by default, use setDefaultProxy(Proxy defaultProxy)

Returns:

A java.net.Proxy to use when making a request.

getProxyPassword

public String getProxyPassword()

Gets the password for the authenticated proxy which will be used when making a request. Default is . To set a password to use setProxyPassword(final String password)

Returns:

A String to use when making a request.

getProxyUsername

public String getProxyUsername()

Gets a username for the authenticated proxy which will be used when making a request. Default is . To set a username use setProxyUsername(final String username)

Returns:

A String to use when making a request.

getRequestCompletedEventHandler

public StorageEventMultiCaster> getRequestCompletedEventHandler()

Gets an event multi-caster that is triggered when a request is completed. It allows event listeners to be dynamically added and removed.

Returns:

A StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object for the requestCompletedEventHandler.

getRequestResults

public ArrayList getRequestResults()

Returns the set of request results that the current operation has created.

Returns:

An ArrayList object that contains RequestResult objects that represent the request results created by the current operation.

getResponseReceivedEventHandler

public StorageEventMultiCaster> getResponseReceivedEventHandler()

Gets an event multi-caster that is triggered when a response is received. It allows event listeners to be dynamically added and removed.

Returns:

A StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object for the responseReceivedEventHandler.

getRetryingEventHandler

public StorageEventMultiCaster> getRetryingEventHandler()

Gets an event multi-caster that is triggered when a request is retried. It allows event listeners to be dynamically added and removed.

Returns:

A StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object for the retryingEventHandler.

getSendingRequestEventHandler

public StorageEventMultiCaster> getSendingRequestEventHandler()

Gets an event multi-caster that is triggered before sending a request. It allows event listeners to be dynamically added and removed.

Returns:

A StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object for the sendingRequestEventHandler.

getUserHeaders

public HashMap getUserHeaders()

Gets any additional headers for the request, for example, for proxy or logging information.

Returns:

A java.util.HashMap which contains the the user headers for the request.

initialize

public void initialize()

Reserved for internal use. Initializes the in order to begin processing a new operation. All operation specific information is erased.

isLoggingEnabled

public boolean isLoggingEnabled()

Indicates whether log entries will be produced for this request.

Returns:

true if logging is enabled; otherwise false.

isLoggingEnabledByDefault

public static boolean isLoggingEnabledByDefault()

Indicates whether the client library should produce log entries by default. The default can be overridden to enable logging for an individual operation context instance by using setLoggingEnabled(boolean loggingEnabled).

Returns:

true if logging is enabled by default; otherwise false.

setClientRequestID

public void setClientRequestID(final String clientRequestID)

Sets the client side request ID.

Parameters:

clientRequestID - A String which contains the client request ID to set.

setClientTimeInMs

public void setClientTimeInMs(final long clientTimeInMs)

Reserved for internal use. Represents the operation latency, in milliseconds, from the client's perspective. This may include any potential retries.

Parameters:

clientTimeInMs - A long which contains the client operation latency in milliseconds.

setDefaultProxy

public static void setDefaultProxy(Proxy defaultProxy)

Specifies the proxy the client library should use by default. The default can be overridden to turn on a proxy for an individual operation context instance by using setProxy(Proxy proxy).

Parameters:

defaultProxy - The java.net.Proxy to use by default, or null to not use a proxy.

setDefaultProxyPassword

public static void setDefaultProxyPassword(final String password)

Sets a default password for an authenticated proxy which will be used when making a request. Default is .

Parameters:

password - A java.lang.String to use when making a request.

setDefaultProxyUsername

public static void setDefaultProxyUsername(final String username)

Sets a default username for an authenticated proxy which will be used when making a request. Default is .

Parameters:

username - A java.lang.String to use when making a request.

setErrorReceivingResponseEventHandler

public void setErrorReceivingResponseEventHandler(final StorageEventMultiCaster> errorReceivingResponseEventHandler)

Sets an event multi-caster that is triggered when a network error occurs before the HTTP response status and headers are received.

Parameters:

errorReceivingResponseEventHandler - The StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object to set for the errorReceivingResponseEventHandler.

setGlobalErrorReceivingResponseEventHandler

public static void setGlobalErrorReceivingResponseEventHandler(final StorageEventMultiCaster> globalErrorReceivingResponseEventHandler)

Sets a global event multi-caster that is triggered when a network error occurs before the HTTP response status and headers are received.

Parameters:

globalErrorReceivingResponseEventHandler - The StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object to set for the globalErrorReceivingResponseEventHandler.

setGlobalRequestCompletedEventHandler

public static void setGlobalRequestCompletedEventHandler(final StorageEventMultiCaster> globalRequestCompletedEventHandler)

Sets a global event multi-caster that is triggered when a request is completed.

Parameters:

globalRequestCompletedEventHandler - The StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object to set for the globalRequestCompletedEventHandler.

setGlobalResponseReceivedEventHandler

public static void setGlobalResponseReceivedEventHandler(final StorageEventMultiCaster> globalResponseReceivedEventHandler)

Sets a global event multi-caster that is triggered when a response is received.

Parameters:

globalResponseReceivedEventHandler - The StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object to set for the globalResponseReceivedEventHandler.

setGlobalRetryingEventHandler

public static void setGlobalRetryingEventHandler(final StorageEventMultiCaster> globalRetryingEventHandler)

Sets a global event multi-caster that is triggered when a request is retried.

Parameters:

globalRetryingEventHandler - The StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object to set for the globalRetryingEventHandler.

setGlobalSendingRequestEventHandler

public static void setGlobalSendingRequestEventHandler(final StorageEventMultiCaster> globalSendingRequestEventHandler)

Sets a global event multi-caster that is triggered before sending a request.

Parameters:

globalSendingRequestEventHandler - The StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object to set for the globalSendingRequestEventHandler.

setLogger

public void setLogger(final org.slf4j.Logger logger)

Sets the org.slf4j.Logger for this operation.

Parameters:

logger - The org.slf4j.Logger to use for this operation.

setLoggingEnabled

public void setLoggingEnabled(boolean loggingEnabled)

Specifies whether log entries will be produced for this request.

Parameters:

loggingEnabled -

true to enable logging; otherwise false to disable logging.

setLoggingEnabledByDefault

public static void setLoggingEnabledByDefault(boolean enableLoggingByDefault)

Specifies whether the client library should produce log entries by default. The default can be overridden to turn on logging for an individual operation context instance by using setLoggingEnabled(boolean loggingEnabled).

Parameters:

enableLoggingByDefault -

true if logging should be enabled by default; otherwise false if logging should be disabled by default.

setProxy

public void setProxy(Proxy proxy)

Sets a proxy which will be used when making a request. Default is . To set a proxy to use by default, use setDefaultProxy(Proxy defaultProxy)

Parameters:

proxy - A java.net.Proxy to use when making a request.

setProxyPassword

public void setProxyPassword(final String password)

Sets a password for an authenticated proxy which will be used when making a request. Default is .

Parameters:

password - A java.lang.String to use when making a request.

setProxyUsername

public void setProxyUsername(final String username)

Sets a username for an authenticated proxy which will be used when making a request. Default is .

Parameters:

username - A java.lang.String to use when making a request.

setRequestCompletedEventHandler

public void setRequestCompletedEventHandler(final StorageEventMultiCaster> requestCompletedEventHandler)

Sets an event multi-caster that is triggered when a request is completed.

Parameters:

requestCompletedEventHandler - The StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object to set for the requestCompletedEventHandler.

setResponseReceivedEventHandler

public void setResponseReceivedEventHandler(final StorageEventMultiCaster> responseReceivedEventHandler)

Sets an event multi-caster that is triggered when a response is received.

Parameters:

responseReceivedEventHandler - The StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object to set for the responseReceivedEventHandler.

setRetryingEventHandler

public void setRetryingEventHandler(final StorageEventMultiCaster> retryingEventHandler)

Sets an event multi-caster that is triggered when a request is retried.

Parameters:

retryingEventHandler - The StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object to set for the retryingEventHandler.

setSendingRequestEventHandler

public void setSendingRequestEventHandler(final StorageEventMultiCaster> sendingRequestEventHandler)

Sets an event multi-caster that is triggered before sending a request.

Parameters:

sendingRequestEventHandler - The StorageEventMultiCaster<EVENT_TYPE,EVENT_LISTENER_TYPE> object to set for the sendingRequestEventHandler.

setUserHeaders

public void setUserHeaders(final HashMap userHeaders)

Sets any additional headers for the request, for example, for proxy or logging information.

Parameters:

userHeaders - A java.util.HashMap which contains any additional headers to set.

Applies to