public abstract class BasicWorkspaceManager extends Object implements MemoryWorkspaceManager
Modifier and Type | Field and Description |
---|---|
protected ThreadLocal<Map<String,MemoryWorkspace>> |
backingMap |
protected AtomicLong |
counter |
protected SynchronizedObject<DebugMode> |
debugMode |
protected WorkspaceConfiguration |
defaultConfiguration |
static String |
WorkspaceDeallocatorThreadName
Deprecated.
|
Constructor and Description |
---|
BasicWorkspaceManager() |
BasicWorkspaceManager(@NonNull WorkspaceConfiguration defaultConfiguration) |
Modifier and Type | Method and Description |
---|---|
boolean |
anyWorkspaceActiveForCurrentThread()
Determine if there are any workspaces open for the current thread.
|
boolean |
checkIfWorkspaceExists(@NonNull String id)
This method checks, if Workspace with a given Id was created before this call
|
boolean |
checkIfWorkspaceExistsAndActive(@NonNull String id)
This method checks, if Workspace with a given Id was created before this call, AND is active at the moment of call
|
void |
destroyAllWorkspacesForCurrentThread()
This method destroys all workspaces allocated in current thread
|
void |
destroyWorkspace()
This method destroy default workspace, if any
|
void |
destroyWorkspace(MemoryWorkspace workspace)
This method destroys given workspace
|
protected void |
ensureThreadExistense() |
List<MemoryWorkspace> |
getAllWorkspacesForCurrentThread()
This method returns all workspaces for current thread
|
List<String> |
getAllWorkspacesIdsForCurrentThread()
This method returns list of workspace IDs for current thread
|
MemoryWorkspace |
getAndActivateWorkspace()
This method gets & activates default workspace
|
MemoryWorkspace |
getAndActivateWorkspace(@NonNull String id)
This method gets & activates workspace with a given Id
|
MemoryWorkspace |
getAndActivateWorkspace(@NonNull WorkspaceConfiguration configuration,
@NonNull String id)
This method gets & activates default with a given configuration and Id
|
DebugMode |
getDebugMode()
This method returns current debug mode active in this JVM
|
String |
getUUID()
Returns globally unique ID
|
MemoryWorkspace |
getWorkspaceForCurrentThread()
This method will return workspace with default configuration and default id.
|
MemoryWorkspace |
getWorkspaceForCurrentThread(@NonNull String id)
This method returns you Workspace for a given Id for current Thread
PLEASE NOTE: If Workspace wasn't defined, new Workspace will be created using current default configuration
|
protected abstract void |
pickReference(MemoryWorkspace workspace) |
void |
printAllocationStatisticsForCurrentThread()
This method prints out basic statistics for workspaces allocated in current thread
|
MemoryWorkspace |
scopeOutOfWorkspaces()
This method temporary opens block out of any workspace scope.
|
void |
setDebugMode(DebugMode mode)
This method allows to enable (and pick one) global debug mode for workspaces
Default value: DISABLED
|
void |
setDefaultWorkspaceConfiguration(@NonNull WorkspaceConfiguration configuration)
This method allows to specify "Default" configuration, that will be used in signatures which do not have WorkspaceConfiguration argument
|
void |
setWorkspaceForCurrentThread(MemoryWorkspace workspace)
This method allows you to set given Workspace as default for current Thread
|
void |
setWorkspaceForCurrentThread(@NonNull MemoryWorkspace workspace,
@NonNull String id)
This method allows you to set given Workspace for spacific Id for current Thread
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createNewWorkspace, createNewWorkspace, createNewWorkspace, createNewWorkspace, getWorkspaceForCurrentThread
protected AtomicLong counter
protected WorkspaceConfiguration defaultConfiguration
protected ThreadLocal<Map<String,MemoryWorkspace>> backingMap
protected SynchronizedObject<DebugMode> debugMode
@Deprecated public static final String WorkspaceDeallocatorThreadName
public BasicWorkspaceManager()
public BasicWorkspaceManager(@NonNull @NonNull WorkspaceConfiguration defaultConfiguration)
public String getUUID()
getUUID
in interface MemoryWorkspaceManager
public void setDefaultWorkspaceConfiguration(@NonNull @NonNull WorkspaceConfiguration configuration)
setDefaultWorkspaceConfiguration
in interface MemoryWorkspaceManager
configuration
- public MemoryWorkspace getWorkspaceForCurrentThread()
getWorkspaceForCurrentThread
in interface MemoryWorkspaceManager
public MemoryWorkspace getWorkspaceForCurrentThread(@NonNull @NonNull String id)
MemoryWorkspaceManager
getWorkspaceForCurrentThread
in interface MemoryWorkspaceManager
public DebugMode getDebugMode()
MemoryWorkspaceManager
getDebugMode
in interface MemoryWorkspaceManager
public void setDebugMode(DebugMode mode)
MemoryWorkspaceManager
setDebugMode
in interface MemoryWorkspaceManager
protected abstract void pickReference(MemoryWorkspace workspace)
public void setWorkspaceForCurrentThread(MemoryWorkspace workspace)
MemoryWorkspaceManager
setWorkspaceForCurrentThread
in interface MemoryWorkspaceManager
public void setWorkspaceForCurrentThread(@NonNull @NonNull MemoryWorkspace workspace, @NonNull @NonNull String id)
MemoryWorkspaceManager
setWorkspaceForCurrentThread
in interface MemoryWorkspaceManager
public void destroyWorkspace(MemoryWorkspace workspace)
destroyWorkspace
in interface MemoryWorkspaceManager
workspace
- public void destroyWorkspace()
destroyWorkspace
in interface MemoryWorkspaceManager
public void destroyAllWorkspacesForCurrentThread()
destroyAllWorkspacesForCurrentThread
in interface MemoryWorkspaceManager
protected void ensureThreadExistense()
public MemoryWorkspace getAndActivateWorkspace()
getAndActivateWorkspace
in interface MemoryWorkspaceManager
public MemoryWorkspace getAndActivateWorkspace(@NonNull @NonNull String id)
getAndActivateWorkspace
in interface MemoryWorkspaceManager
id
- public MemoryWorkspace getAndActivateWorkspace(@NonNull @NonNull WorkspaceConfiguration configuration, @NonNull @NonNull String id)
getAndActivateWorkspace
in interface MemoryWorkspaceManager
configuration
- id
- public boolean checkIfWorkspaceExists(@NonNull @NonNull String id)
checkIfWorkspaceExists
in interface MemoryWorkspaceManager
id
- public boolean checkIfWorkspaceExistsAndActive(@NonNull @NonNull String id)
MemoryWorkspaceManager
checkIfWorkspaceExistsAndActive
in interface MemoryWorkspaceManager
public MemoryWorkspace scopeOutOfWorkspaces()
PLEASE NOTE: Do not forget to close this block.
scopeOutOfWorkspaces
in interface MemoryWorkspaceManager
public void printAllocationStatisticsForCurrentThread()
printAllocationStatisticsForCurrentThread
in interface MemoryWorkspaceManager
public List<String> getAllWorkspacesIdsForCurrentThread()
MemoryWorkspaceManager
getAllWorkspacesIdsForCurrentThread
in interface MemoryWorkspaceManager
public List<MemoryWorkspace> getAllWorkspacesForCurrentThread()
MemoryWorkspaceManager
getAllWorkspacesForCurrentThread
in interface MemoryWorkspaceManager
public boolean anyWorkspaceActiveForCurrentThread()
MemoryWorkspaceManager
anyWorkspaceActiveForCurrentThread
in interface MemoryWorkspaceManager
Copyright © 2020. All rights reserved.