You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by pa...@apache.org on 2011/09/15 00:56:20 UTC

svn commit: r1170887 [1/3] - in /incubator/airavata/trunk/modules/ws-messenger/client: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/airavata/ src/main/java/org/apache/airavata/wsmg/ src/main/jav...

Author: patanachai
Date: Wed Sep 14 22:56:19 2011
New Revision: 1170887

URL: http://svn.apache.org/viewvc?rev=1170887&view=rev
Log:
Add WS-Messenger Client module

Added:
    incubator/airavata/trunk/modules/ws-messenger/client/pom.xml
    incubator/airavata/trunk/modules/ws-messenger/client/src/
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/CommonMsgBrokerClient.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerMsgReceiver.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerNotificationHandler.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerServer.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerServerHandler.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerService.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/MessageBrokerClient.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/MsgBrokerClientException.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/NotificationHandler.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/NotificationProducerStub.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/SubscriptionInfo.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/SubscriptionStub.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WidgetStub.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WseCreateSubscription.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WseMsgBrokerClient.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WsntCreatePublishReg.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WsntMsgBrokerClient.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WsrfResourceStub.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/commons/
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/commons/NotificationProducer.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/msgbox/
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/msgbox/MessagePuller.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/msgbox/MsgboxHandler.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/protocol/
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/protocol/WSEProtocolClient.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/protocol/WSNTProtocolClient.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/util/
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/util/ClientUtil.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/util/DcDate.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/NotificationViewer.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/NotificationViewerFrame.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/README.txt
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/WsntViewerConsumerNotificationHandler.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/CreateMsgBox.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/DestroyMsgBox.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/MsgBoxClient.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/StoreMessage.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/TakeMessages.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/test/
    incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/
    incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/
    incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/
    incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/
    incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/
    incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/
    incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/
    incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ClientUtilTest.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ConfigKeys.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/TestDcDate.java
    incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/gui/
    incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/gui/GUITest.java

Added: incubator/airavata/trunk/modules/ws-messenger/client/pom.xml
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/pom.xml?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/pom.xml (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/pom.xml Wed Sep 14 22:56:19 2011
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+
+    <parent>
+        <artifactId>airavata-ws-messenger</artifactId>
+        <groupId>airavata</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <name>Messenger Client</name>
+    <groupId>airavata</groupId>
+    <artifactId>airavata-messenger-client</artifactId>
+    <url>http://incubator.apache.org/airavata/</url>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <!-- common -->
+        <dependency>
+            <groupId>airavata</groupId>
+            <artifactId>airavata-messenger-commons</artifactId>
+            <version>${airavata.version}</version>
+        </dependency>
+        
+        <!-- Logging -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+
+        <!-- Axis2 -->
+        <dependency>
+            <groupId>org.apache.axis2</groupId>
+            <artifactId>axis2-kernel</artifactId>
+            <version>${axis2.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis2</groupId>
+            <artifactId>axis2-transport-http</artifactId>
+        </dependency>
+
+
+        <!-- Testing -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/CommonMsgBrokerClient.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/CommonMsgBrokerClient.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/CommonMsgBrokerClient.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/CommonMsgBrokerClient.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,161 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.airavata.wsmg.client;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.wsmg.client.msgbox.MessagePuller;
+import org.apache.airavata.wsmg.client.msgbox.MsgboxHandler;
+import org.apache.airavata.wsmg.commons.WsmgVersion;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.addressing.EndpointReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+abstract class CommonMsgBrokerClient implements MessageBrokerClient {
+
+    protected final static OMFactory factory = OMAbstractFactory.getOMFactory();
+    private final static SOAPFactory soapfactory = OMAbstractFactory.getSOAP11Factory();
+
+    private final static Logger logger = LoggerFactory.getLogger(CommonMsgBrokerClient.class);
+    protected ConsumerServer xs;
+    protected MsgboxHandler msgboxHandler = new MsgboxHandler();
+
+    private long socketTimeout = 200000L;
+
+    public CommonMsgBrokerClient(long timeout) {
+        socketTimeout = timeout;
+        WsmgVersion.requireVersionOrExit(WsmgVersion.getVersion());
+    }
+
+
+    public String[] getConsumerServiceEndpointReference() {
+        if (xs == null) {
+            throw new RuntimeException("Consumer server is not started yet");
+        }
+        return xs.getConsumerServiceEPRs();
+    }
+
+
+    public void setTimeOutInMilliSeconds(long timeout) {
+        socketTimeout = timeout;
+    }
+
+    public CommonMsgBrokerClient() {
+        WsmgVersion.requireVersionOrExit(WsmgVersion.getVersion());
+
+    }
+
+    public long getTimeOutInMilliSeconds() {
+        return socketTimeout;
+    }
+
+
+    public String subscribeMsgBox(String brokerService, EndpointReference msgBoxEpr, String topic, String xpath)
+            throws MsgBrokerClientException {
+
+        String msgBoxId = null;
+        String msgBoxUrl = msgBoxEpr.getAddress();
+        int biginIndex = msgBoxUrl.indexOf("clientid");
+        msgBoxId = msgBoxUrl.substring(biginIndex + "clientid".length() + 1);
+
+        if (msgBoxId == null)
+            throw new RuntimeException("Invalid Message Box EPR, message box ID is missing");
+
+        return subscribe(msgBoxEpr.getAddress(), topic, xpath);
+    }
+
+    public String subscribeMsgBox(EndpointReference msgBoxEpr, String topicExpression, String xpathExpression,
+            long expireTime) throws MsgBrokerClientException {
+
+        String msgBoxEventSink = msgBoxEpr.getAddress();
+
+        String formattedEventSink = null;
+
+        if (msgBoxEpr.getAddress().contains("clientid")) {
+            formattedEventSink = msgBoxEventSink;
+        } else {
+            if (msgBoxEpr.getAllReferenceParameters() == null)
+                throw new MsgBrokerClientException("Invalid Message Box EPR, no reference parameters found");
+            String msgBoxId = msgBoxEpr.getAllReferenceParameters()
+                    .get(new QName("http://org.apache.airavata/xgws/msgbox/2004/", "MsgBoxAddr")).getText();
+            if (msgBoxId == null)
+                throw new MsgBrokerClientException("Invalid Message Box EPR, reference parameter MsgBoxAddr is missing");
+            String format = msgBoxEventSink.endsWith("/") ? "%sclientid/%s" : "%s/clientid/%s";
+
+            formattedEventSink = String.format(format, msgBoxEventSink, msgBoxId);
+
+        }
+
+        return subscribe(new EndpointReference(formattedEventSink), topicExpression, xpathExpression, expireTime);
+
+    }
+
+    // ------------------------Message box user
+    // API----------------------------//
+
+    public EndpointReference createPullMsgBox(String msgBoxLocation, long timeout) throws MsgBrokerClientException {
+
+        EndpointReference ret = null;
+        try {
+            ret = msgboxHandler.createPullMsgBox(msgBoxLocation, timeout);
+        } catch (MsgBrokerClientException e) {
+            throw e;
+        }
+
+        return ret;
+    }
+
+    public EndpointReference createPullMsgBox(String msgBoxServerLoc) throws MsgBrokerClientException {
+        EndpointReference ret = null;
+        ret = msgboxHandler.createPullMsgBox(msgBoxServerLoc);
+        return ret;
+    }
+
+    public MessagePuller startPullingEventsFromMsgBox(EndpointReference msgBoxEpr, NotificationHandler handler,
+                                                      long interval, long timeout) throws MsgBrokerClientException {
+
+        MessagePuller ret = null;
+        ret = msgboxHandler.startPullingEventsFromMsgBox(msgBoxEpr, handler, interval, timeout);
+        return ret;
+    }
+
+    public MessagePuller startPullingFromExistingMsgBox(EndpointReference msgBoxAddr, NotificationHandler handler,
+                                                        long interval, long timeout) throws MsgBrokerClientException {
+
+        MessagePuller ret = null;
+        ret = msgboxHandler.startPullingFromExistingMsgBox(msgBoxAddr, handler, interval, timeout);
+        return ret;
+    }
+
+    public String deleteMsgBox(EndpointReference msgBoxEpr, long timeout) throws MsgBrokerClientException {
+        String ret = null;
+        ret = msgboxHandler.deleteMsgBox(msgBoxEpr, timeout);
+        return ret;
+    }
+
+    public void stopPullingEventsFromMsgBox(MessagePuller msgPuller) {
+        msgboxHandler.stopPullingEventsFromMsgBox(msgPuller);
+    }
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerMsgReceiver.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerMsgReceiver.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerMsgReceiver.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerMsgReceiver.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,40 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.MessageReceiver;
+
+public class ConsumerMsgReceiver implements MessageReceiver {
+
+    private ConsumerNotificationHandler notifHandler;
+
+    public ConsumerMsgReceiver(ConsumerNotificationHandler notifHandler) {
+        this.notifHandler = notifHandler;
+    }
+
+    public void receive(MessageContext messageCtx) throws AxisFault {
+        notifHandler.handleNotification(messageCtx.getEnvelope());
+    }
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerNotificationHandler.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerNotificationHandler.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerNotificationHandler.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerNotificationHandler.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,29 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+
+public interface ConsumerNotificationHandler {
+    public void handleNotification(SOAPEnvelope msgEnvelope) throws AxisFault;
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerServer.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerServer.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerServer.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerServer.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,99 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+
+public class ConsumerServer {
+
+    private static final String ADDRESSING_VALIDATE_ACTION = "addressing.validateAction";
+    public static final String SUPPORT_SINGLE_OP = "supportSingleOperation";
+    private ConsumerNotificationHandler handler;
+    private int listeningPort;
+    private SimpleHTTPServer server;
+    private AxisService consumerService = null;
+
+    public ConsumerServer(int listenPort, ConsumerNotificationHandler h) {
+
+        if (listenPort <= 0 || h == null) {
+            throw new IllegalArgumentException("invalid arguments supplied");
+        }
+
+        this.listeningPort = listenPort;
+        this.handler = h;
+        this.server = null;
+        this.consumerService = null;
+        // setConsumerServiceUrl(listenPort);
+
+    }
+
+    public String[] getConsumerServiceEPRs() {
+        return consumerService.getEPRs();
+    }
+
+    /**
+     * @param args
+     * @throws AxisFault
+     * @throws Exception
+     */
+    public void start() throws AxisFault {
+        ConfigurationContext context = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
+
+        context.setProperty(ADDRESSING_VALIDATE_ACTION, Boolean.valueOf(false));
+
+        context.getAxisConfiguration().addParameter(SUPPORT_SINGLE_OP, Boolean.valueOf(true));
+
+        context.getAxisConfiguration().addParameter(ADDRESSING_VALIDATE_ACTION, Boolean.valueOf(false));
+
+        Map<String, MessageReceiver> msgRecieverMap = new HashMap<String, MessageReceiver>();
+        ConsumerMsgReceiver conMsgRcv = new ConsumerMsgReceiver(handler);
+
+        msgRecieverMap.put("http://www.w3.org/ns/wsdl/in-only", conMsgRcv);
+        AxisService service = AxisService.createService(ConsumerService.class.getName(),
+                context.getAxisConfiguration(), msgRecieverMap, null, null, ConsumerServer.class.getClassLoader());
+
+        context.getAxisConfiguration().addService(service);
+        server = new SimpleHTTPServer(context, this.listeningPort);
+        server.start();
+
+        consumerService = service;
+
+    }
+
+    public void stop() {
+        // TODO: add an exeption
+        server.stop();
+    }
+
+    public int getListenPort() {
+        return listeningPort;
+    }
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerServerHandler.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerServerHandler.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerServerHandler.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerServerHandler.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,54 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client;
+
+import org.apache.axis2.AxisFault;
+
+public class ConsumerServerHandler {
+
+    private ConsumerServer xs = null;
+
+    public void createConsumerServer(int listenPort, ConsumerNotificationHandler h) throws MsgBrokerClientException {
+
+        try {
+            xs = new ConsumerServer(listenPort, h);
+            xs.start();
+        } catch (AxisFault f) {
+            throw new MsgBrokerClientException("unable to start the consumer server", f);
+        }
+    }
+
+    public String[] getConsumerServiceEndpointReference() throws MsgBrokerClientException {
+        if (xs == null) {
+            throw new MsgBrokerClientException("Consumer server is not started yet");
+        }
+        return xs.getConsumerServiceEPRs();
+    }
+
+    public void shutdownConsumerService() {
+        if (xs != null) {
+            xs.stop();
+            xs = null;
+        }
+    }
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerService.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerService.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerService.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/ConsumerService.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,30 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client;
+
+public class ConsumerService {
+
+    public void consumer(String msg) {
+        System.out.println(msg);
+    }
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/MessageBrokerClient.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/MessageBrokerClient.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/MessageBrokerClient.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/MessageBrokerClient.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,175 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client;
+
+import org.apache.airavata.wsmg.client.msgbox.MessagePuller;
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+
+import java.rmi.RemoteException;
+
+public interface MessageBrokerClient {
+
+    /**
+     * May be we just use a constructor here
+     * 
+     * @param brokerLocation
+     */
+    public void init(String brokerLocation);
+
+
+    /**
+     * 
+     * @param subscriptionId
+     * @return
+     */
+    public boolean unSubscribe(String subscriptionId) throws MsgBrokerClientException;
+
+    /**
+     * 
+     * @param eventSinkLocation
+     * @param topicExpression
+     * @param xpathExpression
+     * @return
+     * @throws AxisFault
+     */
+    public String subscribe(String eventSinkLocation, String topicExpression, String xpathExpression)
+            throws MsgBrokerClientException;
+
+    public String subscribe(EndpointReference eventSinkLocation, String topicExpression, String xpathExpression)
+            throws MsgBrokerClientException;
+
+    /**
+     * 
+     * @param eventSinkLocation
+     * @param topicExpression
+     * @param xpathExpression
+     * @param expireTime
+     *            with -1, it never expires
+     * @return
+     * @throws AxisFault
+     */
+    public String subscribe(EndpointReference eventSinkLocation, String topicExpression, String xpathExpression,
+            long expireTime) throws MsgBrokerClientException;
+
+    public void publish(String topic, String plainText) throws MsgBrokerClientException;
+
+    public void publish(String topic, OMElement message) throws MsgBrokerClientException;
+
+    /**
+     * 
+     * @param brokerLocation
+     * @param msgBoxEpr
+     * @param topicExpression
+     * @param xpathExpression
+     * @param expireTime
+     *            with -1, it never expires
+     * @return
+     * @throws MsgBrokerClientException
+     */
+    public String subscribeMsgBox(EndpointReference msgBoxEpr, String topicExpression, String xpathExpression,
+            long expireTime) throws MsgBrokerClientException;
+
+
+
+    /**
+     * This method can be used to shutdown the consumer server started
+     */
+    public void shutdownConsumerService();
+
+    /**
+     *
+     * @param port
+     * @param handler
+     * @return
+     * @throws MsgBrokerClientException
+     */
+    public String[] startConsumerService(int port, ConsumerNotificationHandler handler) throws MsgBrokerClientException;
+
+    /**
+     *
+     * @param msgBoxAddr
+     * @param handler
+     * @param backoff
+     * @param timeout
+     * @return
+     * @throws AxisFault
+     */
+    public MessagePuller startPullingFromExistingMsgBox(EndpointReference msgBoxAddr, NotificationHandler handler,
+                                                        long backoff, long timeout) throws MsgBrokerClientException;
+
+    /**
+     *
+     * @param msgBoxAddr
+     * @param handler
+     * @param backoff
+     * @param timeout
+     * @return
+     * @throws RemoteException
+     */
+    public MessagePuller startPullingEventsFromMsgBox(EndpointReference msgBoxAddr, NotificationHandler handler,
+                                                      long backoff, long timeout) throws MsgBrokerClientException;
+
+    // public EndpointReference createPullMsgBox(String msgBoxServerLoc, String userAgent) throws RemoteException ;
+
+    /**
+     *
+     * @param msgPuller
+     */
+    public void stopPullingEventsFromMsgBox(org.apache.airavata.wsmg.client.msgbox.MessagePuller msgPuller)throws MsgBrokerClientException;
+
+    /**
+     *
+     * @return
+     */
+    public String[] getConsumerServiceEndpointReference();
+
+    /**
+     *
+     * @param brokerService
+     * @param msgBoxEpr
+     * @param topic
+     * @param xpath
+     * @return
+     */
+    public String subscribeMsgBox(String brokerService, EndpointReference msgBoxEpr, String topic, String xpath)throws MsgBrokerClientException;
+
+    /**
+     *
+     * @param msgBoxLocation
+     * @param timeout
+     * @return
+     * @throws MsgBrokerClientException
+     */
+    public EndpointReference createPullMsgBox(String msgBoxLocation, long timeout) throws MsgBrokerClientException;
+
+    /**
+     *
+     * @param msgBoxServerLoc
+     * @return
+     * @throws MsgBrokerClientException
+     */
+    public EndpointReference createPullMsgBox(String msgBoxServerLoc) throws MsgBrokerClientException;
+
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/MsgBrokerClientException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/MsgBrokerClientException.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/MsgBrokerClientException.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/MsgBrokerClientException.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,37 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client;
+
+import org.apache.axis2.AxisFault;
+
+public class MsgBrokerClientException extends AxisFault {
+
+    private static final long serialVersionUID = 5609577226544941146L;
+
+    public MsgBrokerClientException(String msg) {
+        super(msg);
+    }
+
+    public MsgBrokerClientException(String msg, Throwable t) {
+        super(msg, t);
+    }
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/NotificationHandler.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/NotificationHandler.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/NotificationHandler.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/NotificationHandler.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,28 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client;
+
+import org.apache.axis2.AxisFault;
+
+public interface NotificationHandler {
+    public void handleNotification(String message) throws AxisFault;
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/NotificationProducerStub.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/NotificationProducerStub.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/NotificationProducerStub.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/NotificationProducerStub.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,190 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.wsmg.client.util.ClientUtil;
+import org.apache.airavata.wsmg.commons.WsmgCommonConstants;
+import org.apache.airavata.wsmg.commons.WsmgNameSpaceConstants;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
+import org.apache.axis2.client.ServiceClient;
+
+/**
+ * 
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+/**
+ * This stub is NOT multi-thread safe!
+ */
+public class NotificationProducerStub extends WidgetStub {
+    private static final String RMASSERTION = "RMAssertion";
+
+    private static final String WSRM_NAMESPACE = "http://schemas.xmlsoap.org/ws/2005/02/rm";
+
+    private static final String WSRM = "wsrm";
+
+    private final static OMFactory factory = OMAbstractFactory.getOMFactory();
+    private final static SOAPFactory soapfactory = OMAbstractFactory.getSOAP11Factory();
+
+    public NotificationProducerStub(EndpointReference widgetEpr, long timeout) {
+        super(widgetEpr, timeout);
+    }
+
+    public OMElement getCurrentMessage(OMElement topicExp) throws AxisFault {
+
+        OMElement message = factory.createOMElement("GetCurrentMessage", WsmgNameSpaceConstants.WSNT_NS);
+        message.addChild(topicExp);
+
+        ServiceClient client = createServiceClient(message);
+
+        OMElement responseMessage = client.sendReceive(message);
+        client.cleanupTransport();
+
+        if (responseMessage.getFirstElement() == null) {
+            return null;
+        }
+        return (OMElement) responseMessage.getChildren().next();
+    }
+
+    private ServiceClient createServiceClient(OMElement message) throws AxisFault {
+
+        String uuid = UUIDGenerator.getUUID();
+        ServiceClient client = new ServiceClient();
+
+        if (client.getAxisConfiguration().getModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING) != null) {
+            client.engageModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING);
+        } else {
+            SOAPHeaderBlock msgId = soapfactory.createSOAPHeaderBlock("MessageID", WsmgNameSpaceConstants.WSA_NS);
+            msgId.setText(uuid);
+            SOAPHeaderBlock to = soapfactory.createSOAPHeaderBlock("To", WsmgNameSpaceConstants.WSA_NS);
+            to.setText(opts.getTo().getAddress());
+
+            SOAPHeaderBlock action = soapfactory.createSOAPHeaderBlock("Action", WsmgNameSpaceConstants.WSA_NS);
+            action.setText(message.getNamespace().getNamespaceURI() + "/" + message.getLocalName());
+
+            client.addHeader(action);
+            client.addHeader(msgId);
+            client.addHeader(to);
+        }
+
+        opts.setMessageId(uuid);
+        opts.setAction(message.getNamespace().getNamespaceURI() + "/" + message.getLocalName());
+
+        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+        opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds());
+        client.setOptions(opts);
+
+        return client;
+    }
+
+    public SubscriptionStub subscribe(EndpointReference consumerReference, OMElement topicExpression, boolean useNotfy)
+            throws AxisFault {
+        return this.subscribe(consumerReference, topicExpression, null, useNotfy, false);
+
+    }
+
+    public SubscriptionStub subscribe(EndpointReference consumerReference, OMElement topicExpression,
+            OMElement xpathExpression, boolean useNotfy) throws AxisFault {
+        return this.subscribe(consumerReference, topicExpression, xpathExpression, useNotfy, false);
+
+    }
+
+    public SubscriptionStub subscribe(EndpointReference consumerReference, OMElement topicExpression, boolean useNotfy,
+            boolean wsrm) throws AxisFault {
+        return subscribe(consumerReference, topicExpression, null, useNotfy, wsrm);
+    }
+
+    public SubscriptionStub subscribe(EndpointReference consumerReference, OMElement topicExpression,
+            OMElement xpathExpression, boolean useNotfy, boolean wsrm) throws AxisFault {
+
+        OMElement message = factory.createOMElement("SubscribeRequest", WsmgNameSpaceConstants.WSNT_NS);
+
+        message.declareNamespace(WsmgNameSpaceConstants.WSNT_NS);
+
+        OMElement eprCrEl = EndpointReferenceHelper.toOM(factory, consumerReference, new QName("ConsumerReference"),
+                WsmgNameSpaceConstants.WSA_NS.getNamespaceURI());
+
+        message.addChild(eprCrEl);
+        eprCrEl.setNamespace(message.getNamespace());
+
+        if (topicExpression != null) {
+            message.addChild(topicExpression);
+            topicExpression.setNamespace(message.getNamespace());
+        }
+        if (xpathExpression != null) {
+            message.addChild(xpathExpression);
+            xpathExpression.setNamespace(message.getNamespace());
+        }
+        OMElement useNotifyEl = factory.createOMElement("UseNotify", message.getNamespace(), message);
+
+        useNotifyEl.setText(useNotfy ? "true" : "false");
+
+        if (wsrm) {
+
+            setPolicyAttachment(message);
+        }
+
+        ServiceClient client = createServiceClient(message);
+
+        OMElement responseMessage = client.sendReceive(message);
+        client.cleanupTransport();
+
+        OMElement sr = responseMessage.getFirstChildWithName(new QName(
+                WsmgNameSpaceConstants.WSNT_NS.getNamespaceURI(), "SubscriptionReference"));
+
+        if (sr == null) {
+            throw new AxisFault("unable to subscribe, invalid response returned by broker");
+        }
+
+        return new SubscriptionStub(EndpointReferenceHelper.fromOM(sr), getTimeoutInMilliSeconds());
+    }
+
+    public static void verbose(String msg) {
+
+        System.err.println(msg);
+    }
+
+    protected void setPolicyAttachment(OMElement message) {
+
+        OMElement policy = factory.createOMElement(WsmgCommonConstants.SUBSCRIPTION_POLICY, message.getNamespace(),
+                message);
+
+        // builder.newFragment(WsmgConstants.WSNT_NS,
+        // WsmgCommonConstants.SUBSCRIPTION_POLICY);
+        OMElement childEl = factory.createOMElement(new QName(WSRM_NAMESPACE, WSRM));
+        // XmlNamespace wsrmNamespace = builder.newNamespace(WSRM,
+        // WSRM_NAMESPACE);
+        policy.addChild(childEl);
+
+    }
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/SubscriptionInfo.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/SubscriptionInfo.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/SubscriptionInfo.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/SubscriptionInfo.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,161 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client;
+
+import org.apache.airavata.wsmg.client.util.ClientUtil;
+
+public class SubscriptionInfo {
+    String eventSourceLocIn = null;
+    String eventSinkLocIn = null;
+    String topicExpression = null;
+    String xpathExpression = null;
+    String eventSinkEndpointReferenceNS = null;
+    String eventSinkEndpointReference = null;
+    long expireTime = ClientUtil.EXPIRE_TIME;
+
+    /**
+     * @param eventSourceLocIn
+     * @param eventSinkLocIn
+     * @param topicExpression
+     * @param xpathExpression
+     * @param eventSinkEndpointReferenceNS
+     * @param eventSinkEndpointReference
+     * @param expireTime
+     */
+    public SubscriptionInfo(String eventSourceLocIn, String eventSinkLocIn, String topicExpression,
+            String xpathExpression, String eventSinkEndpointReferenceNS, String eventSinkEndpointReference,
+            long expireTime) {
+        this.eventSourceLocIn = eventSourceLocIn;
+        this.eventSinkLocIn = eventSinkLocIn;
+        this.topicExpression = topicExpression;
+        this.xpathExpression = xpathExpression;
+        this.eventSinkEndpointReferenceNS = eventSinkEndpointReferenceNS;
+        this.eventSinkEndpointReference = eventSinkEndpointReference;
+        this.expireTime = expireTime;
+    }
+
+    /**
+     * @return Returns the eventSinkEndpointReference.
+     */
+    public String getEventSinkEndpointReference() {
+        return eventSinkEndpointReference;
+    }
+
+    /**
+     * @param eventSinkEndpointReference
+     *            The eventSinkEndpointReference to set.
+     */
+    public void setEventSinkEndpointReference(String eventSinkEndpointReference) {
+        this.eventSinkEndpointReference = eventSinkEndpointReference;
+    }
+
+    /**
+     * @return Returns the eventSinkEndpointReferenceNS.
+     */
+    public String getEventSinkEndpointReferenceNS() {
+        return eventSinkEndpointReferenceNS;
+    }
+
+    /**
+     * @param eventSinkEndpointReferenceNS
+     *            The eventSinkEndpointReferenceNS to set.
+     */
+    public void setEventSinkEndpointReferenceNS(String eventSinkEndpointReferenceNS) {
+        this.eventSinkEndpointReferenceNS = eventSinkEndpointReferenceNS;
+    }
+
+    /**
+     * @return Returns the eventSinkLocIn.
+     */
+    public String getEventSinkLocIn() {
+        return eventSinkLocIn;
+    }
+
+    /**
+     * @param eventSinkLocIn
+     *            The eventSinkLocIn to set.
+     */
+    public void setEventSinkLocIn(String eventSinkLocIn) {
+        this.eventSinkLocIn = eventSinkLocIn;
+    }
+
+    /**
+     * @return Returns the eventSourceLocIn.
+     */
+    public String getEventSourceLocIn() {
+        return eventSourceLocIn;
+    }
+
+    /**
+     * @param eventSourceLocIn
+     *            The eventSourceLocIn to set.
+     */
+    public void setEventSourceLocIn(String eventSourceLocIn) {
+        this.eventSourceLocIn = eventSourceLocIn;
+    }
+
+    /**
+     * @return Returns the expireTime.
+     */
+    public long getExpireTime() {
+        return expireTime;
+    }
+
+    /**
+     * @param expireTime
+     *            The expireTime to set.
+     */
+    public void setExpireTime(long expireTime) {
+        this.expireTime = expireTime;
+    }
+
+    /**
+     * @return Returns the topicExpression.
+     */
+    public String getTopicExpression() {
+        return topicExpression;
+    }
+
+    /**
+     * @param topicExpression
+     *            The topicExpression to set.
+     */
+    public void setTopicExpression(String topicExpression) {
+        this.topicExpression = topicExpression;
+    }
+
+    /**
+     * @return Returns the xpathExpression.
+     */
+    public String getXpathExpression() {
+        return xpathExpression;
+    }
+
+    /**
+     * @param xpathExpression
+     *            The xpathExpression to set.
+     */
+    public void setXpathExpression(String xpathExpression) {
+        this.xpathExpression = xpathExpression;
+    }
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/SubscriptionStub.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/SubscriptionStub.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/SubscriptionStub.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/SubscriptionStub.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,106 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client;
+
+import org.apache.airavata.wsmg.commons.WsmgCommonConstants;
+import org.apache.airavata.wsmg.commons.WsmgNameSpaceConstants;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.ServiceClient;
+
+/**
+ * 
+ * TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code
+ * Templates
+ */
+public class SubscriptionStub extends WsrfResourceStub {
+
+    private final static OMFactory factory = OMAbstractFactory.getOMFactory();
+    private final static SOAPFactory soapfactory = OMAbstractFactory.getSOAP11Factory();
+
+    // private final static XmlInfosetBuilder builder = XmlConstants.BUILDER;
+
+    SubscriptionStub(EndpointReference widgetEpr, long timeout) {
+        super(widgetEpr, timeout);
+    }
+
+    public void pauseSubscription() throws AxisFault {
+
+        OMElement message = factory.createOMElement("PauseSubscription", WsmgNameSpaceConstants.WSNT_NS);
+
+        ServiceClient client = createServiceClient(message);
+        client.sendReceive(message);
+        client.cleanupTransport();
+    }
+
+    public void resumeSubscription() throws AxisFault {
+
+        OMElement message = factory.createOMElement("ResumeSubscription", WsmgNameSpaceConstants.WSNT_NS);
+
+        ServiceClient client = createServiceClient(message);
+        client.sendReceive(message);
+        client.cleanupTransport();
+
+    }
+
+    private ServiceClient createServiceClient(OMElement message) throws AxisFault {
+
+        String uuid = UUIDGenerator.getUUID();
+        ServiceClient client = new ServiceClient();
+
+        if (client.getAxisConfiguration().getModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING) != null) {
+            client.engageModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING);
+        } else {
+            SOAPHeaderBlock msgId = soapfactory.createSOAPHeaderBlock("MessageID", WsmgNameSpaceConstants.WSA_NS);
+            msgId.setText(uuid);
+
+            SOAPHeaderBlock to = soapfactory.createSOAPHeaderBlock("To", WsmgNameSpaceConstants.WSA_NS);
+            to.setText(opts.getTo().getAddress());
+
+            SOAPHeaderBlock action = soapfactory.createSOAPHeaderBlock("Action", WsmgNameSpaceConstants.WSA_NS);
+            action.setText(message.getNamespace().getNamespaceURI() + "/" + message.getLocalName());
+
+            client.addHeader(action);
+            client.addHeader(msgId);
+            client.addHeader(to);
+        }
+        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+        opts.setMessageId(uuid);
+        opts.setAction(message.getNamespace().getNamespaceURI() + "/" + message.getLocalName());
+        opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds());
+        client.setOptions(opts);
+        return client;
+    }
+
+    public static void verbose(String msg) {
+
+        System.err.println(msg);
+
+    }
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WidgetStub.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WidgetStub.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WidgetStub.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WidgetStub.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,88 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client;
+
+import org.apache.airavata.wsmg.commons.WsmgCommonConstants;
+import org.apache.airavata.wsmg.commons.WsmgNameSpaceConstants;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.ServiceClient;
+
+/**
+ * This stub is NOT multi-thread safe!
+ */
+public class WidgetStub extends WsrfResourceStub {
+
+    private final static OMFactory factory = OMAbstractFactory.getOMFactory();
+    private final static SOAPFactory soapfactory = OMAbstractFactory.getSOAP11Factory();
+
+    public WidgetStub(EndpointReference widgetEpr, long timeout) {
+        super(widgetEpr, timeout);
+    }
+
+    public void generateNotification() throws AxisFault {
+
+        OMElement message = factory.createOMElement("generateNotification", WsmgNameSpaceConstants.WIDGET_NS);
+
+        ServiceClient client = createServiceClient(message);
+        client.sendReceive(message);
+        client.cleanupTransport();
+
+    }
+
+    private ServiceClient createServiceClient(OMElement message) throws AxisFault {
+
+        ServiceClient client = new ServiceClient();
+
+        String uuid = UUIDGenerator.getUUID();
+        if (client.getAxisConfiguration().getModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING) != null) {
+            client.engageModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING);
+        } else {
+
+            SOAPHeaderBlock msgId = soapfactory.createSOAPHeaderBlock("MessageID", WsmgNameSpaceConstants.WSA_NS);
+            msgId.setText(uuid);
+
+            SOAPHeaderBlock to = soapfactory.createSOAPHeaderBlock("To", WsmgNameSpaceConstants.WSA_NS);
+            to.setText(opts.getTo().getAddress());
+
+            SOAPHeaderBlock action = soapfactory.createSOAPHeaderBlock("Action", WsmgNameSpaceConstants.WSA_NS);
+            action.setText(message.getNamespace().getNamespaceURI() + "/" + message.getLocalName());
+
+            client.addHeader(action);
+            client.addHeader(msgId);
+            client.addHeader(to);
+        }
+        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+        opts.setMessageId(uuid);
+        opts.setAction(message.getNamespace().getNamespaceURI() + "/generateEvent");
+        opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds());
+        client.setOptions(opts);
+        return client;
+    }
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WseCreateSubscription.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WseCreateSubscription.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WseCreateSubscription.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WseCreateSubscription.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,142 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.wsmg.client.util.ClientUtil;
+import org.apache.airavata.wsmg.commons.WsmgCommonConstants;
+import org.apache.airavata.wsmg.commons.WsmgNameSpaceConstants;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+
+public class WseCreateSubscription {
+    private final OMFactory factory = OMAbstractFactory.getOMFactory();
+    private final static SOAPFactory soapfactory = OMAbstractFactory.getSOAP11Factory();
+    protected EndpointReference brokerEndPointReference;
+
+    protected long timeoutInMilliSeconds;
+
+    public WseCreateSubscription(EndpointReference brokerLocationEPR, long timeout) {
+        this.brokerEndPointReference = brokerLocationEPR;
+        timeoutInMilliSeconds = timeout;
+    }
+
+    public long getTimeoutInMilliSeconds() {
+        return timeoutInMilliSeconds;
+    }
+
+    public void setTimeoutInMilliSeconds(long timeout) {
+        timeoutInMilliSeconds = timeout;
+    }
+
+    public OMElement subscribe(EndpointReference eventSinkReference, OMElement filterEl, boolean useNotfy)
+            throws AxisFault {
+        return subscribe(eventSinkReference, filterEl, useNotfy, ClientUtil.EXPIRE_TIME);
+    }
+
+    public OMElement subscribe(EndpointReference eventSinkReferenceEPR, OMElement filterEl, boolean useNotfy,
+            long expireTime) throws AxisFault {
+
+        OMElement message = createMessageEl(eventSinkReferenceEPR, filterEl, expireTime);
+
+        ServiceClient serviceClient = createServiceClient(message);
+        OMElement responseMessage = serviceClient.sendReceive(message);
+        serviceClient.cleanupTransport();
+        if (responseMessage == null) {
+            throw AxisFault.makeFault(new RuntimeException("no response recieved for subscription message"));
+        }
+        OMElement responseSubscriptionsManagerElement = responseMessage.getFirstChildWithName(new QName(
+                WsmgNameSpaceConstants.WSE_NS.getNamespaceURI(), "SubscriptionManager"));
+        return responseSubscriptionsManagerElement;
+    }
+
+    private ServiceClient createServiceClient(OMElement message) throws AxisFault {
+        Options opts = new Options();
+        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+        opts.setTo(brokerEndPointReference);
+        opts.setAction(message.getNamespace().getNamespaceURI() + "/" + message.getLocalName());
+
+        opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds());
+        opts.setMessageId(UUIDGenerator.getUUID());
+
+        ServiceClient client = new ServiceClient();
+
+        if (client.getAxisConfiguration().getModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING) != null) {
+
+            client.engageModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING);
+        } else {
+            SOAPHeaderBlock msgId = soapfactory.createSOAPHeaderBlock("MessageID", WsmgNameSpaceConstants.WSA_NS);
+            msgId.setText(UUIDGenerator.getUUID());
+
+            SOAPHeaderBlock to = soapfactory.createSOAPHeaderBlock("To", WsmgNameSpaceConstants.WSA_NS);
+            to.setText(opts.getTo().getAddress());
+
+            SOAPHeaderBlock action = soapfactory.createSOAPHeaderBlock("Action", WsmgNameSpaceConstants.WSA_NS);
+            action.setText(message.getNamespace().getNamespaceURI() + "/" + message.getLocalName());
+
+            client.addHeader(action);
+            client.addHeader(msgId);
+            client.addHeader(to);
+        }
+        client.setOptions(opts);
+
+        return client;
+    }
+
+    private OMElement createMessageEl(EndpointReference eventSinkReferenceEPR, OMElement filterEl, long expireTime)
+            throws AxisFault {
+
+        OMElement message = factory.createOMElement("Subscribe", WsmgNameSpaceConstants.WSE_NS);
+
+        OMElement delivery = factory.createOMElement("Delivery", WsmgNameSpaceConstants.WSE_NS);
+
+        OMElement expires = factory.createOMElement("Expires", WsmgNameSpaceConstants.WSE_NS);
+        expires.setText(Long.toString(expireTime));
+        message.addChild(expires);
+
+        OMElement notifyTo = EndpointReferenceHelper.toOM(factory, eventSinkReferenceEPR, new QName(
+                WsmgNameSpaceConstants.WSE_NS.getNamespaceURI(), "NotifyTo"), WsmgNameSpaceConstants.WSA_NS
+                .getNamespaceURI());
+
+        delivery.addChild(notifyTo);
+        message.addChild(delivery);
+
+        if (filterEl != null) {
+            message.addChild(filterEl);
+        }
+
+        message.declareNamespace(WsmgNameSpaceConstants.WSA_NS);
+
+        return message;
+    }
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WseMsgBrokerClient.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WseMsgBrokerClient.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WseMsgBrokerClient.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WseMsgBrokerClient.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,195 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.wsmg.client.commons.NotificationProducer;
+import org.apache.airavata.wsmg.client.protocol.WSEProtocolClient;
+import org.apache.airavata.wsmg.client.util.ClientUtil;
+import org.apache.airavata.wsmg.commons.CommonRoutines;
+import org.apache.airavata.wsmg.commons.WsmgCommonConstants;
+import org.apache.airavata.wsmg.commons.WsmgNameSpaceConstants;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+
+public class WseMsgBrokerClient extends CommonMsgBrokerClient implements MessageBrokerClient {
+
+    private EndpointReference brokerEndpointRef = null;
+
+    protected long timeoutInMilliSeconds = WsmgCommonConstants.DEFAULT_CLIENT_SOCKET_TIME_OUT_MILLIES;
+
+    final static String WIDGET_NS_PREFIX = WsmgNameSpaceConstants.WIDGET_NS.getPrefix() + ":";
+
+    protected NotificationProducer notificationProducer = new NotificationProducer();
+    protected ConsumerServerHandler consumerServerHandler = new ConsumerServerHandler();
+
+    public static EndpointReference createEndpointReference(String brokerURL, String topic) {
+
+        return WSEProtocolClient.createEndpointReference(brokerURL, topic);
+    }
+
+    public void init(String brokerLocation) {
+
+        brokerEndpointRef = new EndpointReference(ClientUtil.formatURLString(brokerLocation));
+
+    }
+
+    public void publish(String topic, String plainText) throws MsgBrokerClientException {
+
+        OMFactory factory = OMAbstractFactory.getOMFactory();
+
+        OMElement wrappedMsg = factory.createOMElement(WsmgCommonConstants.WSMG_PLAIN_TEXT_WRAPPER,
+                WsmgNameSpaceConstants.WSMG_NS);
+
+        wrappedMsg.setText(plainText);
+        publish(topic, wrappedMsg);
+    }
+
+    public void publish(String topic, OMElement message) throws MsgBrokerClientException {
+
+        OMFactory factory = OMAbstractFactory.getOMFactory();
+
+        OMElement topicExpressionEl = null;
+
+        if (topic != null) {
+            topicExpressionEl = factory.createOMElement("Topic", WsmgNameSpaceConstants.WSNT_NS);
+            topicExpressionEl.addAttribute("Dialect", WsmgCommonConstants.TOPIC_EXPRESSION_SIMPLE_DIALECT, null);
+            topicExpressionEl.declareNamespace(WsmgNameSpaceConstants.WIDGET_NS);
+            topicExpressionEl.setText(WIDGET_NS_PREFIX + topic);
+
+        }
+
+        try {
+            notificationProducer.deliverMessage(message, "wse", brokerEndpointRef, getTimeoutInMilliSeconds(),
+                    topicExpressionEl);
+        } catch (AxisFault e) {
+            throw new MsgBrokerClientException("unable to publish msg", e);
+        }
+    }
+
+    public String subscribe(String eventSinkLocation, String topicExpression, String xpathExpression)
+            throws MsgBrokerClientException {
+        return subscribe(new EndpointReference(eventSinkLocation), topicExpression, xpathExpression);
+    }
+
+    public String subscribe(EndpointReference eventSinkLocation, String topicExpression, String xpathExpression)
+            throws MsgBrokerClientException {
+
+        return subscribe(eventSinkLocation, topicExpression, xpathExpression,
+                WsmgCommonConstants.DEFAULT_SUBSCRIPTION_EXPIRATION_TIME);
+    }
+
+    public String subscribe(EndpointReference eventSinkLocation, String topicExpression, String xpathExpression,
+            long expireTime) throws MsgBrokerClientException {
+
+        String subscriptionId = null;
+
+        try {
+            OMElement subscriptionMsg = WSEProtocolClient.createSubscription(eventSinkLocation,
+                    topicExpression, xpathExpression, expireTime);
+            ServiceClient serviceClient = configureServiceClientForSubscription(subscriptionMsg);
+            OMElement responseMessage = serviceClient.sendReceive(subscriptionMsg);
+            serviceClient.cleanupTransport();
+
+            if (responseMessage == null) {
+                throw new MsgBrokerClientException("no response recieved for subscription message");
+            }
+
+            OMElement responseSubscriptionsManagerElement = responseMessage.getFirstChildWithName(new QName(
+                    WsmgNameSpaceConstants.WSE_NS.getNamespaceURI(), "SubscriptionManager"));
+
+            subscriptionId = WSEProtocolClient.decodeSubscribeResponse(responseSubscriptionsManagerElement);
+
+        } catch (AxisFault e) {
+            throw new MsgBrokerClientException("unable to send the subscription", e);
+        }
+
+        return subscriptionId;
+    }
+
+
+
+    public boolean unSubscribe(String subscriptionId) throws MsgBrokerClientException {
+
+        OMFactory factory = OMAbstractFactory.getOMFactory();
+        OMElement message = WSEProtocolClient.createUnsubscribeMsg();
+
+        OMElement identifierEl = factory.createOMElement("Identifier", message.getNamespace());
+
+        identifierEl.setText(subscriptionId);
+        String soapAction = message.getNamespace().getNamespaceURI() + "/" + message.getLocalName();
+
+        Options opts = CommonRoutines.getOptions(soapAction, getTimeoutInMilliSeconds(), brokerEndpointRef);
+
+        try {
+            ServiceClient client = new ServiceClient();
+            client.setOptions(opts);
+            CommonRoutines.setHeaders(soapAction, brokerEndpointRef.getAddress(), client, identifierEl);
+
+            client.sendReceive(message);
+            client.cleanupTransport();
+
+        } catch (AxisFault e) {
+            throw new MsgBrokerClientException("unable to send subscribe msg", e);
+        }
+
+        return true;
+    }
+
+    private ServiceClient configureServiceClientForSubscription(OMElement message) throws AxisFault {
+
+        String soapAction = message.getNamespace().getNamespaceURI() + "/" + message.getLocalName();
+
+        Options opts = CommonRoutines.getOptions(soapAction, getTimeoutInMilliSeconds(), brokerEndpointRef);
+
+        ServiceClient client = new ServiceClient();
+        client.setOptions(opts);
+        CommonRoutines.setHeaders(soapAction, brokerEndpointRef.getAddress(), client);
+        return client;
+    }
+
+    public long getTimeoutInMilliSeconds() {
+        return timeoutInMilliSeconds;
+    }
+
+    public void setTimeoutInMilliSeconds(long timeout) {
+        timeoutInMilliSeconds = timeout;
+    }
+
+    public String[] startConsumerService(int port, ConsumerNotificationHandler handler) throws MsgBrokerClientException {
+
+        consumerServerHandler.createConsumerServer(port, handler);
+        return consumerServerHandler.getConsumerServiceEndpointReference();
+
+    }
+
+    public void shutdownConsumerService() {
+        consumerServerHandler.shutdownConsumerService();
+    }
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WsntCreatePublishReg.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WsntCreatePublishReg.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WsntCreatePublishReg.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/WsntCreatePublishReg.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,117 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.wsmg.commons.WsmgCommonConstants;
+import org.apache.airavata.wsmg.commons.WsmgNameSpaceConstants;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
+import org.apache.axis2.client.ServiceClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code
+ * Templates
+ */
+public class WsntCreatePublishReg extends WidgetStub {
+    private static final Logger logger = LoggerFactory.getLogger(WseCreateSubscription.class);
+    private OMFactory factory = OMAbstractFactory.getOMFactory();
+    private final static SOAPFactory soapfactory = OMAbstractFactory.getSOAP11Factory();
+
+    // private final static XmlInfosetBuilder builder = XmlConstants.BUILDER;
+
+    public WsntCreatePublishReg(EndpointReference widgetEpr, long timeout) {
+        super(widgetEpr, timeout);
+    }
+
+    public WsrfResourceStub registerPublisher(EndpointReference omEndpointReference) throws AxisFault {
+
+        // invoker.setMessageId(null);
+        OMElement message = factory.createOMElement(new QName(WsmgNameSpaceConstants.WSBR_NS.getNamespaceURI(),
+                "RegisterPublisher"));
+        // builder.newFragment(WsmgConstants.WSBR_NS,
+        // "RegisterPublisher");
+
+        // EndpointReference publisherRef;
+
+        OMElement publisherRef = null;
+
+        publisherRef = EndpointReferenceHelper.toOM(factory, omEndpointReference, new QName(
+                WsmgNameSpaceConstants.WSBR_NS.getNamespaceURI(), "PublisherReference"), WsmgNameSpaceConstants.WSA_NS
+                .getNamespaceURI());
+
+        message.addChild(publisherRef);
+
+        ServiceClient client = createServiceClient(message);
+
+        OMElement responseMessage = client.sendReceive(message);
+        client.cleanupTransport();
+
+        OMElement publisherRegistrationRef = responseMessage.getFirstChildWithName(new QName(
+                WsmgNameSpaceConstants.WSBR_NS.getNamespaceURI(), "PublisherRegistrationReference"));
+
+        EndpointReference epr = EndpointReferenceHelper.fromOM(publisherRegistrationRef);
+        return new WsrfResourceStub(epr, getTimeoutInMilliSeconds());
+    }
+
+    private ServiceClient createServiceClient(OMElement message) throws AxisFault {
+        String uuid = UUIDGenerator.getUUID();
+        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+        opts.setMessageId(uuid);
+        opts.setAction(message.getNamespace().getNamespaceURI() + "/" + message.getLocalName());
+        opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds());
+
+        ServiceClient client = new ServiceClient();
+
+        if (client.getAxisConfiguration().getModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING) != null) {
+
+            client.engageModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING);
+        } else {
+            SOAPHeaderBlock msgId = soapfactory.createSOAPHeaderBlock("MessageID", WsmgNameSpaceConstants.WSA_NS);
+            msgId.setText(uuid);
+
+            SOAPHeaderBlock to = soapfactory.createSOAPHeaderBlock("To", WsmgNameSpaceConstants.WSA_NS);
+            to.setText(opts.getTo().getAddress());
+
+            SOAPHeaderBlock action = soapfactory.createSOAPHeaderBlock("Action", WsmgNameSpaceConstants.WSA_NS);
+            action.setText(message.getNamespace().getNamespaceURI() + "/" + message.getLocalName());
+
+            client.addHeader(action);
+            client.addHeader(msgId);
+            client.addHeader(to);
+        }
+        client.setOptions(opts);
+        return client;
+    }
+
+}