portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r702328 - in /portals/jetspeed-2/portal/branches/security-refactoring: components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/ components/jetspeed-security/src/main/java/org/apache/jetspeed/security/ components/jetspeed-securit...
Date Tue, 07 Oct 2008 02:24:17 GMT
Author: ate
Date: Mon Oct  6 19:24:17 2008
New Revision: 702328

URL: http://svn.apache.org/viewvc?rev=702328&view=rev
Log:
Refactoring the generic usage and setup of post spring context bean initialization as was
used for the JetspeedPostContextLoader (now renamed to OnStartupSecuritySynchronizationBean).
Note this replaces the list of bean to be processed to single bean wrappers, making it much
easier and transparent to use
and prevents possibly conflicting mixed spring bean categories which easily can happen with
a list of beans. 

Added:
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/ContextRefreshableBeanInitializer.java
  (contents, props changed)
      - copied, changed from r702322, portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/JetspeedBeanPostProcessor.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/OnStartupSecuritySynchronizationBean.java
  (contents, props changed)
      - copied, changed from r702322, portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/JetspeedPostContextLoader.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/components/RefreshableBean.java
  (contents, props changed)
      - copied, changed from r702322, portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedBeanInitializer.java
Removed:
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/JetspeedPostContextLoader.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/JetspeedBeanPostProcessor.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedBeanInitializer.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/intializer.xml
Modified:
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/security-ldap.xml

Copied: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/ContextRefreshableBeanInitializer.java
(from r702322, portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/JetspeedBeanPostProcessor.java)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/ContextRefreshableBeanInitializer.java?p2=portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/ContextRefreshableBeanInitializer.java&p1=portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/JetspeedBeanPostProcessor.java&r1=702322&r2=702328&rev=702328&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/JetspeedBeanPostProcessor.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/ContextRefreshableBeanInitializer.java
Mon Oct  6 19:24:17 2008
@@ -14,59 +14,42 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jetspeed.security;
+package org.apache.jetspeed.components;
 
-import java.util.List;
-
-import org.springframework.context.ApplicationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.springframework.context.ApplicationEvent;
 import org.springframework.context.ApplicationListener;
 import org.springframework.context.event.ContextRefreshedEvent;
 
 /**
  * @author <a href="mailto:vkumar@apache.org">Vivek Kumar</a>
- * @version $Id:
+ * @version $Id$
  */
-public class JetspeedBeanPostProcessor implements ApplicationListener
+public class ContextRefreshableBeanInitializer implements ApplicationListener
 {
-    private ApplicationContext context;
-    private List<String> beanList = null;
-
+    Log log = LogFactory.getLog(ContextRefreshableBeanInitializer.class);
+    
+    private RefreshableBean bean;
     /**
-     * @param beanList
+     * @param bean
      */
-    public JetspeedBeanPostProcessor(List<String> beanList)
+    public ContextRefreshableBeanInitializer(RefreshableBean bean)
     {
-        this.beanList = beanList;
+        this.bean = bean;
     }
 
     public void onApplicationEvent(ApplicationEvent appEvent)
     {
-        if (appEvent instanceof ContextRefreshedEvent)
+        if (appEvent instanceof ContextRefreshedEvent && bean != null)
         {
-            ContextRefreshedEvent event = (ContextRefreshedEvent) appEvent;
-            this.context = event.getApplicationContext();
-            processBeans();
-        }
-    }
-
-    private void processBeans()
-    {
-        if (beanList != null)
-        {
-            JetspeedBeanInitializer intializer = null;
-            for (String bean : beanList)
+            try
+            {
+                bean.refresh();
+            }
+            catch (Exception ex)
             {
-                try
-                {
-                    intializer = (JetspeedBeanInitializer) context.getBean(bean);
-                    intializer.initialize();
-                }
-                catch (Exception e)
-                {
-                    // Log error messages
-                    e.printStackTrace();
-                }
+                log.error("Failed to refresh bean", ex);
             }
         }
     }

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/ContextRefreshableBeanInitializer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/ContextRefreshableBeanInitializer.java
------------------------------------------------------------------------------
    svn:keywords = Id

Copied: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/OnStartupSecuritySynchronizationBean.java
(from r702322, portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/JetspeedPostContextLoader.java)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/OnStartupSecuritySynchronizationBean.java?p2=portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/OnStartupSecuritySynchronizationBean.java&p1=portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/JetspeedPostContextLoader.java&r1=702322&r2=702328&rev=702328&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/JetspeedPostContextLoader.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/OnStartupSecuritySynchronizationBean.java
Mon Oct  6 19:24:17 2008
@@ -14,12 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jetspeed.components;
+package org.apache.jetspeed.security.spi.impl;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.security.JetspeedBeanInitializer;
+import org.apache.jetspeed.components.RefreshableBean;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.UserManager;
 import org.apache.jetspeed.security.spi.JetspeedSecuritySynchronizer;
@@ -28,9 +28,9 @@
  * @author <a href="mailto:vkumar@apache.org">Vivek Kumar</a>
  * @version $Id:
  */
-public class JetspeedPostContextLoader implements JetspeedBeanInitializer
+public class OnStartupSecuritySynchronizationBean implements RefreshableBean
 {
-    private static final Log log = LogFactory.getLog(JetspeedPostContextLoader.class);
+    private static final Log log = LogFactory.getLog(OnStartupSecuritySynchronizationBean.class);
     private UserManager userManager;
     private JetspeedSecuritySynchronizer synchronizer;
     private boolean synchronizeAllUser;
@@ -40,7 +40,7 @@
      * @param synchronizer
      * @param userManager
      */
-    public JetspeedPostContextLoader(JetspeedSecuritySynchronizer synchronizer, UserManager
userManager, boolean synchronizeAllUser,
+    public OnStartupSecuritySynchronizationBean(JetspeedSecuritySynchronizer synchronizer,
UserManager userManager, boolean synchronizeAllUser,
                                      String synchronizeEntityType)
     {
         this.synchronizer = synchronizer;
@@ -49,7 +49,7 @@
         this.synchronizeEntityType = synchronizeEntityType;
     }
     
-    public void initialize()
+    public void refresh()
     {
         if (synchronizer != null)
         {

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/OnStartupSecuritySynchronizationBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/OnStartupSecuritySynchronizationBean.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/OnStartupSecuritySynchronizationBean.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/components/RefreshableBean.java
(from r702322, portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedBeanInitializer.java)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/components/RefreshableBean.java?p2=portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/components/RefreshableBean.java&p1=portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedBeanInitializer.java&r1=702322&r2=702328&rev=702328&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedBeanInitializer.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/components/RefreshableBean.java
Mon Oct  6 19:24:17 2008
@@ -14,13 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jetspeed.security;
+package org.apache.jetspeed.components;
 
 /** 
  * @author <a href="mailto:vkumar@apache.org">Vivek Kumar</a>
- * @version $Id:
+ * @version $Id$
  */
-public interface JetspeedBeanInitializer
+public interface RefreshableBean
 {
-    void initialize();
+    void refresh();
 }

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/components/RefreshableBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/components/RefreshableBean.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/security-ldap.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/security-ldap.xml?rev=702328&r1=702327&r2=702328&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/security-ldap.xml
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/security-ldap.xml
Mon Oct  6 19:24:17 2008
@@ -38,28 +38,29 @@
       </props>
     </property>
   </bean>
-  
-  
+    
    <bean id="org.apache.jetspeed.security.spi.JetspeedPrincipalAssociationStorageManager"

   	class="org.apache.jetspeed.security.spi.impl.JetspeedPrincipalLdapAssociationStorageManager">
 	
   		<meta key="j2:cat" value="ldap" />  	
     </bean>  	
-  
-  
+    
   <!--
-  	JetspeedPostContextLoader will load the guest user from LDAP, in-case its not in portal
database
-  	It would be required for loading default page  
+  	OnStartupSecuritySynchronizationBean will load the guest user from LDAP, in-case its not
in portal database
+  	It would be required for loading default page.
+    This bean is wrapped in a ContextRefreshableBeanInitializer to kickstart it once the
complete Spring context is initialized.
    -->
-   
-  <bean id="org.apache.jetspeed.security.spi.JetspeedPostContextLoader"
-    class="org.apache.jetspeed.security.spi.JetspeedPostContextLoader">
-    <meta key="j2:cat" value="ldap" />
-    <constructor-arg index="0" ref="org.apache.jetspeed.security.spi.JetspeedSecuritySynchronizer"
/>
-    <constructor-arg index="1" ref="org.apache.jetspeed.security.UserManager" />
-    <constructor-arg index="2" type="boolean" value="false" />
-    <constructor-arg index="3" value="group" />
+  <bean id="_ldapOnStartupSecuritySynchronizer" class="org.apache.jetspeed.components.ContextRefreshableBeanInitializer">
+    <meta key="j2:cat" value="ldap" />
+    <constructor-arg>
+      <bean class="org.apache.jetspeed.security.spi.impl.OnStartupSecuritySynchronizationBean">
+        <constructor-arg index="0" ref="org.apache.jetspeed.security.spi.JetspeedSecuritySynchronizer"
/>
+        <constructor-arg index="1" ref="org.apache.jetspeed.security.UserManager" />
+        <constructor-arg index="2" type="boolean" value="false" />
+        <constructor-arg index="3" value="group" />
+      </bean>
+    </constructor-arg>
   </bean>
-
+  
   <bean id="org.apache.jetspeed.security.spi.JetspeedSecuritySynchronizer"
     class="org.apache.jetspeed.security.spi.impl.DefaultJetspeedSecuritySynchronizer">
     <meta key="j2:cat" value="ldap" />



---------------------------------------------------------------------
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