Author: chris.laprun(a)jboss.com
Date: 2011-09-12 06:49:34 -0400 (Mon, 12 Sep 2011)
New Revision: 7352
Modified:
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/registry/AbstractConsumerRegistry.java
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/registry/InMemoryConsumerRegistry.java
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/registry/xml/XMLConsumerRegistry.java
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/spi/ConsumerRegistrySPI.java
components/wsrp/branches/clustering/consumer/src/test/java/org/gatein/wsrp/test/support/MockConsumerRegistry.java
components/wsrp/branches/clustering/hibernate-impl/src/main/java/org/gatein/wsrp/consumer/registry/hibernate/HibernateConsumerRegistry.java
components/wsrp/branches/clustering/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/JCRConsumerRegistry.java
Log:
- Moved abstract methods from AbstractConsumerRegistry to ConsumerRegistrySPI since it
makes sense for implementations to provide these methods.
Modified:
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/registry/AbstractConsumerRegistry.java
===================================================================
---
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/registry/AbstractConsumerRegistry.java 2011-09-12
10:38:27 UTC (rev 7351)
+++
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/registry/AbstractConsumerRegistry.java 2011-09-12
10:49:34 UTC (rev 7352)
@@ -68,7 +68,7 @@
private static final Logger log =
LoggerFactory.getLogger(AbstractConsumerRegistry.class);
- private ConsumerCache consumers = new InMemoryConsumerCache();
+ protected ConsumerCache consumers = new InMemoryConsumerCache();
public void setConsumerCache(ConsumerCache consumers)
{
@@ -197,7 +197,7 @@
this.federatingPortletInvoker = federatingPortletInvoker;
}
- protected WSRPConsumer createConsumerFrom(ProducerInfo producerInfo)
+ public WSRPConsumer createConsumerFrom(ProducerInfo producerInfo)
{
// make sure we set the registry after loading from DB since registry is not
persisted.
// producerInfo.setRegistry(this);
@@ -325,25 +325,7 @@
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "consumer
id", null);
- // try cache first
- WSRPConsumer consumer = consumers.getConsumer(id);
- if (consumer != null)
- {
- return consumer;
- }
- else
- {
- ProducerInfo info = loadProducerInfo(id);
- if (info != null)
- {
- return createConsumerFrom(info);
- }
- else
- {
- return null;
- }
- }
-
+ return consumers.getConsumer(id);
}
public boolean containsConsumer(String id)
@@ -475,22 +457,6 @@
return RELEASE_SESSIONS_LISTENER + id;
}
- protected abstract void save(ProducerInfo info, String messageOnError) throws
ConsumerException;
-
- protected abstract void delete(ProducerInfo info) throws ConsumerException;
-
- /**
- * Persists the changes made to ProducerInfo.
- *
- * @param producerInfo
- * @return the previous value of the ProducerInfo's id if it has changed,
<code>null</code> otherwise
- */
- protected abstract String update(ProducerInfo producerInfo);
-
- protected abstract Iterator<ProducerInfo> getProducerInfosFromStorage();
-
- protected abstract ProducerInfo loadProducerInfo(String id);
-
protected List<WSRPConsumer> getConsumers(boolean startConsumers)
{
final Collection<WSRPConsumer> consumerz = consumers.getConsumers();
Modified:
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/registry/InMemoryConsumerRegistry.java
===================================================================
---
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/registry/InMemoryConsumerRegistry.java 2011-09-12
10:38:27 UTC (rev 7351)
+++
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/registry/InMemoryConsumerRegistry.java 2011-09-12
10:49:34 UTC (rev 7352)
@@ -53,7 +53,7 @@
}
@Override
- protected WSRPConsumer createConsumerFrom(ProducerInfo producerInfo)
+ public WSRPConsumer createConsumerFrom(ProducerInfo producerInfo)
{
WSRPConsumer consumer = super.createConsumerFrom(producerInfo);
@@ -77,15 +77,13 @@
return oldId;
}
- @Override
- protected void save(ProducerInfo info, String messageOnError)
+ public void save(ProducerInfo info, String messageOnError)
{
// generate a UUID for ProducerInfo
info.setKey(UUID.randomUUID().toString());
}
- @Override
- protected void delete(ProducerInfo info)
+ public void delete(ProducerInfo info)
{
String key = info.getKey();
String removed = keysToIds.remove(key);
@@ -95,8 +93,7 @@
}
}
- @Override
- protected String update(ProducerInfo producerInfo)
+ public String update(ProducerInfo producerInfo)
{
String key = producerInfo.getKey();
String oldId = keysToIds.get(key);
@@ -116,14 +113,12 @@
// do nothing
}
- @Override
- protected Iterator<ProducerInfo> getProducerInfosFromStorage()
+ public Iterator<ProducerInfo> getProducerInfosFromStorage()
{
return new ProducerInfoIterator(consumers.values().iterator());
}
- @Override
- protected ProducerInfo loadProducerInfo(String id)
+ public ProducerInfo loadProducerInfo(String id)
{
if (keysToIds.containsValue(id))
{
Modified:
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/registry/xml/XMLConsumerRegistry.java
===================================================================
---
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/registry/xml/XMLConsumerRegistry.java 2011-09-12
10:38:27 UTC (rev 7351)
+++
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/registry/xml/XMLConsumerRegistry.java 2011-09-12
10:49:34 UTC (rev 7352)
@@ -98,24 +98,21 @@
}
catch (JBossXBException e)
{
- throw new RuntimeException("Couldn't set unmarshall WSRP Consumers
configuration", e);
+ throw new RuntimeException("Couldn't unmarshall WSRP Consumers
configuration", e);
}
}
- @Override
- protected void save(ProducerInfo info, String messageOnError)
+ public void save(ProducerInfo info, String messageOnError)
{
// do nothing
}
- @Override
- protected void delete(ProducerInfo info)
+ public void delete(ProducerInfo info)
{
// do nothing
}
- @Override
- protected String update(ProducerInfo producerInfo)
+ public String update(ProducerInfo producerInfo)
{
return null;
}
Modified:
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/spi/ConsumerRegistrySPI.java
===================================================================
---
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/spi/ConsumerRegistrySPI.java 2011-09-12
10:38:27 UTC (rev 7351)
+++
components/wsrp/branches/clustering/consumer/src/main/java/org/gatein/wsrp/consumer/spi/ConsumerRegistrySPI.java 2011-09-12
10:49:34 UTC (rev 7352)
@@ -24,11 +24,16 @@
package org.gatein.wsrp.consumer.spi;
import org.gatein.pc.federation.FederatingPortletInvoker;
+import org.gatein.wsrp.WSRPConsumer;
import org.gatein.wsrp.api.session.SessionEventBroadcaster;
+import org.gatein.wsrp.consumer.ConsumerException;
+import org.gatein.wsrp.consumer.ProducerInfo;
import org.gatein.wsrp.consumer.handlers.session.SessionRegistry;
import org.gatein.wsrp.consumer.migration.MigrationService;
import org.gatein.wsrp.consumer.registry.ConsumerRegistry;
+import java.util.Iterator;
+
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
public interface ConsumerRegistrySPI extends ConsumerRegistry
{
@@ -47,4 +52,22 @@
void start() throws Exception;
void stop() throws Exception;
+
+ void save(ProducerInfo info, String messageOnError) throws ConsumerException;
+
+ void delete(ProducerInfo info) throws ConsumerException;
+
+ /**
+ * Persists the changes made to ProducerInfo.
+ *
+ * @param producerInfo
+ * @return the previous value of the ProducerInfo's id if it has changed,
<code>null</code> otherwise
+ */
+ String update(ProducerInfo producerInfo);
+
+ Iterator<ProducerInfo> getProducerInfosFromStorage();
+
+ ProducerInfo loadProducerInfo(String id);
+
+ WSRPConsumer createConsumerFrom(ProducerInfo producerInfo);
}
Modified:
components/wsrp/branches/clustering/consumer/src/test/java/org/gatein/wsrp/test/support/MockConsumerRegistry.java
===================================================================
---
components/wsrp/branches/clustering/consumer/src/test/java/org/gatein/wsrp/test/support/MockConsumerRegistry.java 2011-09-12
10:38:27 UTC (rev 7351)
+++
components/wsrp/branches/clustering/consumer/src/test/java/org/gatein/wsrp/test/support/MockConsumerRegistry.java 2011-09-12
10:49:34 UTC (rev 7352)
@@ -39,6 +39,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -144,6 +145,31 @@
//To change body of implemented methods use File | Settings | File Templates.
}
+ public void save(ProducerInfo info, String messageOnError) throws ConsumerException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void delete(ProducerInfo info) throws ConsumerException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String update(ProducerInfo producerInfo)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Iterator<ProducerInfo> getProducerInfosFromStorage()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public ProducerInfo loadProducerInfo(String id)
+ {
+ throw new UnsupportedOperationException();
+ }
+
public void setFederatingPortletInvoker(FederatingPortletInvoker
federatingPortletInvoker)
{
//To change body of implemented methods use File | Settings | File Templates.
@@ -193,4 +219,9 @@
{
return consumers.size();
}
+
+ public WSRPConsumer createConsumerFrom(ProducerInfo producerInfo)
+ {
+ throw new UnsupportedOperationException();
+ }
}
Modified:
components/wsrp/branches/clustering/hibernate-impl/src/main/java/org/gatein/wsrp/consumer/registry/hibernate/HibernateConsumerRegistry.java
===================================================================
---
components/wsrp/branches/clustering/hibernate-impl/src/main/java/org/gatein/wsrp/consumer/registry/hibernate/HibernateConsumerRegistry.java 2011-09-12
10:38:27 UTC (rev 7351)
+++
components/wsrp/branches/clustering/hibernate-impl/src/main/java/org/gatein/wsrp/consumer/registry/hibernate/HibernateConsumerRegistry.java 2011-09-12
10:49:34 UTC (rev 7352)
@@ -42,7 +42,7 @@
private SessionFactory sessionFactory;
private String sessionFactoryJNDIName;
- protected void save(ProducerInfo info, String messageOnError)
+ public void save(ProducerInfo info, String messageOnError)
{
try
{
@@ -55,7 +55,7 @@
}
}
- protected void delete(ProducerInfo info)
+ public void delete(ProducerInfo info)
{
Session session = sessionFactory.getCurrentSession();
@@ -79,7 +79,7 @@
* @return the id that was previously assigned to the specified ProducerInfo or
<code>null</code> if the id hasn't
* been modified
*/
- protected String update(ProducerInfo producerInfo)
+ public String update(ProducerInfo producerInfo)
{
String oldId;
Session session = sessionFactory.getCurrentSession();
@@ -105,15 +105,14 @@
return oldId;
}
- protected Iterator<ProducerInfo> getProducerInfosFromStorage()
+ public Iterator<ProducerInfo> getProducerInfosFromStorage()
{
Session session = sessionFactory.getCurrentSession();
return session.createQuery("from ProducerInfo pi order by
pi.persistentId").iterate();
}
- @Override
- protected ProducerInfo loadProducerInfo(String id)
+ public ProducerInfo loadProducerInfo(String id)
{
Session session = sessionFactory.getCurrentSession();
return (ProducerInfo)session.createQuery("from ProducerInfo pi where
pi.persistentId = :id")
Modified:
components/wsrp/branches/clustering/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/JCRConsumerRegistry.java
===================================================================
---
components/wsrp/branches/clustering/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/JCRConsumerRegistry.java 2011-09-12
10:38:27 UTC (rev 7351)
+++
components/wsrp/branches/clustering/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/JCRConsumerRegistry.java 2011-09-12
10:49:34 UTC (rev 7352)
@@ -109,8 +109,7 @@
this.configurationIS = is;
}
- @Override
- protected void save(ProducerInfo info, String messageOnError)
+ public void save(ProducerInfo info, String messageOnError)
{
try
@@ -132,8 +131,7 @@
}
}
- @Override
- protected void delete(ProducerInfo info)
+ public void delete(ProducerInfo info)
{
if (!persister.delete(info, this))
{
@@ -141,8 +139,7 @@
}
}
- @Override
- protected String update(ProducerInfo producerInfo)
+ public String update(ProducerInfo producerInfo)
{
String key = producerInfo.getKey();
if (key == null)
@@ -184,8 +181,7 @@
return idUnchanged ? null : oldId;
}
- @Override
- protected Iterator<ProducerInfo> getProducerInfosFromStorage()
+ public Iterator<ProducerInfo> getProducerInfosFromStorage()
{
ChromatticSession session = persister.getSession();
ProducerInfosMapping producerInfosMapping = getProducerInfosMapping(session);
@@ -197,8 +193,7 @@
return new MappingToProducerInfoIterator(mappings.iterator(), this);
}
- @Override
- protected ProducerInfo loadProducerInfo(String id)
+ public ProducerInfo loadProducerInfo(String id)
{
ChromatticSession session = persister.getSession();
try