How to access IBM MobileFirst 7.1 default attribute store in session independent mode

不打扰是莪最后的温柔 提交于 2020-01-17 06:52:43

问题


I am working on migrating a IBM MobileFirst 6.3 project to version 7.1 and enabling the 7.1 session independent mode. I have specified the attribute store as the worklight default runtime database.

In the previous version I have used HTTPSession object in HTTP JavaScript adapters to dynamically store some minimal data related to the current user session as shown in the sample code below.

    var request = WL.Server.getClientRequest();
    var session = request.getSession();
    session.setAttribute("ID", "123");
    session.setAttribute("UserName", "xxx");

As I cannot use session object anymore, are there any WL.Server APIs available for explicitly store/retrieve/remove data from the default attribute store (WL run-time database)? Couldn't find any examples on this. Please advise. Thanks.


回答1:


Knowledge center documents this scenario and solution for 7.1 Session Independent mode here

https://www.ibm.com/support/knowledgecenter/en/SSHS8R_7.1.0/com.ibm.worklight.dev.doc/devref/c_java_server_side_api.html#java_server_side_api__java_rest

Saving applicative state between requests in Java RESTful adapters

In versions earlier than V7.1.0, developers were able to store the applicative state in the HTTP session, by using the session object, namely request.getSession() (see WL.Server).

If you are working in session-independent mode that became available starting with IBM MobileFirst Platform Foundation V7.1.0, the applicative state of the adapter must be persisted outside the session, for example, by using a database such as Cloudant®

Sample also is attached in the link above.



来源:https://stackoverflow.com/questions/43920246/how-to-access-ibm-mobilefirst-7-1-default-attribute-store-in-session-independent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!