Assembling so that session data can be shared

By default, the session management facility supports session scoping by web module in accordance with the Servlet 2.3 and later API specification. Only servlets in the same web module can access the data associated with a particular session. However, you can use the IBMApplicationSession object or the IBM® extension, shared session context, to share data outside of the web module scope.

关于此任务

The IBMApplicationSession object is a parent session object that can be retrieved by a web module’s session and can share session attributes across all of the web modules in a business-level application. The default scope of the business-level application is the enterprise application. The shared session context option extends the scope of the session attributes as well. Using the shared session context extension, there is only one session object for the entire business-level application or for the default enterprise application.

If you are using a shared session for a business-level application, then the class files for all objects placed in the session must exist in an isolated shared library and be common among all applications.

The benefit to using the IBMApplicationSession method is that each web module can maintain its own session as well as have a reference to the shared session.

If you’re migrating an application from a previous version of the product, the IBMApplicationSession method requires a change to the application logic of the application.

限制: To use a shared session, you must install all applications within a business-level application on a given server. You cannot split up the enterprise application by servers. For example, you cannot use this option when one enterprise application in “BLA1” is installed on one server and a second enterprise application also in “BLA1” is installed on a different server. In such split installations, applications might share session attributes across web modules using distributed sessions, but session data integrity is lost when concurrent access to a session is made in different web modules. It also severely restricts use of some session management features, like TIME_BASED_WRITES.

For enterprise applications on which this shared session context extension is enabled, the session management configuration on the web module inside the enterprise application is ignored. Then session management configuration defined on enterprise application is used if session management is overwritten at the enterprise application level. Otherwise, the session management configuration on the web container is used. If using multiple enterprise applications within a business-level application, the session management configuration must be common among all applications and web modules within this business-level application.

HttpSession listeners that are defined in all the web modules inside the business-level application or enterprise application are invoked for session events. The order of listener invocation is not guaranteed.

Complete the following to share session data across the business-level application.

过程

  1. Complete the following to share session data using the IBMApplicationSession object within the application code.
    1. Retrieve the session object
      HttpSession session = request.getSession();
    2. 将此对象强制类型转换为 IBMSession 对象并调用 getIBMApplicationSession 方法。
      IBMApplicationSession appSession = ((IBMSession)session).getIBMApplicationSession();
    3. 如同普通会话对象一样使用 appSession。
  2. 完成以下操作以使用共享会话上下文扩展共享会话数据。
    1. 启动组装工具。
    2. 在组装工具中,右键单击您要共享的应用程序(EAR 文件),然后单击打开方式 > 部署描述符编辑器
    3. 在组装工具的应用程序部署描述符编辑器中,在“WebSphere® 扩展”下选择共享会话上下文确保放入会话的属性的类定义可用于企业应用程序中所有 Web 模块。 共享会话上下文未完全满足规范的需求。
    4. 保存应用程序 (EAR) 文件。 在组装工具中,当您关闭应用程序部署描述符编辑器后,确认您要保存对应用程序进行的更改。

指示主题类型的图标 任务主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tprs_sharing_data
文件名:tprs_sharing_data.html