Author: asankaa Date: Thu Nov 27 09:12:05 2008 New Revision: 25111 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=25111
Log: implement the API methods Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/SynapseSubscriptionManager.java branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/SubscriptionMessageBuilder.java branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/managers/DefaultInMemorySubscriptionManager.java Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/SynapseSubscriptionManager.java URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/SynapseSubscriptionManager.java?rev=25111&r1=25110&r2=25111&view=diff ============================================================================== --- branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/SynapseSubscriptionManager.java (original) +++ branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/SynapseSubscriptionManager.java Thu Nov 27 09:12:05 2008 @@ -20,17 +20,18 @@ package org.apache.synapse.eventing; import org.apache.synapse.MessageContext; +import org.wso2.eventing.SubscriptionManager; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; -public abstract class SynapseSubscriptionManager { +public abstract class SynapseSubscriptionManager implements SubscriptionManager { private Map<String, String> properties = new HashMap<String, String>(); - public abstract List<SynapseSubscription> getSubscribers(); + public abstract List<SynapseSubscription> getSynapseSubscribers(); public abstract List<SynapseSubscription> getMatchingSubscribers(MessageContext mc); Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/SubscriptionMessageBuilder.java URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/SubscriptionMessageBuilder.java?rev=25111&r1=25110&r2=25111&view=diff ============================================================================== --- branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/SubscriptionMessageBuilder.java (original) +++ branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/SubscriptionMessageBuilder.java Thu Nov 27 09:12:05 2008 @@ -113,16 +113,19 @@ */ public static SynapseSubscription createSubscription(MessageContext mc) { SynapseSubscription subscription = null; + OMElement notifyToElem = null; OMElement elem = mc.getEnvelope().getBody().getFirstChildWithName(SUBSCRIBE_QNAME); if (elem != null) { OMElement deliveryElem = elem.getFirstChildWithName(DELIVERY_QNAME); if (deliveryElem != null) { - OMElement notifyToElem = deliveryElem.getFirstChildWithName(NOTIFY_TO_QNAME); + notifyToElem = deliveryElem.getFirstChildWithName(NOTIFY_TO_QNAME); if (notifyToElem != null) { Endpoint ep = getEndpointFromWSAAddress(notifyToElem.getFirstElement()); if (ep != null) { subscription = new SynapseSubscription(EventingConstants.WSE_DEFAULT_DELIVERY_MODE); subscription.setEndpoint(ep); + subscription.setAddressUrl(notifyToElem.getFirstElement().getText()); + subscription.setEndpointUrl(notifyToElem.getFirstElement().getText()); } } else { handleException("NotifyTo element not found in the subscription message"); @@ -157,7 +160,6 @@ Calendar calendar = ConverterUtil.convertToDateTime(expiryElem.getText()); subscription.setExpires(calendar); } - subscription.setAddressUrl(mc.getTo().getAddress()); } else { handleException("Subscribe element is required as the payload of the subscription message"); } Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/managers/DefaultInMemorySubscriptionManager.java URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/managers/DefaultInMemorySubscriptionManager.java?rev=25111&r1=25110&r2=25111&view=diff ============================================================================== --- branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/managers/DefaultInMemorySubscriptionManager.java (original) +++ branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/managers/DefaultInMemorySubscriptionManager.java Thu Nov 27 09:12:05 2008 @@ -28,6 +28,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jaxen.JaxenException; +import org.wso2.eventing.Subscription; +import org.wso2.eventing.exceptions.EventException; import java.util.LinkedList; import java.util.List; @@ -77,7 +79,7 @@ return false; } } - public List<SynapseSubscription> getSubscribers() { + public List<SynapseSubscription> getSynapseSubscribers() { LinkedList<SynapseSubscription> list = new LinkedList<SynapseSubscription>(); for (Map.Entry<String, SynapseSubscription> stringSubscriptionEntry : store.entrySet()) { list.add(stringSubscriptionEntry.getValue()); @@ -102,10 +104,39 @@ return list; } + @Deprecated + public String subscribe(Subscription subscription) throws EventException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean unsubscribe(Subscription subscription) 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> getSubscribers() throws EventException { + LinkedList<Subscription> list = new LinkedList<Subscription>(); + for (Map.Entry<String, SynapseSubscription> stringSubscriptionEntry : store.entrySet()) { + list.add(stringSubscriptionEntry.getValue()); + } + return list; + } + + public List<Subscription> getAllSubscribers() throws EventException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + public SynapseSubscription getSubscription(String id) { return store.get(id); } + public int getStatus(Subscription subscription) throws EventException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + public void init() { try { //TODO: pick values from the constants _______________________________________________ Esb-java-dev mailing list [email protected] https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev
