You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ch...@apache.org on 2015/01/27 16:27:03 UTC
[09/13] airavata git commit: retiring ws-messenger and remove
dependency of workflow tracking - AIRAVATA-1556, AIRAVATA-1557
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/amqp/TopicSubscriber.java
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/amqp/TopicSubscriber.java b/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/amqp/TopicSubscriber.java
deleted file mode 100644
index 6516a6b..0000000
--- a/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/amqp/TopicSubscriber.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *
- * 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.amqp;
-
-import java.util.Properties;
-
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.wsmg.client.amqp.rabbitmq.AMQPTopicReceiverImpl;
-
-public class TopicSubscriber {
- public static void main(String args[]) throws AMQPException {
- String host = ServerSettings.getSetting(AMQPUtil.CONFIG_AMQP_PROVIDER_HOST, "localhost");
- String port = ServerSettings.getSetting(AMQPUtil.CONFIG_AMQP_PROVIDER_PORT, "5672");
- String username = ServerSettings.getSetting(AMQPUtil.CONFIG_AMQP_PROVIDER_USERNAME, "guest");
- String password = ServerSettings.getSetting(AMQPUtil.CONFIG_AMQP_PROVIDER_PASSWORD, "guest");
-
- Properties properties = new Properties();
- properties.setProperty(AMQPUtil.CONFIG_AMQP_PROVIDER_HOST, host);
- properties.setProperty(AMQPUtil.CONFIG_AMQP_PROVIDER_PORT, port);
- properties.setProperty(AMQPUtil.CONFIG_AMQP_PROVIDER_USERNAME, username);
- properties.setProperty(AMQPUtil.CONFIG_AMQP_PROVIDER_PASSWORD, password);
-
- MessageConsumer consumer = new MessageConsumer();
- AMQPTopicReceiver receiver = new AMQPTopicReceiverImpl(properties, consumer);
- System.out.println("Waiting for topic messages : \n");
-
- AMQPRoutingKey key = new AMQPRoutingKey("workflowTerminated", "");
- receiver.Subscribe(key);
- }
-
- public static class MessageConsumer implements AMQPCallback {
- public void onMessage(String message) {
- System.out.println("Received : " + message);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ClientUtilTest.java
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ClientUtilTest.java b/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ClientUtilTest.java
deleted file mode 100644
index 9aff14f..0000000
--- a/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ClientUtilTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *
- * 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.util;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-public class ClientUtilTest {
-
- /**
- * Test method for {@link org.apache.airavata.wsmg.util.WsmgUtil#formatURLString(java.lang.String)}.
- */
- @Test
- public void testFormatURLString() {
-
- String url = "http://www.test.com/unit_test";
-
- assertSame(url, ClientUtil.formatURLString(url));
-
- url = "scp://test/test";
-
- assertSame(url, ClientUtil.formatURLString(url));
-
- url = "test/test";
-
- assertTrue(ClientUtil.formatURLString(url).startsWith("http://"));
-
- }
-
- /**
- * Test method for {@link org.apache.airavata.wsmg.util.WsmgUtil#getHostIP()}.
- */
- @Test
- public void testGetHostIP() {
- assertNotNull(ClientUtil.getHostIP());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ConfigKeys.java
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ConfigKeys.java b/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ConfigKeys.java
deleted file mode 100644
index 2a6cce2..0000000
--- a/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ConfigKeys.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *
- * 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.util;
-
-public interface ConfigKeys {
-
- String CONFIG_FILE_NAME = "unit_tests.properties";
-
- String BROKER_EVENTING_SERVICE_EPR = "broker.eventing.service.epr";
- String BROKER_NOTIFICATIONS_SERVICE_EPR = "broker.notification.service.epr";
-
- String CONSUMER_EPR = "consumer.location";
- String CONSUMER_PORT = "consumer.port";
- String TOPIC_SIMPLE = "topic.simple";
- String TOPIC_XPATH = "topic.xpath";
- String AXIS2_REPO = "axis2.repo";
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/TestDcDate.java
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/TestDcDate.java b/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/TestDcDate.java
deleted file mode 100644
index a1ce01b..0000000
--- a/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/TestDcDate.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- *
- * 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.util;
-
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
-public class TestDcDate extends TestCase {
-
- @Test
- public void testDcDate() {
- DcDate d;
-
- // d = new DcDate("1997-07-16T19:20:30.45+01:00");
-
- d = new DcDate(TimeZone.getDefault());
-
- String dc = d.getDcDate();
-
- // System.out.println(getClass()+" dc="+dc);
-
- new DcDate(dc);
- Calendar loc = new GregorianCalendar();
- assertEquals(d.getYear(), loc.get(Calendar.YEAR));
- assertEquals(d.getMonth(), loc.get(Calendar.MONTH) + 1);
- assertEquals(d.getDay(), loc.get(Calendar.DAY_OF_MONTH));
- assertEquals(d.getHour(), loc.get(Calendar.HOUR_OF_DAY));
- assertEquals(d.getMinute(), loc.get(Calendar.MINUTE));
-
- int tzOffset = TimeZone.getDefault().getRawOffset() / (60 * 1000);
- int tzOffsetHours = tzOffset / 60;
- assertEquals(tzOffset, d.getTimeZoneOffset());
-
- DcDate dZ = new DcDate(TimeZone.getTimeZone("GMT"));
-
- // System.out.println(getClass()+" dZ="+dZ);
-
- assertEquals(0, dZ.getTimeZoneOffset());
- // assertEquals(d.getDay() + tzOffset, dZ.getDay()); //may fail!
- int localHour = dZ.getHour() + tzOffsetHours;
- if (localHour > 24) {
- localHour -= 24;
- }
- if (localHour < 0) {
- localHour += 24;
- }
- // assertEquals(d.getHour(), localHour);
-
- //
- d = new DcDate("1997");
- assertEquals(1997, d.getYear());
- //
- d = new DcDate("1997-07");
- assertEquals(1997, d.getYear());
- assertEquals(7, d.getMonth());
- //
- d = new DcDate("1997-07-16");
- assertEquals(1997, d.getYear());
- assertEquals(7, d.getMonth());
- assertEquals(16, d.getDay());
-
- // 1997-07-16T19:20+01:00
- d = new DcDate("1997-07-16T19:20+01:00");
- assertEquals(1997, d.getYear());
- assertEquals(7, d.getMonth());
- assertEquals(16, d.getDay());
- assertEquals(19, d.getHour());
- assertEquals(20, d.getMinute());
- assertEquals(1 * 60, d.getTimeZoneOffset());
- // 1997-07-16T19:20:30+01:00
- d = new DcDate("1997-07-16T19:20:30+01:00");
- // 1997-07-16T19:20:30.45+01:00
- d = new DcDate("1997-07-16T19:20:30.45+01:00");
- assertEquals("45", d.getDecimalFraction());
- // Ex: 2004-04-13T11:53:15.4362784-04:00
- d = new DcDate("2004-04-13T11:53:15.4362784-04:00");
- assertEquals(13, d.getDay());
- assertEquals("4362784", d.getDecimalFraction());
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/gui/GUITest.java
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/gui/GUITest.java b/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/gui/GUITest.java
deleted file mode 100644
index e5bd2a2..0000000
--- a/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/gui/GUITest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- *
- * 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.gui;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class GUITest {
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testGUI() {
- NotificationViewer.main(null);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/commons/pom.xml
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/commons/pom.xml b/modules/ws-messenger/commons/pom.xml
deleted file mode 100644
index 36dfb62..0000000
--- a/modules/ws-messenger/commons/pom.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--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. -->
-
-<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>
- <groupId>org.apache.airavata</groupId>
- <artifactId>airavata-ws-messenger</artifactId>
- <version>0.15-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>airavata-messenger-commons</artifactId>
- <name>Airavata Messenger Commons</name>
- <url>http://airavata.apache.org/</url>
- <packaging>jar</packaging>
-
- <dependencies>
- <!-- 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.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/CommonRoutines.java
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/CommonRoutines.java b/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/CommonRoutines.java
deleted file mode 100644
index 4c97419..0000000
--- a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/CommonRoutines.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- *
- * 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.commons;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.net.SocketAddress;
-import java.net.SocketTimeoutException;
-import java.net.URI;
-import java.net.UnknownHostException;
-import java.text.DateFormat;
-import java.text.DecimalFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.util.UUIDGenerator;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.SOAPHeaderBlock;
-import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
-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 CommonRoutines {
-
- private static XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
- private static XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance();
-
- // Format date to string like "2004-06-26T21:07:00.000-08:00"
- public static String getXsdDateTime(Date time) {
- Date now = time;
- DateFormat ISO8601Local = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
- TimeZone timeZone = TimeZone.getDefault();
- ISO8601Local.setTimeZone(timeZone);
- int offset = timeZone.getOffset(now.getTime());
- String sign = "+";
- if (offset < 0) {
- offset = -offset;
- sign = "-";
- }
- int hours = offset / 3600000;
- int minutes = (offset - hours * 3600000) / 60000;
- if (offset != hours * 3600000 + minutes * 60000) {
- // E.g. TZ=Asia/Riyadh87
- throw new RuntimeException("TimeZone offset (" + sign + offset + " ms) is not an exact number of minutes");
- }
- DecimalFormat twoDigits = new DecimalFormat("00");
- String ISO8601Now = ISO8601Local.format(now) + sign + twoDigits.format(hours) + ":" + twoDigits.format(minutes);
- return ISO8601Now;
- }
-
- public static SOAPEnvelope reader2SOAPEnvelope(Reader reader) throws XMLStreamException {
-
- XMLStreamReader inflow = getXMLInputFactory().createXMLStreamReader(reader);
-
- StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow);
- SOAPEnvelope omEnvelope = builder.getSOAPEnvelope();
- return omEnvelope;
- }
-
- private static XMLInputFactory getXMLInputFactory() {
- return xmlInputFactory;
- }
-
- private static XMLOutputFactory getXMLOutputFactory() {
- return xmlOutputFactory;
- }
-
- public static OMElement reader2OMElement(Reader reader) throws XMLStreamException {
-
- XMLStreamReader inflow = getXMLInputFactory().createXMLStreamReader(reader);
-
- StAXOMBuilder builder = new StAXOMBuilder(inflow);
- OMElement omElement = builder.getDocumentElement();
- return omElement;
- }
-
- public static String omToString(OMElement element) {
-
- StringWriter writer = new StringWriter();
-
- String ret = null;
- try {
- XMLStreamWriter streamWriter = getXMLOutputFactory().createXMLStreamWriter(writer);
-
- element.serializeAndConsume(streamWriter);
- streamWriter.flush();
- ret = writer.toString();
-
- } catch (Exception e) {
- throw new RuntimeException("unable to serialize the OMElement", e);
- }
- return ret;
- }
-
- public static boolean isAvailable(URI address) {
- // Create a socket with a timeout
- try {
- // exclude message box URL from availability check.
- // if(addressString.indexOf("MsgBox")>0) return true;
- // How to parse the address to port
- InetAddress addr = InetAddress.getByName(address.getHost());
- int port = address.getPort();
- if (port == -1) { // URI has no port, invalid URI. Here I choose not
- // to try port 80.
- return false;
- }
- SocketAddress sockaddr = new InetSocketAddress(addr, port);
-
- // Create an unbound socket
- Socket sock = new Socket();
-
- // This method will block no more than timeoutMs.
- // If the timeout occurs, SocketTimeoutException is thrown.
- int timeoutMs = 1000; // 2 seconds
- sock.connect(sockaddr, timeoutMs);
- sock.close();
- // System.out.println("Still
- // availabe:"+address.getHost()+":"+address.getPort());
- } catch (UnknownHostException e) {
- // e.printStackTrace();
- return false;
- } catch (SocketTimeoutException e) {
- // e.printStackTrace();
- return false;
- } catch (IOException e) {
- // e.printStackTrace();
- return false;
- }
-
- return true;
- }
-
- public static String readFromStream(InputStream in) throws IOException {
- StringBuffer wsdlStr = new StringBuffer();
-
- int read;
-
- byte[] buf = new byte[1024];
- while ((read = in.read(buf)) > 0) {
- wsdlStr.append(new String(buf, 0, read));
- }
- in.close();
- return wsdlStr.toString();
- }
-
- public static Options getOptions(String soapAction, long timeout, EndpointReference destination) {
- Options opts = new Options();
- opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
- opts.setAction(soapAction);
-
- opts.setTimeOutInMilliSeconds(timeout);
- opts.setMessageId(UUIDGenerator.getUUID());
- opts.setTo(destination);
-
- return opts;
- }
-
- public static void setHeaders(String soapAction, String destination, ServiceClient client,
- OMElement... customHeaders) throws AxisFault {
-
- SOAPFactory soapfactory = OMAbstractFactory.getSOAP11Factory();
-
- SOAPHeaderBlock msgId = soapfactory.createSOAPHeaderBlock("MessageID", NameSpaceConstants.WSA_NS);
- msgId.setText(UUIDGenerator.getUUID());
-
- SOAPHeaderBlock to = soapfactory.createSOAPHeaderBlock("To", NameSpaceConstants.WSA_NS);
- to.setText(destination);
-
- SOAPHeaderBlock action = soapfactory.createSOAPHeaderBlock("Action", NameSpaceConstants.WSA_NS);
- action.setText(soapAction);
-
- client.addHeader(action);
- client.addHeader(msgId);
- client.addHeader(to);
-
- for (OMElement h : customHeaders) {
- try {
- client.addHeader(org.apache.axiom.om.util.ElementHelper.toSOAPHeaderBlock(h, soapfactory));
- } catch (Exception e) {
- throw AxisFault.makeFault(e);
- }
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/MsgBoxQNameConstants.java
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/MsgBoxQNameConstants.java b/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/MsgBoxQNameConstants.java
deleted file mode 100644
index fdef461..0000000
--- a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/MsgBoxQNameConstants.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *
- * 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.commons;
-
-import javax.xml.namespace.QName;
-
-public class MsgBoxQNameConstants {
-
- public static final QName MSG_BOXID_QNAME = new QName("http://org.apache.airavata/ws-messenger/msgbox/2011/",
- "MsgBoxId", "msgbox");
- public static final QName MSGBOX_STATUS_QNAME = new QName("http://org.apache.airavata/ws-messenger/msgbox/2011/",
- "status", "msgbox");
- public static final QName MSGBOX_MESSAGE_QNAME = new QName("http://org.apache.airavata/ws-messenger/msgbox/2011/",
- "messages", "msgbox");
-
- /*
- * Request
- */
- public static final QName STOREMSG_QNAME = new QName("http://org.apache.airavata/ws-messenger/msgbox/2011/",
- "storeMessages", "msgbox");
- public static final QName DESTROYMSG_QNAME = new QName("http://org.apache.airavata/ws-messenger/msgbox/2011/",
- "destroyMsgBox", "msgbox");
- public static final QName TAKEMSGS_QNAME = new QName("http://org.apache.airavata/ws-messenger/msgbox/2011/",
- "takeMessages", "msgbox");
- public static final QName CREATEMSG_BOX = new QName("http://org.apache.airavata/ws-messenger/msgbox/2011/",
- "createMsgBox", "msgbox");
-
- /*
- * Response
- */
- public static final QName STOREMSG_RESP_QNAME = new QName("http://org.apache.airavata/ws-messenger/msgbox/2011/",
- "storeMessagesResponse", "msgbox");
- public static final QName DESTROY_MSGBOX_RESP_QNAME = new QName(
- "http://org.apache.airavata/ws-messenger/msgbox/2011/", "destroyMsgBoxResponse", "msgbox");
- public static final QName CREATE_MSGBOX_RESP_QNAME = new QName(
- "http://org.apache.airavata/ws-messenger/msgbox/2011/", "createMsgBoxResponse", "msgbox");
- public static final QName TAKE_MSGBOX_RESP_QNAME = new QName(
- "http://org.apache.airavata/ws-messenger/msgbox/2011/", "takeMessagesResponse", "msgbox");
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/NameSpaceConstants.java
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/NameSpaceConstants.java b/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/NameSpaceConstants.java
deleted file mode 100644
index 9fce3ff..0000000
--- a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/NameSpaceConstants.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- *
- * 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.commons;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
-
-public abstract class NameSpaceConstants {
-
- public final static OMFactory factory = OMAbstractFactory.getOMFactory();
-
- public final static OMNamespace WSMG_NS = factory.createOMNamespace(
- "http://org.apache.airavata/ws-messenger/wsmg/2011", "wsmg");
-
- public final static OMNamespace MSG_BOX = factory.createOMNamespace(
- "http://org.apache.airavata/ws-messenger/msgbox/2011", "msgbox");
-
- public final static OMNamespace WIDGET_NS = factory.createOMNamespace("http://widgets.com", "widget");
-
- /**
- * WS Addressing
- */
- public final static OMNamespace WSA_NS = factory.createOMNamespace("http://www.w3.org/2005/08/addressing", "wsa");
-
- /**
- * WS Notification
- *
- * https://www.ibm.com/developerworks/library/specification/ws-notification/
- *
- */
- public final static OMNamespace WSNT_NS = factory.createOMNamespace(
- "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification", "wsnt");
-
- public final static OMNamespace WSBR_NS = factory.createOMNamespace(
- "http://www.ibm.com/xmlns/stdwip/web-services/WS-BrokeredNotification", "wsbn");
-
- /**
- * WS Resource specification namespace
- *
- * http://www.ibm.com/developerworks/webservices/library/specification/ws-resource/
- *
- */
- public final static OMNamespace WSRP_NS = factory.createOMNamespace(
- "http://www.ibm.com/xmlns/stdwip/web-services/WS-ResourceProperties", "wsrp");
-
- public final static OMNamespace WSRL_NS = factory.createOMNamespace(
- "http://www.ibm.com/xmlns/stdwip/web-services/WS-ResourceLifetime", "wsrl");
-
- /**
- * Web Services Eventing (WS-Eventing)
- *
- * http://schemas.xmlsoap.org/ws/2004/08/eventing/
- */
- public final static OMNamespace WSE_NS = factory.createOMNamespace(
- "http://schemas.xmlsoap.org/ws/2004/08/eventing", "wse");
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/WsmgCommonConstants.java
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/WsmgCommonConstants.java b/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/WsmgCommonConstants.java
deleted file mode 100644
index 4e7d245..0000000
--- a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/WsmgCommonConstants.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- *
- * 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.commons;
-
-public class WsmgCommonConstants {
-
- public static final String AXIS_MODULE_NAME_ADDRESSING = "addressing";
-
- public final static String VERSION = WsmgVersion.getSpecVersion(); // "0.14";
-
- public final static String UTF8 = "UTF-8";
-
- public final static String TOPIC_PREFIX = "topic/";
-
- public final static String PREFIX = "" + System.currentTimeMillis();
-
- public final static String SUBSCRIPTION_POLICY = "SubscriptionPolicy";
-
- public final static String SUBSCRIPTION_ID = "Identifier";
-
- public final static String WILDCARD_TOPIC = ">";
-
- public final static String TOPIC_EXPRESSION_SIMPLE_DIALECT = "http://www.ibm.com/xmlns/stdwip/web-services/WS-Topics/TopicExpression/simple";
- public final static String XPATH_DIALECT = "http://www.w3.org/TR/1999/REC-xpath-19991116";
- public final static String TOPIC_AND_XPATH_DIALECT = "http://docs.oasis-open.org/wsn";
-
- public static final String WSMG_PLAIN_TEXT_WRAPPER = "plainTextWrapper";
-
- public static final int WSRM_POLICY_TRUE = 1;
-
- public static final int WSRM_POLICY_FALSE = 0;
-
- public static final String BROKER_SERVICE_LOCATION = "broker.service.location";
-
- public static final String BROKER_WSMGCONFIG = "broker.wsmgconfig";
-
- public static final String BROKER_INITED = "broker.inited";
-
- public static final String EPR_SOURCE_HELPER_TO_OM_GET_EPR_PROPERTIES = "http://www.w3.org/2005/08/addressing";
-
- public final static String WSMG_PUBLISH_SOAP_ACTION = "http://org.apache.airavata/WseNotification";
-
- public static final String STORAGE_TYPE_IN_MEMORY = "memory";
- public static final String STORAGE_TYPE_PERSISTANT = "persistent";
-
- public static final String DELIVERY_METHOD_THREAD_CREW = "pcrew";
- public static final String DELIVERY_METHOD_PARALLEL = "parallel";
- public static final String DELIVERY_METHOD_SERIAL = "serial";
-
- public static final int DEFAULT_SENDING_BATCH_SIZE = 10;
- public static final int DEFAULT_SENDING_THREAD_POOL_SIZE = 4;
-
- public static final long DEFAULT_CLIENT_SOCKET_TIME_OUT_MILLIES = 300000L;
- public static final int DEFAULT_SUBSCRIPTION_EXPIRATION_TIME = 1000 * 60 * 60 * 72; // 72 hours
-
-// public static final String CONFIGURATION_FILE_NAME = "configuration.file.name";
- public static final String CONFIG_JDBC_URL = "broker.jdbc.url";
- public static final String CONFIG_JDBC_DRIVER = "broker.jdbc.driver";
- public static final String CONFIG_START_DELIVERY_THREADS = "broker.start.delivery.thread";
- public static final String CONFIG_DELIVERY_METHOD = "broker.delivery.method";
- public static final String CONFIG_STORAGE_TYPE = "broker.storage.type";
- public static final String CONFIG_SOCKET_TIME_OUT = "broker.socket.timeout";
- public static final String CONFIG_MAX_MESSAGE_DELIVER_RETRIES = "broker.msg.delivery.retries";
- public static final String CONFIG_AXIS2_REPO = "axis2.repository";
- public static final String CONFIG_CONSUMER_URL_EXPIRATION_TIME_GAP = "consumer.expiration.time.gap";
-
- public static final String CONFIG_SENDING_BATCH_SIZE = "sending.batch.size";
- public static final String CONFIG_SENDING_THREAD_POOL_SIZE = "sending.thread.pool.size";
-
-// public static final String BROKER_CONFIGURATION_FILE_NAME = "airavata-server.properties";
-
- public static final String DELIVERY_PROTOCOL = "broker.delivery.protocol";
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/WsmgVersion.java
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/WsmgVersion.java b/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/WsmgVersion.java
deleted file mode 100644
index 8e097eb..0000000
--- a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/WsmgVersion.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- *
- * 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.commons;
-
-public class WsmgVersion {
-
- public final static String SPEC_VERSION = "1.0.0";
-
- private final static String BUILD = "";
-
- private final static String PROJECT_NAME = "WSMG";
-
- private final static String IMPL_VERSION = SPEC_VERSION + BUILD;
-
- private final static String USER_AGENT = PROJECT_NAME + "/" + IMPL_VERSION;
-
- private static int VERSION_MAJOR = -1;
-
- private static int VERSION_MINOR = -1;
-
- private static int VERSION_INCREMENT = -1;
-
- public static String getUserAgent() {
- return USER_AGENT;
- }
-
- public static String getVersion() {
- return SPEC_VERSION;
- }
-
- public static String getSpecVersion() {
- return SPEC_VERSION;
- }
-
- public static String getImplementationVersion() {
- return IMPL_VERSION;
- }
-
- /**
- * Print version when exxecuted from command line.
- */
- public static void main(String[] args) {
- String SPEC_OPT = "-spec";
- String IMPL_OPT = "-impl";
- if (SPEC_OPT.equals(args[0])) {
- System.out.println(SPEC_VERSION);
- } else if (IMPL_OPT.equals(args[0])) {
- System.out.println(IMPL_VERSION);
- } else {
- System.err
- .println(WsmgVersion.class.getName() + " Error: " + SPEC_OPT + " or " + IMPL_OPT + " is required");
- System.exit(1);
- }
-
- }
-
- public static void requireVersionOrExit(String version) {
- try {
- requireVersion(version);
- } catch (Exception ex) {
- ex.printStackTrace(System.err);
- System.err.println("Error: could not find required version " + version + " of " + PROJECT_NAME + ": "
- + ex.getMessage());
- System.err.println("Please make sure that JAR file with " + PROJECT_NAME + " with version " + version
- + " (or higher) is available.");
- System.err.println("Please make sure there is no more than one JAR file with " + PROJECT_NAME);
- System.err.println("Exiting");
- System.exit(1);
- }
- }
-
- /**
- * Version mut be of form M.N[.K] where M is major version, N is minor version and K is icrement. This method
- * returns true if current major version is the same and minor is bigger or equal to current minor verion. If
- * provided major and minor verisons are equals to current version then increment is also checked and check is
- * passed when increment is bigger or equal to current increment version.
- */
- public static void requireVersion(String version) throws IllegalStateException {
- // check dependencies
-
- // NOTE: this is safe as int operations are atomic ...
- if (VERSION_MAJOR < 0)
- extractCurrentVersion();
- int[] parsed;
- try {
- parsed = parseVersion(version);
- } catch (NumberFormatException ex) {
- throw new IllegalStateException("could not parse " + PROJECT_NAME + " version string " + version);
- }
- int major = parsed[0];
- int minor = parsed[1];
- int increment = parsed[2];
-
- if (major != VERSION_MAJOR) {
- throw new IllegalStateException("required " + PROJECT_NAME + " " + version + " has different major version"
- + " from current " + SPEC_VERSION);
- }
- if (minor > VERSION_MINOR) {
- throw new IllegalStateException("required " + PROJECT_NAME + " " + version + " has too big minor version"
- + " when compared to current " + SPEC_VERSION);
- }
- if (minor == VERSION_MINOR) {
- if (increment > VERSION_INCREMENT) {
- throw new IllegalStateException("required " + PROJECT_NAME + " " + version
- + " has too big increment version" + " when compared to current " + SPEC_VERSION);
- }
- }
- }
-
- /**
- * Parse verion string N.M[.K] into thre subcomponents (M=major,N=minor,K=increment) that are returned in array with
- * three elements. M and N must be non negative, and K if present must be positive integer. Increment K is optional
- * and if not present in verion strig it is returned as zero.
- */
- public static int[] parseVersion(String version) throws NumberFormatException {
- int[] parsed = new int[3];
- int firstDot = version.indexOf('.');
- if (firstDot == -1) {
- throw new NumberFormatException("expected version string N.M but there is no dot in " + version);
- }
- String majorVersion = version.substring(0, firstDot);
- parsed[0] = Integer.parseInt(majorVersion);
- if (parsed[0] < 0) {
- throw new NumberFormatException("major N version number in N.M can not be negative in " + version);
- }
- int secondDot = version.indexOf('.', firstDot + 1);
- String minorVersion;
- if (secondDot >= 0) {
- minorVersion = version.substring(firstDot + 1, secondDot);
- } else {
- minorVersion = version.substring(firstDot + 1);
- }
- parsed[1] = Integer.parseInt(minorVersion);
- if (parsed[1] < 0) {
- throw new NumberFormatException("minor M version number in N.M can not be negative in " + version);
- }
- if (secondDot >= 0) {
- String incrementVersion = version.substring(secondDot + 1);
- parsed[2] = Integer.parseInt(incrementVersion);
- if (parsed[2] < 0) {
- throw new NumberFormatException("increment K version number in N.M.K must be positive number in "
- + version);
- }
- }
- return parsed;
- }
-
- private static synchronized void extractCurrentVersion() throws IllegalStateException {
- int[] parsed;
- try {
- parsed = parseVersion(SPEC_VERSION);
- } catch (NumberFormatException ex) {
- throw new IllegalStateException("internal problem: could not parse current " + PROJECT_NAME
- + " version string " + SPEC_VERSION);
- }
- VERSION_MAJOR = parsed[0];
- VERSION_MINOR = parsed[1];
- VERSION_INCREMENT = parsed[2];
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/config/ConfigurationManager.java
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/config/ConfigurationManager.java b/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/config/ConfigurationManager.java
deleted file mode 100644
index 004a98c..0000000
--- a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/config/ConfigurationManager.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- *
- * 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.commons.config;
-
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ConfigurationManager {
- protected static final Logger logger = LoggerFactory.getLogger(ConfigurationManager.class);
-// 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:::" + configFileName, e);
-// }
-// }
-
- public String getConfig(String configName) throws Exception {
- try {
- return ServerSettings.getSetting(configName);
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new Exception(e.getMessage(), e);
- }
- }
-
- public String getConfig(String configName, String defaultVal) {
- return ServerSettings.getSetting(configName, defaultVal);
- }
-
- public int getConfig(String configName, int defaultVal) {
- return Integer.parseInt(getConfig(configName, Integer.toString(defaultVal)));
- }
-
- public long getConfig(String configName, long defaultVal) throws ApplicationSettingsException {
- return Long.parseLong(getConfig(configName, Long.toString(defaultVal)));
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/storage/ConnectionPool.java
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/storage/ConnectionPool.java b/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/storage/ConnectionPool.java
deleted file mode 100644
index 127c0b2..0000000
--- a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/storage/ConnectionPool.java
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- *
- * 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.commons.storage;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Stack;
-import java.util.concurrent.Semaphore;
-
-import javax.sql.DataSource;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A class for preallocating, recycling, and managing JDBC connections.
- */
-public class ConnectionPool {
- private static final Logger logger = LoggerFactory.getLogger(ConnectionPool.class);
-
- private long MAX_IDLE_TIME = 5 * 60 * 1000; // 5 minutes
-
- private String driver;
- private String url;
- private String username;
- private String password;
- private String jdbcUrl;
-
- private int maxConnections;
-
- private boolean autoCommit = true;
- private boolean waitIfBusy;
-
- private Semaphore needConnection = new Semaphore(0);
- private boolean stop;
-
- private Stack<Connection> availableConnections;
- private Stack<Connection> busyConnections;
-
- private HashMap<Connection, Long> lastAccessTimeRecord = new HashMap<Connection, Long>();
-
- private String urlType = "";
-
- private DataSource datasource;
-
- private int transactionIsolation = Connection.TRANSACTION_NONE;
-
- private Thread clenupThread;
- private Thread producerThread;
-
- public ConnectionPool(String driver, String url, String username, String password, int initialConnections,
- int maxConnections, boolean waitIfBusy) throws SQLException {
- this.driver = driver;
- this.url = url;
- this.username = username;
- this.password = password;
- this.urlType = "speratedURL";
- initialize(initialConnections, maxConnections, waitIfBusy);
- }
-
- public ConnectionPool(String driver, String jdbcUrl, int initialConnections, int maxConnections,
- boolean waitIfBusy, boolean autoCommit, int transactionIsolation) throws SQLException {
- this.driver = driver;
- this.jdbcUrl = jdbcUrl;
- this.urlType = "simpleURL";
- this.autoCommit = autoCommit;
- this.transactionIsolation = transactionIsolation;
- initialize(initialConnections, maxConnections, waitIfBusy);
- }
-
- public ConnectionPool(String driver, String jdbcUrl, int initialConnections, int maxConnections, boolean waitIfBusy)
- throws SQLException {
- this.driver = driver;
- this.jdbcUrl = jdbcUrl;
- this.urlType = "simpleURL";
- initialize(initialConnections, maxConnections, waitIfBusy);
- }
-
- public ConnectionPool(DataSource dataSource, int initialConnections, int maxConnections, boolean waitIfBusy)
- throws SQLException {
- this.urlType = "dataSource";
- this.datasource = dataSource;
- initialize(initialConnections, maxConnections, waitIfBusy);
- }
-
- /**
- * Check if this connection pool is auto commit or not
- *
- * @return
- */
- public boolean isAutoCommit() {
- return this.autoCommit;
- }
-
- private void initialize(int initialConnections, int maxConnections, boolean waitIfBusy) throws SQLException {
- this.maxConnections = maxConnections;
- this.waitIfBusy = waitIfBusy;
-
- int sizeOfConnections = (initialConnections > maxConnections) ? maxConnections : initialConnections;
-
- availableConnections = new Stack<Connection>();
- busyConnections = new Stack<Connection>();
-
- for (int i = 0; i < sizeOfConnections; i++) {
- Connection con = makeNewConnection();
- setTimeStamp(con);
- availableConnections.push(con);
-
- }
-
- producerThread = new Thread(new FillUpThread());
- producerThread.start();
-
- clenupThread = new Thread(new CleanUpThread());
- clenupThread.start();
- }
-
- public synchronized Connection getConnection() throws SQLException {
- if (!availableConnections.isEmpty()) {
- Connection existingConnection = availableConnections.pop();
-
- // If connection on available list is closed (e.g.,
- // it timed out), then remove it from available list
- // and race for a connection again.
- if (existingConnection.isClosed()) {
- lastAccessTimeRecord.remove(existingConnection);
- // notifyAll for fairness
- notifyAll();
- } else {
- busyConnections.push(existingConnection);
- setTimeStamp(existingConnection);
- return existingConnection;
- }
- } else if (!waitIfBusy && busyConnections.size() >= maxConnections) {
- // You reached maxConnections limit and waitIfBusy flag is false.
- // Throw SQLException in such a case.
- throw new SQLException("Connection limit reached");
- } else {
-
- if (busyConnections.size() < maxConnections) {
- // available connection is empty, but total number of connection
- // doesn't reach maxConnection. Request for more connection
- needConnection.release();
- }
-
- try {
- // wait for free connection
- wait();
- } catch (InterruptedException ie) {
- }
- }
- // always race for connection forever
- return getConnection();
- }
-
- // This explicitly makes a new connection. Called in
- // the foreground when initializing the ConnectionPool,
- // and called in the background when running.
- private Connection makeNewConnection() throws SQLException {
- try {
- // Load database driver if not already loaded
- Class.forName(driver);
- Connection connection;
- // Establish network connection to database
- if (urlType.equals("speratedURL")) {
- connection = DriverManager.getConnection(url, username, password);
- } else if (urlType.equals("simpleURL")) {
- connection = DriverManager.getConnection(jdbcUrl);
- } else { // if(urlType.equals("dataSource")){
- connection = datasource.getConnection();
- }
- connection.setTransactionIsolation(this.transactionIsolation);
- connection.setAutoCommit(this.autoCommit);
- return connection;
- } catch (ClassNotFoundException cnfe) {
- // Simplify try/catch blocks of people using this by
- // throwing only one exception type.
- throw new SQLException("Can't find class for driver: " + driver);
- }
- }
-
- private synchronized void fillUpConnection(Connection conn) {
- setTimeStamp(conn);
- availableConnections.push(conn);
-
- // notify all since new connection is created
- notifyAll();
- }
-
- private void setTimeStamp(Connection connection) {
- lastAccessTimeRecord.put(connection, System.currentTimeMillis());
- }
-
- // The database connection cannot be left idle for too long, otherwise TCP
- // connection will be broken.
- /**
- * From http://forums.mysql.com/read.php?39,28450,57460#msg-57460 Okay, then it looks like wait_timeout on the
- * server is killing your connection (it is set to 8 hours of idle time by default). Either set that value higher on
- * your server, or configure your connection pool to not hold connections idle that long (I prefer the latter). Most
- * folks I know that run MySQL with a connection pool in high-load production environments only let connections sit
- * idle for a matter of minutes, since it only takes a few milliseconds to open a connection, and the longer one
- * sits idle the more chance it will go "bad" because of a network hiccup or the MySQL server being restarted.
- *
- * @throws SQLException
- */
- private boolean isConnectionStale(Connection connection) {
- long currentTime = System.currentTimeMillis();
- long lastAccess = lastAccessTimeRecord.get(connection);
- if (currentTime - lastAccess > MAX_IDLE_TIME) {
- return true;
- } else
- return false;
- }
-
- private synchronized void closeStaleConnections() {
- // close idle connections
- Iterator<Connection> iter = availableConnections.iterator();
- while (iter.hasNext()) {
- Connection existingConnection = iter.next();
- if (isConnectionStale(existingConnection)) {
- try {
- existingConnection.close();
- iter.remove();
- } catch (SQLException sql) {
- logger.error(sql.getMessage(), sql);
- }
- }
- }
- // close busy connections that have been checked out for too long.
- // This should not happen since this means program has bug for not
- // releasing connections .
- iter = busyConnections.iterator();
- while (iter.hasNext()) {
- Connection busyConnection = iter.next();
- if (isConnectionStale(busyConnection)) {
- try {
- busyConnection.close();
- iter.remove();
- logger.warn("****Connection has checked out too long. Forced release. Check the program for calling release connection [free(Connection) method]");
- } catch (SQLException sql) {
- logger.error(sql.getMessage(), sql);
- }
- }
- }
- }
-
- public synchronized void free(Connection connection) {
- busyConnections.removeElement(connection);
- availableConnections.addElement(connection);
- // Wake up threads that are waiting for a connection
- notifyAll();
- }
-
- /**
- * Close all the connections. Use with caution: be sure no connections are in use before calling. Note that you are
- * not <I>required</I> to call this when done with a ConnectionPool, since connections are guaranteed to be closed
- * when garbage collected. But this method gives more control regarding when the connections are closed.
- */
- public synchronized void dispose() {
- logger.info("Connection Pool Shutting down");
-
- // stop clean up thread
- this.stop = true;
- this.clenupThread.interrupt();
-
- // stop producer up thread
- this.producerThread.interrupt();
-
- // close all connection
- closeConnections(availableConnections);
- availableConnections = new Stack<Connection>();
- closeConnections(busyConnections);
- busyConnections = new Stack<Connection>();
- lastAccessTimeRecord.clear();
-
- logger.info("All connection is closed");
-
- try {
- this.clenupThread.join();
- this.producerThread.join();
- } catch (Exception e) {
- logger.error("Cannot shutdown cleanup thread", e);
- }
-
- logger.info("Connection Pool Shutdown");
- }
-
- private void closeConnections(Stack<Connection> connections) {
- while (!connections.isEmpty()) {
- Connection connection = connections.pop();
- try {
- if (!connection.isClosed()) {
- connection.close();
- }
- } catch (SQLException sqle) {
- // Ignore errors; garbage collect anyhow
- logger.warn(sqle.getMessage());
- }
- }
- }
-
- public synchronized String toString() {
- String info = "ConnectionPool(" + url + "," + username + ")" + ", available=" + availableConnections.size()
- + ", busy=" + busyConnections.size() + ", max=" + maxConnections;
- return (info);
- }
-
- class CleanUpThread implements Runnable {
- public void run() {
- while (!stop) {
- try {
- Thread.sleep(MAX_IDLE_TIME);
- closeStaleConnections();
- } catch (InterruptedException e) {
- logger.info("Clean up thread is interrupted to close");
- }
- }
- }
- }
-
- class FillUpThread implements Runnable {
- public void run() {
- while (!stop) {
- try {
- // block until get
- needConnection.acquire();
-
- Connection conn = makeNewConnection();
- fillUpConnection(conn);
- } catch (SQLException e) {
- // cannot create connection (increase semaphore value back)
- needConnection.release();
- logger.error(e.getMessage(), e);
- } catch (InterruptedException e) {
- logger.info("Fill up thread is interrupted to close");
- break;
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/storage/DatabaseCreator.java
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/storage/DatabaseCreator.java b/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/storage/DatabaseCreator.java
deleted file mode 100644
index 9ca9c1e..0000000
--- a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/storage/DatabaseCreator.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- *
- * 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.commons.storage;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.sql.Statement;
-import java.util.StringTokenizer;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class creates the database tables required for messagebox and messagebroker with default configuration this
- * class creates embedded derby database in local file system. User can specify required database in appropriate
- * properties files.
- */
-public class DatabaseCreator {
-
- public enum DatabaseType {
- derby("(?i).*derby.*"), mysql("(?i).*mysql.*"), other("");
-
- private String pattern;
-
- private DatabaseType(String matchingPattern) {
- this.pattern = matchingPattern;
- }
-
- public String getMatchingPattern() {
- return this.pattern;
- }
- }
-
- private static DatabaseType[] supportedDatabase = new DatabaseType[] { DatabaseType.derby, DatabaseType.mysql };
-
- private static Logger log = LoggerFactory.getLogger(DatabaseCreator.class);
- private static final String delimiter = ";";
-
- /**
- * Creates database
- *
- * @throws Exception
- */
- public static void createMsgBoxDatabase(Connection conn) throws Exception {
- createDatabase("msgBox", conn);
- }
-
- /**
- * Creates database
- *
- * @throws Exception
- */
- public static void createMsgBrokerDatabase(Connection conn) throws Exception {
- createDatabase("msgBroker", conn);
- }
-
- /**
- * Checks whether database tables are created by using select * on given table name
- *
- * @param tableName
- * Table which should be existed
- * @return <code>true</core> if checkSQL is success, else <code>false</code> .
- */
- public static boolean isDatabaseStructureCreated(String tableName, Connection conn) {
- try {
-
- log.debug("Running a query to test the database tables existence.");
-
- // check whether the tables are already created with a query
- Statement statement = null;
- try {
- statement = conn.createStatement();
- ResultSet rs = statement.executeQuery("select * from " + tableName);
- if (rs != null) {
- rs.close();
- }
- } finally {
- try {
- if (statement != null) {
- statement.close();
- }
- } catch (SQLException e) {
- return false;
- }
- }
- } catch (SQLException e) {
- return false;
- }
-
- return true;
- }
-
- /**
- * executes given sql
- *
- * @param sql
- * @throws Exception
- */
- private static void executeSQL(String sql, Connection conn) throws Exception {
- // Check and ignore empty statements
- if ("".equals(sql.trim())) {
- return;
- }
-
- Statement statement = null;
- try {
- log.debug("SQL : " + sql);
-
- boolean ret;
- int updateCount = 0, updateCountTotal = 0;
- statement = conn.createStatement();
- ret = statement.execute(sql);
- updateCount = statement.getUpdateCount();
- do {
- if (!ret) {
- if (updateCount != -1) {
- updateCountTotal += updateCount;
- }
- }
- ret = statement.getMoreResults();
- if (ret) {
- updateCount = statement.getUpdateCount();
- }
- } while (ret);
-
- log.debug(sql + " : " + updateCountTotal + " rows affected");
-
- SQLWarning warning = conn.getWarnings();
- while (warning != null) {
- log.warn(warning + " sql warning");
- warning = warning.getNextWarning();
- }
- conn.clearWarnings();
- } catch (SQLException e) {
- if (e.getSQLState().equals("X0Y32")) {
- // eliminating the table already exception for the derby
- // database
- log.info("Table Already Exists", e);
- } else {
- throw new Exception("Error occurred while executing : " + sql, e);
- }
- } finally {
- if (statement != null) {
- try {
- statement.close();
- } catch (SQLException e) {
- log.error("Error occurred while closing result set.", e);
- }
- }
- }
- }
-
- /**
- * computes relatational database type using database name
- *
- * @return DatabaseType
- * @throws Exception
- *
- */
- public static DatabaseType getDatabaseType(Connection conn) throws Exception {
- try {
- if (conn != null && (!conn.isClosed())) {
- DatabaseMetaData metaData = conn.getMetaData();
- String databaseProductName = metaData.getDatabaseProductName();
- return checkType(databaseProductName);
- }
- } catch (SQLException e) {
- String msg = "Failed to create Airavatadatabase." + e.getMessage();
- log.error(msg, e);
- throw new Exception(msg, e);
- }
- return DatabaseType.other;
- }
-
- /**
- * Overloaded method with String input
- *
- * @return DatabaseType
- * @throws Exception
- *
- */
- public static DatabaseType getDatabaseType(String dbUrl) throws Exception {
- return checkType(dbUrl);
- }
-
- private static DatabaseType checkType(String text) throws Exception {
- try {
- if (text != null) {
- for (DatabaseType type : supportedDatabase) {
- if (text.matches(type.getMatchingPattern()))
- return type;
- }
- }
- String msg = "Unsupported database: " + text
- + ". Database will not be created automatically by the Airavata. "
- + "Please create the database using appropriate database scripts for " + "the database.";
- throw new Exception(msg);
-
- } catch (SQLException e) {
- String msg = "Failed to create Airavatadatabase." + e.getMessage();
- log.error(msg, e);
- throw new Exception(msg, e);
- }
- }
-
- /**
- * Get scripts location which is prefix + "-" + databaseType + ".sql"
- *
- * @param prefix
- * @param databaseType
- * @return script location
- */
- private static String getScriptLocation(String prefix, DatabaseType databaseType) {
- String scriptName = prefix + "-" + databaseType + ".sql";
- log.debug("Loading database script from :" + scriptName);
- return "database_scripts" + File.separator + scriptName;
- }
-
- private static void createDatabase(String prefix, Connection conn) throws Exception {
- Statement statement = null;
- try {
- conn.setAutoCommit(false);
- statement = conn.createStatement();
- executeSQLScript(getScriptLocation(prefix, DatabaseCreator.getDatabaseType(conn)), conn);
- conn.commit();
- log.debug("Tables are created successfully.");
- } catch (SQLException e) {
- String msg = "Failed to create database tables for Airavata resource store. " + e.getMessage();
- log.error(msg, e);
- conn.rollback();
- throw new Exception(msg, e);
- } finally {
- conn.setAutoCommit(true);
- try {
- if (statement != null) {
- statement.close();
- }
- } catch (SQLException e) {
- log.error("Failed to close statement.", e);
- }
- }
- }
-
- private static void executeSQLScript(String dbscriptName, Connection conn) throws Exception {
- StringBuffer sql = new StringBuffer();
- BufferedReader reader = null;
-
- try {
- InputStream is = DatabaseCreator.class.getClassLoader().getResourceAsStream(dbscriptName);
- if(is == null){
- is = DatabaseCreator.class.getClassLoader().getResourceAsStream((new File(dbscriptName)).getName());
- }
- reader = new BufferedReader(new InputStreamReader(is));
- String line;
- while ((line = reader.readLine()) != null) {
- line = line.trim();
- if (line.startsWith("//")) {
- continue;
- }
- if (line.startsWith("--")) {
- continue;
- }
- StringTokenizer st = new StringTokenizer(line);
- if (st.hasMoreTokens()) {
- String token = st.nextToken();
- if ("REM".equalsIgnoreCase(token)) {
- continue;
- }
- }
- sql.append(" ").append(line);
-
- // SQL defines "--" as a comment to EOL
- // and in Oracle it may contain a hint
- // so we cannot just remove it, instead we must end it
- if (line.indexOf("--") >= 0) {
- sql.append("\n");
- }
- if ((checkStringBufferEndsWith(sql, delimiter))) {
- executeSQL(sql.substring(0, sql.length() - delimiter.length()), conn);
- sql.replace(0, sql.length(), "");
- }
- }
- // Catch any statements not followed by ;
- if (sql.length() > 0) {
- executeSQL(sql.toString(), conn);
- }
- } catch (IOException e) {
- log.error("Error occurred while executing SQL script for creating Airavata database", e);
- throw new Exception("Error occurred while executing SQL script for creating Airavata database", e);
-
- } finally {
- if (reader != null) {
- reader.close();
- }
- }
- }
-
- /**
- * Checks that a string buffer ends up with a given string. It may sound trivial with the existing JDK API but the
- * various implementation among JDKs can make those methods extremely resource intensive and perform poorly due to
- * massive memory allocation and copying. See
- *
- * @param buffer
- * the buffer to perform the check on
- * @param suffix
- * the suffix
- * @return <code>true</code> if the character sequence represented by the argument is a suffix of the character
- * sequence represented by the StringBuffer object; <code>false</code> otherwise. Note that the result will
- * be <code>true</code> if the argument is the empty string.
- */
- public static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix) {
- if (suffix.length() > buffer.length()) {
- return false;
- }
- // this loop is done on purpose to avoid memory allocation performance
- // problems on various JDKs
- // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and
- // implementation is ok though does allocation/copying
- // StringBuffer.toString().endsWith() does massive memory
- // allocation/copying on JDK 1.5
- // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169
- int endIndex = suffix.length() - 1;
- int bufferIndex = buffer.length() - 1;
- while (endIndex >= 0) {
- if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) {
- return false;
- }
- bufferIndex--;
- endIndex--;
- }
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/storage/JdbcStorage.java
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/storage/JdbcStorage.java b/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/storage/JdbcStorage.java
deleted file mode 100644
index 03c4a0a..0000000
--- a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/storage/JdbcStorage.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- *
- * 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.commons.storage;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class JdbcStorage {
- private static Logger log = LoggerFactory.getLogger(JdbcStorage.class);
-
- private ConnectionPool connectionPool;
-
- public JdbcStorage(String jdbcUrl, String jdbcDriver) {
- // default init connection and max connection
- this(3, 50, jdbcUrl, jdbcDriver, true);
- }
-
- public JdbcStorage(int initCon, int maxCon, String url, String driver, boolean enableTransactions) {
- try {
- if (enableTransactions) {
- connectionPool = new ConnectionPool(driver, url, initCon, maxCon, true, false,
- Connection.TRANSACTION_SERIALIZABLE);
- } else {
- connectionPool = new ConnectionPool(driver, url, initCon, maxCon, true);
- }
- } catch (Exception e) {
- throw new RuntimeException("Failed to create database connection pool.", e);
- }
- }
-
- /**
- * Check if this connection pool is auto commit or not
- *
- * @return
- */
- public boolean isAutoCommit() {
- return connectionPool.isAutoCommit();
- }
-
- public void commit(Connection conn) {
- try {
- if (conn != null && !conn.getAutoCommit()) {
- conn.commit();
- }
- } catch (SQLException sqle) {
- log.error("Cannot commit data", sqle);
- }
- }
-
- public void commitAndFree(Connection conn) {
- commit(conn);
- closeConnection(conn);
- }
-
- public void rollback(Connection conn) {
- try {
- if (conn != null && !conn.getAutoCommit()) {
- conn.rollback();
- }
- } catch (SQLException sqle) {
- log.error("Cannot Rollback data", sqle);
- }
- }
-
- public void rollbackAndFree(Connection conn) {
- rollback(conn);
- closeConnection(conn);
- }
-
- public Connection connect() throws SQLException{
-
- Connection conn = null;
- try {
- conn = connectionPool.getConnection();
- } catch (SQLException e) {
- log.error(e.getMessage(), e);
- throw new SQLException(e);
- }
- return conn;
- }
-
- /**
- * This method is provided so that you can have better control over the statement. For example: You can use
- * stmt.setString to convert quotation mark automatically in an UPDATE statement
- *
- * NOTE: Statement is closed after execution
- */
- public int executeUpdateAndClose(PreparedStatement stmt) throws SQLException {
- int rows = 0;
- try {
- rows = stmt.executeUpdate();
- if (rows == 0) {
- log.info("Problem: 0 rows affected by insert/update/delete statement.");
- }
- } finally {
- stmt.close();
- }
- return rows;
- }
-
- public int executeUpdateAndCloseWithPrintLogMessages(PreparedStatement stmt, boolean printLogs) throws SQLException {
- int rows = 0;
- try {
- rows = stmt.executeUpdate();
- if (rows == 0) {
- if(printLogs){
- log.info("Problem: 0 rows affected by insert/update/delete statement.");
- }
- }
- } finally {
- stmt.close();
- }
- return rows;
- }
-
- public int countRow(String tableName, String columnName) throws SQLException {
- String query = new String("SELECT COUNT(" + columnName + ") FROM " + tableName);
- int count = -1;
- Connection conn = null;
- PreparedStatement stmt = null;
- try {
- conn = connectionPool.getConnection();
- stmt = conn.prepareStatement(query);
- ResultSet rs = stmt.executeQuery();
- rs.next();
- count = rs.getInt(1);
- commit(conn);
- } catch (SQLException sql) {
- rollback(conn);
- throw sql;
- } finally {
- try {
- if (stmt != null && !stmt.isClosed()) {
- stmt.close();
- }
- } finally {
- closeConnection(conn);
- }
- }
- return count;
- }
-
- public void quietlyClose(Connection conn, Statement... stmts) {
- if (stmts != null) {
- for (Statement stmt : stmts) {
- try {
- if (stmt != null && !stmt.isClosed()) {
- stmt.close();
- }
- } catch (SQLException sql) {
- log.error(sql.getMessage(), sql);
- }
- }
- }
- closeConnection(conn);
- }
-
- public void closeConnection(Connection conn) {
- if (conn != null) {
- connectionPool.free(conn);
- }
- }
-
- public void closeAllConnections() {
- if (connectionPool != null)
- connectionPool.dispose();
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/util/Axis2Utils.java
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/util/Axis2Utils.java b/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/util/Axis2Utils.java
deleted file mode 100644
index d74b259..0000000
--- a/modules/ws-messenger/commons/src/main/java/org/apache/airavata/wsmg/commons/util/Axis2Utils.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * 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.commons.util;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.dispatchers.AddressingBasedDispatcher;
-import org.apache.axis2.engine.Handler;
-import org.apache.axis2.engine.Phase;
-
-public class Axis2Utils {
-
- public static void overrideAddressingPhaseHander(ConfigurationContext configContext,
- AddressingBasedDispatcher dispatcher) {
-
- List<Phase> inflowPhases = configContext.getAxisConfiguration().getPhasesInfo().getINPhases();
- boolean foundFlag = false;
-
- for (Phase p : inflowPhases) {
-
- if (p.getName().equalsIgnoreCase("Addressing")) {
-
- List<Handler> handlers = p.getHandlers();
-
- for (Iterator<Handler> ite = handlers.iterator(); ite.hasNext();) {
- Handler h = ite.next();
- if (h.getClass().isAssignableFrom(dispatcher.getClass())) {
- p.removeHandler(h.getHandlerDesc());
- break;
- }
- }
-
- p.addHandler(dispatcher, 0);
- foundFlag = true;
- break;
- }
-
- }
-
- if (!foundFlag) {
- throw new RuntimeException("unable to find addressing phase - inside inflow phases");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/message-monitor/pom.xml
----------------------------------------------------------------------
diff --git a/modules/ws-messenger/message-monitor/pom.xml b/modules/ws-messenger/message-monitor/pom.xml
deleted file mode 100644
index 35bc3ff..0000000
--- a/modules/ws-messenger/message-monitor/pom.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--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. -->
-
-<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>
- <groupId>org.apache.airavata</groupId>
- <artifactId>airavata-ws-messenger</artifactId>
- <version>0.15-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>airavata-message-monitor</artifactId>
- <name>Airavata WS Monitor</name>
- <url>http://airavata.apache.org/</url>
- <packaging>jar</packaging>
-
-
- <dependencies>
- <dependency>
- <groupId>org.apache.airavata</groupId>
- <artifactId>airavata-workflow-model-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.airavata</groupId>
- <artifactId>airavata-messenger-commons</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ogce</groupId>
- <artifactId>atomixmiser</artifactId>
- <version>${atomixmiser.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ogce</groupId>
- <artifactId>yfilter</artifactId>
- <version>${yfilter.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.airavata</groupId>
- <artifactId>airavata-common-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>wsdl4j</groupId>
- <artifactId>wsdl4j</artifactId>
- <version>1.6.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-http</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-local</artifactId>
- </dependency>
-
- <!-- Logging -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.airavata</groupId>
- <artifactId>airavata-messenger-client</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- </dependencies>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- </properties>
-</project>