Author: chris.laprun(a)jboss.com
Date: 2007-03-04 19:05:03 -0500 (Sun, 04 Mar 2007)
New Revision: 6533
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java
trunk/registration/src/main/org/jboss/portal/registration/RegistrationPersistenceManager.java
trunk/registration/src/main/org/jboss/portal/registration/impl/RegistrationManagerImpl.java
trunk/registration/src/main/org/jboss/portal/registration/impl/RegistrationPersistenceManagerImpl.java
Log:
- Added RegistrationPersistenceManager.getRegistrations method and implementations.
- Properly retrieve Registration from DB in RegistrationManagerImpl and remove incorrect
registrations map.
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java 2007-03-05
00:03:04 UTC (rev 6532)
+++
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java 2007-03-05
00:05:03 UTC (rev 6533)
@@ -32,17 +32,17 @@
import org.jboss.portal.portlet.state.NoSuchStateException;
import org.jboss.portal.portlet.state.PropertyMap;
import org.jboss.portal.portlet.state.SimplePropertyMap;
+import org.jboss.portal.portlet.state.producer.PortletStateContext;
import org.jboss.portal.portlet.state.producer.PortletStatePersistenceManager;
-import org.jboss.portal.portlet.state.producer.PortletStateContext;
import org.jboss.portal.registration.Consumer;
import org.jboss.portal.registration.ConsumerGroup;
import org.jboss.portal.registration.DuplicateRegistrationException;
import org.jboss.portal.registration.NoSuchRegistrationException;
import org.jboss.portal.registration.Registration;
import org.jboss.portal.registration.RegistrationException;
+import org.jboss.portal.registration.RegistrationLocal;
import org.jboss.portal.registration.RegistrationPersistenceManager;
import org.jboss.portal.registration.RegistrationStatus;
-import org.jboss.portal.registration.RegistrationLocal;
import javax.naming.InitialContext;
import java.util.Collection;
@@ -457,6 +457,13 @@
return query.list();
}
+ public Collection getRegistrations()
+ {
+ Session session = getCurrentSession();
+ Query query = session.createQuery("from PersistentRegistration");
+ return query.list();
+ }
+
private PersistentRegistration getRegistrationById(Session session, String
registrationId) throws IllegalArgumentException, NoSuchRegistrationException
{
PersistentRegistration registration = findRegistrationById(session,
registrationId);
Modified:
trunk/registration/src/main/org/jboss/portal/registration/RegistrationPersistenceManager.java
===================================================================
---
trunk/registration/src/main/org/jboss/portal/registration/RegistrationPersistenceManager.java 2007-03-05
00:03:04 UTC (rev 6532)
+++
trunk/registration/src/main/org/jboss/portal/registration/RegistrationPersistenceManager.java 2007-03-05
00:05:03 UTC (rev 6533)
@@ -84,4 +84,6 @@
Consumer addConsumerToGroupNamed(String consumerId, String groupName) throws
RegistrationException;
Collection getConsumers();
+
+ Collection getRegistrations();
}
Modified:
trunk/registration/src/main/org/jboss/portal/registration/impl/RegistrationManagerImpl.java
===================================================================
---
trunk/registration/src/main/org/jboss/portal/registration/impl/RegistrationManagerImpl.java 2007-03-05
00:03:04 UTC (rev 6532)
+++
trunk/registration/src/main/org/jboss/portal/registration/impl/RegistrationManagerImpl.java 2007-03-05
00:05:03 UTC (rev 6533)
@@ -23,7 +23,6 @@
package org.jboss.portal.registration.impl;
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
import org.jboss.logging.Logger;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.jems.as.system.AbstractJBossService;
@@ -55,12 +54,9 @@
private RegistrationPolicy policy;
private RegistrationPersistenceManager persistenceManager;
- private Map registrations;
-
public RegistrationManagerImpl()
{
- registrations = new ConcurrentHashMap();
}
public RegistrationPolicy getPolicy()
@@ -102,9 +98,6 @@
String handle = policy.createRegistrationHandleFor(registration.getId());
registration.setRegistrationHandle(handle);
- // associate the handle to the consumer for easy retrieval
- registrations.put(handle, registration);
-
return registration;
}
@@ -242,7 +235,6 @@
registration.clearAssociatedState();
persistenceManager.removeRegistration(registration.getId());
- registrations.remove(registration.getRegistrationHandle());
}
public ConsumerGroup getConsumerGroup(String groupName) throws RegistrationException
@@ -272,9 +264,8 @@
private Object getConsumerOrRegistration(String registrationHandle, boolean
getConsumer)
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(registrationHandle,
"registration handle", null);
- // this particular implementations uses a map though it could delegate to the
registry and make a DB query to retrieve the info
- Registration registration = (Registration)registrations.get(registrationHandle);
+ Registration registration =
persistenceManager.getRegistration(registrationHandle);
if (registration == null)
{
return null;
@@ -335,7 +326,7 @@
public void propertiesHaveChanged()
{
log.debug("Registration properties have changed, existing registrations will
be invalidated...");
- for (Iterator regs = registrations.values().iterator(); regs.hasNext();)
+ for (Iterator regs = persistenceManager.getRegistrations().iterator();
regs.hasNext();)
{
Registration reg = (Registration)regs.next();
reg.setStatus(RegistrationStatus.INVALID);
Modified:
trunk/registration/src/main/org/jboss/portal/registration/impl/RegistrationPersistenceManagerImpl.java
===================================================================
---
trunk/registration/src/main/org/jboss/portal/registration/impl/RegistrationPersistenceManagerImpl.java 2007-03-05
00:03:04 UTC (rev 6532)
+++
trunk/registration/src/main/org/jboss/portal/registration/impl/RegistrationPersistenceManagerImpl.java 2007-03-05
00:05:03 UTC (rev 6533)
@@ -175,6 +175,11 @@
return Collections.unmodifiableCollection(consumers.values());
}
+ public Collection getRegistrations()
+ {
+ return Collections.unmodifiableCollection(registrations.values());
+ }
+
public Collection getConsumerGroups()
{
return Collections.unmodifiableCollection(groups.values());