Author: mwringe
Date: 2010-09-23 09:32:47 -0400 (Thu, 23 Sep 2010)
New Revision: 4358
Added:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPortletContextChangeListener.java
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPPortletInvoker.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPolicy.java
Log:
GTNWSRP-72: add a RegistrationPortletContextListener to handle when portlet contexts get
updated for a registration. Add listener to the RegistrationPolicy so it can handle when
to save portlet contexts.
Make the registrationManager always have a registration policy, fixes an NPE when the
producer has isRegistrationRequired false.
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java 2010-09-23
12:18:43 UTC (rev 4357)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java 2010-09-23
13:32:47 UTC (rev 4358)
@@ -36,7 +36,7 @@
* @version $Revision: 8966 $
* @since 2.6
*/
-public interface RegistrationManager extends RegistrationPropertyChangeListener,
RegistrationPolicyChangeListener
+public interface RegistrationManager extends RegistrationPropertyChangeListener,
RegistrationPolicyChangeListener, RegistrationPortletContextChangeListener
{
RegistrationPolicy getPolicy();
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java 2010-09-23
12:18:43 UTC (rev 4357)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java 2010-09-23
13:32:47 UTC (rev 4358)
@@ -128,4 +128,6 @@
void addPortletHandle(Registration registration, String portletHandle);
void removePortletHandle(Registration registration, String portletHandle);
void updatePortletHandles(List<String> portlets);
+
+ void addPortletContextChangeListener(RegistrationPortletContextChangeListener
listener);
}
Added:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPortletContextChangeListener.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPortletContextChangeListener.java
(rev 0)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPortletContextChangeListener.java 2010-09-23
13:32:47 UTC (rev 4358)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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.gatein.registration;
+
+/**
+ * @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
+ * @version $Revision$
+ */
+public interface RegistrationPortletContextChangeListener
+{
+ void portletContextsHaveChanged(Registration registration);
+}
+
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java 2010-09-23
12:18:43 UTC (rev 4357)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java 2010-09-23
13:32:47 UTC (rev 4358)
@@ -360,4 +360,9 @@
{
setPolicy(policy);
}
+
+ public void portletContextsHaveChanged(Registration registration)
+ {
+ persistenceManager.saveChangesTo(registration);
+ }
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java 2010-09-23
12:18:43 UTC (rev 4357)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java 2010-09-23
13:32:47 UTC (rev 4358)
@@ -31,6 +31,7 @@
import org.gatein.registration.RegistrationException;
import org.gatein.registration.RegistrationManager;
import org.gatein.registration.RegistrationPolicy;
+import org.gatein.registration.RegistrationPortletContextChangeListener;
import org.gatein.registration.RegistrationStatus;
import org.gatein.wsrp.registration.PropertyDescription;
import org.slf4j.Logger;
@@ -59,6 +60,8 @@
//Stores a list of the default portlet handles which should be available to all
registrations (ie not cloned handles)
List<String> defaultPortletHandleList = new ArrayList<String>();
+
+ List<RegistrationPortletContextChangeListener> listeners;
@Override
public boolean equals(Object o)
@@ -228,6 +231,7 @@
if (registration != null &&
!registration.getPortletHandles().contains(portletHandle))
{
registration.getPortletHandles().add(portletHandle);
+ updatePortletContextListeners(registration);
}
}
@@ -251,6 +255,7 @@
if (registration != null)
{
registration.getPortletHandles().remove(portletHandle);
+ updatePortletContextListeners(registration);
}
}
@@ -258,4 +263,24 @@
{
this.defaultPortletHandleList = portletHandles;
}
+
+ public void addPortletContextChangeListener(RegistrationPortletContextChangeListener
listener)
+ {
+ if (listeners == null)
+ {
+ listeners = new ArrayList<RegistrationPortletContextChangeListener>();
+ }
+ listeners.add(listener);
+ }
+
+ protected void updatePortletContextListeners(Registration registration)
+ {
+ if (listeners != null)
+ {
+ for (RegistrationPortletContextChangeListener listener : listeners)
+ {
+ listener.portletContextsHaveChanged(registration);
+ }
+ }
+ }
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java 2010-09-23
12:18:43 UTC (rev 4357)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java 2010-09-23
13:32:47 UTC (rev 4358)
@@ -29,6 +29,7 @@
import org.gatein.registration.RegistrationException;
import org.gatein.registration.RegistrationManager;
import org.gatein.registration.RegistrationPolicy;
+import org.gatein.registration.RegistrationPortletContextChangeListener;
import org.gatein.wsrp.registration.PropertyDescription;
import javax.xml.namespace.QName;
@@ -121,4 +122,9 @@
{
delegate.updatePortletHandles(portletHandles);
}
+
+ public void addPortletContextChangeListener(RegistrationPortletContextChangeListener
listener)
+ {
+ delegate.addPortletContextChangeListener(listener);
+ }
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPPortletInvoker.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPPortletInvoker.java 2010-09-23
12:18:43 UTC (rev 4357)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPPortletInvoker.java 2010-09-23
13:32:47 UTC (rev 4358)
@@ -228,7 +228,6 @@
Registration registration = RegistrationLocal.getRegistration();
String portletHandle =
WSRPUtils.convertToWSRPPortletContext(portletContext).getPortletHandle();
this.getRegistrationManager().getPolicy().addPortletHandle(registration,
portletHandle);
- this.getRegistrationManager().getPersistenceManager().saveChangesTo(registration);
}
protected void removePortletContext(PortletContext portletContext)
@@ -236,7 +235,6 @@
Registration registration = RegistrationLocal.getRegistration();
String portletHandle =
WSRPUtils.convertToWSRPPortletContext(portletContext).getPortletHandle();
this.getRegistrationManager().getPolicy().removePortletHandle(registration,
portletHandle);
- this.getRegistrationManager().getPersistenceManager().saveChangesTo(registration);
}
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java 2010-09-23
12:18:43 UTC (rev 4357)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java 2010-09-23
13:32:47 UTC (rev 4358)
@@ -383,11 +383,10 @@
registrationRequirements.addRegistrationPolicyChangeListener(registrationManager);
registrationRequirements.addRegistrationPropertyChangeListener(registrationManager);
- if (registrationRequirements.isRegistrationRequired())
- {
- registrationManager.setPolicy(registrationRequirements.getPolicy());
- }
-
+ registrationManager.setPolicy(registrationRequirements.getPolicy());
+
+
registrationManager.getPolicy().addPortletContextChangeListener(registrationManager);
+
started = true;
}
}
Modified:
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPolicy.java
===================================================================
---
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPolicy.java 2010-09-23
12:18:43 UTC (rev 4357)
+++
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPolicy.java 2010-09-23
13:32:47 UTC (rev 4358)
@@ -28,6 +28,7 @@
import org.gatein.registration.RegistrationException;
import org.gatein.registration.RegistrationManager;
import org.gatein.registration.RegistrationPolicy;
+import org.gatein.registration.RegistrationPortletContextChangeListener;
import org.gatein.wsrp.registration.PropertyDescription;
import javax.xml.namespace.QName;
@@ -86,4 +87,8 @@
{
}
+ public void addPortletContextChangeListener(RegistrationPortletContextChangeListener
listener)
+ {
+ }
+
}