UniPRT SDK  v1.0.0.0
com.UniPRT.Sdk.Json.JsonCommController Class Reference

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
 

Detailed Description

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).

Constructor & Destructor Documentation

◆ JsonCommController()

com.UniPRT.Sdk.Json.JsonCommController.JsonCommController ( )
private

Member Function Documentation

◆ ConnectionCount()

int com.UniPRT.Sdk.Json.JsonCommController.ConnectionCount ( )

get number of connections. Note each connection can have multiple users.

◆ CreateMgmtComm() [1/2]

JsonComm com.UniPRT.Sdk.Json.JsonCommController.CreateMgmtComm ( IComm  ptrComm)

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().

◆ CreateMgmtComm() [2/2]

JsonComm com.UniPRT.Sdk.Json.JsonCommController.CreateMgmtComm ( String  commDescriptor)

◆ Descriptors()

List<String> com.UniPRT.Sdk.Json.JsonCommController.Descriptors ( )

get list of connection descriptors

◆ Instance()

◆ ReleaseMgmtComm()

void com.UniPRT.Sdk.Json.JsonCommController.ReleaseMgmtComm ( String  commDescriptor)

◆ UserCount()

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().

Member Data Documentation

◆ _syncLockComm

final Object com.UniPRT.Sdk.Json.JsonCommController._syncLockComm = new Object()
staticprivate

◆ instance

volatile JsonCommController com.UniPRT.Sdk.Json.JsonCommController.instance
staticprivate

◆ syncLockInstance

final Object com.UniPRT.Sdk.Json.JsonCommController.syncLockInstance = new Object()
staticprivate

The documentation for this class was generated from the following file: