portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Sean Taylor" <da...@bluesunrise.com>
Subject RE: Synchronized and PortletConfig (long)
Date Thu, 01 Mar 2001 22:00:26 GMT

This problem you described was very confusing for me as a new Jetspeed user,
as Im sure others have experienced.
Its about time that it is fixed, and I believe this is the right time with
the new Portlet API.

Concerning performance, the current code, as you have pointed out, creates a
lot of new instances with each request.
Do you plan to cache and re-use portlet sets on a per user or session basis?
Also, currently, having the same portlet ref'd twice on the same psml page
is a problem.

If its not too much trouble, I'd like to briefly understand your new
implementation.
How much of this will you rewrite?

- david



> -----Original Message-----
> From: Stephan Hesmer [mailto:shesmer@raleigh.ibm.com]
> Sent: Thursday, March 01, 2001 6:24 AM
> To: Jetspeed Development
> Subject: Synchronized and PortletConfig (long)
>
>
> The basic problem is that we store per-user variables in the
> PortletConfig.
> These are:
> * Dictionary      layoutConstraints
> * int             layoutPosition
> * Dictionary      skin
> * PortletSet      currentSet
>
> All variables need to be stored in a class that is created
> for every user.
> In our case it is created even in every request.
>
> What is going on in the current Jetspeed?
> ----------------------------------------------------
> ( Legend: Every function that is synchronized is prefixed
> with <sync>. Every
> class that is a singleton per-user is prefixed with <singleton> )
> ( Best viewed with a fixed width font)
>
> When a user accesses a page (for example the default home
> page), the PSML
> file is loaded into a Portlets tree. Next, a new  PortletSet
> tree is created
> out of the Portlets tree. Now let us have a closer look at
> how this is going
> on:
> -> (1) PortletSetFactory.getPortletSet
>   -> new PortletSet
>   -> PortletSet.setController
>   -> PortletSet.setPortletConfig
>     -> PortletConfig is returned from PortletConfigFactory.
>       Note: PortletConfigFactory in every function call creates a new
>             PortletConfig object. PortletConfig should only exist once
>             per portlet, but here it is misused to save per-user data.
>   -> for each subtree in Portlets do
>     -> <sync>PortletSet.addPortlet( child_PortletSet ) (2)
>       child_PortletSet is created recursively with calling
> again (see 1)
>   -> for each portlet in Portlets do
>     -> <singleton>PortletFactory.getPortlet( portlet ) (3)
>
>
> (2) <sync>PortletSet.addPortlet( child )
> -> add( child )
> -> child.getPortletConfig
>   -> <sync>PortletConfig.setPortletSet( this )
>   -> <sync>PortletConfig.setLayout
>   -> <sync>PortletConfig.setPosition
>
>
> (3) <singleton>PortletFactory.getPortlet( portlet )
> -> PortletConfigFactory.getPortletConfig( portlet )
>   Note: PortletConfigFactory creates in every function call a new
>         PortletConfig object. PortletConfig should only exist once
>         per portlet, but here it is misused to save per-user data.
> -> <sync>PortletSet.addPortlet( portlet ) (see 2)
>
>
> As you can see, the PortletConfig is created every time the factory is
> called. This leads to NO failure when the PortletConfig is stored in a
> PortletSet (see 2), because the PortletSet exists per-request
> (this means,
> that it is created anew for every request).
> When a PortletSet subtree is added to the parent PortletSet
> in (2), the
> PortletConfig is also initialized with the parent PortletSet,
> the layout and
> the position. This leads to no failure because first the PortletSet is
> created for every request and second the PortletConfig is
> created every time
> the factory is called. So, we don't have any failure here.
> But we would not
> need the synchronized in (2).
> But, when a portlet is added to the PortletSet tree in (3), the
> PortletConfig is assigned to the portlet that exists only
> once per system.
> Now imagine, that 3 request at the same time are processed. Then, the
> PortletConfig is created in every request, but assigned to
> the very same
> portlet. Note, the PortletConfig function in the portlet are
> synchronized
> (see 2). Here, it is only necessary as the data currently is
> stored in the
> wrong object with the wrong scope (singleton per portlet). However, it
> should be stored in an object with a per-user scope in which
> case we do not
> need the synchronized statement. Furthermore, other requests would not
> override others "skin" or "positions" anymore.
>
> Hope this summary is enough for you.
>
> Stephan
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org
>
>



Mime
View raw message