Share via


SdkContext Class

  • java.lang.Object
    • com.microsoft.azure.management.resources.fluentcore.utils.SdkContext

public class SdkContext

The class to contain the common factory methods required for SDK framework.

Constructor Summary

Constructor Description
SdkContext()

Method Summary

Modifier and Type Method and Description
static org.joda.time.DateTime dateTimeNow()
static rx.Observable<T> delayedEmitAsync(T event, int milliseconds)

Wrapper delayed emission, based on delayProvider.

static ResourceNamerFactory getResourceNamerFactory()

Gets the current factory for ResourceNamer.

static rx.Scheduler getRxScheduler()

Gets the current Rx Scheduler for the SDK framework.

static void prepareFileLocation(File[] files)

Prepares the location for file to be created.

static java.lang.String randomResourceName(String prefix, int maxLen)

Gets a random name.

static java.lang.String[] randomResourceNames(String prefix, int maxLen, int count)

Generates the specified number of random resource names with the same prefix.

static java.lang.String randomUuid()

Gets a random UUID.

static void setDelayProvider(DelayProvider delayProvider)

Function to override the DelayProvider.

static void setFileProvider(FileProvider fileProvider)

Sets the FileProvider for SDK framework, by default it does nothing.

static void setResourceNamerFactory(ResourceNamerFactory resourceNamerFactory)

Function to override the ResourceNamerFactory.

static void setRxScheduler(Scheduler rxScheduler)

Sets the Rx Scheduler for SDK framework, by default is Scheduler.io().

static void sleep(int milliseconds)

Wrapper for sleep, based on delayProvider.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

SdkContext

public SdkContext()

Method Details

dateTimeNow

public static DateTime dateTimeNow()

Returns:

the current date time.

delayedEmitAsync

public static Observable delayedEmitAsync(T event, int milliseconds)

Wrapper delayed emission, based on delayProvider.

Parameters:

event - the event to emit
milliseconds - the delay in milliseconds

Returns:

delayed observable

getResourceNamerFactory

public static ResourceNamerFactory getResourceNamerFactory()

Gets the current factory for ResourceNamer.

Returns:

resourceNamer factory.

getRxScheduler

public static Scheduler getRxScheduler()

Gets the current Rx Scheduler for the SDK framework.

Returns:

current rx scheduler.

prepareFileLocation

public static void prepareFileLocation(File[] files)

Prepares the location for file to be created.

Parameters:

files - the files to be created.

Throws:

java.io.IOException - thrown when failed on IO.

randomResourceName

public static String randomResourceName(String prefix, int maxLen)

Gets a random name.

Parameters:

prefix - the prefix to be used if possible
maxLen - the maximum length for the random generated name

Returns:

the random name

randomResourceNames

public static String[] randomResourceNames(String prefix, int maxLen, int count)

Generates the specified number of random resource names with the same prefix.

Parameters:

prefix - the prefix to be used if possible
maxLen - the maximum length for the random generated name
count - the number of names to generate

Returns:

random names

randomUuid

public static String randomUuid()

Gets a random UUID.

Returns:

the random UUID.

setDelayProvider

public static void setDelayProvider(DelayProvider delayProvider)

Function to override the DelayProvider.

Parameters:

delayProvider - delayProvider to override.

setFileProvider

public static void setFileProvider(FileProvider fileProvider)

Sets the FileProvider for SDK framework, by default it does nothing.

Parameters:

fileProvider - the FileProvider to override.

setResourceNamerFactory

public static void setResourceNamerFactory(ResourceNamerFactory resourceNamerFactory)

Function to override the ResourceNamerFactory.

Parameters:

resourceNamerFactory - factory to override.

setRxScheduler

public static void setRxScheduler(Scheduler rxScheduler)

Sets the Rx Scheduler for SDK framework, by default is Scheduler.io().

Parameters:

rxScheduler - current Rx Scheduler to be used in SDK framework.

sleep

public static void sleep(int milliseconds)

Wrapper for sleep, based on delayProvider.

Parameters:

milliseconds - number of millisecond for which thread should put on sleep.

Applies to