[ 
http://www.stripesframework.org/jira/browse/STS-429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11104#action_11104
 ] 

Vadim Gerassimov commented on STS-429:
--------------------------------------

I understand the situation. I have some proposals about the plugin.

First, if maxTime is negative there is no need even no create a new thread:

 /**
         * Start deleter thread.
         */
        public void valueBound(HttpSessionBindingEvent event) {
            key = event.getName();
            session = event.getSession();
            if (maxTime > 0) {
                    deleter = new Deleter();
                    Thread t = new Thread(deleter);
                    t.start();
            }
        }
        /**
         * Stop deleter thread.
         */
        public void valueUnbound(HttpSessionBindingEvent event) {
                if (maxTime > 0) {
                    deleter.cancel();
                    deleter = null;
                }
        }

Second, about serializable() in @Session. In fact, if I understand correctly, 
there is no need for this attribute in annotation:

protected Object setAttribute(HttpSession session, String key, Object object, 
int maxTime) {
        if (object == null) {
            // If object is null, remove attribute.
            Object ret = session.getAttribute(key);
            session.removeAttribute(key);
            return ret;
        }
        else if (object instanceof java.io.Serializable) {
            Object ret = session.getAttribute(key);
            session.setAttribute(key, new MaxTimeSaver(object, maxTime));
            return ret;
        }
        else {
            Object ret = session.getAttribute(key);
            session.setAttribute(key, new NoSerializeSaver(object, maxTime));
            return ret;
        }
    }

However, I have doubts about life time of annotated object in session. If 
programmer will use this feature (to optimize session usage) the final product 
for end user might be non deterministic.

Example. Some field (let's it be String) is annotated with @Session where 
maxTime (for instance 5 min) is specified as positive value. From some request 
the field was populated and user sees its value on the screen (it might be some 
complex form) as expected. He submits something related to complex form and 
still see the field value - it's OK. After 5 min user submits again something 
(related to the complex form) and does not see the value of annotated field 
anymore. 

I think for session usage optimization it's better to make some webflow 
mechanism (a'la spring webflow, conversion context in jboss seam). What do you 
think? Stripes architecture is very flexible.


> @Session annotation to save and restore fields automatically
> ------------------------------------------------------------
>
>                 Key: STS-429
>                 URL: http://www.stripesframework.org/jira/browse/STS-429
>             Project: Stripes
>          Issue Type: New Feature
>            Reporter: Christian Poitras
>            Assignee: Tim Fennell
>            Priority: Minor
>         Attachments: session-plugin.jar, session-plugin2.jar, 
> session-plugin3.jar, session-plugin4.jar
>
>
> I've added a @Session annotation and an interceptor that automatically saves 
> annotated fields in session and restores the fields on following request.
> This could be a great add-on to Stripes.

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

        

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to