Global parameter for retargeting

I have a parent project with a retargeting popup inherited by all my projects. This retargeting popup launches different projects. Also in this parent project is the login popup which queries, authenticates and constructs a displayed login name (first initial last name). I can't use the username system tag for this as it's a badge number that we don't want displayed.

The login is fetching the first and last name from the SQL table and constructing a first inital + last name that I store in the same client tag for each project.

The retargeting maintains the current login credentials, but to avoid re-running the login authentification, I use the client tag to maintain the displayed user by passing the user as a global variable that this is a retargeting instance of the app. An initial opening of app sets the client tag to the default view only user, a retargeting instance sets the client tag to the global variable.

Long story short, I'm using the same retargeting user global variable to notify the startup script of each client to either set the client tag to the passed user or start with the default view only user.

It's working really well, but I read several threads on global variable memory leakage (albeit with classes), and I wanted to make sure what I'm doing is viable and not completely off track. My concern, do I need to default this global variable as soon as I use it to set the user since other hmis will use this when retargeting? Is there any concern with a race condition if two HMIs happen to retarget at the exact same time (miniscule chance, but nevertheless).

My other thought was just to create a global tag folder and create unique tags for each client to pass the constructed username, but then I'm faced with unique tag names for each app. Using the same client tag for any app, makes replication simpler.

It is always safe to store simple data types (strings, numbers) in the dictionary from system.util.getGlobals(). That dictionary exists independently in each JVM, so there is no possibility of one client HMI clashing with another.

1 Like