airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sma...@apache.org
Subject svn commit: r1142461 [2/2] - in /incubator/airavata/ws-messaging/trunk/messagebox: ./ .settings/ resources/ src/ src/main/ src/main/org/ src/main/org/apache/ src/main/org/apache/airavata/ src/main/org/apache/airavata/wsmg/ src/main/org/apache/airavata/...
Date Sun, 03 Jul 2011 17:01:45 GMT
Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/StoreMessageHandler.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/StoreMessageHandler.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/StoreMessageHandler.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/StoreMessageHandler.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,121 @@
+/*
+ *
+ * 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.msgbox;
+
+import java.util.List;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingFaultsHelper;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.dispatchers.AddressingBasedDispatcher;
+import org.apache.axis2.engine.Phase;
+import org.apache.axis2.util.JavaUtils;
+import org.apache.log4j.Logger;
+
+public class StoreMessageHandler extends AddressingBasedDispatcher {
+    private static final String WSMG_MSGSTORE_SOAP_ACTION = "http://www.extreme.indiana.edu/xgws/msgbox/2004/storeMessages";
+    private static final String ADDRESSING_VALIDATE_ACTION = "addressing.validateAction";
+    Logger logger = Logger.getLogger(StoreMessageHandler.class);
+    private Phase addressingPhase = null;
+
+    private AxisOperation messageBoxOperation = null;
+
+    public StoreMessageHandler() {
+
+    }
+
+    public org.apache.axis2.engine.Handler.InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+
+        InvocationResponse response = InvocationResponse.CONTINUE;
+        if (msgContext.getAxisService() == null || msgContext.getAxisOperation() == null) {
+
+            boolean validateAction = JavaUtils.isTrue(msgContext.getProperty(ADDRESSING_VALIDATE_ACTION), true);
+            msgContext.setProperty(ADDRESSING_VALIDATE_ACTION, Boolean.valueOf(false));
+
+            response = super.invoke(msgContext);
+
+            if (isForMessageBoxService(msgContext))
+                validateMsgBoxStoreOperation(msgContext);
+            if (validateAction)
+                checkAction(msgContext);
+            msgContext.setProperty(ADDRESSING_VALIDATE_ACTION, Boolean.valueOf(validateAction));
+
+        }
+        return response;
+    }
+
+    private void validateMsgBoxStoreOperation(MessageContext msgContext) {
+        if (msgContext.getAxisOperation() == null) {
+            AxisService service = msgContext.getAxisService();
+            AxisOperation storeMsgOperation = getMessageBoxOperation(service);
+
+            msgContext.setAxisOperation(storeMsgOperation);
+        }
+    }
+
+    private boolean isForMessageBoxService(MessageContext msgContext) {
+        return msgContext.getAxisService() != null && msgContext.getAxisService().getName().equals("MsgBoxService");
+    }
+
+    private AxisOperation getMessageBoxOperation(AxisService msgBoxService) {
+        if (messageBoxOperation == null)
+            messageBoxOperation = msgBoxService.getOperationBySOAPAction(WSMG_MSGSTORE_SOAP_ACTION);
+        return messageBoxOperation;
+    }
+
+    private void checkAction(MessageContext msgContext) throws AxisFault {
+
+        Phase addPhase = getAddressingPhase(msgContext);
+
+        if (addPhase == null) {
+            logger.error("unable to locate addressing phase object");
+        }
+
+        if (msgContext.getCurrentPhaseIndex() + 1 == addPhase.getHandlerCount()) {
+            if (msgContext.getAxisService() == null || msgContext.getAxisOperation() == null)
+                AddressingFaultsHelper.triggerActionNotSupportedFault(msgContext, msgContext.getWSAAction());
+        }
+
+    }
+
+    private Phase getAddressingPhase(MessageContext context) {
+
+        if (addressingPhase == null) {
+
+            List<Phase> inFlowPhases = context.getConfigurationContext().getAxisConfiguration().getPhasesInfo()
+                    .getINPhases();
+
+            for (Phase p : inFlowPhases) {
+                if (p.getName().equalsIgnoreCase("Addressing")) {
+                    addressingPhase = p;
+                }
+            }
+
+        }
+
+        return addressingPhase;
+
+    }
+
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/CreateMsgBox.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/CreateMsgBox.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/CreateMsgBox.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/CreateMsgBox.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,112 @@
+/*
+ *
+ * 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.msgbox.client;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.wsmg.msgbox.util.MsgBoxCommonConstants;
+import org.apache.airavata.wsmg.msgbox.util.MsgBoxNameSpConsts;
+import org.apache.airavata.wsmg.msgbox.util.MsgBoxUtils;
+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.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.log4j.Logger;
+
+public class CreateMsgBox {
+    org.apache.log4j.Logger logger = Logger.getLogger(CreateMsgBox.class);
+    private final OMFactory factory = OMAbstractFactory.getOMFactory();
+    protected String msgBoxEndPointReference;
+    protected long timeoutInMilliSeconds;
+    private String msgBoxId;
+    private OMElement responseEl;
+
+    public CreateMsgBox(String msgBoxLocation, long timeout) {
+        this.msgBoxEndPointReference = msgBoxLocation;
+        responseEl = OMAbstractFactory.getOMFactory().createOMElement(
+                new QName("http://www.extreme.indiana.edu/xgws/msgbox/2004/", "MsgBoxId"));
+
+        timeoutInMilliSeconds = timeout;
+    }
+
+    public long getTimeoutInMilliSeconds() {
+        return timeoutInMilliSeconds;
+    }
+
+    public void setTimeoutInMilliSeconds(long timeout) {
+        timeoutInMilliSeconds = timeout;
+    }
+
+    public EndpointReference execute() throws AxisFault {
+        ServiceClient serviceClient = createServiceClient();
+        OMElement responseMessage = null;
+        try {
+            responseMessage = serviceClient.sendReceive(createMessageEl());
+        } finally {
+            serviceClient.cleanupTransport();
+        }
+
+        if (responseMessage == null) {
+            throw AxisFault.makeFault(new RuntimeException("no response recieved for subscription message"));
+        }
+        String response = responseMessage.getFirstElement().getText();
+        this.responseEl.setText(response);
+        this.msgBoxEndPointReference = MsgBoxUtils.formatMessageBoxUrl(this.msgBoxEndPointReference, response);
+        return new EndpointReference(this.msgBoxEndPointReference);
+    }
+
+    private OMElement createMessageEl() throws AxisFault {
+        OMElement message = factory.createOMElement("createMsgBox", MsgBoxNameSpConsts.MSG_BOX);
+        OMElement msgBoxId = factory.createOMElement("MsgBoxId", MsgBoxNameSpConsts.MSG_BOX);
+        msgBoxId.setText("Create message box");
+        message.addChild(msgBoxId);
+        message.declareNamespace(MsgBoxNameSpConsts.MSG_BOX);
+        return message;
+    }
+
+    private ServiceClient createServiceClient() throws AxisFault {
+        String uuid = UUIDGenerator.getUUID();
+        Options opts = new Options();
+        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+        opts.setTo(new EndpointReference(this.msgBoxEndPointReference));
+        opts.setMessageId(uuid);
+        opts.setAction(MsgBoxNameSpConsts.MSG_BOX.getNamespaceURI() + "/" + "createMsgBox");
+
+        opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds());
+        ServiceClient client = new ServiceClient();
+        try {
+            client.engageModule(MsgBoxCommonConstants.AXIS_MODULE_NAME_ADDRESSING);
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module engaged");
+        } catch (AxisFault e) {
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module not engaged :" + e);
+        }
+        client.setOptions(opts);
+        return client;
+    }
+
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/DestroyMsgBox.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/DestroyMsgBox.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/DestroyMsgBox.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/DestroyMsgBox.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,113 @@
+/*
+ *
+ * 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.msgbox.client;
+
+import org.apache.airavata.wsmg.msgbox.util.MsgBoxCommonConstants;
+import org.apache.airavata.wsmg.msgbox.util.MsgBoxNameSpConsts;
+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.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.log4j.Logger;
+
+public class DestroyMsgBox {
+    private EndpointReference msgBoxEndPointReference = null;
+    private long timeoutInMilliSeconds = 0;
+    org.apache.log4j.Logger logger = Logger.getLogger(DestroyMsgBox.class);
+    private String msgBoxId = null;
+    private final OMFactory factory = OMAbstractFactory.getOMFactory();
+
+    public DestroyMsgBox(EndpointReference msgBoxEpr, long timeout) throws AxisFault {
+        this.msgBoxEndPointReference = msgBoxEpr;
+        this.timeoutInMilliSeconds = timeout;
+        String address = msgBoxEpr.getAddress();
+        int biginIndex = address.indexOf("clientid");
+        if (biginIndex != -1) {
+            msgBoxId = address.substring(biginIndex + "clientid".length() + 1);
+        } else {
+            throw new AxisFault("Invalid Message Box EPR cannot find message box ID");
+        }
+    }
+
+    public long getTimeoutInMilliSeconds() {
+        return timeoutInMilliSeconds;
+    }
+
+    public void setTimeoutInMilliSeconds(long timeout) {
+        timeoutInMilliSeconds = timeout;
+    }
+
+    public String execute() throws AxisFault {
+        OMElement message = createMessageEl(this.msgBoxId);
+        ServiceClient serviceClient = createServiceClient(message);
+
+        OMElement responseMessage = null;
+        try {
+            responseMessage = serviceClient.sendReceive(message);
+        } finally {
+            serviceClient.cleanupTransport();
+        }
+
+        responseMessage = serviceClient.sendReceive(message);
+        if (responseMessage == null) {
+            throw AxisFault.makeFault(new RuntimeException("no response recieved for subscription message"));
+        }
+        return responseMessage.getFirstElement().getText();
+    }
+
+    private OMElement createMessageEl(String msgboxid) throws AxisFault {
+        OMElement message = factory.createOMElement("destroyMsgBox", MsgBoxNameSpConsts.MSG_BOX);
+        OMElement msgBoxId = factory.createOMElement("MsgBoxId", MsgBoxNameSpConsts.MSG_BOX);
+        msgBoxId.setText(msgboxid);
+        message.addChild(msgBoxId);
+        message.declareNamespace(MsgBoxNameSpConsts.MSG_BOX);
+        return message;
+    }
+
+    private ServiceClient createServiceClient(OMElement message) throws AxisFault {
+        String uuid = UUIDGenerator.getUUID();
+        Options opts = new Options();
+        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+        opts.setTo(msgBoxEndPointReference);
+        opts.setMessageId(uuid);
+        opts.setAction(message.getNamespace().getNamespaceURI() + "/" + message.getLocalName());
+
+        opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds());
+
+        ServiceClient client = new ServiceClient();
+        try {
+            client.engageModule(MsgBoxCommonConstants.AXIS_MODULE_NAME_ADDRESSING);
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module engaged");
+        } catch (AxisFault e) {
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module not engaged :" + e);
+        }
+
+        client.setOptions(opts);
+        return client;
+    }
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/MsgBoxClient.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/MsgBoxClient.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/MsgBoxClient.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/MsgBoxClient.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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.msgbox.client;
+
+import java.rmi.RemoteException;
+import java.util.Iterator;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.log4j.Logger;
+
+public class MsgBoxClient {
+
+    int msgsAtOnce = 10;
+    static Logger logger = Logger.getLogger(MsgBoxClient.class);
+
+    public MsgBoxClient() {
+    }
+
+    public EndpointReference createMessageBox(String msgBoxLocation, long timeout) throws RemoteException {
+        CreateMsgBox msgBox = new CreateMsgBox(msgBoxLocation, timeout);
+        return msgBox.execute();
+    }
+
+    public String storeMessage(EndpointReference msgBoxEpr, long timeout, OMElement messageIn) throws RemoteException {
+        StoreMessage strMsg = new StoreMessage(msgBoxEpr, timeout);
+        return strMsg.execute(messageIn);
+    }
+
+    public Iterator<OMElement> takeMessagesFromMsgBox(EndpointReference msgBoxEpr, long timeout) throws RemoteException {
+        TakeMessages takeMsgs = new TakeMessages(msgBoxEpr, timeout);
+        return takeMsgs.execute();
+    }
+
+    public String deleteMsgBox(EndpointReference msgBoxEpr, long timeout) throws RemoteException {
+        DestroyMsgBox destroyMsgBox = new DestroyMsgBox(msgBoxEpr, timeout);
+        return destroyMsgBox.execute();
+    }
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/StoreMessage.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/StoreMessage.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/StoreMessage.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/StoreMessage.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,114 @@
+/*
+ *
+ * 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.msgbox.client;
+
+import org.apache.airavata.wsmg.msgbox.util.MsgBoxCommonConstants;
+import org.apache.airavata.wsmg.msgbox.util.MsgBoxNameSpConsts;
+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.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.log4j.Logger;
+
+public class StoreMessage {
+    private final OMFactory factory = OMAbstractFactory.getOMFactory();
+    protected EndpointReference msgBoxEndPointReference;
+    protected long timeoutInMilliSeconds;
+    org.apache.log4j.Logger logger = Logger.getLogger(StoreMessage.class);
+    private String msgBoxId;
+
+    public StoreMessage(EndpointReference msgBoxEpr, long timeout) throws AxisFault {
+        this.msgBoxEndPointReference = msgBoxEpr;
+        this.timeoutInMilliSeconds = timeout;
+        String address = msgBoxEpr.getAddress();
+        int biginIndex = address.indexOf("clientid");
+        if (biginIndex != -1) {
+            msgBoxId = address.substring(biginIndex + "clientid".length() + 1);
+        } else {
+            throw new AxisFault("Invalid Message Box EPR cannot find message box ID");
+        }
+    }
+
+    public long getTimeoutInMilliSeconds() {
+        return timeoutInMilliSeconds;
+    }
+
+    public void setTimeoutInMilliSeconds(long timeout) {
+        timeoutInMilliSeconds = timeout;
+    }
+
+    public String execute(OMElement messageIn) throws AxisFault {
+        // OMElement message = createMessageEl(this.msgBoxId, messageIn);
+        ServiceClient serviceClient = createServiceClient();
+
+        OMElement responseMessage = null;
+
+        try {
+            responseMessage = serviceClient.sendReceive(messageIn);
+        } finally {
+            serviceClient.cleanupTransport();
+        }
+
+        if (responseMessage == null) {
+            throw AxisFault.makeFault(new RuntimeException("no response recieved for subscription message"));
+        }
+        return responseMessage.getFirstElement().getText();
+    }
+
+    private OMElement createMessageEl(String msgboxid, OMElement messageIn) throws AxisFault {
+        OMElement message = factory.createOMElement("storeMessages", MsgBoxNameSpConsts.MSG_BOX);
+        OMElement messageElement = factory.createOMElement("message", MsgBoxNameSpConsts.MSG_BOX);
+        OMElement msgBoxId = factory.createOMElement("MsgBoxId", MsgBoxNameSpConsts.MSG_BOX);
+        msgBoxId.setText(msgboxid);
+        message.addChild(msgBoxId);
+        messageElement.addChild(messageIn);
+        message.addChild(messageElement);
+        message.declareNamespace(MsgBoxNameSpConsts.MSG_BOX);
+        return message;
+    }
+
+    private ServiceClient createServiceClient() throws AxisFault {
+        String uuid = UUIDGenerator.getUUID();
+        Options opts = new Options();
+        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+        opts.setTo(msgBoxEndPointReference);
+        opts.setMessageId(uuid);
+        opts.setAction(MsgBoxNameSpConsts.MSG_BOX.getNamespaceURI() + "/" + "storeMessages");
+
+        opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds());
+        ServiceClient client = new ServiceClient();
+        try {
+            client.engageModule(MsgBoxCommonConstants.AXIS_MODULE_NAME_ADDRESSING);
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module engaged");
+        } catch (AxisFault e) {
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module not engaged :" + e);
+        }
+        client.setOptions(opts);
+        return client;
+    }
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/TakeMessages.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/TakeMessages.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/TakeMessages.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/TakeMessages.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,118 @@
+/*
+ *
+ * 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.msgbox.client;
+
+import java.util.Iterator;
+
+import org.apache.airavata.wsmg.msgbox.util.MsgBoxCommonConstants;
+import org.apache.airavata.wsmg.msgbox.util.MsgBoxNameSpConsts;
+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.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.log4j.Logger;
+
+public class TakeMessages {
+    private final OMFactory factory = OMAbstractFactory.getOMFactory();
+    protected EndpointReference msgBoxEndPointReference;
+    protected long timeoutInMilliSeconds;
+    private String msgBoxId;
+    org.apache.log4j.Logger logger = Logger.getLogger(TakeMessages.class);
+
+    public TakeMessages(EndpointReference msgBoxEpr, long timeout) throws AxisFault {
+        this.msgBoxEndPointReference = msgBoxEpr;
+        this.timeoutInMilliSeconds = timeout;
+        String address = msgBoxEpr.getAddress();
+        int biginIndex = address.indexOf("clientid");
+        if (biginIndex != -1) {
+            msgBoxId = address.substring(biginIndex + "clientid".length() + 1);
+        } else {
+            throw new AxisFault("Invalid Message Box EPR cannot find message box ID");
+        }
+    }
+
+    public long getTimeoutInMilliSeconds() {
+        return timeoutInMilliSeconds;
+    }
+
+    public void setTimeoutInMilliSeconds(long timeout) {
+        timeoutInMilliSeconds = timeout;
+    }
+
+    public Iterator<OMElement> execute() throws AxisFault {
+        OMElement message = createMessageEl(this.msgBoxId);
+        ServiceClient serviceClient = createServiceClient(message);
+
+        OMElement responseMessage = null;
+        try {
+            responseMessage = serviceClient.sendReceive(message);
+
+            if (responseMessage == null) {
+                throw AxisFault.makeFault(new RuntimeException("no response recieved for subscription message"));
+            }
+
+            responseMessage.build(); // free the input stream.
+
+        } finally {
+            serviceClient.cleanupTransport();
+        }
+
+        Iterator<OMElement> children = responseMessage.getFirstElement().getChildren();
+        return children;
+    }
+
+    private OMElement createMessageEl(String msgboxid) throws AxisFault {
+        OMElement message = factory.createOMElement("takeMessages", MsgBoxNameSpConsts.MSG_BOX);
+        OMElement msgBoxId = factory.createOMElement("MsgBoxId", MsgBoxNameSpConsts.MSG_BOX);
+        msgBoxId.setText(msgboxid);
+        message.addChild(msgBoxId);
+        message.declareNamespace(MsgBoxNameSpConsts.MSG_BOX);
+        return message;
+    }
+
+    private ServiceClient createServiceClient(OMElement message) throws AxisFault {
+        String uuid = UUIDGenerator.getUUID();
+        Options opts = new Options();
+        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+        opts.setTo(msgBoxEndPointReference);
+        opts.setMessageId(uuid);
+        opts.setAction(message.getNamespace().getNamespaceURI() + "/" + message.getLocalName());
+
+        opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds());
+        ServiceClient client = new ServiceClient();
+        try {
+            client.engageModule(MsgBoxCommonConstants.AXIS_MODULE_NAME_ADDRESSING);
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module engaged");
+        } catch (AxisFault e) {
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module not engaged :" + e);
+        }
+
+        client.setOptions(opts);
+        return client;
+    }
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/ConfigKeys.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/ConfigKeys.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/ConfigKeys.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/ConfigKeys.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.msgbox.util;
+
+public class ConfigKeys {
+    public static final String CONFIG_FILE_NAME = "msgBox.properties";
+    public static final String MSG_PRESV_DAYS = "messagePreservationDays";
+    public static final String MSG_PRESV_HRS = "messagePreservationHours";
+    public static final String MSG_PRESV_MINS = "messagePreservationMinutes";
+    public static String JDBC_DRIVER = "msgBox.jdbc.driver";
+    public static String MSG_BOX_JDBC_URL = "msgBox.jdbc.url";
+    public static String USE_DATABSE_STORAGE = "msgBox.usedatabase";
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/ConfigurationManager.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/ConfigurationManager.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/ConfigurationManager.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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.msgbox.util;
+
+import java.util.Properties;
+
+public class ConfigurationManager {
+    protected Properties configurations = new Properties();
+
+    public ConfigurationManager(String configFileName) {
+        try {
+            configurations.load(this.getClass().getClassLoader().getResourceAsStream(configFileName));
+
+        } catch (Exception e) {
+            throw new RuntimeException("unable to load configurations", e);
+        }
+
+    }
+
+    public String getConfig(String configName) {
+
+        return configurations.getProperty(configName);
+    }
+
+    public String getConfig(String configName, String defaultVal) {
+        return configurations.getProperty(configName, defaultVal);
+    }
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxCommonConstants.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxCommonConstants.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxCommonConstants.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxCommonConstants.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,36 @@
+/*
+ *
+ * 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.msgbox.util;
+
+import javax.xml.namespace.QName;
+
+public class MsgBoxCommonConstants {
+
+    public static final String DB_IMPLEMENTED_TRUE = "database.inited";
+    public static final String MSGBOX_STORAGE = "msgbox.storage";
+    public static final String CONF_MANAGER = "conf.manager";
+    public static final String INIT_MSG_BOX_SKELETON_TRUE = "init.msgbox.skeleton";
+    public static final String AXIS_MODULE_NAME_ADDRESSING = "addressing";
+    public static final QName MSG_BOXID_QNAME = new QName("http://www.extreme.indiana.edu/xgws/msgbox/2004/",
+            "MsgBoxId");
+
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxNameSpConsts.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxNameSpConsts.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxNameSpConsts.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxNameSpConsts.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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.msgbox.util;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+
+public class MsgBoxNameSpConsts {
+
+    private final static OMFactory factory = OMAbstractFactory.getOMFactory();
+
+    public final static OMNamespace MSG_BOX = factory.createOMNamespace(
+            "http://www.extreme.indiana.edu/xgws/msgbox/2004", "msg");
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxOperations.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxOperations.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxOperations.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxOperations.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,53 @@
+/*
+ *
+ * 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.msgbox.util;
+
+public enum MsgBoxOperations {
+    STORE_MSGS("storeMessages"), DESTROY_MSGBOX("destroyMsgBox"), TAKE_MSGS("takeMessages"), CREATE_MSGBOX(
+            "createMsgBox");
+
+    private final String name;
+
+    private MsgBoxOperations(String n) {
+        name = n;
+    }
+
+    public String toString() {
+        return name;
+    }
+
+    public boolean equals(String s) {
+        return name.equals(s);
+    }
+
+    public static MsgBoxOperations valueFrom(String s) {
+        for (MsgBoxOperations status : MsgBoxOperations.values()) {
+            if (status.toString().equalsIgnoreCase(s)) {
+                return status;
+            }
+
+        }
+
+        throw new RuntimeException("invalid WsEventingOperation:- " + s);
+
+    }
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxUtils.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxUtils.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxUtils.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxUtils.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,71 @@
+/*
+ *
+ * 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.msgbox.util;
+
+import java.io.Reader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+
+public class MsgBoxUtils {
+
+    public static SOAPEnvelope reader2SOAPEnvilope(Reader reader) throws XMLStreamException {
+        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+        XMLStreamReader inflow = inputFactory.createXMLStreamReader(reader);
+
+        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow);
+        SOAPEnvelope omEnvelope = builder.getSOAPEnvelope();
+        return omEnvelope;
+    }
+
+    public static OMElement reader2OMElement(Reader reader) throws XMLStreamException {
+        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+        XMLStreamReader inflow = inputFactory.createXMLStreamReader(reader);
+
+        StAXOMBuilder builder = new StAXOMBuilder(inflow);
+        OMElement omElement = builder.getDocumentElement();
+        return omElement;
+    }
+
+    public static String formatMessageBoxUrl(String msgBoxServiceUrl, String msgboxId) {
+        return msgBoxServiceUrl.endsWith("/") ? msgBoxServiceUrl + "clientid/" + msgboxId : msgBoxServiceUrl
+                + "/clientid/" + msgboxId;
+    }
+
+    public static String formatURLString(String url) {
+
+        if (url == null) {
+            throw new IllegalArgumentException("url can't be null");
+        }
+
+        if (url.indexOf("//") < 0) {
+            url = "http://" + url; // use default http
+        }
+        return url;
+    }
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/README.txt
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/README.txt?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/README.txt (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/README.txt Sun Jul  3 17:01:43 2011
@@ -0,0 +1,28 @@
+wsmg-msgbox Quick Start Guide- Sample 1 
+=================================
+
+This sample demonstrate how create a message box, how to store a message and retrieve that message and ultimately how to destroy the created
+message box. 
+
+
+
+Pre-Requisites
+==============
+
+Apache Ant 1.7.1 or later
+Apache Axis2 1.5 or later
+
+
+
+Steps:
+======
+
+1) configure and run wsmg-msgbox. please refer wsmg-msgbox user guide to know how to run the wsmg-msgbox.
+
+2) configure 'build.properties' located in the sample directory.
+
+3) set configurations in './conf/configuration.properties' file.
+
+4) run following command:
+      ant run
+      

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/build.properties
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/build.properties?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/build.properties (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/build.properties Sun Jul  3 17:01:43 2011
@@ -0,0 +1,24 @@
+#
+#
+# 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.
+#
+#
+
+
+
+axis2.home=/Apps/axis2-1.5.1

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/build.xml
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/build.xml?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/build.xml (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/build.xml Sun Jul  3 17:01:43 2011
@@ -0,0 +1,80 @@
+<!--
+
+ 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.
+
+-->
+
+<?xml version="1.0"?>
+
+
+<project name="msgboxsamples" default="run" basedir=".">
+
+	<property file="build.properties" />
+	<property name="lib.path" value="../../" />
+	<property name="dest.dir" value="bin" />
+	<property name="src.dir" value="src" />
+	<property name="conf.dir" location="conf" />
+
+	
+
+	<path id="msgbox.class.path">
+		<fileset dir="${lib.path}">
+			<include name="*.jar" />
+		</fileset>
+
+		<fileset dir="${axis2.home}/lib">
+			<include name="*.jar" />
+		</fileset>
+
+		<path location="${conf.dir}" />
+
+		<pathelement location="${dest.dir}" />
+
+	</path>
+
+
+	<target name="clean">
+		<delete dir="${dest.dir}" />
+	</target>
+
+	<target name="build" depends="makeDest">
+		<antcall target="compile" />
+	</target>
+
+	<target name="makeDest">
+		<mkdir dir="${dest.dir}" />
+	</target>
+
+
+	<target name="compile" depends="makeDest">
+		<javac debug="true" srcdir="${src.dir}" destdir="${dest.dir}">
+			<classpath refid="msgbox.class.path" />
+		</javac>
+	</target>
+
+
+	<target name="run" depends="build">
+
+		<java classname="wsmg.samples.msgBox.SimpleMsgBoxExec" fork="true">
+			<classpath refid="msgbox.class.path" />
+		</java>
+
+	</target>
+
+
+</project>

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/conf/configuration.properties
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/conf/configuration.properties?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/conf/configuration.properties (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/conf/configuration.properties Sun Jul  3 17:01:43 2011
@@ -0,0 +1,24 @@
+#
+#
+# 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.
+#
+#
+
+axis2.repository=/Apps/axis2-1.5/lib
+msgbox.service.url=http://localhost:8080/axis2/services/MsgBoxService
+msgbox.id=67889-28837892-33457700-33-4889uu9688--4770333068

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/src/wsmg/samples/msgBox/SimpleMsgBoxExec.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/src/wsmg/samples/msgBox/SimpleMsgBoxExec.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/src/wsmg/samples/msgBox/SimpleMsgBoxExec.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/src/wsmg/samples/msgBox/SimpleMsgBoxExec.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,95 @@
+/*
+ *
+ * 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 wsmg.samples.msgBox;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.UUID;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.addressing.EndpointReference;
+
+import wsmg.samples.util.ConfigKeys;
+import edu.indiana.extreme.www.xgws.msgbox.client.MsgBoxClient;
+import edu.indiana.extreme.www.xgws.msgbox.util.MsgBoxUtils;
+
+public class SimpleMsgBoxExec {
+
+	private static Properties getDefaults() {
+		Properties defaults = new Properties();
+		defaults.setProperty(ConfigKeys.MSGBOX_SERVICE_URL,
+				"http://localhost:8080/axis2/services/MsgBoxService");
+		return defaults;
+	}
+
+	public static void main(String[] args) throws IOException {
+
+		Properties configurations = new Properties(getDefaults());
+		URL configURL = ClassLoader
+				.getSystemResource(ConfigKeys.CONFIG_FILE_NAME);
+
+		if (configURL != null) {
+			configurations.load(configURL.openStream());
+
+		} else {
+			System.out
+					.println("unable to load configurations defaults will be used");
+		}
+
+		String msgBoxId = UUID.randomUUID().toString();
+		MsgBoxClient client = new MsgBoxClient();
+
+		EndpointReference msgBoxEpr = client.createMessageBox(configurations
+				.getProperty(ConfigKeys.MSGBOX_SERVICE_URL), 500L);
+
+		try {
+			client.storeMessage(msgBoxEpr, 500L, MsgBoxUtils
+					.reader2OMElement(new StringReader(
+							"<test>A simple test message</test>")));
+		} catch (XMLStreamException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		Iterator<OMElement> iterator = client.takeMessagesFromMsgBox(msgBoxEpr,
+				500L);
+		int i = 0;
+		if (iterator != null)
+			while (iterator.hasNext()) {
+				i++;
+				System.out.println("Retrieved message :" + i);
+				try {
+					System.out.println(iterator.next().toStringWithConsume());
+				} catch (XMLStreamException e) {
+					e.printStackTrace();
+				}
+			}
+
+		System.out.println("Delete message box response :  "
+				+ client.deleteMsgBox(msgBoxEpr, 500L));
+	}
+
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/src/wsmg/samples/util/ConfigKeys.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/src/wsmg/samples/util/ConfigKeys.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/src/wsmg/samples/util/ConfigKeys.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/src/wsmg/samples/util/ConfigKeys.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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 wsmg.samples.util;
+
+public class ConfigKeys {
+	
+	public static final String AXIS2_REPO = "axis2.repository";
+	public static final String CONFIG_FILE_NAME = "configuration.properties";
+	public static final String MSGBOX_SERVICE_URL = "msgbox.service.url";
+	public static final String MSGBOX_ID = "msgbox.id";
+
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/InMemoryMessageBoxServer.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/InMemoryMessageBoxServer.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/InMemoryMessageBoxServer.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/InMemoryMessageBoxServer.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,283 @@
+/*
+ *
+ * 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.msgbox.tests;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.airavata.wsmg.msgbox.MsgBoxServiceLifeCycle;
+import org.apache.airavata.wsmg.msgbox.MsgBoxServiceMessageReceiverInOut;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.deployment.DeploymentEngine;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.InOutAxisOperation;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.engine.ListenerManager;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+
+public class InMemoryMessageBoxServer {
+    private static int count = 0;
+
+    private static SimpleHTTPServer receiver;
+
+    public static final int TESTING_PORT = 5555;
+
+    public static final String FAILURE_MESSAGE = "Intentional Failure";
+
+    public static synchronized void deployService(AxisService service) throws AxisFault {
+        receiver.getConfigurationContext().getAxisConfiguration().addService(service);
+    }
+
+    public static synchronized void unDeployService(QName service) throws AxisFault {
+        receiver.getConfigurationContext().getAxisConfiguration().removeService(service.getLocalPart());
+    }
+
+    public static synchronized void unDeployClientService() throws AxisFault {
+        if (receiver.getConfigurationContext().getAxisConfiguration() != null) {
+            receiver.getConfigurationContext().getAxisConfiguration().removeService("AnonymousService");
+        }
+    }
+
+    public static synchronized void start() throws Exception {
+        start(prefixBaseDirectory(Constants.TESTING_REPOSITORY));
+    }
+
+    public static synchronized void start(String repository) throws Exception {
+        if (count == 0) {
+            ConfigurationContext er = getNewConfigurationContext(repository);
+
+            receiver = new SimpleHTTPServer(er, TESTING_PORT);
+
+            try {
+                receiver.start();
+                ListenerManager listenerManager = er.getListenerManager();
+                TransportInDescription trsIn = new TransportInDescription(Constants.TRANSPORT_HTTP);
+                trsIn.setReceiver(receiver);
+                if (listenerManager == null) {
+                    listenerManager = new ListenerManager();
+                    listenerManager.init(er);
+                }
+                listenerManager.addListener(trsIn, true);
+                System.out.print("Server started on port " + TESTING_PORT + ".....");
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        try {
+            Thread.sleep(2000);
+        } catch (InterruptedException e1) {
+            throw new AxisFault("Thread interuptted", e1);
+        }
+
+        count++;
+    }
+
+    public static synchronized void start(String repository, String axis2xml) throws Exception {
+        if (count == 0) {
+            ConfigurationContext er = getNewConfigurationContext(repository, axis2xml);
+
+            receiver = new SimpleHTTPServer(er, TESTING_PORT);
+
+            try {
+                receiver.start();
+                System.out.print("Server started on port " + TESTING_PORT + ".....");
+            } catch (Exception e) {
+                throw AxisFault.makeFault(e);
+            }
+
+            try {
+                Thread.sleep(2000);
+            } catch (InterruptedException e1) {
+                throw new AxisFault("Thread interuptted", e1);
+            }
+            startMessageBox();
+        }
+        count++;
+    }
+
+    public static void startMessageBox() throws Exception {
+
+        AxisService axisService = new AxisService("MsgBoxService");
+        axisService.addParameter("configuration.file.name", "wsmg.broker.properties");
+        axisService.setServiceLifeCycle(new MsgBoxServiceLifeCycle());
+
+        createOperation(axisService, "storeMessages", new MsgBoxServiceMessageReceiverInOut(),
+                "http://www.extreme.indiana.edu/xgws/msgbox/2004/storeMessages",
+                "http://www.extreme.indiana.edu/xgws/msgbox/2004/MsgBoxPT/storeMessagesResponse");
+        createOperation(axisService, "destroyMsgBox", new MsgBoxServiceMessageReceiverInOut(),
+                "http://www.extreme.indiana.edu/xgws/msgbox/2004/destroyMsgBox",
+                "http://www.extreme.indiana.edu/xgws/msgbox/2004/MsgBoxPT/destroyMsgBoxResponse");
+        createOperation(axisService, "takeMessages", new MsgBoxServiceMessageReceiverInOut(),
+                "http://www.extreme.indiana.edu/xgws/msgbox/2004/takeMessages",
+                "http://www.extreme.indiana.edu/xgws/msgbox/2004/MsgBoxPT/takeMessagesResponse");
+        createOperation(axisService, "createMsgBox", new MsgBoxServiceMessageReceiverInOut(),
+                "http://www.extreme.indiana.edu/xgws/msgbox/2004/createMsgBox",
+                "http://www.extreme.indiana.edu/xgws/msgbox/2004/MsgBoxPT/createMsgBoxResponse");
+        axisService.addParameter("configuration.file.name", "msgBox.properties");
+        axisService.addParameter("ServiceClass", "edu.indiana.extreme.www.xgws.msgbox.MsgBoxServiceSkeleton");
+
+        InMemoryMessageBoxServer.deployService(axisService);
+
+        new MsgBoxServiceLifeCycle().startUp(InMemoryMessageBoxServer.getConfigurationContext(), axisService);
+
+    }
+
+    public static void createOperation(AxisService axisService, String name, MessageReceiver messageReceiver,
+            String inputAction, String outputAction) {
+        InOutAxisOperation operation1 = new InOutAxisOperation(new QName(name));
+        operation1.setMessageReceiver(messageReceiver);
+        operation1.setOutputAction(outputAction);
+        axisService.addOperation(operation1);
+        if (inputAction != null) {
+            axisService.mapActionToOperation(inputAction, operation1);
+        }
+    }
+
+    public static ConfigurationContext getNewConfigurationContext(String repository) throws Exception {
+        if (repository != null) {
+            return ConfigurationContextFactory.createConfigurationContextFromFileSystem(repository, repository
+                    + "/conf/axis2.xml");
+        } else {
+            return ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
+        }
+    }
+
+    public static ConfigurationContext getNewConfigurationContext(String repository, String axis2xml) throws Exception {
+        // File file = new File(prefixBaseDirectory(repository));
+        // if (!file.exists()) {
+        // throw new Exception("repository directory "
+        // + file.getAbsolutePath() + " does not exists");
+        // }
+        return ConfigurationContextFactory.createConfigurationContextFromFileSystem(repository, axis2xml);
+    }
+
+    public static synchronized void stop() throws AxisFault {
+        if (count == 1) {
+            receiver.stop();
+            while (receiver.isRunning()) {
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException e1) {
+                    // nothing to do here
+                }
+            }
+            count = 0;
+            // tp.doStop();
+            System.out.print("Server stopped .....");
+        } else {
+            count--;
+        }
+        receiver.getConfigurationContext().terminate();
+    }
+
+    public static ConfigurationContext getConfigurationContext() {
+        return receiver.getConfigurationContext();
+    }
+
+    public static ServiceContext createAdressedEnabledClientSide(AxisService service) throws AxisFault {
+        File file = getAddressingMARFile();
+        TestCase.assertTrue(file.exists());
+        ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(
+                prefixBaseDirectory("target/test-resources/integrationRepo"), null);
+        AxisModule axisModule = DeploymentEngine.buildModule(file, configContext.getAxisConfiguration());
+        configContext.getAxisConfiguration().addModule(axisModule);
+
+        configContext.getAxisConfiguration().addService(service);
+
+        ServiceGroupContext serviceGroupContext = configContext
+                .createServiceGroupContext(service.getAxisServiceGroup());
+        return serviceGroupContext.getServiceContext(service);
+    }
+
+    static class AddressingFilter implements FilenameFilter {
+        public boolean accept(File dir, String name) {
+            return name.startsWith("addressing") && name.endsWith(".mar");
+        }
+    }
+
+    private static File getAddressingMARFile() {
+        File dir = new File(prefixBaseDirectory(Constants.TESTING_REPOSITORY + "/modules"));
+        File[] files = dir.listFiles(new AddressingFilter());
+        TestCase.assertTrue(files.length == 1);
+        File file = files[0];
+        TestCase.assertTrue(file.exists());
+        return file;
+    }
+
+    public static ConfigurationContext createClientConfigurationContext() throws AxisFault {
+        File file = getAddressingMARFile();
+        TestCase.assertTrue(file.exists());
+
+        ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(
+                prefixBaseDirectory(Constants.TESTING_PATH + "/integrationRepo"),
+                prefixBaseDirectory(Constants.TESTING_PATH + "/integrationRepo/conf/axis2.xml"));
+        AxisModule axisModule = DeploymentEngine.buildModule(file, configContext.getAxisConfiguration());
+        configContext.getAxisConfiguration().addModule(axisModule);
+        return configContext;
+    }
+
+    public static ConfigurationContext createClientConfigurationContext(String repo) throws AxisFault {
+        return ConfigurationContextFactory.createConfigurationContextFromFileSystem(repo, repo + "/conf/axis2.xml");
+    }
+
+    public static ServiceContext createAdressedEnabledClientSide(AxisService service, String clientHome)
+            throws AxisFault {
+        File file = getAddressingMARFile();
+        TestCase.assertTrue(file.exists());
+
+        ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(
+                clientHome, null);
+        AxisModule axisModule = DeploymentEngine.buildModule(file, configContext.getAxisConfiguration());
+
+        configContext.getAxisConfiguration().addModule(axisModule);
+        // sysContext.getAxisConfiguration().engageModule(moduleDesc.getName());
+
+        configContext.getAxisConfiguration().addService(service);
+        ServiceGroupContext serviceGroupContext = configContext
+                .createServiceGroupContext(service.getAxisServiceGroup());
+        return serviceGroupContext.getServiceContext(service);
+    }
+
+    public static String prefixBaseDirectory(String path) {
+        // String baseDir;
+        // try {
+        // baseDir = new File(System.getProperty("basedir", ".")).getCanonicalPath();
+        // } catch (IOException e) {
+        // throw new RuntimeException(e);
+        // }
+        // return baseDir + "/" + path;
+        return path;
+    }
+
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/MessageBoxStressTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/MessageBoxStressTest.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/MessageBoxStressTest.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/MessageBoxStressTest.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,115 @@
+/*
+ *
+ * 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.msgbox.tests;
+
+import java.io.StringReader;
+import java.util.Iterator;
+import java.util.UUID;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.airavata.wsmg.msgbox.client.MsgBoxClient;
+import org.apache.airavata.wsmg.msgbox.util.MsgBoxUtils;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.ServiceClient;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class MessageBoxStressTest extends TestCase {
+    private int port = 5555;
+
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+
+    }
+
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        InMemoryMessageBoxServer.start(null, null);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+    }
+
+    @Test
+    public void testMessageBox() throws Exception {
+
+        String msgBoxId = UUID.randomUUID().toString();
+        MsgBoxClient user = new MsgBoxClient();
+
+        // test publish with Epr
+        EndpointReference msgBoxEpr = user.createMessageBox("http://localhost:" + port
+                + "/axis2/services/MsgBoxService", 500L);
+
+        System.out.println(msgBoxEpr.toString());
+        user.storeMessage(msgBoxEpr, 500L,
+                MsgBoxUtils.reader2OMElement(new StringReader("<test>A simple test message</test>")));
+
+        Iterator<OMElement> iterator = user.takeMessagesFromMsgBox(msgBoxEpr, 500L);
+        int i = 0;
+        if (iterator != null)
+            while (iterator.hasNext()) {
+                i++;
+                System.out.println("Retrieved message :" + i);
+                System.out.println(iterator.next().toStringWithConsume());
+            }
+
+        System.out.println("Delete message box response :  " + user.deleteMsgBox(msgBoxEpr, 500L));
+
+        // test invocations with id encoded in the Url
+        msgBoxId = UUID.randomUUID().toString();
+        user = new MsgBoxClient();
+
+        // test publish with Epr
+        msgBoxEpr = user.createMessageBox("http://localhost:" + port + "/axis2/services/MsgBoxService", 500L);
+
+        String mesgboxUrl = "http://localhost:" + port + "/axis2/services/MsgBoxService/clientid/" + msgBoxId;
+
+        ServiceClient client = new ServiceClient();
+        client.getOptions().setTo(new EndpointReference(mesgboxUrl));
+
+        OMElement request = OMAbstractFactory.getOMFactory().createOMElement(new QName("foo"));
+        request.setText("bar");
+        client.sendReceive(request);
+
+        iterator = user.takeMessagesFromMsgBox(new EndpointReference(mesgboxUrl), 500L);
+        assertTrue(iterator.hasNext());
+        iterator.next();
+        assertFalse(iterator.hasNext());
+
+        System.out.println("All tests Done");
+
+    }
+
+}

Added: incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/MsgBoxTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/MsgBoxTest.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/MsgBoxTest.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/MsgBoxTest.java Sun Jul  3 17:01:43 2011
@@ -0,0 +1,108 @@
+/*
+ *
+ * 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.msgbox.tests;
+
+import java.io.StringReader;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.apache.airavata.wsmg.msgbox.client.MsgBoxClient;
+import org.apache.airavata.wsmg.msgbox.util.MsgBoxUtils;
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.addressing.EndpointReference;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class MsgBoxTest extends TestCase {
+
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+
+    }
+
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+    }
+
+    @Before
+    public void setUp() throws Exception {
+    }
+
+    @After
+    public void tearDown() throws Exception {
+    }
+
+    @Test
+    public void testMessageBox() throws Exception {
+
+        String fill = "aaaaaaaaaaa";
+
+        for (int i = 0; i < 5; i++) {
+            fill = fill + fill;
+        }
+
+        System.out.println("fill size : " + fill.length());
+
+        MsgBoxClient user = new MsgBoxClient();
+
+        EndpointReference msgBoxEpr = user
+                .createMessageBox("http://localhost:8080/axis2/services/MsgBoxService", 5000L);
+        /*
+         * user.storeMessage(msgBoxEpr, 500L, MsgBoxUtils .reader2OMElement(new StringReader(
+         * "<test>simple test message 1</test>"))); user.storeMessage(msgBoxEpr, 500L, MsgBoxUtils .reader2OMElement(new
+         * StringReader( "<test>simple test message 2</test>"))); user.storeMessage(msgBoxEpr, 500L, MsgBoxUtils
+         * .reader2OMElement(new StringReader( "<test>simple test message 3</test>"))); user.storeMessage(msgBoxEpr,
+         * 500L, MsgBoxUtils .reader2OMElement(new StringReader( "<test>simple test message 4</test>")));
+         */
+
+        EndpointReference msgBoxEprTcpMon = new EndpointReference(msgBoxEpr.getAddress().replace("8080", "5050"));
+
+        for (int i = 0; i < 10; i++) {
+            String msg = String.format("<msg><seq>%d</seq><fill>%s</fill></msg>", i, fill);
+
+            user.storeMessage(msgBoxEpr, 500L, MsgBoxUtils.reader2OMElement(new StringReader(msg)));
+
+            Thread.sleep(200L);
+        }
+
+        Iterator<OMElement> iterator = null;
+
+        try {
+            iterator = user.takeMessagesFromMsgBox(msgBoxEprTcpMon, 5000L);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        if (iterator != null)
+            while (iterator.hasNext()) {
+
+                System.out.println(iterator.next().toStringWithConsume());
+            }
+
+        System.out.println("Delete message box response :  " + user.deleteMsgBox(msgBoxEpr, 5000L));
+    }
+
+}



Mime
View raw message