You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2011/07/03 19:01:45 UTC
svn commit: r1142461 [1/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/...
Author: smarru
Date: Sun Jul 3 17:01:43 2011
New Revision: 1142461
URL: http://svn.apache.org/viewvc?rev=1142461&view=rev
Log:
cleaned up messagebox
Added:
incubator/airavata/ws-messaging/trunk/messagebox/
incubator/airavata/ws-messaging/trunk/messagebox/.classpath
incubator/airavata/ws-messaging/trunk/messagebox/.project
incubator/airavata/ws-messaging/trunk/messagebox/.settings/
incubator/airavata/ws-messaging/trunk/messagebox/.settings/org.eclipse.jdt.core.prefs
incubator/airavata/ws-messaging/trunk/messagebox/.settings/org.maven.ide.eclipse.prefs
incubator/airavata/ws-messaging/trunk/messagebox/pom.xml
incubator/airavata/ws-messaging/trunk/messagebox/resources/
incubator/airavata/ws-messaging/trunk/messagebox/resources/log4j.properties
incubator/airavata/ws-messaging/trunk/messagebox/resources/msgBox.properties
incubator/airavata/ws-messaging/trunk/messagebox/resources/msgbox_tables.sql (with props)
incubator/airavata/ws-messaging/trunk/messagebox/resources/services.xml (with props)
incubator/airavata/ws-messaging/trunk/messagebox/src/
incubator/airavata/ws-messaging/trunk/messagebox/src/main/
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/ConfigurationManager.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/MsgBoxServiceLifeCycle.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/MsgBoxServiceMessageReceiverInOut.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/MsgBoxServiceSkeleton.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/ProcessingContext.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/ConnectionPool.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/DatabaseStorageImpl.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/JdbcStorage.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/MessageBoxDB.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/MsgBoxStorage.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/memory/
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/memory/InMemoryImpl.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/StoreMessageHandler.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/CreateMsgBox.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/DestroyMsgBox.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/MsgBoxClient.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/StoreMessage.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/client/TakeMessages.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/ConfigKeys.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/ConfigurationManager.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxCommonConstants.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxNameSpConsts.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxOperations.java
incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/util/MsgBoxUtils.java
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/README.txt
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/bin/
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/bin/wsmg/
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/bin/wsmg/samples/
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/bin/wsmg/samples/msgBox/
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/bin/wsmg/samples/util/
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/build.properties
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/build.xml
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/conf/
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/conf/configuration.properties
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/src/
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/src/wsmg/
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/src/wsmg/samples/
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/src/wsmg/samples/msgBox/
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/src/wsmg/samples/msgBox/SimpleMsgBoxExec.java
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/src/wsmg/samples/util/
incubator/airavata/ws-messaging/trunk/messagebox/src/samples/msgBoxSample/src/wsmg/samples/util/ConfigKeys.java
incubator/airavata/ws-messaging/trunk/messagebox/src/test/
incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/
incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/
incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/
incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/
incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/
incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/
incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/InMemoryMessageBoxServer.java
incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/MessageBoxStressTest.java
incubator/airavata/ws-messaging/trunk/messagebox/src/test/org/apache/airavata/wsmg/msgbox/tests/MsgBoxTest.java
Added: incubator/airavata/ws-messaging/trunk/messagebox/.classpath
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/.classpath?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/.classpath (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/.classpath Sun Jul 3 17:01:43 2011
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main"/>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: incubator/airavata/ws-messaging/trunk/messagebox/.project
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/.project?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/.project (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/.project Sun Jul 3 17:01:43 2011
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>MessageBox</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
Added: incubator/airavata/ws-messaging/trunk/messagebox/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/.settings/org.eclipse.jdt.core.prefs?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/.settings/org.eclipse.jdt.core.prefs (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/.settings/org.eclipse.jdt.core.prefs Sun Jul 3 17:01:43 2011
@@ -0,0 +1,6 @@
+#Sun Jul 03 12:43:44 EDT 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
Added: incubator/airavata/ws-messaging/trunk/messagebox/.settings/org.maven.ide.eclipse.prefs
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/.settings/org.maven.ide.eclipse.prefs?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/.settings/org.maven.ide.eclipse.prefs (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/.settings/org.maven.ide.eclipse.prefs Sun Jul 3 17:01:43 2011
@@ -0,0 +1,8 @@
+#Sun Jul 03 12:43:44 EDT 2011
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
Added: incubator/airavata/ws-messaging/trunk/messagebox/pom.xml
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/pom.xml?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/pom.xml (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/pom.xml Sun Jul 3 17:01:43 2011
@@ -0,0 +1,112 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <artifactId>ws-messenger</artifactId>
+ <groupId>Airavata</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>Airavata</groupId>
+ <artifactId>MessageBox</artifactId>
+ <packaging>jar</packaging>
+ <name>MessageBox</name>
+ <url>http://incubator.apache.org/airavata/</url>
+
+ <distributionManagement>
+ <repository>
+ <id>extreme-lab-maven2-repository</id>
+ <name>Extreme Lab Maven2 Repository</name>
+ <url>scp://rainier.extreme.indiana.edu/l/extreme/java/repository/</url>
+ </repository>
+ </distributionManagement>
+ <repositories>
+ <repository>
+ <id>m2-snapshot-repository</id>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ <releases>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ <version>${axis2.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.6</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-transport-local</artifactId>
+ <version>1.5</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-transport-http</artifactId>
+ <version>1.5</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-adb</artifactId>
+ <version>${axis2.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <sourceDirectory>src/main</sourceDirectory>
+ <testSourceDirectory>src/test</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-aar-maven-plugin</artifactId>
+ <version>${axis2.version}</version>
+ <configuration>
+ <servicesXmlFile>resources/services.xml</servicesXmlFile>
+ </configuration>
+ <executions>
+ <execution>
+ <id>createAAR</id>
+ <phase>package</phase>
+ <goals>
+ <goal>aar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <resources>
+ <resource>
+ <directory>resources</directory>
+ <targetPath>META-INF</targetPath>
+ <includes>
+ <include>**/*.wsdl</include>
+ <include>**/*.xml</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+ <properties>
+ <axis2.version>1.5</axis2.version>
+ </properties>
+</project>
Added: incubator/airavata/ws-messaging/trunk/messagebox/resources/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/resources/log4j.properties?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/resources/log4j.properties (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/resources/log4j.properties Sun Jul 3 17:01:43 2011
@@ -0,0 +1,6 @@
+### direct log messages to stdout ###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+log4j.rootLogger=info, stdout
Added: incubator/airavata/ws-messaging/trunk/messagebox/resources/msgBox.properties
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/resources/msgBox.properties?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/resources/msgBox.properties (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/resources/msgBox.properties Sun Jul 3 17:01:43 2011
@@ -0,0 +1,7 @@
+msgBox.jdbc.driver=com.mysql.jdbc.Driver
+msgBox.jdbc.url=jdbc:mysql://127.0.0.1:3306/wsmg?user=root&password=root
+msgBox.usedatabase=false
+messagePreservationDays=2
+messagePreservationHours=0
+messagePreservationMinutes=0
+
Added: incubator/airavata/ws-messaging/trunk/messagebox/resources/msgbox_tables.sql
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/resources/msgbox_tables.sql?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/resources/msgbox_tables.sql (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/resources/msgbox_tables.sql Sun Jul 3 17:01:43 2011
@@ -0,0 +1,19 @@
+
+CREATE TABLE `msgBoxes` (
+ `msgboxid` varchar(100) NOT NULL default '',
+ PRIMARY KEY (`msgboxid`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+
+DROP TABLE IF EXISTS msgbox;
+
+CREATE TABLE `msgbox` (
+ `id` int(11) NOT NULL auto_increment,
+ `xml` longblob NOT NULL,
+ `msgboxid` varchar(100) NOT NULL default '""',
+ `messageid` varchar(100) default '""',
+ `soapaction` varchar(100) default '""',
+ `time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`),
+ KEY `MSGBOXID` (`msgboxid`)
+) ENGINE=MyISAM AUTO_INCREMENT=7665 DEFAULT CHARSET=latin1;
\ No newline at end of file
Propchange: incubator/airavata/ws-messaging/trunk/messagebox/resources/msgbox_tables.sql
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/airavata/ws-messaging/trunk/messagebox/resources/services.xml
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/resources/services.xml?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/resources/services.xml (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/resources/services.xml Sun Jul 3 17:01:43 2011
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!-- This file was auto-generated from WSDL -->
+ <!--
+ by the Apache Axis2 version: 1.4 Built on : Apr 26, 2008 (06:24:30
+ EDT)
+ -->
+<serviceGroup>
+ <service name="MsgBoxService" scope="application"
+ class="edu.indiana.extreme.www.xgws.msgbox.MsgBoxServiceLifeCycle">
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/ns/wsdl/in-out"
+ class="edu.indiana.extreme.www.xgws.msgbox.MsgBoxServiceMessageReceiverInOut" />
+ </messageReceivers>
+ <parameter name="ServiceClass">edu.indiana.extreme.www.xgws.msgbox.MsgBoxServiceSkeleton
+ </parameter>
+ <parameter name="useOriginalwsdl">false</parameter>
+ <parameter name="modifyUserWSDLPortAddress">true</parameter>
+ <operation name="storeMessages" mep="http://www.w3.org/ns/wsdl/in-out"
+ namespace="http://www.extreme.indiana.edu/xgws/msgbox/2004/">
+ <actionMapping>http://www.extreme.indiana.edu/xgws/msgbox/2004/storeMessages
+ </actionMapping>
+ <outputActionMapping>http://www.extreme.indiana.edu/xgws/msgbox/2004/MsgBoxPT/storeMessagesResponse
+ </outputActionMapping>
+ </operation>
+ <operation name="destroyMsgBox" mep="http://www.w3.org/ns/wsdl/in-out"
+ namespace="http://www.extreme.indiana.edu/xgws/msgbox/2004/">
+ <actionMapping>http://www.extreme.indiana.edu/xgws/msgbox/2004/destroyMsgBox
+ </actionMapping>
+ <outputActionMapping>http://www.extreme.indiana.edu/xgws/msgbox/2004/MsgBoxPT/destroyMsgBoxResponse
+ </outputActionMapping>
+ </operation>
+ <operation name="takeMessages" mep="http://www.w3.org/ns/wsdl/in-out"
+ namespace="http://www.extreme.indiana.edu/xgws/msgbox/2004/">
+ <actionMapping>http://www.extreme.indiana.edu/xgws/msgbox/2004/takeMessages
+ </actionMapping>
+ <outputActionMapping>http://www.extreme.indiana.edu/xgws/msgbox/2004/MsgBoxPT/takeMessagesResponse
+ </outputActionMapping>
+ </operation>
+ <operation name="createMsgBox" mep="http://www.w3.org/ns/wsdl/in-out"
+ namespace="http://www.extreme.indiana.edu/xgws/msgbox/2004/">
+ <actionMapping>http://www.extreme.indiana.edu/xgws/msgbox/2004/createMsgBox
+ </actionMapping>
+ <outputActionMapping>http://www.extreme.indiana.edu/xgws/msgbox/2004/MsgBoxPT/createMsgBoxResponse
+ </outputActionMapping>
+ </operation>
+ <parameter name="configuration.file.name" locked="false">msgBox.properties</parameter>
+ </service>
+
+</serviceGroup>
Propchange: incubator/airavata/ws-messaging/trunk/messagebox/resources/services.xml
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/ConfigurationManager.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/ConfigurationManager.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/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;
+
+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/MsgBoxServiceLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/MsgBoxServiceLifeCycle.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/MsgBoxServiceLifeCycle.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/MsgBoxServiceLifeCycle.java Sun Jul 3 17:01:43 2011
@@ -0,0 +1,140 @@
+/*
+ *
+ * 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.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.airavata.wsmg.msgbox.Storage.DB_Pool.DatabaseStorageImpl;
+import org.apache.airavata.wsmg.msgbox.Storage.DB_Pool.JdbcStorage;
+import org.apache.airavata.wsmg.msgbox.Storage.memory.InMemoryImpl;
+import org.apache.airavata.wsmg.msgbox.util.ConfigKeys;
+import org.apache.airavata.wsmg.msgbox.util.MsgBoxCommonConstants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.Handler;
+import org.apache.axis2.engine.Phase;
+import org.apache.log4j.Logger;
+
+public class MsgBoxServiceLifeCycle implements org.apache.axis2.engine.ServiceLifeCycle {
+
+ private static final String CONFIGURATION_FILE_NAME = "configuration.file.name";
+ Logger logger = Logger.getLogger(MsgBoxServiceLifeCycle.class);
+ JdbcStorage db;
+
+ public void shutDown(ConfigurationContext configurationcontext, AxisService axisservice) {
+ System.out.println("Message box shutting down");
+ if (db != null)
+ db.closeAllConnections();
+ }
+
+ public void startUp(ConfigurationContext configurationcontext, AxisService axisservice) {
+
+ overrideAddressingPhaseHander(configurationcontext);
+
+ // Load the configuration file from the classpath
+ ConfigurationManager confmanager = new ConfigurationManager("msgBox.properties");
+ configurationcontext.setProperty(MsgBoxCommonConstants.CONF_MANAGER, confmanager);
+ initDatabase(configurationcontext, confmanager);
+ configurationcontext.setProperty(MsgBoxCommonConstants.INIT_MSG_BOX_SKELETON_TRUE, false);
+ }
+
+ public void initDatabase(ConfigurationContext configurationcontext, ConfigurationManager confmanager) {
+
+ boolean dbImplemented = true;
+ if (confmanager.getConfig(ConfigKeys.USE_DATABSE_STORAGE).equalsIgnoreCase("true")) {
+ if (!checkConnection(confmanager)) {
+ logger.fatal("Database creation failure at MsgBoxServiceLifeCycle class. Cannot connect with the database");
+ throw new RuntimeException("Database failure");
+ }
+ db = new JdbcStorage(true, confmanager);
+ try {
+ MsgBoxServiceSkeleton.setStorage(new DatabaseStorageImpl(db));
+ } catch (SQLException e) {
+ throw new RuntimeException("Database failure");
+ }
+ }
+ if (confmanager.getConfig(ConfigKeys.USE_DATABSE_STORAGE).equalsIgnoreCase("false")) {
+ ConcurrentHashMap<String, LinkedList<String>> map = new ConcurrentHashMap<String, LinkedList<String>>();
+ InMemoryImpl tempStor = new InMemoryImpl();
+ tempStor.setMap(map);
+ MsgBoxServiceSkeleton.setStorage(tempStor);
+ dbImplemented = false;
+ }
+
+ configurationcontext.setProperty(MsgBoxCommonConstants.DB_IMPLEMENTED_TRUE, dbImplemented);
+ }
+
+ public boolean checkConnection(ConfigurationManager confmanager) {
+ boolean dbexists = true;
+ Connection conn;
+ try {
+ Class.forName(confmanager.getConfig(ConfigKeys.JDBC_DRIVER)).newInstance();
+ conn = DriverManager.getConnection(confmanager.getConfig(ConfigKeys.MSG_BOX_JDBC_URL));
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ logger.fatal("Database connect is not closed at the test", e);
+ }
+ } catch (Exception e) {
+ logger.fatal("Checked for database connection with provided info. Failed connection", e);
+ dbexists = false;
+ }
+ return dbexists;
+ }
+
+ private void overrideAddressingPhaseHander(ConfigurationContext configContext) {
+ 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(StoreMessageHandler.class)) {
+ p.removeHandler(h.getHandlerDesc());
+ break;
+ }
+ }
+
+ p.addHandler(new StoreMessageHandler(), 0);
+ foundFlag = true;
+ break;
+ }
+
+ }
+
+ if (!foundFlag) {
+ throw new RuntimeException("unable to find addressing phase - inside inflow phases");
+ }
+
+ }
+}
Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/MsgBoxServiceMessageReceiverInOut.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/MsgBoxServiceMessageReceiverInOut.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/MsgBoxServiceMessageReceiverInOut.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/MsgBoxServiceMessageReceiverInOut.java Sun Jul 3 17:01:43 2011
@@ -0,0 +1,154 @@
+/*
+ *
+ * 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 org.apache.airavata.wsmg.msgbox.util.MsgBoxOperations;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.log4j.Logger;
+
+/**
+ * MsgBoxServiceMessageReceiverInOut message receiver
+ */
+
+public class MsgBoxServiceMessageReceiverInOut extends org.apache.axis2.receivers.AbstractInOutMessageReceiver {
+
+ private static org.apache.log4j.Logger logger = Logger.getLogger(MsgBoxServiceMessageReceiverInOut.class);
+
+ public void invokeBusinessLogic(org.apache.axis2.context.MessageContext msgContext,
+ org.apache.axis2.context.MessageContext newMsgContext) throws org.apache.axis2.AxisFault {
+
+ // get the implementation class for the Web Service
+ Object obj = getTheImplementationObject(msgContext);
+
+ MsgBoxServiceSkeleton skel = (MsgBoxServiceSkeleton) obj;
+
+ // Out Envelop
+ org.apache.axiom.soap.SOAPEnvelope envelope = null;
+ // Find the axisOperation that has been set by the Dispatch phase.
+ org.apache.axis2.description.AxisOperation op = msgContext.getOperationContext().getAxisOperation();
+ if (op == null) {
+ throw new org.apache.axis2.AxisFault(
+ "Operation is not located, if this is doclit style the SOAP-ACTION should specified via the SOAP Action to use the RawXMLProvider");
+ }
+
+ String operationName = getOperationName(msgContext);
+ MsgBoxOperations msgType = MsgBoxOperations.valueFrom(operationName);
+ SOAPEnvelope enlp = msgContext.getEnvelope();
+ // set messageboxId
+ String clientId = null;
+ String toAddress = msgContext.getTo().getAddress();
+ int biginIndex = toAddress.indexOf("clientid");
+ clientId = toAddress.substring(biginIndex + "clientid".length() + 1);
+ try {
+ ProcessingContext procCtxt = new ProcessingContext();
+
+ switch (msgType) {
+
+ case STORE_MSGS: {
+ if (biginIndex != -1) {
+
+ procCtxt.setMessage(enlp.getBody().getFirstElement());
+ procCtxt.setMsgBoxId(clientId);
+ procCtxt.setMessageId(msgContext.getMessageID());
+ procCtxt.setSoapAction(msgContext.getSoapAction());
+ OMElement response = skel.storeMessages(procCtxt);
+ envelope = toEnvelope(getSOAPFactory(msgContext), response);
+ }
+
+ else {
+ throw new AxisFault("clientid cannot be found");
+ }
+
+ }
+ break;
+
+ case DESTROY_MSGBOX: {
+ if (biginIndex != -1) {
+ procCtxt.setMsgBoxId(clientId);
+ envelope = toEnvelope(getSOAPFactory(msgContext), skel.destroyMsgBox(procCtxt));
+ } else {
+ throw new AxisFault("clientid cannot be found");
+ }
+ }
+ break;
+
+ case TAKE_MSGS: {
+ if (biginIndex != -1) {
+ procCtxt.setMsgBoxId(clientId);
+ OMElement respEl = skel.takeMessages(procCtxt);
+ envelope = toEnvelope(getSOAPFactory(msgContext), respEl);
+ } else {
+ throw new AxisFault("clientid cannot be found");
+ }
+ }
+ break;
+
+ case CREATE_MSGBOX: {
+ // procCtxt.setMsgBoxId(clientId);
+ OMElement response = skel.createMsgBox();
+ envelope = toEnvelope(getSOAPFactory(msgContext), response);
+
+ }
+ break;
+
+ }
+
+ } catch (Exception e) {
+ logger.fatal("Exception", e);
+ throw new AxisFault("Exception in Message Box ", e);
+ }
+
+ newMsgContext.setEnvelope(envelope);
+ newMsgContext.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+ }
+
+ //
+
+ private org.apache.axiom.soap.SOAPEnvelope toEnvelope(SOAPFactory factory, OMElement response) {
+
+ org.apache.axiom.soap.SOAPEnvelope emptyEnvelope = factory.getDefaultEnvelope();
+ emptyEnvelope.getBody().addChild(response);
+ return emptyEnvelope;
+ }
+
+ protected String getOperationName(MessageContext inMsg) throws AxisFault {
+
+ org.apache.axis2.description.AxisOperation op = inMsg.getOperationContext().getAxisOperation();
+ if (op == null) {
+ throw new AxisFault(
+ "Operation is not located, if this is doclit style the SOAP-ACTION should specified via the SOAP Action to use the RawXMLProvider");
+ }
+
+ java.lang.String operationName = null;
+ if ((op.getName() == null)
+ || ((operationName = org.apache.axis2.util.JavaUtils.xmlNameToJava(op.getName().getLocalPart())) == null)) {
+ throw new AxisFault("invalid operation found");
+ }
+
+ return operationName;
+ }
+
+}// end of class
Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/MsgBoxServiceSkeleton.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/MsgBoxServiceSkeleton.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/MsgBoxServiceSkeleton.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/MsgBoxServiceSkeleton.java Sun Jul 3 17:01:43 2011
@@ -0,0 +1,177 @@
+/*
+ *
+ * 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.io.StringReader;
+import java.sql.SQLException;
+import java.util.LinkedList;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.wsmg.msgbox.Storage.MsgBoxStorage;
+import org.apache.airavata.wsmg.msgbox.Storage.memory.InMemoryImpl;
+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.OMNamespace;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.service.Lifecycle;
+import org.apache.log4j.Logger;
+
+// Referenced classes of package edu.indiana.extreme.www.xgws.msgbox._2004:
+// ProcessingContext
+
+public class MsgBoxServiceSkeleton implements Lifecycle {
+
+ public MsgBoxServiceSkeleton() {
+ dbImplenented = true;
+ }
+
+ public void init(ServiceContext servicecontext) throws AxisFault {
+ }
+
+ public static void setStorage(MsgBoxStorage storageIn) {
+ storage = storageIn;
+ }
+
+ public void destroy(ServiceContext serviceContext) {
+ if (logger.isDebugEnabled())
+ logger.debug("Stopping Service....");
+ if (!dbImplenented)
+ setMap2();
+ }
+
+ public OMElement createMsgBox() throws Exception {
+ OMElement dd = factory.createOMElement(ProcessingContext.CREATE_MSGBOX_RESP_QNAME);
+ String createdMsgBoxId = "";
+ OMNamespace omNs = factory.createOMNamespace("http://www.extreme.indiana.edu/xgws/msgbox/2004/", "ns1");
+ OMElement url = factory.createOMElement("msgboxid", omNs);
+ try {
+ createdMsgBoxId = storage.createMsgBox();
+ } catch (Exception e) {
+ logger.fatal((new StringBuilder()).append("Error creating the message box ").append(createdMsgBoxId)
+ .toString(), e);
+ AxisFault f = new AxisFault((new StringBuilder()).append("Error creating the message box ")
+ .append(createdMsgBoxId).toString(), e);
+ f.setFaultCode("6000");
+ throw f;
+ }
+ url.setText(createdMsgBoxId);
+ dd.addChild(url);
+ return dd;
+ }
+
+ String getRandom(int length) {
+ UUID uuid = UUID.randomUUID();
+ String myRandom = uuid.toString();
+ return myRandom.substring(1, length);
+ }
+
+ public OMElement storeMessages(ProcessingContext procCtxt) throws Exception {
+ String clientid = "";
+ OMElement message = procCtxt.getMessage();
+ OMElement status = factory.createOMElement(new QName((new StringBuilder())
+ .append(MsgBoxNameSpConsts.MSG_BOX.getNamespaceURI()).append("/").toString(), "status", "msg"));
+ if (procCtxt.getMsgBoxAddr() != null)
+ clientid = procCtxt.getMsgBoxAddr();
+ try {
+ storage.putMessageIntoMsgBox(clientid, procCtxt.getMessageId(), procCtxt.soapAction, message);
+ status.setText("true");
+ } catch (SQLException e) {
+ logger.fatal((new StringBuilder()).append("Exception thrown while storing message: ").append(message)
+ .append("in msgbx: ").append(clientid).toString(), e);
+ status.setText("false");
+ }
+ OMElement resp = factory.createOMElement(ProcessingContext.STOREMSG_RESP_QNAME);
+ resp.addChild(status);
+ resp.declareNamespace(MsgBoxNameSpConsts.MSG_BOX);
+ return resp;
+ }
+
+ public OMElement takeMessages(ProcessingContext procCtxt) throws Exception {
+ String key = "";
+ if (procCtxt.getMsgBoxAddr() != null)
+ key = procCtxt.getMsgBoxAddr();
+ OMElement respEl = factory.createOMElement(new QName((new StringBuilder())
+ .append(MsgBoxNameSpConsts.MSG_BOX.getNamespaceURI()).append("/").toString(), "takeMessagesResponse",
+ "msg"));
+ OMElement messageSet = factory.createOMElement(new QName((new StringBuilder())
+ .append(MsgBoxNameSpConsts.MSG_BOX.getNamespaceURI()).append("/").toString(), "messages", "msg"));
+ try {
+ LinkedList<String> list = (LinkedList<String>) storage.takeMessagesFromMsgBox(key);
+ int i = 0;
+ if (list != null)
+ while (list.size() > 0) {
+ messageSet.addChild(MsgBoxUtils.reader2OMElement(new StringReader(list.removeFirst())));
+ i++;
+ }
+ else if (logger.isDebugEnabled())
+ logger.info(" no messages..");
+ } catch (Exception e) {
+ logger.fatal((new StringBuilder()).append("error taking mesages.. of message box.. - ").append(key)
+ .toString(), e);
+ }
+ respEl.addChild(messageSet);
+ respEl.declareNamespace(MsgBoxNameSpConsts.MSG_BOX);
+ return respEl;
+ }
+
+ public OMElement destroyMsgBox(ProcessingContext procCtxt) throws Exception {
+ String addr = "";
+ OMElement statusEl = factory.createOMElement(new QName(ProcessingContext.DESTROY_MSGBOX_RESP_QNAME
+ .getNamespaceURI(), "status"));
+ if (procCtxt.getMsgBoxAddr() != null) {
+ addr = procCtxt.getMsgBoxAddr();
+ storage.destroyMsgBox(addr);
+ statusEl.setText("true");
+ } else {
+ statusEl.setText("false");
+ }
+ OMElement respEl = factory.createOMElement(ProcessingContext.DESTROY_MSGBOX_RESP_QNAME);
+ respEl.addChild(statusEl);
+ return respEl;
+ }
+
+ public void removeAncientMessages() {
+ throw new UnsupportedOperationException("Do not support in memory tmeout of messages");
+ }
+
+ public void setMap2() {
+ logger.debug("storing the map.. method..\n");
+ if (!dbImplenented) {
+ InMemoryImpl mem = (InMemoryImpl) storage;
+ map = mem.getMap();
+ }
+ }
+
+ private static OMFactory factory = OMAbstractFactory.getOMFactory();
+ private static MsgBoxStorage storage;
+ boolean dbImplenented;
+ static Logger logger = Logger.getLogger(MsgBoxServiceSkeleton.class);
+ ConcurrentHashMap map;
+
+}
Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/ProcessingContext.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/ProcessingContext.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/ProcessingContext.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/ProcessingContext.java Sun Jul 3 17:01:43 2011
@@ -0,0 +1,84 @@
+/*
+ *
+ * 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 javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+
+public class ProcessingContext {
+
+ public ProcessingContext() {
+ }
+
+ public OMElement getMessage() {
+ return localMessage;
+ }
+
+ public void setMessage(OMElement param) {
+ localMessage = param;
+ }
+
+ public String getMsgBoxAddr() {
+ return localMsgBoxAddr;
+ }
+
+ public void setMsgBoxId(String param) {
+ localMsgBoxAddr = param;
+ }
+
+ public String getMessageId() {
+ return messageID;
+ }
+
+ public void setMessageId(String param) {
+ messageID = param;
+ }
+
+ public String getSoapAction() {
+ return soapAction;
+ }
+
+ public void setSoapAction(String param) {
+ soapAction = param;
+ }
+
+ protected OMElement localMessage;
+ protected String soapAction;
+ protected String messageID;
+ protected String localMsgBoxAddr;
+ public static final QName STOREMSG_QNAME = new QName("http://www.extreme.indiana.edu/xgws/msgbox/2004/",
+ "storeMessages", "msg");
+ public static final QName DESTROYMSG_QNAME = new QName("http://www.extreme.indiana.edu/xgws/msgbox/2004/",
+ "destroyMsgBox", "msg");
+ public static final QName TAKEMSGS_QNAME = new QName("http://www.extreme.indiana.edu/xgws/msgbox/2004/",
+ "takeMessages", "ns1");
+ public static final QName CREATEMSG_BOX = new QName("http://www.extreme.indiana.edu/xgws/msgbox/2004/",
+ "createMsgBox", "msg");
+ public static final QName STOREMSG_RESP_QNAME = new QName("http://www.extreme.indiana.edu/xgws/msgbox/2004/",
+ "storeMessagesResponse", "msg");
+ public static final QName DESTROY_MSGBOX_RESP_QNAME = new QName("http://www.extreme.indiana.edu/xgws/msgbox/2004/",
+ "destroyMsgBoxResponse", "ns1");
+ public static final QName CREATE_MSGBOX_RESP_QNAME = new QName("http://www.extreme.indiana.edu/xgws/msgbox/2004/",
+ "createMsgBoxResponse", "msg");
+
+}
Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/ConnectionPool.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/ConnectionPool.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/ConnectionPool.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/ConnectionPool.java Sun Jul 3 17:01:43 2011
@@ -0,0 +1,342 @@
+/*
+ *
+ * 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.Storage.DB_Pool;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.sql.DataSource;
+
+import org.apache.log4j.Logger;
+
+/**
+ * A class for preallocating, recycling, and managing JDBC connections.
+ */
+public class ConnectionPool implements Runnable {
+ private long MAX_IDLE_TIME = 5 * 60 * 1000; // 5 minutes
+ private String driver, url, username, password, jdbcUrl;
+
+ private int initialConnections, maxConnections;
+
+ private boolean waitIfBusy;
+
+ private Vector availableConnections, busyConnections;
+
+ private boolean connectionPending = false;
+
+ private HashMap lastAccessTimeRecord = new HashMap();
+
+ private String urlType = "";
+
+ private DataSource datasource;
+
+ private boolean autoCommit = true;
+
+ private int transactionIsolation = Connection.TRANSACTION_NONE;
+ static Logger logger = Logger.getLogger(ConnectionPool.class);
+
+ public ConnectionPool(String driver, String url, String username, String password, int initialConnections,
+ int maxConnections, boolean waitIfBusy) throws SQLException {
+ this(initialConnections, maxConnections, waitIfBusy);
+ this.driver = driver;
+ this.url = url;
+ this.username = username;
+ this.password = password;
+ urlType = "speratedURL";
+ createConnectionPool();
+ }
+
+ public ConnectionPool(String driver, String jdbcUrl, int initialConnections, int maxConnections,
+ boolean waitIfBusy, boolean autoCommit, int transactionIsolation) throws SQLException {
+ this(initialConnections, maxConnections, waitIfBusy);
+ this.driver = driver;
+ this.jdbcUrl = jdbcUrl;
+ urlType = "simpleURL";
+ this.autoCommit = autoCommit;
+ this.transactionIsolation = transactionIsolation;
+ createConnectionPool();
+ }
+
+ public ConnectionPool(String driver, String jdbcUrl, int initialConnections, int maxConnections, boolean waitIfBusy)
+ throws SQLException {
+ this(initialConnections, maxConnections, waitIfBusy);
+ this.driver = driver;
+ this.jdbcUrl = jdbcUrl;
+ urlType = "simpleURL";
+ createConnectionPool();
+ }
+
+ public ConnectionPool(DataSource dataSource, int initialConnections, int maxConnections, boolean waitIfBusy)
+ throws SQLException {
+ this(initialConnections, maxConnections, waitIfBusy);
+ urlType = "dataSource";
+ this.datasource = dataSource;
+ createConnectionPool();
+ }
+
+ protected ConnectionPool(int initialConnections, int maxConnections, boolean waitIfBusy) throws SQLException {
+ this.initialConnections = initialConnections;
+ this.maxConnections = maxConnections;
+ this.waitIfBusy = waitIfBusy;
+ if (initialConnections > maxConnections) {
+ initialConnections = maxConnections;
+ }
+ availableConnections = new Vector(initialConnections);
+ busyConnections = new Vector();
+ CleanUpThread cleanUpThread = new CleanUpThread();
+ new Thread(cleanUpThread).start();
+ }
+
+ private void createConnectionPool() throws SQLException {
+ for (int i = 0; i < initialConnections; i++) {
+ availableConnections.addElement(makeNewConnection());
+ }
+ }
+
+ public synchronized Connection getConnection() throws SQLException {
+ if (!availableConnections.isEmpty()) {
+ Connection existingConnection = (Connection) availableConnections.lastElement();
+ int lastIndex = availableConnections.size() - 1;
+ // System.out.println("ConnectionNo="+lastIndex);
+ availableConnections.removeElementAt(lastIndex);
+
+ ((Long) lastAccessTimeRecord.get(existingConnection)).longValue();
+ // If connection on available list is closed (e.g.,
+ // it timed out), then remove it from available list
+ // and repeat the process of obtaining a connection.
+ // Also wake up threads that were waiting for a
+ // connection because maxConnection limit was reached.
+ if (existingConnection.isClosed()) {
+ notifyAll(); // Freed up a spot for anybody waiting
+ Connection connection = getConnection();
+ setTimeStamp(connection);
+ return (connection);
+ } else {
+ busyConnections.addElement(existingConnection);
+ setTimeStamp(existingConnection);
+ return existingConnection;
+ }
+ } else {
+ // Three possible cases:
+ // 1) You haven't reached maxConnections limit. So
+ // establish one in the background if there isn't
+ // already one pending, then wait for
+ // the next available connection (whether or not
+ // it was the newly established one).
+ // 2) You reached maxConnections limit and waitIfBusy
+ // flag is false. Throw SQLException in such a case.
+ // 3) You reached maxConnections limit and waitIfBusy
+ // flag is true. Then do the same thing as in second
+ // part of step 1: wait for next available connection.
+ if ((totalConnections() < maxConnections) && !connectionPending) {
+ makeBackgroundConnection();
+ } else if (!waitIfBusy) {
+ throw new SQLException("Connection limit reached");
+ }
+ // Wait for either a new connection to be established
+ // (if you called makeBackgroundConnection) or for
+ // an existing connection to be freed up.
+ try {
+ wait();
+ } catch (InterruptedException ie) {
+ }
+ // Someone freed up a connection, so try again.
+ Connection connection = getConnection();
+ setTimeStamp(connection);
+ return connection;
+ }
+ }
+
+ // You can't just make a new connection in the foreground
+ // when none are available, since this can take several
+ // seconds with a slow network connection. Instead,
+ // start a thread that establishes a new connection,
+ // then wait. You get woken up either when the new connection
+ // is established or if someone finishes with an existing
+ // connection.
+ private void makeBackgroundConnection() {
+ connectionPending = true;
+ try {
+ Thread connectThread = new Thread(this);
+ connectThread.start();
+ } catch (OutOfMemoryError oome) {
+ // Give up on new connection
+ }
+ }
+
+ public void run() {
+ try {
+ Connection connection = makeNewConnection();
+ synchronized (this) {
+ availableConnections.addElement(connection);
+ connectionPending = false;
+ notifyAll();
+ }
+ } catch (Exception e) { // SQLException or OutOfMemory
+ // Give up on new connection and wait for existing one
+ // to free up.
+ }
+ }
+
+ // 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);
+ setTimeStamp(connection);
+ 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 void setTimeStamp(Connection connection) {
+ lastAccessTimeRecord.put(connection, Long.valueOf(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) throws SQLException {
+ long currentTime = System.currentTimeMillis();
+ long lastAccess = ((Long) lastAccessTimeRecord.get(connection)).longValue();
+ if (currentTime - lastAccess > MAX_IDLE_TIME) {
+ // connection.close();
+ // System.out.println("*************JDBC Connection Stale!");
+ return true;
+ } else
+ return false;
+ }
+
+ private void closeStaleConnections() throws SQLException {
+ // close idle connections
+ Iterator iter = availableConnections.iterator();
+ while (iter.hasNext()) {
+ Connection existingConnection = (Connection) iter.next();
+ if (isConnectionStale(existingConnection)) {
+ existingConnection.close();
+ iter.remove();
+ }
+ }
+ // close busy connections that have been checked out for too long.
+ // This should not happen sinc ethis means program has bug for not releasing connections .
+ iter = busyConnections.iterator();
+ while (iter.hasNext()) {
+ Connection busyConnection = (Connection) iter.next();
+ if (isConnectionStale(busyConnection)) {
+ iter.remove();
+ busyConnection.close();
+ logger.warn("****Connection has checked out too long. Forced release. Check the program for unReleased connection.");
+ }
+ }
+ }
+
+ public synchronized void free(Connection connection) {
+ busyConnections.removeElement(connection);
+ availableConnections.addElement(connection);
+ // Wake up threads that are waiting for a connection
+ notifyAll();
+ }
+
+ public synchronized int totalConnections() {
+ return (availableConnections.size() + busyConnections.size());
+ }
+
+ /**
+ * 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 closeAllConnections() {
+ closeConnections(availableConnections);
+ availableConnections = new Vector();
+ closeConnections(busyConnections);
+ busyConnections = new Vector();
+ lastAccessTimeRecord.clear();
+ }
+
+ private void closeConnections(Vector connections) {
+ try {
+ for (int i = 0; i < connections.size(); i++) {
+ Connection connection = (Connection) connections.elementAt(i);
+ if (!connection.isClosed()) {
+ connection.close();
+ }
+ }
+ } catch (SQLException sqle) {
+ // Ignore errors; garbage collect anyhow
+ }
+ }
+
+ 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 (true) {
+ try {
+ Thread.sleep(MAX_IDLE_TIME);
+ } catch (InterruptedException e) {
+ logger.warn(e);
+ }
+ try {
+ closeStaleConnections();
+ } catch (SQLException e) {
+ logger.warn(e);
+ // e.printStackTrace();
+ }
+ }
+ }
+ }
+
+}
Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/DatabaseStorageImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/DatabaseStorageImpl.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/DatabaseStorageImpl.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/DatabaseStorageImpl.java Sun Jul 3 17:01:43 2011
@@ -0,0 +1,89 @@
+/*
+ *
+ * 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.Storage.DB_Pool;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.UUID;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.airavata.wsmg.msgbox.Storage.MsgBoxStorage;
+import org.apache.axiom.om.OMElement;
+
+public class DatabaseStorageImpl implements MsgBoxStorage {
+
+ // private MessageBoxDB messageBoxDB;
+
+ // private final static MLogger logger = MLogger.getLogger();
+
+ public DatabaseStorageImpl(JdbcStorage db) throws SQLException {
+ MessageBoxDB.setJdbcStorage(db);
+ }
+
+ public String createMsgBox() throws SQLException, IOException {
+ // String uuid = FastUUIDGen.nextUUID();// generate uuid
+
+ String uuid = UUID.randomUUID().toString();
+ MessageBoxDB.createMsgBx(uuid, "msgBoxes");
+ return uuid;
+ }
+
+ public void destroyMsgBox(String key) throws Exception {
+ try {
+ MessageBoxDB.deleteMessageBox(key);
+ } catch (SQLException e) {
+ throw new Exception("Could not destroy the message box with key " + key, e);
+ }
+ // logger.finest("Message box with key " + key +
+ // " was destroyed successfully");
+
+ }
+
+ public List<String> takeMessagesFromMsgBox(String key) throws Exception {
+ // String[] message;
+ List<String> list = null;
+
+ try {
+ list = MessageBoxDB.removeAllMessagesforClient(key);
+
+ } catch (SQLException e) {
+ throw new Exception("Error reading the message with the key " + key, e);
+ } catch (IOException e) {
+ throw new Exception("Error reading the message with the key " + key, e);
+ }
+
+ return list;
+ }
+
+ public void putMessageIntoMsgBox(String msgBoxID, String messageID, String soapAction, OMElement message)
+ throws SQLException, IOException, XMLStreamException {
+ MessageBoxDB.addMessage(msgBoxID, messageID, soapAction, message);
+ }
+
+ public void removeAncientMessages() throws Exception {
+ MessageBoxDB.removeAncientMessages();
+
+ }
+
+}
Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/JdbcStorage.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/JdbcStorage.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/JdbcStorage.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/JdbcStorage.java Sun Jul 3 17:01:43 2011
@@ -0,0 +1,172 @@
+/*
+ *
+ * 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.Storage.DB_Pool;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.airavata.wsmg.msgbox.ConfigurationManager;
+import org.apache.airavata.wsmg.msgbox.util.ConfigKeys;
+
+public class JdbcStorage {
+
+ private String jdbcUrl = null;
+
+ private String messagePreservationDays;
+
+ private String messagePreservationHours;
+
+ private String messagePreservationMinutes;
+
+ private PreparedStatement stmt = null;
+
+ private ResultSet rs = null;
+
+ private ResultSetMetaData rsmd = null;
+
+ // private Connection conn = null;
+ private ConnectionPool connectionPool;
+
+ private String jdbcDriver;
+
+ public JdbcStorage(boolean enableTransactions, ConfigurationManager configs) {
+
+ jdbcUrl = configs.getConfig(ConfigKeys.MSG_BOX_JDBC_URL);
+ jdbcDriver = configs.getConfig(ConfigKeys.JDBC_DRIVER);
+ this.messagePreservationDays = configs.getConfig(ConfigKeys.MSG_PRESV_DAYS);
+ this.messagePreservationHours = configs.getConfig(ConfigKeys.MSG_PRESV_HRS);
+ this.messagePreservationMinutes = configs.getConfig(ConfigKeys.MSG_PRESV_MINS);
+
+ try {
+ if (enableTransactions) {
+ connectionPool = new ConnectionPool(jdbcDriver, jdbcUrl, 10, 50, true, false,
+ Connection.TRANSACTION_SERIALIZABLE);
+ } else {
+ connectionPool = new ConnectionPool(jdbcDriver, jdbcUrl, 10, 50, true);
+ }
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ throw new RuntimeException("Failed to create database connection poll.", e);
+ }
+
+ }
+
+ public Connection connect() throws SQLException {
+
+ Connection conn = connectionPool.getConnection();
+ return conn;
+ }
+
+ public void closeConnection(Connection conn) throws java.sql.SQLException {
+
+ connectionPool.free(conn);
+ }
+
+ public int update(String query) throws java.sql.SQLException {
+ int result = 0;
+ // connect();
+ Connection conn = connectionPool.getConnection();
+ stmt = conn.prepareStatement(query);
+ result = stmt.executeUpdate();
+ stmt.close();
+ connectionPool.free(conn);
+
+ return result;
+ }
+
+ /**
+ * This method is provided so that yo can have better control over the statement. For example: You can use
+ * stmt.setString to convert quotation mark automatically in an INSERT statement
+ */
+ public int insert(PreparedStatement stmt) throws java.sql.SQLException {
+ int rows = 0;
+
+ rows = stmt.executeUpdate();
+ stmt.close();
+ return rows;
+ }
+
+ public int insert(String query) throws java.sql.SQLException {
+ int rows = 0;
+
+ Connection conn = connectionPool.getConnection();
+ stmt = conn.prepareStatement(query);
+ rows = stmt.executeUpdate();
+ stmt.close();
+ connectionPool.free(conn);
+
+ return rows;
+ }
+
+ public ResultSet query(String query) throws SQLException {
+ Connection conn = connectionPool.getConnection();
+ // Create a scrollable ResultSet so that I can use rs.last() to get
+ // total number of rows without using another COUNT in SQL query
+ Statement lstmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet rs = lstmt.executeQuery(query);
+ connectionPool.free(conn);
+ return rs;
+ }
+
+ public int countRow(String tableName, String columnName) throws java.sql.SQLException {
+ String query = new String("SELECT COUNT(" + columnName + ") FROM " + tableName);
+ Connection conn = connectionPool.getConnection();
+ stmt = conn.prepareStatement(query);
+ rs = stmt.executeQuery();
+ rs.next();
+ int count = rs.getInt(1);
+ stmt.close();
+ connectionPool.free(conn);
+ return count;
+ }
+
+ public int getMessagePreservationDays() {
+ return Integer.parseInt(messagePreservationDays);
+ }
+
+ public int getMessagePreservationHours() {
+ return Integer.parseInt(messagePreservationHours);
+ }
+
+ public int getMessagePreservationMinutes() {
+ return Integer.parseInt(messagePreservationMinutes);
+ }
+
+ public long getInterval() {
+ long interval = this.getMessagePreservationDays() * 24;
+ interval = (interval + this.getMessagePreservationHours()) * 60;
+ interval = (interval + this.getMessagePreservationMinutes()) * 60;
+ interval = interval * 1000;
+ return interval;
+ }
+
+ public void closeAllConnections() {
+ if (connectionPool != null)
+ connectionPool.closeAllConnections();
+ }
+
+}
Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/MessageBoxDB.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/MessageBoxDB.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/MessageBoxDB.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/DB_Pool/MessageBoxDB.java Sun Jul 3 17:01:43 2011
@@ -0,0 +1,183 @@
+/*
+ *
+ * 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.Storage.DB_Pool;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.log4j.Logger;
+
+public class MessageBoxDB {
+
+ static Logger logger = Logger.getLogger(MessageBoxDB.class);
+
+ private static Set<String> msgBoxids;
+
+ public static final String SELECT_ALL_FROM_MSGBOXES = "SELECT * FROM msgBoxes";
+
+ private static JdbcStorage db;
+
+ public static String SQL_STORE_MESSAGE_STATEMENT = "INSERT INTO msgbox (xml, msgboxid, messageid,soapaction) VALUES (?,?,?,?)";
+
+ public static String SQL_CREATE_MSGBOX_STATEMENT = "INSERT INTO %s (msgboxid) VALUES ('%s')";
+
+ public static String SQL_DELETE_ALL_STATEMENT = "DELETE FROM %s WHERE msgboxid='%s'";
+
+ public static String SQL_SELECT_STATEMENT1 = "SELECT * FROM %s WHERE msgboxid='%s' ORDER BY '%s' DESC";
+
+ public static String SQL_DELETE_ANCIENT_STATEMENT = "DELETE FROM %s WHERE time <'%s'";
+
+ public MessageBoxDB(JdbcStorage db) {
+ this.db = db;
+ }
+
+ public static void createMsgBx(String messageBoxId, String tableName) throws SQLException, IOException {
+ if (!msgBoxids.contains(messageBoxId)) {
+ Connection connection = db.connect();
+ Statement statement = connection.createStatement();
+ statement.execute(String.format(SQL_CREATE_MSGBOX_STATEMENT, tableName, messageBoxId));
+ connection.commit();
+ db.closeConnection(connection);
+ msgBoxids.add(messageBoxId);
+ } else
+ throw new AxisFault("The message box ID requested already exists");
+ }
+
+ public static void addMessage(String msgBoxID, String messageID, String soapAction, OMElement message)
+ throws SQLException, IOException, XMLStreamException {
+ if (msgBoxids.contains(msgBoxID)) {
+ Connection connection = db.connect();
+ PreparedStatement stmt = connection.prepareStatement(SQL_STORE_MESSAGE_STATEMENT);
+ byte[] buffer;
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(output);
+ out.writeObject(message.toStringWithConsume());
+ buffer = output.toByteArray();
+ ByteArrayInputStream in = new ByteArrayInputStream(buffer);
+ stmt.setBinaryStream(1, in, buffer.length);
+ stmt.setString(2, msgBoxID);
+ stmt.setString(3, messageID);
+ stmt.setString(4, soapAction);
+ db.insert(stmt);
+ stmt.close();
+ connection.commit();
+ db.closeConnection(connection);
+ } else {
+ throw new AxisFault("Currently a messagebox is not available with given message box id :" + msgBoxID);
+ }
+ }
+
+ public static void deleteMessageBox(String msgBoxId) throws SQLException {
+
+ if (msgBoxids.contains(msgBoxId)) {
+ Connection connection = db.connect();
+ Statement statement = connection.createStatement();
+ statement.execute(String.format(SQL_DELETE_ALL_STATEMENT, "msgbox", msgBoxId));
+ statement.execute(String.format(SQL_DELETE_ALL_STATEMENT, "msgBoxes", msgBoxId));
+ db.closeConnection(connection);
+ msgBoxids.remove(msgBoxId);
+ }
+ }
+
+ public static List<String> removeAllMessagesforClient(String msgBoxId) throws SQLException, IOException,
+ ClassNotFoundException, XMLStreamException {
+ LinkedList<String> list = new LinkedList<String>();
+ if (msgBoxids.contains(msgBoxId)) {
+ Connection connection = db.connect();
+
+ PreparedStatement stmt = connection.prepareStatement(String.format(SQL_SELECT_STATEMENT1, "msgbox",
+ msgBoxId, String.format("%s.%s", "msgbox", "id")));
+ ResultSet resultSet = stmt.executeQuery();
+ resultSet.beforeFirst();
+
+ while (resultSet.next()) {
+ InputStream in = resultSet.getAsciiStream("xml");
+ ObjectInputStream s = new ObjectInputStream(in);
+ String xmlString = (String) s.readObject();
+ System.out.println(xmlString);
+ list.addFirst(xmlString);
+ }
+ resultSet.close();
+ stmt.close();
+ stmt = connection.prepareStatement(String.format(SQL_DELETE_ALL_STATEMENT, "msgbox", msgBoxId));
+ db.insert(stmt);
+ stmt.close();
+ connection.commit();
+ db.closeConnection(connection);
+ }
+ return list;
+ }
+
+ public static void removeAncientMessages() {
+ try {
+ Connection connection = db.connect();
+ long interval = db.getInterval();
+ long persevetime = (System.currentTimeMillis() - interval);
+ PreparedStatement stmt = connection.prepareStatement(String.format(SQL_DELETE_ANCIENT_STATEMENT, "msgBox",
+ persevetime));
+ db.insert(stmt);
+ stmt.close();
+ db.closeConnection(connection);
+ } catch (SQLException e) {
+ logger.fatal("Caught exception while removing old entries from msgbox db table", e);
+ }
+
+ }
+
+ public static void setJdbcStorage(JdbcStorage db2) throws SQLException {
+ db = db2;
+ setMsgBoxidList();
+
+ }
+
+ private static void setMsgBoxidList() throws SQLException {
+ msgBoxids = Collections.synchronizedSet(new HashSet<String>());
+ Connection connection = db.connect();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(SELECT_ALL_FROM_MSGBOXES);
+ while (resultSet.next()) {
+ msgBoxids.add(resultSet.getString("msgboxid"));
+ }
+ statement.close();
+ connection.commit();
+ db.closeConnection(connection);
+ }
+
+}
Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/MsgBoxStorage.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/MsgBoxStorage.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/MsgBoxStorage.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/MsgBoxStorage.java Sun Jul 3 17:01:43 2011
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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.Storage;
+
+import java.util.List;
+
+import org.apache.axiom.om.OMElement;
+
+/**
+ * Message Box storage backend.
+ */
+public interface MsgBoxStorage {
+ public String createMsgBox() throws Exception;
+
+ // DELETE FROM msgbox WHERE msgboxid=key
+ public void destroyMsgBox(String key) throws Exception;
+
+ // SELECT * FROM msgbox WHERE msgboxid=key ORDER BY id LIMIT 1
+ // DELETE FROM msgbox WHERE msgboxid=key AND id=*
+ public List<String> takeMessagesFromMsgBox(String key) throws Exception;
+
+ // INSERT INTO msgbox ...
+ public void putMessageIntoMsgBox(String msgBoxID, String messageID, String soapAction, OMElement message)
+ throws Exception;
+
+ /**
+ * The ancientness is defined in the db.config file.
+ */
+ public void removeAncientMessages() throws Exception;
+
+ // public void closeConnection() throws Exception;
+}
Added: incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/memory/InMemoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/memory/InMemoryImpl.java?rev=1142461&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/memory/InMemoryImpl.java (added)
+++ incubator/airavata/ws-messaging/trunk/messagebox/src/main/org/apache/airavata/wsmg/msgbox/Storage/memory/InMemoryImpl.java Sun Jul 3 17:01:43 2011
@@ -0,0 +1,119 @@
+/*
+ *
+ * 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.Storage.memory;
+
+import java.util.LinkedList;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.airavata.wsmg.msgbox.Storage.MsgBoxStorage;
+import org.apache.axiom.om.OMElement;
+import org.apache.log4j.Logger;
+
+public class InMemoryImpl implements MsgBoxStorage {
+ static Logger logger = Logger.getLogger(InMemoryImpl.class);
+
+ ConcurrentHashMap<String, LinkedList<String>> map;
+
+ public ConcurrentHashMap<String, LinkedList<String>> getMap() {
+ return map;
+ }
+
+ public void setMap(ConcurrentHashMap<String, LinkedList<String>> map) {
+ this.map = map;
+ }
+
+ public String createMsgBox() throws Exception {
+
+ String clientid = UUID.randomUUID().toString();
+ lookupQueue(clientid); // that will create an empty queue
+ return clientid;
+ }
+
+ public void destroyMsgBox(String key) throws Exception {
+ if (map.containsKey(key))
+ map.remove(key);
+ }
+
+ public LinkedList<String> takeMessagesFromMsgBox(String key) throws Exception {
+
+ LinkedList<String> list;
+
+ synchronized (map) {
+ list = map.get(key);
+
+ if (list == null)
+ throw new IllegalArgumentException("no message box with key " + key);
+ }
+ return list;
+
+ }
+
+ public void putMessageIntoMsgBox(String msgBoxID, String messageID, String soapAction, OMElement message)
+ throws Exception {
+
+ // To change body of implemented methods use File | Settings | File Templates.
+ LinkedList<String> list = lookupQueue(msgBoxID);
+ if (list == null) {
+ throw new IllegalArgumentException("no message box with key " + msgBoxID + " to store the msg");
+ }
+ synchronized (list) {
+ list.addLast(message.toStringWithConsume());
+ logger.info("Message Stored in list with key " + msgBoxID);
+ }
+ }
+
+ /**
+ * The ancientness is defined in the db.config file.
+ */
+ public void removeAncientMessages() {
+ // To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void closeConnection() throws Exception {
+ // TODOn - store map back
+ }
+
+ private LinkedList<String> lookupQueue(String key) {
+
+ logger.debug("lookupQueue: calling the getMap method...");
+
+ if (key == null)
+ throw new IllegalArgumentException();
+ synchronized (map) {
+ LinkedList<String> v = map.get(key);
+ logger.debug(key + " is being searched in map..");
+
+ if (v != null) {
+ logger.info("key found in map.. " + key);
+ return v;
+ }
+
+ logger.info("key not found in map.. " + key);
+ LinkedList<String> list = new LinkedList<String>();
+ map.put(key, list);
+ logger.debug("new list created in map.. calling the setMap method...");
+ // this.setMap(map);
+ return list;
+ }
+ }
+}