Author: chris.laprun(a)jboss.com
Date: 2011-10-17 13:38:18 -0400 (Mon, 17 Oct 2011)
New Revision: 7752
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/Consumer.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/ConsumerImpl.java
Log:
- Added getRegistration(id) method.
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/Consumer.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/Consumer.java 2011-10-17
17:34:08 UTC (rev 7751)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/Consumer.java 2011-10-17
17:38:18 UTC (rev 7752)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -59,6 +59,15 @@
Collection<Registration> getRegistrations() throws RegistrationException;
/**
+ * Retrieves the registration specified with the given identifier if it's
associated with this Consumer.
+ *
+ * @param id
+ * @return
+ * @throws RegistrationException
+ */
+ Registration getRegistration(String id) throws RegistrationException;
+
+ /**
* Returns the group that this consumer belongs to.
*
* @return the consumer group
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/ConsumerImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/ConsumerImpl.java 2011-10-17
17:34:08 UTC (rev 7751)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/ConsumerImpl.java 2011-10-17
17:38:18 UTC (rev 7752)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -35,8 +35,8 @@
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.HashMap;
+import java.util.Map;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -49,15 +49,16 @@
private String name;
private String identity;
private String consumerAgent;
- private Set<Registration> registrations;
+ private Map<String, Registration> registrations;
private ConsumerGroup group;
- private ConsumerCapabilities capabilities;
+ private ConsumerCapabilities capabilities = new ConsumerCapabilitiesImpl();
private String key;
private ConsumerImpl()
{
init();
+ throw new RuntimeException("default constructor");
}
ConsumerImpl(String identity, String name)
@@ -72,7 +73,7 @@
private void init()
{
- registrations = new HashSet<Registration>(7);
+ registrations = new HashMap<String, Registration>(7);
capabilities = new ConsumerCapabilitiesImpl();
}
@@ -143,7 +144,7 @@
if (ParameterValidation.existsAndIsNotEmpty(registrations))
{
RegistrationStatus result = RegistrationStatus.VALID;
- for (Registration registration : registrations)
+ for (Registration registration : registrations.values())
{
RegistrationStatus status = registration.getStatus();
@@ -165,9 +166,16 @@
public Collection<Registration> getRegistrations() throws RegistrationException
{
- return Collections.unmodifiableSet(registrations);
+ return Collections.unmodifiableCollection(registrations.values());
}
+ public Registration getRegistration(String id) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Registration
identifier", null);
+
+ return registrations.get(id);
+ }
+
public ConsumerGroup getGroup()
{
return group;
@@ -177,7 +185,7 @@
{
ParameterValidation.throwIllegalArgExceptionIfNull(registration,
"Registration");
- registrations.add(registration);
+ registrations.put(registration.getPersistentKey(), registration);
}
public void setPersistentKey(String key)
@@ -189,7 +197,7 @@
{
ParameterValidation.throwIllegalArgExceptionIfNull(registration,
"Registration");
- registrations.remove(registration);
+ registrations.remove(registration.getPersistentKey());
}
public void setGroup(ConsumerGroup group) throws RegistrationException
Show replies by date