Java 类javax.servlet.http.HttpSessionBindingEvent 实例源码
项目:convertigo-engine
文件:HttpSessionListener.java
public void valueUnbound(HttpSessionBindingEvent event) {
try {
Engine.logContext.debug("HTTP session stopping...");
HttpSession httpSession = event.getSession();
String httpSessionID = httpSession.getId();
if (Engine.theApp != null) Engine.theApp.contextManager.removeAll(httpSessionID);
removeSession(httpSessionID);
Engine.logContext.debug("HTTP session stopped [" + httpSessionID + "]");
} catch(Exception e) {
Engine.logContext.error("Exception during unbinding HTTP session listener", e);
}
}
项目:lams
文件:SessionListenerBridge.java
@Override
public void attributeUpdated(final Session session, final String name, final Object value, final Object old) {
if(name.startsWith(IO_UNDERTOW)) {
return;
}
final HttpSessionImpl httpSession = SecurityActions.forSession(session, servletContext, false);
if (old != value) {
if (old instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) old).valueUnbound(new HttpSessionBindingEvent(httpSession, name, old));
}
applicationListeners.httpSessionAttributeReplaced(httpSession, name, old);
}
if (value instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) value).valueBound(new HttpSessionBindingEvent(httpSession, name, value));
}
}
项目:parabuild-ci
文件:ChartDeleter.java
/**
* When this object is unbound from the session (including upon session
* expiry) the files that have been added to the ArrayList are iterated
* and deleted.
*
* @param event the session unbind event.
*/
public void valueUnbound(HttpSessionBindingEvent event) {
Iterator iter = this.chartNames.listIterator();
while (iter.hasNext()) {
String filename = (String) iter.next();
File file = new File(
System.getProperty("java.io.tmpdir"), filename
);
if (file.exists()) {
file.delete();
}
}
return;
}
项目:opengse
文件:HttpSessionImpl.java
/**
* Removes the object bound with the specified name from
* this session.
*/
public void removeAttribute(String name) {
maybeThrowIllegalStateException();
checkValid();
Object value = getAttribute(name);
// notify binding listeners
if (value != null) {
sessionData_.remove(name);
updateCache();
if (value instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) value).valueUnbound(
new HttpSessionBindingEvent(this, name));
}
}
// notify attribute listeners
ServletSessionCache.getCache(cacheId_).
notifySessionAttributeRemoved(this, name);
}
项目:spring4-understanding
文件:MockHttpSession.java
/**
* Serialize the attributes of this session into an object that can be
* turned into a byte array with standard Java serialization.
*
* @return a representation of this session's serialized state
*/
public Serializable serializeState() {
HashMap<String, Serializable> state = new HashMap<String, Serializable>();
for (Iterator<Map.Entry<String, Object>> it = this.attributes.entrySet().iterator(); it.hasNext();) {
Map.Entry<String, Object> entry = it.next();
String name = entry.getKey();
Object value = entry.getValue();
it.remove();
if (value instanceof Serializable) {
state.put(name, (Serializable) value);
}
else {
// Not serializable... Servlet containers usually automatically
// unbind the attribute in this case.
if (value instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) value).valueUnbound(new HttpSessionBindingEvent(this, name, value));
}
}
}
return state;
}
项目:vaadin-vertx-samples
文件:VertxWrappedSessionUT.java
@Test
public void shouldUnbindOnInvalidate() throws Exception {
Map<String, Object> sampleData = new HashMap<>();
HttpSessionBindingListener mockA = mock(HttpSessionBindingListener.class);
HttpSessionBindingListener mockC = mock(HttpSessionBindingListener.class);
sampleData.put("a", mockA);
sampleData.put("b", "b");
sampleData.put("c", mockC);
sampleData.put("b", "b");
when(session.data()).thenReturn(sampleData);
vertxWrappedSession.invalidate();
verify(session).destroy();
ArgumentCaptor<HttpSessionBindingEvent> sessionBindingEventCaptor = ArgumentCaptor.forClass(HttpSessionBindingEvent.class);
verify(mockA).valueUnbound(sessionBindingEventCaptor.capture());
verify(mockC).valueUnbound(sessionBindingEventCaptor.capture());
assertThat(sessionBindingEventCaptor.getAllValues()).hasSize(2);
assertHttpSessionBindingEvent("a", mockA, sessionBindingEventCaptor.getAllValues().get(0));
assertHttpSessionBindingEvent("c", mockC, sessionBindingEventCaptor.getAllValues().get(1));
}
项目:nbone
文件:MockHttpSession.java
/**
* Serialize the attributes of this session into an object that can be
* turned into a byte array with standard Java serialization.
*
* @return a representation of this session's serialized state
*/
public Serializable serializeState() {
HashMap<String, Serializable> state = new HashMap<String, Serializable>();
for (Iterator<Map.Entry<String, Object>> it = this.attributes.entrySet().iterator(); it.hasNext();) {
Map.Entry<String, Object> entry = it.next();
String name = entry.getKey();
Object value = entry.getValue();
it.remove();
if (value instanceof Serializable) {
state.put(name, (Serializable) value);
}
else {
// Not serializable... Servlet containers usually automatically
// unbind the attribute in this case.
if (value instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) value).valueUnbound(new HttpSessionBindingEvent(this, name, value));
}
}
}
return state;
}
项目:tomcat7
文件:CrawlerSessionManagerValve.java
@Override
public void valueUnbound(HttpSessionBindingEvent event) {
String clientIp = sessionIdClientIp.remove(event.getSession().getId());
if (clientIp != null) {
clientIpSessionId.remove(clientIp);
}
}
项目:tasfe-framework
文件:HttpSessionImpl.java
@Override
public void removeAttribute(String name) {
if (attributes != null) {
Object value = attributes.get(name);
if (value != null && value instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) value).valueUnbound(new HttpSessionBindingEvent(this, name, value));
}
attributes.remove(name);
}
}
项目:tasfe-framework
文件:HttpSessionImpl.java
@Override
public void setAttribute(String name, Object value) {
attributes.put(name, value);
if (value != null && value instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) value).valueBound(new HttpSessionBindingEvent(this, name, value));
}
}
项目:lams
文件:SessionListenerBridge.java
@Override
public void attributeAdded(final Session session, final String name, final Object value) {
if(name.startsWith(IO_UNDERTOW)) {
return;
}
final HttpSessionImpl httpSession = SecurityActions.forSession(session, servletContext, false);
applicationListeners.httpSessionAttributeAdded(httpSession, name, value);
if (value instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) value).valueBound(new HttpSessionBindingEvent(httpSession, name, value));
}
}
项目:lams
文件:SessionListenerBridge.java
@Override
public void attributeRemoved(final Session session, final String name, final Object old) {
if(name.startsWith(IO_UNDERTOW)) {
return;
}
final HttpSessionImpl httpSession = SecurityActions.forSession(session, servletContext, false);
if (old != null) {
applicationListeners.httpSessionAttributeRemoved(httpSession, name, old);
if (old instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) old).valueUnbound(new HttpSessionBindingEvent(httpSession, name, old));
}
}
}
项目:gitplex-mit
文件:PageStoreManager.java
@Override
public void valueUnbound(HttpSessionBindingEvent event)
{
// WICKET-5164 use the original sessionId
IPageStore store = getPageStore();
// store might be null if destroyed already
if (store != null)
{
store.unbind(sessionId);
}
}
项目:ChronoBike
文件:OnlineSession.java
public void valueUnbound(HttpSessionBindingEvent event)
{
if(event.getName().equals("AppSession"))
{
Log.logNormal("Removing session");
OnlineSession session = (OnlineSession)event.getValue();
m_ResourceManager.removeSession(session);
}
else
{
Log.logImportant("Removing unknown object from session: "+event.getName());
}
}
项目:parabuild-ci
文件:ChartDeleter.java
/**
* When this object is unbound from the session (including upon session
* expiry) the files that have been added to the ArrayList are iterated
* and deleted.
*
* @param event the session unbind event.
*/
public void valueUnbound(HttpSessionBindingEvent event) {
Iterator iter = this.chartNames.listIterator();
while (iter.hasNext()) {
String filename = (String) iter.next();
File file = new File(System.getProperty("java.io.tmpdir"), filename);
if (file.exists()) {
file.delete();
}
}
return;
}
项目:apache-tomcat-7.0.73-with-comment
文件:CrawlerSessionManagerValve.java
@Override
public void valueUnbound(HttpSessionBindingEvent event) {
String clientIp = sessionIdClientIp.remove(event.getSession().getId());
if (clientIp != null) {
clientIpSessionId.remove(clientIp);
}
}
项目:apache-tomcat-7.0.73-with-comment
文件:SessionListener.java
/**
* Record the fact that a servlet context attribute was added.
*
* @param event
* The session attribute event
*/
@Override
public void attributeAdded(HttpSessionBindingEvent event) {
log("attributeAdded('" + event.getSession().getId() + "', '"
+ event.getName() + "', '" + event.getValue() + "')");
}
项目:apache-tomcat-7.0.73-with-comment
文件:SessionListener.java
/**
* Record the fact that a servlet context attribute was removed.
*
* @param event
* The session attribute event
*/
@Override
public void attributeRemoved(HttpSessionBindingEvent event) {
log("attributeRemoved('" + event.getSession().getId() + "', '"
+ event.getName() + "', '" + event.getValue() + "')");
}
项目:apache-tomcat-7.0.73-with-comment
文件:SessionListener.java
/**
* Record the fact that a servlet context attribute was replaced.
*
* @param event
* The session attribute event
*/
@Override
public void attributeReplaced(HttpSessionBindingEvent event) {
log("attributeReplaced('" + event.getSession().getId() + "', '"
+ event.getName() + "', '" + event.getValue() + "')");
}
项目:apache-tomcat-7.0.73-with-comment
文件:SessionListener.java
/**
* Record the fact that a servlet context attribute was added.
*
* @param event
* The session attribute event
*/
@Override
public void attributeAdded(HttpSessionBindingEvent event) {
log("attributeAdded('" + event.getSession().getId() + "', '"
+ event.getName() + "', '" + event.getValue() + "')");
}
项目:apache-tomcat-7.0.73-with-comment
文件:SessionListener.java
/**
* Record the fact that a servlet context attribute was removed.
*
* @param event
* The session attribute event
*/
@Override
public void attributeRemoved(HttpSessionBindingEvent event) {
log("attributeRemoved('" + event.getSession().getId() + "', '"
+ event.getName() + "', '" + event.getValue() + "')");
}
项目:apache-tomcat-7.0.73-with-comment
文件:SessionListener.java
/**
* Record the fact that a servlet context attribute was replaced.
*
* @param event
* The session attribute event
*/
@Override
public void attributeReplaced(HttpSessionBindingEvent event) {
log("attributeReplaced('" + event.getSession().getId() + "', '"
+ event.getName() + "', '" + event.getValue() + "')");
}
项目:jaffa-framework
文件:UserSession.java
/** This is invoked, whenever an instance of this class is added to the HttpSession object.
* Currently, this method will set the session timeout value
* @param httpSessionBindingEvent the event that identifies the session.
*/
public void valueBound(HttpSessionBindingEvent httpSessionBindingEvent) {
if (log.isDebugEnabled())
log.debug("valueBound event");
if(ContextManagerFactory.instance().getProperty(UserSession.RULE_TIMEOUT) != null ) {
if (log.isDebugEnabled())
log.debug("Setting Timeout to "+(String) ContextManagerFactory.instance().getProperty(UserSession.RULE_TIMEOUT));
httpSessionBindingEvent.getSession().setMaxInactiveInterval(Integer.parseInt((String) ContextManagerFactory.instance().getProperty(UserSession.RULE_TIMEOUT)));
}
}
项目:jaffa-framework
文件:UserSession.java
/** This is invoked, whenever an instance of this class is removed from the HttpSession object.
* This can happen by an explicit session.removeAttribute(), or if the HttpSession is invalidated or if the HttpSession times out.
* It will kill all related components.
* It will de-register from the Session Manager.
* It will null out all internal references.
* @param httpSessionBindingEvent the event that identifies the session.
*/
public void valueUnbound(HttpSessionBindingEvent httpSessionBindingEvent) {
if (log.isDebugEnabled())
log.debug("The valueUnbound method has been invoked. This will kill the UserSession.");
// kill this usersession
killUserSession();
}
项目:jaffa-framework
文件:MockHttpServletRequest.java
public void setAttribute(String string, Object object) {
Object originalValue = attr.put(string, object);
if (originalValue != null && originalValue instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) originalValue).valueUnbound(new HttpSessionBindingEvent(this, string));
}
if (object != null && object instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) object).valueBound(new HttpSessionBindingEvent(this, string));
}
}
项目:sgroup
文件:NewSessionListener.java
@Override
public void attributeAdded(HttpSessionBindingEvent httpSessionBindingEvent) {
ServletContext servletContext = httpSessionBindingEvent.getSession().getServletContext();
Object loginCount = httpSessionBindingEvent.getSession().getAttribute("loginCount");
if (loginCount == null || "0".equals(loginCount)) {
servletContext.setAttribute("loginCount", 1);
} else {
servletContext.setAttribute("loginCount", Integer.parseInt(loginCount.toString()) + 1);
}
}
项目:sgroup
文件:NewSessionListener.java
@Override
public void attributeRemoved(HttpSessionBindingEvent httpSessionBindingEvent) {
ServletContext servletContext = httpSessionBindingEvent.getSession().getServletContext();
Object loginCount = httpSessionBindingEvent.getSession().getAttribute("loginCount");
if (loginCount == null || "0".equals(loginCount)) {
servletContext.setAttribute("loginCount", 0);
} else {
servletContext.setAttribute("loginCount", Integer.parseInt(loginCount.toString()) - 1);
}
}
项目:lazycat
文件:CrawlerSessionManagerValve.java
@Override
public void valueUnbound(HttpSessionBindingEvent event) {
String clientIp = sessionIdClientIp.remove(event.getSession().getId());
if (clientIp != null) {
clientIpSessionId.remove(clientIp);
}
}
项目:dwr
文件:DefaultScriptSessionManager.java
public void valueUnbound(HttpSessionBindingEvent arg0)
{
if (scriptSessionManager != null && httpSessionId != null)
{
scriptSessionManager.disassociateAllScriptSessionsFromHttpSession(httpSessionId);
}
}
项目:jfreechart
文件:ChartDeleter.java
/**
* When this object is unbound from the session (including upon session
* expiry) the files that have been added to the ArrayList are iterated
* and deleted.
*
* @param event the session unbind event.
*/
@Override
public void valueUnbound(HttpSessionBindingEvent event) {
Iterator iter = this.chartNames.listIterator();
while (iter.hasNext()) {
String filename = (String) iter.next();
File file = new File(
System.getProperty("java.io.tmpdir"), filename
);
if (file.exists()) {
file.delete();
}
}
}
项目:HttpSessionReplacer
文件:HttpSessionNotifier.java
/**
* Notifies listeners that attribute was added. See {@link SessionNotifier}
* {@link #attributeAdded(RepositoryBackedSession, String, Object)}.
* <p>
* If the added attribute <code>value</code> is a HttpSessionBindingListener,
* it will receive the {@link HttpSessionBindingEvent}. If there are
* {@link HttpSessionAttributeListener} instances associated to
* {@link ServletContext}, they will be notified via
* {@link HttpSessionAttributeListener#attributeAdded(HttpSessionBindingEvent)}
* .
*/
@Override
public void attributeAdded(RepositoryBackedSession session, String key, Object value) {
// If the
if (session instanceof HttpSession && value instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener)value).valueBound(new HttpSessionBindingEvent((HttpSession)session, key));
}
HttpSessionBindingEvent event = new HttpSessionBindingEvent((HttpSession)session, key, value);
for (HttpSessionAttributeListener listener : descriptor.getHttpSessionAttributeListeners()) {
listener.attributeAdded(event);
}
}
项目:HttpSessionReplacer
文件:TestHttpSessionNotifier.java
@Test
public void testAttributeAdded() {
HttpSessionAttributeListener listener = mock(HttpSessionAttributeListener.class);
descriptor.addHttpSessionAttributeListener(listener);
notifier.attributeAdded(session, "Test", "value");
verify(listener).attributeAdded(any(HttpSessionBindingEvent.class));
HttpSessionBindingListener bindingListener = mock(HttpSessionBindingListener.class);
notifier.attributeAdded(session, "Test", bindingListener);
verify(listener, times(2)).attributeAdded(any(HttpSessionBindingEvent.class));
verify(bindingListener).valueBound(any(HttpSessionBindingEvent.class));
}
项目:HttpSessionReplacer
文件:TestHttpSessionNotifier.java
@Test
public void testAttributeReplaced() {
HttpSessionAttributeListener listener = mock(HttpSessionAttributeListener.class);
notifier.attributeReplaced(session, "Test", "very-old-value");
verify(listener, never()).attributeReplaced(any(HttpSessionBindingEvent.class));
descriptor.addHttpSessionAttributeListener(listener);
notifier.attributeReplaced(session, "Test", "old-value");
verify(listener).attributeReplaced(any(HttpSessionBindingEvent.class));
HttpSessionBindingListener bindingListener = mock(HttpSessionBindingListener.class);
notifier.attributeReplaced(session, "Test", bindingListener);
verify(listener, times(2)).attributeReplaced(any(HttpSessionBindingEvent.class));
verify(bindingListener).valueUnbound(any(HttpSessionBindingEvent.class));
}
项目:HttpSessionReplacer
文件:TestHttpSessionNotifier.java
@Test
public void testAttributeRemoved() {
notifier.attributeRemoved(session, "Test", "very-old-value");
HttpSessionAttributeListener listener = mock(HttpSessionAttributeListener.class);
descriptor.addHttpSessionAttributeListener(listener);
notifier.attributeRemoved(session, "Test", "old-value");
verify(listener).attributeRemoved(any(HttpSessionBindingEvent.class));
HttpSessionBindingListener bindingListener = mock(HttpSessionBindingListener.class);
notifier.attributeRemoved(session, "Test", bindingListener);
verify(listener, times(2)).attributeRemoved(any(HttpSessionBindingEvent.class));
verify(bindingListener).valueUnbound(any(HttpSessionBindingEvent.class));
}
项目:sistra
文件:InstanciaManager.java
public void valueUnbound(HttpSessionBindingEvent event) {
Set keys = new HashSet(keySet());
for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
String idInstancia = (String) iterator.next();
Object o = get(idInstancia);
if (o != null && o instanceof InstanciaDelegate) {
InstanciaDelegate delegate = (InstanciaDelegate) o;
remove(idInstancia);
delegate.destroy();
}
}
}
项目:sistra
文件:InstanciaManager.java
public void valueUnbound(HttpSessionBindingEvent event) {
Set keys = new HashSet(keySet());
for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
String idInstancia = (String) iterator.next();
Object o = remove(idInstancia);
if (o != null && o instanceof InstanciaDelegate) {
InstanciaDelegate delegate = (InstanciaDelegate) o;
delegate.destroy();
}
}
}
项目:spring-security-registration
文件:LoggedUser.java
@Override
public void valueUnbound(HttpSessionBindingEvent event) {
List<String> users = activeUserStore.getUsers();
LoggedUser user = (LoggedUser) event.getValue();
if (users.contains(user.getUsername())) {
users.remove(user.getUsername());
}
}
项目:nebo
文件:NettyHttpSession.java
@Override
public void setAttribute(String name, Object value) {
assertIsValid();
Assert.notNull(name, "Attribute name must not be null");
if (value != null) {
this.attributes.put(name, value);
if (value instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) value).valueBound(new HttpSessionBindingEvent(this, name, value));
}
}
else {
removeAttribute(name);
}
}
项目:nebo
文件:NettyHttpSession.java
@Override
public void removeAttribute(String name) {
assertIsValid();
Assert.notNull(name, "Attribute name must not be null");
Object value = this.attributes.remove(name);
if (value instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) value).valueUnbound(new HttpSessionBindingEvent(this, name, value));
}
}
项目:nebo
文件:NettyHttpSession.java
/**
* Clear all of this session's attributes.
*/
public void clearAttributes() {
for (Iterator<Map.Entry<String, Object>> it = this.attributes.entrySet().iterator(); it.hasNext();) {
Map.Entry<String, Object> entry = it.next();
String name = entry.getKey();
Object value = entry.getValue();
it.remove();
if (value instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) value).valueUnbound(new HttpSessionBindingEvent(this, name, value));
}
}
}