本文整理汇总了Java中javax.servlet.http.HttpSessionActivationListener类的典型用法代码示例。如果您正苦于以下问题:Java HttpSessionActivationListener类的具体用法?Java HttpSessionActivationListener怎么用?Java HttpSessionActivationListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HttpSessionActivationListener类属于javax.servlet.http包,在下文中一共展示了HttpSessionActivationListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: passivate
import javax.servlet.http.HttpSessionActivationListener; //导入依赖的package包/类
/**
* Perform the internal processing required to passivate
* this session.
*/
public void passivate() {
// Notify interested session event listeners
fireSessionEvent(Session.SESSION_PASSIVATED_EVENT, null);
// Notify ActivationListeners
HttpSessionEvent event = null;
String keys[] = keys();
for (int i = 0; i < keys.length; i++) {
Object attribute = attributes.get(keys[i]);
if (attribute instanceof HttpSessionActivationListener) {
if (event == null)
event = new HttpSessionEvent(getSession());
try {
((HttpSessionActivationListener)attribute)
.sessionWillPassivate(event);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
manager.getContainer().getLogger().error
(sm.getString("standardSession.attributeEvent"), t);
}
}
}
}
示例2: passivate
import javax.servlet.http.HttpSessionActivationListener; //导入依赖的package包/类
/**
* Perform the internal processing required to passivate
* this session.
*/
public void passivate() {
// Notify ActivationListeners
HttpSessionEvent event = null;
String keys[] = keys();
for (int i = 0; i < keys.length; i++) {
Object attribute = getAttribute(keys[i]);
if (attribute instanceof HttpSessionActivationListener) {
if (event == null)
event = new HttpSessionEvent(this);
// FIXME: Should we catch throwables?
((HttpSessionActivationListener)attribute).sessionWillPassivate(event);
}
}
}
示例3: activate
import javax.servlet.http.HttpSessionActivationListener; //导入依赖的package包/类
/**
* Perform internal processing required to activate this
* session.
*/
public void activate() {
// Notify ActivationListeners
HttpSessionEvent event = null;
String keys[] = keys();
for (int i = 0; i < keys.length; i++) {
Object attribute = getAttribute(keys[i]);
if (attribute instanceof HttpSessionActivationListener) {
if (event == null)
event = new HttpSessionEvent(this);
// FIXME: Should we catch throwables?
((HttpSessionActivationListener)attribute).sessionDidActivate(event);
}
}
}
示例4: passivate
import javax.servlet.http.HttpSessionActivationListener; //导入依赖的package包/类
/**
* Simulate a passivate operation.
*/
public void passivate() {
Enumeration<String> names = this.getAttributeNames();
String[] keys;
synchronized(names) {
List<String> nameList = Collections.list(names);
keys = new String[nameList.size()];
for (int i = 0; i < nameList.size(); i++) {
keys[i] = nameList.get(i);
}
}
for (String key : keys) {
Object value = this.getAttribute(key);
if (value != null && value instanceof HttpSessionActivationListener) {
((HttpSessionActivationListener)value).sessionWillPassivate(new HttpSessionEvent(this));
}
}
active = false;
}
示例5: isWeb
import javax.servlet.http.HttpSessionActivationListener; //导入依赖的package包/类
private static boolean isWeb(final Class<?> beanClass) {
if (Servlet.class.isAssignableFrom(beanClass)
|| Filter.class.isAssignableFrom(beanClass)) {
return true;
}
if (EventListener.class.isAssignableFrom(beanClass)) {
return HttpSessionAttributeListener.class.isAssignableFrom(beanClass)
|| ServletContextListener.class.isAssignableFrom(beanClass)
|| ServletRequestListener.class.isAssignableFrom(beanClass)
|| ServletContextAttributeListener.class.isAssignableFrom(beanClass)
|| HttpSessionListener.class.isAssignableFrom(beanClass)
|| HttpSessionBindingListener.class.isAssignableFrom(beanClass)
|| HttpSessionActivationListener.class.isAssignableFrom(beanClass)
|| HttpSessionIdListener.class.isAssignableFrom(beanClass)
|| ServletRequestAttributeListener.class.isAssignableFrom(beanClass);
}
return false;
}
示例6: stop
import javax.servlet.http.HttpSessionActivationListener; //导入依赖的package包/类
public void stop() {
ClassLoader old = getTccl();
try {
setTccl(servletContext.getClassLoader());
this.started = false;
final Map<String, SessionPersistenceManager.PersistentSession> objectData = new HashMap<>();
for (String sessionId : sessionManager.getTransientSessions()) {
Session session = sessionManager.getSession(sessionId);
if (session != null) {
final HttpSessionEvent event = new HttpSessionEvent(SecurityActions.forSession(session, servletContext, false));
final Map<String, Object> sessionData = new HashMap<>();
for (String attr : session.getAttributeNames()) {
final Object attribute = session.getAttribute(attr);
sessionData.put(attr, attribute);
if (attribute instanceof HttpSessionActivationListener) {
((HttpSessionActivationListener) attribute).sessionWillPassivate(event);
}
}
objectData.put(sessionId, new PersistentSession(new Date(session.getLastAccessedTime() + (session.getMaxInactiveInterval() * 1000)), sessionData));
}
}
sessionPersistenceManager.persistSessions(deploymentName, objectData);
this.data.clear();
} finally {
setTccl(old);
}
}
示例7: handleRequest
import javax.servlet.http.HttpSessionActivationListener; //导入依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
final String incomingSessionId = servletContext.getSessionConfig().findSessionId(exchange);
if (incomingSessionId == null || !data.containsKey(incomingSessionId)) {
next.handleRequest(exchange);
return;
}
//we have some old data
PersistentSession result = data.remove(incomingSessionId);
if (result != null) {
long time = System.currentTimeMillis();
if (time < result.getExpiration().getTime()) {
final HttpSessionImpl session = servletContext.getSession(exchange, true);
final HttpSessionEvent event = new HttpSessionEvent(session);
for (Map.Entry<String, Object> entry : result.getSessionData().entrySet()) {
if (entry.getValue() instanceof HttpSessionActivationListener) {
((HttpSessionActivationListener) entry.getValue()).sessionDidActivate(event);
}
if(entry.getKey().startsWith(HttpSessionImpl.IO_UNDERTOW)) {
session.getSession().setAttribute(entry.getKey(), entry.getValue());
} else {
session.setAttribute(entry.getKey(), entry.getValue());
}
}
}
}
next.handleRequest(exchange);
}
示例8: testAttributeBeingStored
import javax.servlet.http.HttpSessionActivationListener; //导入依赖的package包/类
@Test
public void testAttributeBeingStored() {
HttpSessionActivationListener object = mock(HttpSessionActivationListener.class);
notifier.attributeBeingStored(mock(RepositoryBackedSession.class), "Test", object);
notifier.attributeBeingStored(session, "Test", "dummy");
verify(object, never()).sessionWillPassivate(any(HttpSessionEvent.class));
notifier.attributeBeingStored(session, "Test", object);
verify(object).sessionWillPassivate(any(HttpSessionEvent.class));
}
示例9: testAttributeHasBeenRestored
import javax.servlet.http.HttpSessionActivationListener; //导入依赖的package包/类
@Test
public void testAttributeHasBeenRestored() {
HttpSessionActivationListener object = mock(HttpSessionActivationListener.class);
notifier.attributeHasBeenRestored(mock(RepositoryBackedSession.class), "Test", object);
notifier.attributeHasBeenRestored(mock(RepositoryBackedSession.class), "Test", "dummy");
notifier.attributeHasBeenRestored(session, "Test", "dummy");
verify(object, never()).sessionWillPassivate(any(HttpSessionEvent.class));
notifier.attributeHasBeenRestored(session, "Test", object);
verify(object).sessionDidActivate(any(HttpSessionEvent.class));
}
示例10: valueUnbound
import javax.servlet.http.HttpSessionActivationListener; //导入依赖的package包/类
public void valueUnbound(HttpSessionBindingEvent event) {
for (EventListener listener: PluginWebInstanceRepository.getListeners()) {
if (listener instanceof HttpSessionActivationListener) {
((HttpSessionBindingListener) listener).valueUnbound(event);
}
}
}
示例11: sessionWillPassivate
import javax.servlet.http.HttpSessionActivationListener; //导入依赖的package包/类
public void sessionWillPassivate(HttpSessionEvent se) {
for (EventListener listener: PluginWebInstanceRepository.getListeners()) {
if (listener instanceof HttpSessionActivationListener) {
((HttpSessionActivationListener) listener).sessionWillPassivate(se);
}
}
}
示例12: sessionDidActivate
import javax.servlet.http.HttpSessionActivationListener; //导入依赖的package包/类
public void sessionDidActivate(HttpSessionEvent se) {
for (EventListener listener: PluginWebInstanceRepository.getListeners()) {
if (listener instanceof HttpSessionAttributeListener) {
((HttpSessionActivationListener) listener).sessionDidActivate(se);
}
}
}
示例13: addListenerInstance
import javax.servlet.http.HttpSessionActivationListener; //导入依赖的package包/类
private void addListenerInstance(final Object listenerInstance,
final List<ServletContextAttributeListener> contextAttributeListeners,
final List<ServletContextListener> contextListeners,
final List<ServletRequestAttributeListener> requestAttributeListeners,
final List<ServletRequestListener> requestListeners, final List<HttpSessionActivationListener> sessionActivationListeners,
final List<HttpSessionAttributeListener> sessionAttributeListeners, final List<HttpSessionListener> sessionListeners) {
if (listenerInstance instanceof ServletContextAttributeListener) {
contextAttributeListeners.add((ServletContextAttributeListener) listenerInstance);
}
if (listenerInstance instanceof ServletContextListener) {
contextListeners.add((ServletContextListener) listenerInstance);
}
if (listenerInstance instanceof ServletRequestAttributeListener) {
requestAttributeListeners.add((ServletRequestAttributeListener) listenerInstance);
}
if (listenerInstance instanceof ServletRequestListener) {
requestListeners.add((ServletRequestListener) listenerInstance);
}
if (listenerInstance instanceof HttpSessionActivationListener) {
sessionActivationListeners.add((HttpSessionActivationListener) listenerInstance);
}
if (listenerInstance instanceof HttpSessionAttributeListener) {
sessionAttributeListeners.add((HttpSessionAttributeListener) listenerInstance);
}
if (listenerInstance instanceof HttpSessionListener) {
sessionListeners.add((HttpSessionListener) listenerInstance);
}
}
示例14: activate
import javax.servlet.http.HttpSessionActivationListener; //导入依赖的package包/类
/**
* Perform internal processing required to activate this
* session.
*/
public void activate() {
// Initialize access count
if (ACTIVITY_CHECK) {
accessCount = new AtomicInteger();
}
// Notify interested session event listeners
fireSessionEvent(Session.SESSION_ACTIVATED_EVENT, null);
// Notify ActivationListeners
HttpSessionEvent event = null;
String keys[] = keys();
for (int i = 0; i < keys.length; i++) {
Object attribute = attributes.get(keys[i]);
if (attribute instanceof HttpSessionActivationListener) {
if (event == null)
event = new HttpSessionEvent(getSession());
try {
((HttpSessionActivationListener)attribute)
.sessionDidActivate(event);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
manager.getContainer().getLogger().error
(sm.getString("standardSession.attributeEvent"), t);
}
}
}
}
示例15: save
import javax.servlet.http.HttpSessionActivationListener; //导入依赖的package包/类
void save(Writer w) throws IOException {
if (expired)
return;
// can't use append because old JDK
w.write(id);
w.write(':');
w.write(Integer.toString(inactiveInterval));
w.write(':');
w.write(servletContext == null || servletContext.getServletContextName() == null ? "" : servletContext
.getServletContextName());
w.write(':');
w.write(Long.toString(lastAccessTime));
w.write("\r\n");
Enumeration e = getAttributeNames();
ByteArrayOutputStream os = new ByteArrayOutputStream(1024 * 16);
while (e.hasMoreElements()) {
String aname = (String) e.nextElement();
Object so = get(aname);
if (so instanceof Serializable) {
os.reset();
ObjectOutputStream oos = new ObjectOutputStream(os);
try {
oos.writeObject(so);
w.write(aname);
w.write(":");
w.write(Utils.base64Encode(os.toByteArray()));
w.write("\r\n");
} catch (IOException ioe) {
servletContext.log("TJWS: Can't replicate/store a session value of '" + aname + "' class:"
+ so.getClass().getName(), ioe);
}
} else
servletContext.log("TJWS: Non serializable session object has been " + so.getClass().getName()
+ " skiped in storing of " + aname, null);
if (so instanceof HttpSessionActivationListener)
((HttpSessionActivationListener) so).sessionWillPassivate(new HttpSessionEvent(this));
}
w.write("$$\r\n");
}