[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-3655) Caching in ServerConversationContext

Nicolas Feybesse (JIRA) jira-events at lists.jboss.org
Wed Dec 3 08:07:36 EST 2008


    [ https://jira.jboss.org/jira/browse/JBSEAM-3655?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12440879#action_12440879 ] 

Nicolas Feybesse commented on JBSEAM-3655:
------------------------------------------

Michaël,

I think you are right : there was a bug in Seam already. (I remember some problems I encountered with initializeTemporaryConversation())

I think there are two needs with Manager.instance().initializeTemporaryConversation()  :

1) When we really want a new virgin conversation : the maps need to be cleaned and the cache too (for example : we don't want to keep the EntityManager)

2) When we want a new conversation, but we want to keep objects that are alraedy added.

Personally, I need the two behaviors.

I propose :

public initializeTemporaryConversation(boolean keepContent){  ... }

What about Manager.instance().leaveConversation() ?

NF

> Caching in ServerConversationContext 
> -------------------------------------
>
>                 Key: JBSEAM-3655
>                 URL: https://jira.jboss.org/jira/browse/JBSEAM-3655
>             Project: Seam
>          Issue Type: Bug
>          Components: Core
>            Reporter: Michael Youngstrom
>            Assignee: Michael Youngstrom
>             Fix For: 2.1.1.CR1, 2.1.1.CR2
>
>
> In my application profiling the SeamELResolver is an extremely hot spot.  ServerConversationContext was the hottest.  I think it would be safe to create a request scoped cache on ServerCovnersationContext.  I believe nobody can really be add or removing values from the conversation without going through the ServerConversationContext.  In my tests caching resolution of conversation values greatly improved EL performance.
> Index: src/main/org/jboss/seam/contexts/ServerConversationContext.java
> ===================================================================
> --- src/main/org/jboss/seam/contexts/ServerConversationContext.java	(revision 9465)
> +++ src/main/org/jboss/seam/contexts/ServerConversationContext.java	(working copy)
> @@ -36,6 +36,7 @@
>     private final Set<String> removals = new HashSet<String>();
>     private final String id;
>     private final List<String> idStack;
> +   private final Map<String, Object> cache = new HashMap<String, Object>();
>     
>     private List<String> getIdStack()
>     {
> @@ -81,8 +82,15 @@
>        this.idStack = new LinkedList<String>();
>        idStack.add(id);
>     }
> +
> +	public Object get(String name) {
> +        if (!cache.containsKey(name)) {
> +            cache.put(name, resolveValue(name));
> +        }
> +        return cache.get(name);
> +    }
>        
> -    public Object get(String name) 
> +	protected Object resolveValue(String name)
>      {
>        Object result = additions.get(name);
>        if (result!=null)
> @@ -148,6 +156,7 @@
>     public void set(String name, Object value) 
>     {
>        if ( Events.exists() ) Events.instance().raiseEvent("org.jboss.seam.preSetVariable." + name);
> +	  cache.remove(name);
>        if (value==null)
>        {
>           //yes, we need this
> @@ -185,6 +194,7 @@
>  	public void remove(String name) 
>     {
>        if ( Events.exists() ) Events.instance().raiseEvent("org.jboss.seam.preRemoveVariable." + name);
> +	  cache.remove(name);
>        additions.remove(name);
>        removals.add(name);
>        if ( Events.exists() ) Events.instance().raiseEvent("org.jboss.seam.postRemoveVariable." + name);
> @@ -245,6 +255,7 @@
>     
>     public void clear()
>     {
> +	  cache.clear();
>        additions.clear();
>        removals.addAll( getNamesFromSession() );
>     }

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

       




More information about the seam-issues mailing list