OperationContext Class
- java.
lang. Object - com.
microsoft. azure. storage. OperationContext
- com.
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) |
Storage |
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. |
Storage |
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. |
Storage |
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. |
Storage |
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. |
Storage |
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. |
Storage |
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 Request |
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) |
Storage |
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<Request |
getRequestResults()
Returns the set of request results that the current operation has created. |
Storage |
getResponseReceivedEventHandler()
Gets an event multi-caster that is triggered when a response is received. It allows event listeners to be dynamically added and removed. |
Storage |
getRetryingEventHandler()
Gets an event multi-caster that is triggered when a request is retried. It allows event listeners to be dynamically added and removed. |
Storage |
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:
getClientRequestID
public String getClientRequestID()
Gets the client side trace ID.
Returns:
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:
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:
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:
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:
getErrorReceivingResponseEventHandler
public StorageEventMultiCaster
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:
errorReceivingResponseEventHandler
.getGlobalErrorReceivingResponseEventHandler
public static StorageEventMultiCaster
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:
globabErrorReceivingResponseEventHandler
.getGlobalRequestCompletedEventHandler
public static StorageEventMultiCaster
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:
globalRequestCompletedEventHandler
.getGlobalResponseReceivedEventHandler
public static StorageEventMultiCaster
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:
globalResponseReceivedEventHandler
.getGlobalRetryingEventHandler
public static StorageEventMultiCaster
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:
globalRetryingEventHandler
.getGlobalSendingRequestEventHandler
public static StorageEventMultiCaster
Gets a global event multi-caster that is triggered before sending a request. It allows event listeners to be dynamically added and removed.
Returns:
globalSendingRequestEventHandler
.getLastResult
public synchronized RequestResult getLastResult()
Gets the last request result encountered for the operation.
Returns:
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:
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:
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:
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:
getRequestCompletedEventHandler
public StorageEventMultiCaster
Gets an event multi-caster that is triggered when a request is completed. It allows event listeners to be dynamically added and removed.
Returns:
requestCompletedEventHandler
.getRequestResults
public ArrayList
Returns the set of request results that the current operation has created.
Returns:
ArrayList
object that contains RequestResult objects that represent the request results created by the current operation.getResponseReceivedEventHandler
public StorageEventMultiCaster
Gets an event multi-caster that is triggered when a response is received. It allows event listeners to be dynamically added and removed.
Returns:
responseReceivedEventHandler
.getRetryingEventHandler
public StorageEventMultiCaster
Gets an event multi-caster that is triggered when a request is retried. It allows event listeners to be dynamically added and removed.
Returns:
retryingEventHandler
.getSendingRequestEventHandler
public StorageEventMultiCaster
Gets an event multi-caster that is triggered before sending a request. It allows event listeners to be dynamically added and removed.
Returns:
sendingRequestEventHandler
.getUserHeaders
public HashMap
Gets any additional headers for the request, for example, for proxy or logging information.
Returns:
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:
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:
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:
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:
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:
setErrorReceivingResponseEventHandler
public void setErrorReceivingResponseEventHandler(final StorageEventMultiCaster
Sets an event multi-caster that is triggered when a network error occurs before the HTTP response status and headers are received.
Parameters:
errorReceivingResponseEventHandler
.
setGlobalErrorReceivingResponseEventHandler
public static void setGlobalErrorReceivingResponseEventHandler(final StorageEventMultiCaster
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
.
setGlobalRequestCompletedEventHandler
public static void setGlobalRequestCompletedEventHandler(final StorageEventMultiCaster
Sets a global event multi-caster that is triggered when a request is completed.
Parameters:
globalRequestCompletedEventHandler
.
setGlobalResponseReceivedEventHandler
public static void setGlobalResponseReceivedEventHandler(final StorageEventMultiCaster
Sets a global event multi-caster that is triggered when a response is received.
Parameters:
globalResponseReceivedEventHandler
.
setGlobalRetryingEventHandler
public static void setGlobalRetryingEventHandler(final StorageEventMultiCaster
Sets a global event multi-caster that is triggered when a request is retried.
Parameters:
globalRetryingEventHandler
.
setGlobalSendingRequestEventHandler
public static void setGlobalSendingRequestEventHandler(final StorageEventMultiCaster
Sets a global event multi-caster that is triggered before sending a request.
Parameters:
globalSendingRequestEventHandler
.
setLogger
public void setLogger(final org.slf4j.Logger logger)
Sets the org.slf4j.Logger for this operation.
Parameters:
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:
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:
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:
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:
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:
setRequestCompletedEventHandler
public void setRequestCompletedEventHandler(final StorageEventMultiCaster
Sets an event multi-caster that is triggered when a request is completed.
Parameters:
requestCompletedEventHandler
.
setResponseReceivedEventHandler
public void setResponseReceivedEventHandler(final StorageEventMultiCaster
Sets an event multi-caster that is triggered when a response is received.
Parameters:
responseReceivedEventHandler
.
setRetryingEventHandler
public void setRetryingEventHandler(final StorageEventMultiCaster
Sets an event multi-caster that is triggered when a request is retried.
Parameters:
retryingEventHandler
.
setSendingRequestEventHandler
public void setSendingRequestEventHandler(final StorageEventMultiCaster
Sets an event multi-caster that is triggered before sending a request.
Parameters:
sendingRequestEventHandler
.
setUserHeaders
public void setUserHeaders(final HashMap
Sets any additional headers for the request, for example, for proxy or logging information.
Parameters:
java.util.HashMap
which contains any additional headers to set.
Applies to
Azure SDK for Java