You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by un...@apache.org on 2004/02/18 13:15:01 UTC
cvs commit: cocoon-2.1/src/blocks/jms/java/org/apache/cocoon/components/jms JMSEventListener.java
unico 2004/02/18 04:15:01
Modified: src/blocks/jms/java/org/apache/cocoon/components/jms
JMSEventListener.java
Log:
allow multiple events for a single message
Revision Changes Path
1.8 +15 -13 cocoon-2.1/src/blocks/jms/java/org/apache/cocoon/components/jms/JMSEventListener.java
Index: JMSEventListener.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/jms/java/org/apache/cocoon/components/jms/JMSEventListener.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- JMSEventListener.java 15 Feb 2004 21:30:00 -0000 1.7
+++ JMSEventListener.java 18 Feb 2004 12:15:01 -0000 1.8
@@ -161,14 +161,16 @@
if (service == null) {
service = (EventAware) this.manager.lookup(this.serviceName);
}
- Event event = this.convertMessage(message);
- if (this.getLogger().isInfoEnabled())
- this.getLogger().info(
- "Notifying "
- + this.serviceName
- + " of "
- + event);
- service.processEvent(event);
+ Event[] events = eventsFromMessage(message);
+ for (int i = 0; i < events.length; i++) {
+ if (this.getLogger().isDebugEnabled())
+ this.getLogger().debug(
+ "Notifying "
+ + this.serviceName
+ + " of "
+ + events[i]);
+ service.processEvent(events[i]);
+ }
} catch (ServiceException e) {
if (this.getLogger().isErrorEnabled()) {
this.getLogger().error(
@@ -183,9 +185,9 @@
}
}
}
-
+
/**
- * Convert the message contents to a cache event. The default implementation
+ * Convert the message contents to (a series of) cache event. The default implementation
* assumes that the message contains the trigger name, a '|', and a table name.
* It extracts the tablename and creates a NamedEvent with it.
* Override this method to provide your own message to event mappings.
@@ -193,10 +195,10 @@
* @param message the JMS message.
* @return the cache event.
*/
- protected Event convertMessage(Message message) {
+ protected Event[] eventsFromMessage(Message message) {
String name = message.toString();
int pos = name.indexOf('|');
- return new NamedEvent(name.substring(pos + 1));
+ return new Event[] { new NamedEvent(name.substring(pos + 1)) };
}
}