User Storage for C# and Java

Lorenz Alder, Senior Consultant / Software Architect

User Storage helps us with integration of third party libraries such as mail, ftp, NoSQL DB, file system access etc. Once an object is instantiated through source code, we store it in User Storage and make it accessible to all CA Plex functions in the call graph.

The CA Plex runtime supports the following methods to store any Java or C# object in a globally accessible Store.

Set

public void setToUserStorage(String key, Object obj)

Get

public Object getFromUserStorage(String key)

Remove

public void removeFromUserStorage(String key)

Java syntax examples

getApp().setToUserStorage("WantToFindTheObjWithThisName", myObj);myClass myObj = (myClass)(getApp().getFromUserStorage("WantToFindTheObjWithThisName"));if(myObj != null){    // do some stuff with myObj}

C# syntax examples

M_ObApp.setToUserStorage("WantToFindTheObjWithThisName", myObj);myClass myObj = (myClass)(M_ObApp.getFromUserStorage("WantToFindTheObjWithThisName"));if(myObj != null){    // do some stuff with myObj}

Best practice

Create wrapper classes for third party libraries with only the methods you actually need. This simplifies the API and will let you change the implementation easily when better libraries become available.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

 
 
© 2013 CM First Group - All rights reserved