diff --git a/src/net/java/sip/communicator/impl/protocol/sip/EventPackageSupport.java b/src/net/java/sip/communicator/impl/protocol/sip/EventPackageSupport.java
index 74b06f6ca..1e7dcdf0a 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/EventPackageSupport.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/EventPackageSupport.java
@@ -104,7 +104,7 @@ public class EventPackageSupport
* the Timer support which is to execute the
* time-based tasks of the new instance
*/
- public EventPackageSupport(
+ protected EventPackageSupport(
ProtocolProviderServiceSipImpl protocolProvider,
String eventPackage,
int subscriptionDuration,
@@ -153,6 +153,18 @@ protected void addSubscription(String callId, Subscription subscription)
}
}
+ /**
+ * Gets the name of the event package this instance implements and carried
+ * in the Event and Allow-Events headers.
+ *
+ * @return the name of the event package this instance implements and
+ * carried in the Event and Allow-Events headers
+ */
+ public final String getEventPackage()
+ {
+ return eventPackage;
+ }
+
/**
* Safely returns the ServerTransaction associated with a
* specific RequestEvent or creates a new one if the specified
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java
index 7cd0cfc5e..dcf45e1c3 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java
@@ -1790,16 +1790,40 @@ public void registerMethodProcessor(String method,
}
else
{
- Class extends MethodProcessor> methodProcessorClass =
- methodProcessor.getClass();
- for (Iterator processorIter =
- processors.iterator(); processorIter.hasNext();)
+ /*
+ * Prevent the registering of multiple instances of one and the same
+ * OperationSet class and take only the latest registration into
+ * account.
+ */
+ Iterator processorIter = processors.iterator();
+ Class extends MethodProcessor> methodProcessorClass
+ = methodProcessor.getClass();
+ /*
+ * EventPackageSupport and its extenders provide a generic mechanizm
+ * for building support for a specific event package so allow them
+ * to register multiple instances of one and the same class as long
+ * as they are handling different event packages.
+ */
+ String eventPackage
+ = (methodProcessor instanceof EventPackageSupport)
+ ? ((EventPackageSupport) methodProcessor).getEventPackage()
+ : null;
+
+ while (processorIter.hasNext())
{
- if (processorIter.next().getClass()
- .equals(methodProcessorClass))
- {
- processorIter.remove();
- }
+ MethodProcessor processor = processorIter.next();
+
+ if (!processor.getClass().equals(methodProcessorClass))
+ continue;
+ if ((eventPackage != null)
+ && (processor instanceof EventPackageSupport)
+ && !eventPackage
+ .equals(
+ ((EventPackageSupport) processor)
+ .getEventPackage()))
+ continue;
+
+ processorIter.remove();
}
}
processors.add(methodProcessor);