Controller that manages JSON connections with printer and allows multiple modules to share the same connection. More...
Classes | |
class | JsonConnection |
Public Member Functions | |
JsonComm | CreateMgmtComm (String commDescriptor) |
Creates or returns existing connection that allows for mgmt/JSON communication. More... | |
JsonComm | CreateMgmtComm (IComm ptrComm) |
Creates or returns existing connection that allows for mgmt/JSON communication. More... | |
void | ReleaseMgmtComm (String commDescriptor) |
Release the json comm resources tied to the commDescriptor More... | |
int | UserCount (String commdDescriptor) |
get the active user count for a given commDescriptor. More... | |
int | ConnectionCount () |
get number of connections. Note each connection can have multiple users. More... | |
List< String > | Descriptors () |
get list of connection descriptors More... | |
Static Public Member Functions | |
static JsonCommController | Instance () |
Private Member Functions | |
JsonCommController () | |
Static Private Attributes | |
static final Object | _syncLockComm = new Object() |
static final Object | syncLockInstance = new Object() |
static volatile JsonCommController | instance |
Controller that manages JSON connections with printer and allows multiple modules to share the same connection.
For case where a shared comm resource is needed by multiple modules or to make it easier for connection(s) to printer to be created.
Why is this needed?
Manage/track comm connections to make instantiating of objects that share comm resources to single printer easier.
Doesn't seem like a big deal... Doesn't seem too useful...
But, keep in mind that the above instantiation of objects could happen at different parts of the user's code and one piece of code may not be aware of any existing shared connections to the printer. By doing this centralized manager/tracker, the user's burden is reduced, creating a better user experience (assuming the code works as intended).
This is a hybrid of a "disposable" singleton pattern (only one comm and one JSON parser for each printer) and a factory pattern that creates the instance of the class and manages the release of the class resources when all consumers have released the resource via the IDisposable pattern from each of the consumer classes (the MgmtModules that require comm + json msgs).
|
private |
Referenced by com.UniPRT.Sdk.Json.JsonCommController.Instance().
int com.UniPRT.Sdk.Json.JsonCommController.ConnectionCount | ( | ) |
get number of connections. Note each connection can have multiple users.
Creates or returns existing connection that allows for mgmt/JSON communication.
ptrComm is the communication connection to printer.
References com.UniPRT.Sdk.Json.JsonCommController._syncLockComm, and com.UniPRT.Sdk.Comm.IComm.Descriptor().
JsonComm com.UniPRT.Sdk.Json.JsonCommController.CreateMgmtComm | ( | String | commDescriptor | ) |
Creates or returns existing connection that allows for mgmt/JSON communication.
commDescriptor types supported:
"TCP:ip:port" NOTE: Descriptors must match exactly when releasing on call to ReleaseMgmtComm
References com.UniPRT.Sdk.Json.JsonCommController._syncLockComm.
Referenced by com.UniPRT.Sdk.Settings.Configs.Configs(), com.UniPRT.Sdk.Mgmt.Listener.ListenerChannelsConnectorGet(), com.UniPRT.Sdk.Mgmt.Messenger.Messenger(), com.UniPRT.Sdk.Json.OdvMonitor.OdvMonitor(), com.UniPRT.Sdk.Json.PrinterMonitor.PrinterMonitor(), com.UniPRT.Sdk.Json.RfidMonitor.RfidMonitor(), and com.UniPRT.Sdk.Json.SettingsReadWrite.SettingsReadWrite().
List<String> com.UniPRT.Sdk.Json.JsonCommController.Descriptors | ( | ) |
get list of connection descriptors
|
static |
References com.UniPRT.Sdk.Json.JsonCommController.instance, com.UniPRT.Sdk.Json.JsonCommController.JsonCommController(), and com.UniPRT.Sdk.Json.JsonCommController.syncLockInstance.
Referenced by com.UniPRT.Sdk.Settings.Configs.Configs(), com.UniPRT.Sdk.Settings.Configs.Dispose(), com.UniPRT.Sdk.Json.OdvMonitor.Dispose(), com.UniPRT.Sdk.Json.RfidMonitor.Dispose(), com.UniPRT.Sdk.Json.SettingsReadWrite.Dispose(), com.UniPRT.Sdk.Json.PrinterMonitor.Dispose(), com.UniPRT.Sdk.Mgmt.Listener.ListenerChannelsConnectorGet(), com.UniPRT.Sdk.Mgmt.Messenger.Messenger(), com.UniPRT.Sdk.Json.OdvMonitor.OdvMonitor(), com.UniPRT.Sdk.Json.PrinterMonitor.PrinterMonitor(), com.UniPRT.Sdk.Json.RfidMonitor.RfidMonitor(), and com.UniPRT.Sdk.Json.SettingsReadWrite.SettingsReadWrite().
void com.UniPRT.Sdk.Json.JsonCommController.ReleaseMgmtComm | ( | String | commDescriptor | ) |
Release the json comm resources tied to the commDescriptor
References com.UniPRT.Sdk.Json.JsonCommController._syncLockComm.
Referenced by com.UniPRT.Sdk.Settings.Configs.Dispose(), com.UniPRT.Sdk.Json.OdvMonitor.Dispose(), com.UniPRT.Sdk.Json.RfidMonitor.Dispose(), com.UniPRT.Sdk.Json.SettingsReadWrite.Dispose(), and com.UniPRT.Sdk.Json.PrinterMonitor.Dispose().
int com.UniPRT.Sdk.Json.JsonCommController.UserCount | ( | String | commdDescriptor | ) |
get the active user count for a given commDescriptor.
References com.UniPRT.Sdk.Json.JsonCommController.JsonConnection.UserCount().
|
staticprivate |
|
staticprivate |
Referenced by com.UniPRT.Sdk.Json.JsonCommController.Instance().
|
staticprivate |
Referenced by com.UniPRT.Sdk.Json.JsonCommController.Instance().