portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r691681 - in /portals/jetspeed-2/portal/branches/security-refactoring: components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/ jetspeed-portal-resources/src/main/resources/assembly/
Date Wed, 03 Sep 2008 16:50:23 GMT
Author: ate
Date: Wed Sep  3 09:50:22 2008
New Revision: 691681

URL: http://svn.apache.org/viewvc?rev=691681&view=rev
Log:
Moving back to static references of Spring beans within PortletEntityImpl to reduce the overhead
of having to go through the (Spring) ComponentManager looking them up for each new instance.
The major change now is that these static references are *not* directly set by those Spring
beans onto the PortletEntityImpl but *injected* transparently through Spring.

This vastly reduces the coupling between these beans and much reliable lifecycle "management"
of the references as they will be automatically nullified again when the Spring context is
destroyed.
Clearing out the static references is very important to support reloading the Spring context
(possibly with a new classloader) like happens with the (non-forked) test-cases and in the
future hopefully will help making the Jetspeed portal itself reloadable.

This change for PortletEntityImpl is just one step: new functionality (like for the security
refactoring) and other existing directly injected static references should be dealt with in
the same way.  

Added:
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/static-bean-references.xml
  (with props)
Modified:
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java?rev=691681&r1=691680&r2=691681&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
Wed Sep  3 09:50:22 2008
@@ -27,7 +27,6 @@
 
 import javax.portlet.PortletMode;
 
-import org.apache.jetspeed.Jetspeed;
 import org.apache.jetspeed.JetspeedActions;
 import org.apache.jetspeed.aggregator.RenderTrackable;
 import org.apache.jetspeed.components.portletpreferences.PortletPreferencesProvider;
@@ -68,11 +67,11 @@
 {   
     private Long oid;
     private JetspeedObjectID id;
-    private PortletPreferencesProvider portletPreferencesProvider;
-    private PortletEntityAccessComponent portletEntityAccess;    
-    private PortletRegistry registry;
-    private RequestContextComponent requestContextComponent;
-    private PageManager pageManager;
+    private static PortletPreferencesProvider portletPreferencesProvider;
+    private static PortletEntityAccessComponent portletEntityAccess;    
+    private static PortletRegistry registry;
+    private static RequestContextComponent requestContextComponent;
+    private static PageManager pageManager;
     
     protected PreferenceSetComposite pagePreferenceSet;
     protected Map perPrincipalPrefs = new HashMap();
@@ -143,7 +142,6 @@
 //        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) perPrincipalPrefs.get(principal);
         if (preferenceSet == null || !dirty)
         {
-            retrievePortletPreferencesProvider();
             preferenceSet = portletPreferencesProvider.getPreferenceSet(this, principal.getName());
             perPrincipalPrefs.put(principal, preferenceSet);
             /*
@@ -220,7 +218,6 @@
         // (becuase the PortletApplication has yet to be registered).
         if(this.portletDefinition == null)
         {
-            retrievePortletRegistry();
             PortletDefinition pd = registry.getPortletDefinitionByIdentifier(getPortletUniqueName());
             if ( pd != null )
             {
@@ -236,7 +233,6 @@
         
         // Wrap the portlet defintion every request thread
         // JS2-852: don't use thread local
-        retrieveRequestContextComponent();
         RequestContext rc = requestContextComponent.getRequestContext();
         String entityFragmentKey = getEntityFragmentKey();
         PortletDefinition fpd = null;
@@ -274,7 +270,6 @@
      */
     public void store() throws IOException
     {
-        retrievePortletEntityAccess();
         try
         {
             portletEntityAccess.storePortletEntity(this);
@@ -306,7 +301,6 @@
         
         if (preferenceSet != null)
         {
-            retrievePortletPreferencesProvider();
             portletPreferencesProvider.savePreferenceSet(this, principal.getName(), preferenceSet);
         }
         dirty = false;
@@ -314,9 +308,6 @@
     
     private void storeToPage()
     {
-        retrievePageManager();
-        retrieveRequestContextComponent();
-        
         PreferenceSet preferenceSet = this.pagePreferenceSet;
         List preferences = new ArrayList();
         
@@ -425,7 +416,6 @@
         {
             portletDefinition = (PortletDefinitionComposite) composite;
             // if the portletDefinition is modified, clear threadlocal fragmentPortletDefinition
cache
-            retrieveRequestContextComponent();
             RequestContext rc = requestContextComponent.getRequestContext();
             if (rc != null)
             {
@@ -445,7 +435,6 @@
      */
     public Principal getPrincipal()
     {
-        retrieveRequestContextComponent();
         if (requestContextComponent == null)
         {
             // TODO: shouldn't be possible anymore
@@ -562,7 +551,6 @@
     {
         this.fragment = fragment;
         // if the fragment is set, clear threadlocal fragmentPortletDefinition cache
-        retrieveRequestContextComponent();
         RequestContext rc = requestContextComponent.getRequestContext();
         if (rc != null)
         {
@@ -616,7 +604,6 @@
             {
             }
         }
-        retrieveRequestContextComponent();
         RequestContext context = requestContextComponent.getRequestContext();
         
         try
@@ -636,43 +623,28 @@
         return "org.apache.jetspeed" + entityId ;
     }
     
-    private void retrievePortletRegistry()
+    public void setPortletRegistry(PortletRegistry registry)
     {
-        if (registry == null)
-        {
-            registry = (PortletRegistry)Jetspeed.getComponentManager().getComponent("portletRegistry");
-        }
+        PortletEntityImpl.registry = registry;
     }
 
-    private void retrieveRequestContextComponent()
+    public void setRequestContextComponent(RequestContextComponent requestContextComponent)
     {
-        if (requestContextComponent == null)
-        {
-            requestContextComponent = (RequestContextComponent)Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.request.RequestContextComponent");
-        }
+        PortletEntityImpl.requestContextComponent = requestContextComponent;
     }
-
-    private void retrievePortletEntityAccess()
+    
+    public static void setPortletPreferencesProvider(PortletPreferencesProvider portletPreferencesProvider)
     {
-        if (portletEntityAccess == null)
-        {
-            portletEntityAccess = (PortletEntityAccessComponent)Jetspeed.getComponentManager().getComponent("portletEntityAccess");
-        }
+        PortletEntityImpl.portletPreferencesProvider = portletPreferencesProvider;
     }
 
-    private void retrievePortletPreferencesProvider()
+    public static void setPortletEntityAccess(PortletEntityAccessComponent portletEntityAccess)
     {
-        if (portletPreferencesProvider == null)
-        {
-            portletPreferencesProvider = (PortletPreferencesProvider)Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.components.portletpreferences.PortletPreferencesProvider");
-        }
+        PortletEntityImpl.portletEntityAccess = portletEntityAccess;
     }
 
-    private void retrievePageManager()
+    public static void setPageManager(PageManager pageManager)
     {
-        if (pageManager == null)
-        {
-            pageManager = (PageManager)Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.page.PageManager");
-        }
+        PortletEntityImpl.pageManager = pageManager;
     }
 }
\ No newline at end of file

Added: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/static-bean-references.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/static-bean-references.xml?rev=691681&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/static-bean-references.xml
(added)
+++ portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/static-bean-references.xml
Wed Sep  3 09:50:22 2008
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+  <bean id="_portletEntityImplPortletRegistryInitializer" class="org.apache.jetspeed.components.LifecycleAwareStaticClassInitializer">
+    <meta key="j2:cat" value="default,registry"/>
+      <property name="className" value="org.apache.jetspeed.components.portletentity.PortletEntityImpl"/>
+      <property name="methodName" value="setPortletRegistry"/>
+      <property name="typeName" value="org.apache.jetspeed.components.portletregistry.PortletRegistry"/>
+      <property name="value"><ref bean="portletRegistry"/></property>
+  </bean>
+
+  <bean id="_portletEntityImplPortletEntityAccessComponentInitializer" class="org.apache.jetspeed.components.LifecycleAwareStaticClassInitializer">
+    <meta key="j2:cat" value="default,registry"/>
+      <property name="className" value="org.apache.jetspeed.components.portletentity.PortletEntityImpl"/>
+      <property name="methodName" value="setPortletEntityAccess"/>
+      <property name="typeName" value="org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent"/>
+      <property name="value"><ref bean="portletEntityAccess"/></property>
+  </bean>
+
+  <bean id="_portletEntityImplPortletPreferencesProviderInitializer" class="org.apache.jetspeed.components.LifecycleAwareStaticClassInitializer">
+    <meta key="j2:cat" value="default,registry"/>
+      <property name="className" value="org.apache.jetspeed.components.portletentity.PortletEntityImpl"/>
+      <property name="methodName" value="setPortletPreferencesProvider"/>
+      <property name="typeName" value="org.apache.jetspeed.components.portletpreferences.PortletPreferencesProvider"/>
+      <property name="value"><ref bean="org.apache.jetspeed.components.portletpreferences.PortletPreferencesProvider"/></property>
+  </bean>
+
+  <bean id="_portletEntityImplPageManagerInitializer" class="org.apache.jetspeed.components.LifecycleAwareStaticClassInitializer">
+    <meta key="j2:cat" value="xmlPageManager,dbPageManager" />
+      <property name="className" value="org.apache.jetspeed.components.portletentity.PortletEntityImpl"/>
+      <property name="methodName" value="setPageManager"/>
+      <property name="typeName" value="org.apache.jetspeed.page.PageManager"/>
+      <property name="value"><ref bean="org.apache.jetspeed.page.PageManager"/></property>
+  </bean>
+
+  <bean id="_portletEntityImplRequestContextComponentInitializer" class="org.apache.jetspeed.components.LifecycleAwareStaticClassInitializer">
+    <meta key="j2:cat" value="default,registry"/>
+      <property name="className" value="org.apache.jetspeed.components.portletentity.PortletEntityImpl"/>
+      <property name="methodName" value="setRequestContextComponent"/>
+      <property name="typeName" value="org.apache.jetspeed.request.RequestContextComponent"/>
+      <property name="value"><ref bean="org.apache.jetspeed.request.RequestContextComponent"/></property>
+  </bean>
+
+</beans>
\ No newline at end of file

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/static-bean-references.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/static-bean-references.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/static-bean-references.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message