Package com.senzing.sdk.core
Class SzCoreEnvironment
java.lang.Object
com.senzing.sdk.core.SzCoreEnvironment
- All Implemented Interfaces:
SzEnvironment
Provides the core implementation of
SzEnvironment
that directly
initializes the Senzing SDK modules and provides management of the Senzing
environment in this process.
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The builder class for creating an instance ofSzCoreEnvironment
. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The default instance name to use for the Senzing initialization.static final String
The default "bootstrap" settings with which to initialize theSzCoreEnvironment
when an explicit settings value has not been provided viaSzCoreEnvironment.Builder.settings(String)
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Destroys thisSzEnvironment
and invalidates any SDK singleton references that has previously provided.long
Gets the currently active configuration ID for theSzEnvironment
.static SzCoreEnvironment
Gets the current active instance ofSzCoreEnvironment
.Provides a reference to theSzConfigManager
instance associated with thisSzEnvironment
.Provides a reference to theSzDiagnostic
instance associated with thisSzEnvironment
.Provides a reference to theSzEngine
instance associated with thisSzEnvironment
.Provides a reference to theSzProduct
instance associated with thisSzEnvironment
.boolean
Checks if this instance has had itsSzEnvironment.destroy()
method called.static SzCoreEnvironment.Builder
Creates a new instance ofSzCoreEnvironment.Builder
for setting up an instance ofSzCoreEnvironment
.void
reinitialize
(long configId) Reinitializes theSzEnvironment
with the specified configuration ID.
-
Field Details
-
DEFAULT_INSTANCE_NAME
The default instance name to use for the Senzing initialization. The value is""Senzing Instance"
. An explicit value can be provided viaSzCoreEnvironment.Builder.instanceName(String)
during initialization.- See Also:
-
DEFAULT_SETTINGS
The default "bootstrap" settings with which to initialize theSzCoreEnvironment
when an explicit settings value has not been provided viaSzCoreEnvironment.Builder.settings(String)
. If this is used it will initialize Senzing when installed in its default path and provide full access access to only theSzProduct
interface as well as limited access to theSzConfigManager
interface (i.e.: for functionality not dealing with registered configuration ID's). The value of this constant is"{ }"
.NOTE: Using these settings is only useful for accessing the the full functionality of the
SzProduct
interface and limited functionality of theSzConfigManager
interface sinceSzEngine
andSzDiagnostic
require database access to connect to the Senzing repository. Further, someSzConfigManager
functionality (particularly any functionality that works with registered configurations that have configuration ID's) also requires database access to connect to the Senzing repository.The value of this constant is
"{ }"
.- See Also:
-
-
Method Details
-
newBuilder
Creates a new instance ofSzCoreEnvironment.Builder
for setting up an instance ofSzCoreEnvironment
. Keep in mind that while multipleSzCoreEnvironment.Builder
instances can exists, only one active instance ofSzCoreEnvironment
can exist at time. An active instance is one that has not yet been destroyed.- Returns:
- The
SzCoreEnvironment.Builder
for configuring and initializing theSzCoreEnvironment
.
-
getActiveInstance
Gets the current active instance ofSzCoreEnvironment
. An active instance is is one that has been constructed and has not yet been destroyed. There can be at most one active instance. If no active instance exists thennull
is returned.- Returns:
- The current active instance of
SzCoreEnvironment
, ornull
if there is no active instance.
-
getConfigManager
Description copied from interface:SzEnvironment
Provides a reference to theSzConfigManager
instance associated with thisSzEnvironment
.Usage:
// How to obtain an SzConfigManager instance try { // obtain the SzEnvironment (varies by application)
SzEnvironment
env = getEnvironment(); // get the config manager SzConfigManager configMgr = env.getConfigManager(); ... } catch (SzException e) { // handle or rethrow the exception logError("Failed to get SzConfigManager.", e); }- Specified by:
getConfigManager
in interfaceSzEnvironment
- Returns:
- The
SzConfigManager
instance associated with thisSzEnvironment
. - Throws:
IllegalStateException
- If thisSzEnvironment
instance has been destroyed.SzException
- If there was a failure in obtaining or initializing theSzConfigManager
instance.
-
getDiagnostic
Description copied from interface:SzEnvironment
Provides a reference to theSzDiagnostic
instance associated with thisSzEnvironment
.Usage:
// How to obtain an SzDiagnostic instance try { // obtain the SzEnvironment (varies by application)
SzEnvironment
env = getEnvironment(); SzDiagnostic diagnostic = env.getDiagnostic(); ... } catch (SzException e) { // handle or rethrow the exception logError("Failed to get SzDiagnostic.", e); }- Specified by:
getDiagnostic
in interfaceSzEnvironment
- Returns:
- The
SzDiagnostic
instance associated with thisSzEnvironment
. - Throws:
IllegalStateException
- If thisSzEnvironment
instance has been destroyed.SzException
- If there was a failure in obtaining or initializing theSzDiagnostic
instance.
-
getEngine
Description copied from interface:SzEnvironment
Provides a reference to theSzEngine
instance associated with thisSzEnvironment
.Usage:
// How to obtain an SzEngine instance try { // obtain the SzEnvironment (varies by application)
SzEnvironment
env = getEnvironment(); SzEngine engine = env.getEngine(); ... } catch (SzException e) { // handle or rethrow the exception logError("Failed to get SzEngine.", e); }- Specified by:
getEngine
in interfaceSzEnvironment
- Returns:
- The
SzEngine
instance associated with thisSzEnvironment
. - Throws:
IllegalStateException
- If thisSzEnvironment
instance has been destroyed.SzException
- If there was a failure in obtaining or initializing theSzEngine
instance.
-
getProduct
Description copied from interface:SzEnvironment
Provides a reference to theSzProduct
instance associated with thisSzEnvironment
.Usage:
// How to obtain an SzProduct instance try { // obtain the SzEnvironment (varies by application)
SzEnvironment
env = getEnvironment(); SzProduct product = env.getProduct(); ... } catch (SzException e) { // handle or rethrow the exception logError("Failed to get SzProduct.", e); }- Specified by:
getProduct
in interfaceSzEnvironment
- Returns:
- The
SzProduct
instance associated with thisSzEnvironment
. - Throws:
IllegalStateException
- If thisSzEnvironment
instance has been destroyed.SzException
- If there was a failure in obtaining or initializing theSzProduct
instance.
-
destroy
public void destroy()Description copied from interface:SzEnvironment
Destroys thisSzEnvironment
and invalidates any SDK singleton references that has previously provided. If this instance has already been destroyed then this method has no effect.Usage:
// obtain the SzEnvironment (varies by application) SzEnvironment env = getEnvironment(); if (!env.isDestroyed()) { // destroy the environment env.destroy(); }
- Specified by:
destroy
in interfaceSzEnvironment
-
isDestroyed
public boolean isDestroyed()Description copied from interface:SzEnvironment
Checks if this instance has had itsSzEnvironment.destroy()
method called.Usage:
// obtain the SzEnvironment (varies by application) SzEnvironment env = getEnvironment(); if (!env.isDestroyed()) { // destroy the environment env.destroy(); }
- Specified by:
isDestroyed
in interfaceSzEnvironment
- Returns:
true
if this instance has had itsSzEnvironment.destroy()
method called, otherwisefalse
.
-
getActiveConfigId
Description copied from interface:SzEnvironment
Gets the currently active configuration ID for theSzEnvironment
.Usage:
// How to get the active config ID for the SzEnvironment try { // obtain the SzEnvironment (varies by application) SzEnvironment env = getEnvironment(); // get the active config ID long activeConfigId = env.getActiveConfigId(); // do something with the active config ID (varies by application) SzConfigManager configMgr = env.getConfigManager(); long defaultConfigId = configMgr.getDefaultConfigId(); if (activeConfigId != defaultConfigId) { // reinitialize the environment with the default config ID env.reinitialize(defaultConfigId); } } catch (SzException e) { // handle or rethrow the exception logError("Failed to verify the active config ID.", e); }
- Specified by:
getActiveConfigId
in interfaceSzEnvironment
- Returns:
- The currently active configuration ID.
- Throws:
IllegalStateException
- If thisSzEnvironment
instance has been destroyed.SzException
- If there was a failure in obtaining the active config ID.
-
reinitialize
Description copied from interface:SzEnvironment
Reinitializes theSzEnvironment
with the specified configuration ID.Usage:
// How to get the active config ID for the SzEnvironment try { // obtain the SzEnvironment (varies by application) SzEnvironment env = getEnvironment(); // get the active config ID long activeConfigId = env.getActiveConfigId(); // do something with the active config ID (varies by application) SzConfigManager configMgr = env.getConfigManager(); long defaultConfigId = configMgr.getDefaultConfigId(); if (activeConfigId != defaultConfigId) { // reinitialize the environment with the default config ID env.reinitialize(defaultConfigId); } } catch (SzException e) { // handle or rethrow the exception logError("Failed to verify the active config ID.", e); }
- Specified by:
reinitialize
in interfaceSzEnvironment
- Parameters:
configId
- The configuration ID with which to initialize.- Throws:
IllegalStateException
- If thisSzEnvironment
instance has been destroyed.SzException
- If there was a failure reinitializing.
-