portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephan Hesmer" <shes...@raleigh.ibm.com>
Subject Synchronized and PortletConfig (long)
Date Thu, 01 Mar 2001 14:23:31 GMT
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



Mime
View raw message