cancel
Showing results for 
Search instead for 
Did you mean: 

BO SDK会话问题

former_member197088
Participant
0 Kudos

今天BO突然有点卡,在CMC看了下有几百个会话,都是测试用户的,应该是代码没有自动注销会话,请问用SDK如何实现用户登陆后使用会话,退出即注销掉会话?

Accepted Solutions (1)

Accepted Solutions (1)

former_member186271
Participant
0 Kudos

有几点需要注意一下:

1. 需要在创建完token后把enterprisesession进行logoff。

IEnterpriseSession的logoff方法。

2. 也可以设置成在HTTP的session过期后,自动让enterprise session进行logoff。

Sample HTTPSessionListener code:

package com.businessobjects.sample;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import java.util.Enumeration;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
/** Checks a Http Session before it's destroyed to see if there are any
* IEnterpriseSession objects.  Invoke logoff method for any such objects found.
*/
public class EnterpriseSessionLogout implements HttpSessionListener {
 public void sessionCreated(HttpSessionEvent event) {}
    public void sessionDestroyed(HttpSessionEvent event) {
  HttpSession session = event.getSession();
  for(Enumeration iname = session.getAttributeNames() ; iname.hasMoreElements() ;){
   Object attribute = session.getAttribute((String) iname.nextElement());
   if(attribute != null && attribute instanceof IEnterpriseSession)
    ((IEnterpriseSession) attribute).logoff();
  }
}
}
former_member197088
Participant
0 Kudos

嗯,好的,谢谢了,我先试试。

Answers (0)