User Context Methods

User (or business) contexts have two primary functions:
  • A user context is a container of modules. Every module is parented to one and only one user context.
  • User contexts provide isolated execution environments. The operations of one user context are not visible to any other user context.
Note: Recall that there is no functional difference between a user context and a business context. Whether contexts are used to provide each user with their own environment, or whether they are used to insulate business units from one another, is application-specific. The set of functionality is the same. SAS Micro Analytic Service uses the UserContext construct for both business and user contexts.
Here is a list of available methods:
newUserContext
long newUserContext(java.lang.String displayName)
Creates a new user or business context and returns an opaque pointer to it. Modules are organized by user context. User contexts are isolated from one another.
Parameter
displayName - The name that is used in log messages.
Return
handle - The opaque context identifier (opaque pointer) that is used to pass to functions that require a user context identifier.
deleteUserContext
void deleteUserContext(long userContext)
Deletes a user context and all modules that are associated with it.
Parameter
userContext - The opaque user context handle of the context to delete.
userContextExists
boolean userContextExists(long userContext)
Queries the existence of a user context.
Parameter
userContext - The opaque user context handle.
Return
Boolean - True if the context exists, False otherwise.
getUserContextDisplayName
java.lang.String getUserContextDisplayName(long userContext)
Retrieves the display name of the given user context.
Parameter
userContext - The opaque user context handle.
getModuleIDs
long[] getModuleIDs(long userContext)
Retrieves the IDs of all modules that are currently loaded in the system.
Return
The long array of the module IDs.
getModuleNames
java.lang.String[] getModuleNames(long userContext)
Retrieves the names of all modules that are currently loaded in the system.
Returns
The string array of the module IDs.
Note: The C modules are named according to the value of the displayName argument passed to newModuleContext(). DS2 modules are named for the DS2 package that the module represents (such as the package name given in the source code).
Note: If the value of the displayName argument to newModuleContext() differs from the DS2 package name that was given in the source code, the module name changes when the first revision of the DS2 package is created.
getUserContextCreationDateTime
java.util.Date getUserContextCreationDateTime(long userContext)
Gets the user context creation datetime.
Parameter
userContext - The opaque user context handle.
Return
The creation datetime in SAS form (GMT seconds since 1960).
getUserContextLastModifiedDateTime
java.util.Date getUserContextLastModifiedDateTime(long userContext)
Gets the user context last modified datetime.
Parameter
userContext - The opaque user context handle.
Return
The datetime of the last modification in SAS form (GMT seconds since 1960).
Here is an example of creating a new user context:
long userCtx  = tk.newUserContext("A user context");
if (userCtx <= 0) {
	    System.out.println("   User context creation failed.");
	    return;
}
The user context handle that is returned from newUserContext() actually represents a C language pointer that is maintained in the SAS Micro Analytic Service core. The pointer is opaque to Java and represented as a value of type long. This value can be used to pass to any method that requires a user context identifier. It should not be modified.