-
1. Re: Destroy all beans etc from session.
sherkan777 Apr 30, 2009 1:47 PM (in response to giannisapi)I follow your question and add mine. Is possible to check, that everythink any references/etc was completly cleaned from session to clean by GC?
-
2. Re: Destroy all beans etc from session.
giannisapi Apr 30, 2009 2:32 PM (in response to giannisapi)hahahah join the club my friend, i think it would be really usefull if this could be done. I am pretty sure it ll be possible but i just cant figure out how. I am searching for it right now, if i find anything i will update asap.
thanks,
giannis -
3. Re: Destroy all beans etc from session.
niox.nikospara.yahoo.com Apr 30, 2009 4:37 PM (in response to giannisapi)Hi Gianni,
There is allways the servlet API (HttpSession.getAttributeNames() and HttpSession.removeAttribute(String name)) that you can use. For a more advanced way:
Session EJBs may (required by SEAM I think) have removal methods, annotated with @Remove. Calling this method will remove the instance from the container (EJB 3 specs, par.4.3.11).
SEAM implements the observer pattern, see docs par.6.9. So if you configure your @Remove methods to also be @Observers of a specific event, raised from a page action when your home page loads, this would effectively remove them.
Eg:
// in every component that you want removed @Name("mycomponent") @Stateful(...) public class MySessionComponent { ... @Remove @Observer("home.page.event") public void remove() { ... } ... }
And in the home page action:
public void homePageAction() { ... Events.instance().raiseEvent("home.page.event"); ... }
-
4. Re: Destroy all beans etc from session.
giannisapi Apr 30, 2009 4:53 PM (in response to giannisapi)Hi niko,
As i am at work now i dont have time to implement and provide my results. But thanks a lot of your help this should help a lot.
Thanks, Eyxaristo,
giannis -
5. Re: Destroy all beans etc from session.
gonorrhea May 1, 2009 1:01 AM (in response to giannisapi)In a generic sense here is how to invalidate a session from Faces:
ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext(); HttpServletResponse response = (HttpServletResponse)ectx.getResponse(); HttpSession session = (HttpSession)ectx.getSession(false); session.invalidate();
Then you need to spawn a new HttpSession but I'm not familiar with how to do this programmatically in the context of a Seam app. This would typically involve authentication and authorization of course.
In case you're not interested in Session invalidation, but rather destroying all LRCs (or demoting them all to temporary conversations). If that's the case, then something like this may do the trick...
SiA:
Seam maintains a list of all long-running conversations and metadata about each one
in the built-in Seam component named conversationEntries. These conversations
are exported to the session-scoped context variable conversationList as a list of
ConversationEntry objects, whose properties are shown in table 7.7. This list
excludes all entries that aren’t displayable by default. You can use the conversation-
Entries component to export a custom list.pages.xml:
<page view-id="/home.xhtml" > <action execute="#{foo.cleanup}"/> </page>
@Name("foo") public class Foo{ public void cleanup(){ //code loops thru list of ConversationEntry objects and invokes destroy() method on each instance. } }
NOTE: I haven't actually tested this and there may be a better
standard
way of solving this problem... -
6. Re: Destroy all beans etc from session.
kapitanpetko May 1, 2009 5:00 AM (in response to giannisapi)If you really want to delete everything, just invalidate the session:
org.jboss.seam.web.Session.instance().invalidate();
You shouldn't invalidate the HttpSession directly, because Seam stores all kind of
stuff in there, hence the need to call a Seam API. The call above schedule's the
session for invalidation, actual work is done at the end of the request.HTH