Skip to main content

[JIRA] Created: (SERVLET_SPEC-68) Change HttpSessionListener to extend new HttpSessionCreateListener, HttpSessionDestroyListener

  • From: "beamerblvd (JIRA)" <jira-no-reply@...>
  • To: issues@...
  • Subject: [JIRA] Created: (SERVLET_SPEC-68) Change HttpSessionListener to extend new HttpSessionCreateListener, HttpSessionDestroyListener
  • Date: Mon, 18 Mar 2013 00:56:53 +0000 (GMT+00:00)
  • Auto-submitted: auto-generated

Change HttpSessionListener to extend new HttpSessionCreateListener, 
HttpSessionDestroyListener
----------------------------------------------------------------------------------------------

                 Key: SERVLET_SPEC-68
                 URL: http://java.net/jira/browse/SERVLET_SPEC-68
             Project: servlet-spec
          Issue Type: Improvement
            Reporter: beamerblvd


The HttpSessionListener interface contains two methods: sessionCreated() and 
sessionDestroyed(). Sometimes listeners are only interested in creation or 
destruction, but not both. Also, this prevents lambda expressions from being 
passed to ServletContext#addListener(T) for creation and destruction events. 
For example, I can add an HttpSessionIdListener listener to a ServletContext 
with a lambda expression:

{code}context.addListener((HttpSessionIdListener)(e, s) -> {
    // do something
});{code}

I'd like to also be able to do:

{code}context.addListener((HttpSessionCreateListener)(e) -> {
    // do something
});
context.addListener((HttpSessionDestroyListener)(e) -> {
    // do something
});{code}

Particularly, I might not care about creation events, so I might just do the 
latter.

I recommend:

{code}interface HttpSessionCreateListener
    - sessionCreated(HttpSessionEvent)
interface HttpSessionDestroyListener
    - sessionDestroyed(HttpSessionEvent)
interface HttpSessionListener extends HttpSessionCreateListener, 
HttpSessionDestroyListener{code}

This would be a compile-safe change and would not break web applications with 
existing HttpSessionListeners.

There are a few other interfaces that could possibly use a similar 
separation, though I am not suggesting that this be applied to ALL of them:

{code}HttpSessionActivationListener:
    HttpSessionActivateListener
    HttpSessionPassivateListener
HttpSessionAttributeListener:
    HttpSessionAttributeAddListener
    HttpSessionAttributeRemoveListener
    HttpSessionAttributeReplaceListener
HttpSessionBindingListener:
    HttpSessionBindListener
    HttpSessionUnbindListener
ServletContextAttributeListener:
    ServletContextAttributeAddListener
    ServletContextAttributeRemoveListener
    ServletContextAttributeReplaceListener
ServletContextListener:
    ServletContextDestroyListener
    ServletContextInitializeListener
ServletRequestAttributeListener:
    ServletRequestAttributeAddListener
    ServletRequestAttributeRemoveListener
    ServletRequestAttributeReplaceListener
ServletRequestListener:
    ServletRequestDestroyListener
    ServletRequestInitializeListener{code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://java.net/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


[JIRA] Created: (SERVLET_SPEC-68) Change HttpSessionListener to extend new HttpSessionCreateListener, HttpSessionDestroyListener

beamerblvd (JIRA) 03/18/2013
 
 
Close
loading
Please Confirm
Close