You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by as...@apache.org on 2009/03/28 11:25:17 UTC
svn commit: r759451 - in
/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing:
SynapseSubscriptionManager.java filters/TopicBasedEventFilter.java
managers/DefaultInMemorySubscriptionManager.java
Author: asanka
Date: Sat Mar 28 10:25:16 2009
New Revision: 759451
URL: http://svn.apache.org/viewvc?rev=759451&view=rev
Log:
Make the Event a generic class to hold any form of event (in synapse it will be the synapse message ctx). Add new TopicBasedEventFilter. Required latest update of wso2eventing-api-1.2-SNAPSHOT for compile.
Added:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/filters/TopicBasedEventFilter.java (contents, props changed)
- copied, changed from r756411, synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/filters/XPathBasedEventFilter.java
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/SynapseSubscriptionManager.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/managers/DefaultInMemorySubscriptionManager.java
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/SynapseSubscriptionManager.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/SynapseSubscriptionManager.java?rev=759451&r1=759450&r2=759451&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/SynapseSubscriptionManager.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/SynapseSubscriptionManager.java Sat Mar 28 10:25:16 2009
@@ -100,5 +100,5 @@
public String getPropertyValue(String name) {
return properties.get(name);
- }
+ }
}
Copied: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/filters/TopicBasedEventFilter.java (from r756411, synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/filters/XPathBasedEventFilter.java)
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/filters/TopicBasedEventFilter.java?p2=synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/filters/TopicBasedEventFilter.java&p1=synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/filters/XPathBasedEventFilter.java&r1=756411&r2=759451&rev=759451&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/filters/XPathBasedEventFilter.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/filters/TopicBasedEventFilter.java Sat Mar 28 10:25:16 2009
@@ -20,36 +20,19 @@
package org.apache.synapse.eventing.filters;
import org.apache.synapse.MessageContext;
-import org.apache.synapse.eventing.SynapseEventFilter;
import org.apache.synapse.util.xpath.SynapseXPath;
+import org.wso2.eventing.EventFilter;
+import org.wso2.eventing.Event;
/**
- *
+ * Topic baed event filter that match the subscription based on a given topic
*/
-public class XPathBasedEventFilter implements SynapseEventFilter {
+public class TopicBasedEventFilter implements EventFilter<MessageContext> {
private SynapseXPath sourceXpath;
private String resultValue;
private static final String FILTER_SEP = "/";
- public boolean isSatisfied(MessageContext mc) {
- String evaluatedValue = sourceXpath.stringValueOf(mc);
- if (evaluatedValue.equals(resultValue)) {
- return true;
- } else if (evaluatedValue.startsWith((resultValue + FILTER_SEP).trim())) {
- return true;
- }
- return false;
- }
-
- public SynapseXPath getSourceXpath() {
- return sourceXpath;
- }
-
- public void setSourceXpath(SynapseXPath sourceXpath) {
- this.sourceXpath = sourceXpath;
- }
-
public String getResultValue() {
return resultValue;
}
@@ -61,4 +44,23 @@
public String toString() {
return resultValue;
}
-}
+
+ public SynapseXPath getSourceXpath() {
+ return sourceXpath;
+ }
+
+ public void setSourceXpath(SynapseXPath sourceXpath) {
+ this.sourceXpath = sourceXpath;
+ }
+
+ public boolean match(Event<MessageContext> event) {
+ MessageContext messageContext = event.getMessage();
+ String evaluatedValue = sourceXpath.stringValueOf(messageContext);
+ if (evaluatedValue.equals(resultValue)) {
+ return true;
+ } else if (evaluatedValue.startsWith((resultValue + FILTER_SEP).trim())) {
+ return true;
+ }
+ return false;
+ }
+}
\ No newline at end of file
Propchange: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/filters/TopicBasedEventFilter.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/filters/TopicBasedEventFilter.java
------------------------------------------------------------------------------
svn:mergeinfo =
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/managers/DefaultInMemorySubscriptionManager.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/managers/DefaultInMemorySubscriptionManager.java?rev=759451&r1=759450&r2=759451&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/managers/DefaultInMemorySubscriptionManager.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/managers/DefaultInMemorySubscriptionManager.java Sat Mar 28 10:25:16 2009
@@ -27,9 +27,11 @@
import org.apache.synapse.eventing.SynapseSubscriptionManager;
import org.apache.synapse.eventing.SynapseEventingConstants;
import org.apache.synapse.eventing.filters.XPathBasedEventFilter;
+import org.apache.synapse.eventing.filters.TopicBasedEventFilter;
import org.apache.synapse.util.xpath.SynapseXPath;
import org.jaxen.JaxenException;
import org.wso2.eventing.Subscription;
+import org.wso2.eventing.Event;
import org.wso2.eventing.exceptions.EventException;
import java.util.Calendar;
@@ -93,14 +95,18 @@
public List<SynapseSubscription> getMatchingSubscribers(MessageContext mc) {
final LinkedList<SynapseSubscription> list = new LinkedList<SynapseSubscription>();
+ String evaluatedValue = null;
for (Map.Entry<String, SynapseSubscription> stringSubscriptionEntry : store.entrySet()) {
//TODO : pick the filter based on the dialect
- XPathBasedEventFilter filter = new XPathBasedEventFilter();
+ //XPathBasedEventFilter filter = new XPathBasedEventFilter();
+ TopicBasedEventFilter filter = new TopicBasedEventFilter();
if (filter != null) {
filter.setResultValue(stringSubscriptionEntry.getValue().getFilterValue());
filter.setSourceXpath(topicXPath);
+ //evaluatedValue = topicXPath.stringValueOf(mc);
}
- if (filter == null || filter.isSatisfied(mc)) {
+ Event<MessageContext> event = new Event(mc);
+ if (filter == null || filter.match(event)) {
SynapseSubscription subscription = stringSubscriptionEntry.getValue();
Calendar current = Calendar.getInstance(); //Get current date and time
if (subscription.getExpires() != null) {
@@ -134,14 +140,27 @@
return null; //To change body of implemented methods use File | Settings | File Templates.
}
- public boolean unsubscribe(Subscription subscription) throws EventException {
+ public boolean unsubscribe(String s) throws EventException {
return false; //To change body of implemented methods use File | Settings | File Templates.
}
+
public String renew(Subscription subscription) throws EventException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
+ public List<Subscription> getSubscriptions() throws EventException {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public List<Subscription> getAllSubscriptions() throws EventException {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public List<Subscription> getMatchingSubscriptions(String s) throws EventException {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public List<Subscription> getSubscribers() throws EventException {
LinkedList<Subscription> list = new LinkedList<Subscription>();
for (Map.Entry<String, SynapseSubscription> stringSubscriptionEntry : store.entrySet()) {
@@ -158,6 +177,10 @@
return store.get(id);
}
+ public Subscription getStatus(String s) throws EventException {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public Subscription getStatus(Subscription subscription) throws EventException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}