[portal-commits] JBoss Portal SVN: r12000 - in branches/JBoss_Portal_Branch_2_7: core-wsrp/src/resources/portal-wsrp-admin-war/jsf/consumers and 2 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Sat Sep 27 04:30:17 EDT 2008


Author: chris.laprun at jboss.com
Date: 2008-09-27 04:30:17 -0400 (Sat, 27 Sep 2008)
New Revision: 12000

Added:
   branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfoPostLoadEventListener.java
Modified:
   branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
   branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/jsf/consumers/editConsumer.xhtml
   branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java
   branches/JBoss_Portal_Branch_2_7/wsrp/src/resources/portal-wsrp-sar/conf/hibernate/consumer/hibernate.cfg.xml
Log:
- Added Hibernate post-load event listener: does not currently work due to 2nd level cache interference (?)

Modified: branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java	2008-09-26 15:13:04 UTC (rev 11999)
+++ branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java	2008-09-27 08:30:17 UTC (rev 12000)
@@ -510,6 +510,7 @@
       FacesContext.getCurrentInstance().renderResponse();
    }
 
+   // todo: valueChangeListener not needed anymore when events on RegistrationProperties work  
    public void regPropListener(ValueChangeEvent event)
    {
       if (!registrationLocallyModified)

Modified: branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/jsf/consumers/editConsumer.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/jsf/consumers/editConsumer.xhtml	2008-09-26 15:13:04 UTC (rev 11999)
+++ branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/jsf/consumers/editConsumer.xhtml	2008-09-27 08:30:17 UTC (rev 12000)
@@ -95,6 +95,7 @@
                               <td>#{prop.value.name}</td>
                               <td>#{prop.value.description.label.value}</td>
                               <td>
+                                 <!-- todo: valueChangeListener not needed anymore when events on RegistrationProperties work -->
                                  <h:inputText id="prop-value-input" value="#{prop.value.value}" size="50"
                                               valueChangeListener="#{consumer.regPropListener}"
                                               disabled="#{consumer.registrationModified}"/>

Added: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfoPostLoadEventListener.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfoPostLoadEventListener.java	                        (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfoPostLoadEventListener.java	2008-09-27 08:30:17 UTC (rev 12000)
@@ -0,0 +1,53 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.portal.wsrp.consumer;
+
+import org.hibernate.event.PostLoadEvent;
+import org.hibernate.event.PostLoadEventListener;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class RegistrationInfoPostLoadEventListener implements PostLoadEventListener
+{
+   /**
+    * Once the object is loaded from Hibernate, greedily load the associated RegistrationProperties and register with
+    * them as a listener for changes in their value.
+    *
+    * @param event
+    */
+   public void onPostLoad(PostLoadEvent event)
+   {
+      Object entity = event.getEntity();
+      if (entity instanceof RegistrationInfo)
+      {
+         RegistrationInfo info = (RegistrationInfo)entity;
+
+         for (RegistrationProperty property : info.getRegistrationProperties().values())
+         {
+            property.setListener(info);
+         }
+      }
+   }
+}

Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java	2008-09-26 15:13:04 UTC (rev 11999)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java	2008-09-27 08:30:17 UTC (rev 12000)
@@ -231,12 +231,18 @@
 
    private void notifyListener(String oldValue, String newValue)
    {
+      // listener can be null, especially when props are unfrozen from Hibernate
       if (listener != null)
       {
          listener.propertyValueChanged(this, oldValue, newValue);
       }
    }
 
+   public void setListener(PropertyChangeListener listener)
+   {
+      this.listener = listener;
+   }
+
    /** todo: Should be package-only, public for tests... */
    public static interface PropertyChangeListener
    {

Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/resources/portal-wsrp-sar/conf/hibernate/consumer/hibernate.cfg.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/resources/portal-wsrp-sar/conf/hibernate/consumer/hibernate.cfg.xml	2008-09-26 15:13:04 UTC (rev 11999)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/resources/portal-wsrp-sar/conf/hibernate/consumer/hibernate.cfg.xml	2008-09-27 08:30:17 UTC (rev 12000)
@@ -54,5 +54,10 @@
 
       <!-- Mapping files -->
       <mapping resource="conf/hibernate/consumer/domain.hbm.xml"/>
+
+      <event type="post-load">
+         <listener class="org.jboss.portal.wsrp.consumer.RegistrationInfoPostLoadEventListener"/>
+         <listener class="org.hibernate.event.def.DefaultPostLoadEventListener"/>
+      </event>
    </session-factory>
 </hibernate-configuration>
\ No newline at end of file




More information about the portal-commits mailing list