You are viewing a plain text version of this content. The canonical link for it is here.
Posted to sandesha-dev@ws.apache.org by mc...@apache.org on 2008/10/21 17:07:46 UTC

svn commit: r706650 [2/3] - in /webservices/sandesha/trunk/java/modules/persistence: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/sandesha2/ src/main/java/org/apache/sandesha2/storage/ src/main/...

Added: webservices/sandesha/trunk/java/modules/persistence/src/main/java/org/apache/sandesha2/storage/jdbc/PersistentStorageManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/persistence/src/main/java/org/apache/sandesha2/storage/jdbc/PersistentStorageManager.java?rev=706650&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/modules/persistence/src/main/java/org/apache/sandesha2/storage/jdbc/PersistentStorageManager.java (added)
+++ webservices/sandesha/trunk/java/modules/persistence/src/main/java/org/apache/sandesha2/storage/jdbc/PersistentStorageManager.java Tue Oct 21 08:07:45 2008
@@ -0,0 +1,326 @@
+/*
+ * 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.sandesha2.storage.jdbc;
+
+import java.io.*;
+import java.util.HashMap;
+import java.sql.*;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.ModuleConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.policy.SandeshaPolicyBean;
+import org.apache.sandesha2.polling.PollingManager;
+import org.apache.sandesha2.storage.SandeshaStorageException;
+import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.Transaction;
+import org.apache.sandesha2.storage.beanmanagers.InvokerBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.RMSBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.SenderBeanMgr;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.workers.Invoker;
+import org.apache.sandesha2.workers.SandeshaThread;
+import org.apache.sandesha2.workers.Sender;
+
+/**
+ * A Storage Manager implementation for managing Sandesha2 beans.
+ * 
+ * Needs this parameter in module.xml or axis2.xml :
+ * 
+ *   db.driver				JDBC Driver class name
+ *   db.connectionstring	JDBC connection string
+ *   db.user				Data Base user name
+ *   db.password			Data Base user password
+ *   
+ *   Transactions are supposed to be attached to a thread (see inMemoryStorageManager)
+ *   hence the ThreadLocal threadTransaction variable (instead of the transactions HashMap
+ *   used by inMemoryStorageManager).
+ * 
+ *   MessageContexts are stored in a HashMap, as in inMemoryStorageManager, AND in DataBase
+ *   as backup in case of failure.
+ */
+
+public class PersistentStorageManager extends StorageManager {
+	
+	private Connection DbConnection = null;
+	private String DbConnectionString = null;
+	private String DbDriver = null;
+	private String DbUser = null;
+	private String DbPassword = null;
+    private PersistentRMSBeanMgr  pRMSBeanMgr = null;
+    private PersistentRMDBeanMgr pRMDBeanMgr = null;
+    private PersistentSenderBeanMgr pSenderBeanMgr = null;
+    private PersistentInvokerBeanMgr pInvokerBeanMgr = null;
+    private Sender sender = null;
+    private Invoker invoker = null;
+    private PollingManager pollingManager = null;
+    private boolean useSerialization = false;
+	private HashMap<String,MessageContext> storageMap = null;
+    private static ThreadLocal threadTransaction = null;
+	private static final Log log = LogFactory.getLog(PersistentStorageManager.class);
+
+	public SandeshaThread getInvoker() {
+		return invoker;
+	}
+
+	public PollingManager getPollingManager() {
+		return pollingManager;
+	}
+
+	public SandeshaThread getSender() {
+		return sender;
+	}
+
+	
+	public PersistentStorageManager(ConfigurationContext context)
+	  throws SandeshaException
+	{
+		super (context);
+		log.info("create PersistentStorageManager");
+		storageMap = new HashMap ();
+		threadTransaction = new ThreadLocal();
+		pRMSBeanMgr = new PersistentRMSBeanMgr (this);
+		pRMDBeanMgr = new PersistentRMDBeanMgr (this);
+		pSenderBeanMgr = new PersistentSenderBeanMgr (this);
+		pInvokerBeanMgr = new PersistentInvokerBeanMgr (this);
+		sender = new Sender();
+		// Note that while inOrder is a global property we can decide if we need the
+		// invoker thread at this point. If we change this to be a sequence-level
+		// property then we'll need to revisit this.
+		SandeshaPolicyBean policy = SandeshaUtil.getPropertyBean(context.getAxisConfiguration());
+		useSerialization = policy.isUseMessageSerialization();
+		if(policy.isInOrder()) invoker = new Invoker();
+		if(policy.isEnableMakeConnection()) pollingManager = new PollingManager();
+        ModuleConfiguration mc = context.getAxisConfiguration().getModuleConfig("sandesha2");
+        Parameter param = mc.getParameter("db.connectionstring");
+		if ( param != null ) {
+			DbConnectionString = (String)param.getValue();
+		  log.debug(param.getName() + "=" + DbConnectionString);
+		}
+		param = mc.getParameter("db.driver");
+		if ( param != null ) {
+			DbDriver = (String)param.getValue();
+		  log.debug(param.getName() + "=" + DbDriver);
+		}
+		param = mc.getParameter("db.user");
+		if ( param != null ) {
+			DbUser = (String)param.getValue();
+		  log.debug(param.getName() + "=" + DbUser);
+		}
+		param = mc.getParameter("db.password");
+		if ( param != null ) {
+			DbPassword = (String)param.getValue();
+		  log.debug(param.getName() + "=" + DbPassword);
+		}
+	}
+	public void shutdown()
+	{
+		if ( DbConnection != null ) {
+			try {
+				DbConnection.close();
+				DbConnection = null;
+			} catch (Exception ex) {}
+		}
+		super.shutdown();
+	}
+
+	public InvokerBeanMgr getInvokerBeanMgr()
+	{
+		return pInvokerBeanMgr;
+	}
+
+	public RMDBeanMgr getRMDBeanMgr()
+	{
+		return pRMDBeanMgr;
+	}
+
+	public RMSBeanMgr getRMSBeanMgr()
+	{
+		return pRMSBeanMgr;
+	}
+
+	public SenderBeanMgr getSenderBeanMgr()
+	{
+		return pSenderBeanMgr;
+	}
+
+	public boolean requiresMessageSerialization() {
+		return useSerialization;
+	}
+
+	public boolean hasUserTransaction(MessageContext msg)
+	{
+		// Answer to : Is there a user transaction in play ?
+		// but what is a 'user transaction' ?
+		return false;
+	}
+	
+	public Transaction getTransaction()
+	{
+		Transaction transaction = (Transaction) threadTransaction.get();
+		if (transaction == null) {
+			transaction = new JDBCTransaction(this);
+			threadTransaction.set(transaction);
+		} else {
+			// We don't want to overwrite or return an existing transaction, as someone
+			// else should decide if we commit it or not. If we get here then we probably
+			// have a bug.
+			if(log.isDebugEnabled()) log.debug("Possible re-used transaction: ");
+			transaction = null;
+		}
+		return transaction;
+	}
+	
+	public void removeTransaction()
+	{
+		threadTransaction.set(null);
+	}
+
+	/**
+	 *  Returns the connection attached to the current transaction if exists
+	 *  or the "common" connection.
+	 *  
+	 * @return Data Base Connection
+	 */
+	public Connection getDbConnection()
+	{
+		JDBCTransaction transaction = (JDBCTransaction) threadTransaction.get();
+		if ( transaction == null )return DbConnection;
+		return transaction.getDbConnection();
+	}
+	
+
+	public void  initStorage (AxisModule moduleDesc)
+	  throws SandeshaStorageException
+	{
+		log.info("init PersistentStorageManager");
+		if ( DbConnectionString == null || DbDriver == null )
+				throw new SandeshaStorageException ("Can't proceed. Needed properties are not set.");
+
+	    DbConnection = dbConnect();
+	}
+	
+	public Connection  dbConnect ()
+	  throws SandeshaStorageException
+	{
+			try {
+	    	   Class.forName(DbDriver);
+	    	   return DriverManager.getConnection(DbConnectionString,DbUser,DbPassword);
+			} catch (Exception ex) {
+				log.error("Unable to create DB connection ", ex);
+				throw new SandeshaStorageException(ex);
+			}		
+	}
+
+	public MessageContext retrieveMessageContext(String key,ConfigurationContext configContext)
+	  throws SandeshaStorageException
+	{
+		log.debug("Enter retrieveMessageContext for key " + key);
+		/**/
+		if (storageMap.containsKey(key)) {
+			log.debug("retrieveMessageContext get from cache");
+			return (MessageContext) storageMap.get(key);
+		}
+		/**/
+		try {
+		  Statement stmt = getDbConnection().createStatement();
+		  /**/
+		  ResultSet rs = stmt.executeQuery("select * from wsrm_msgctx where ctx_key='" +
+					key + "'");
+		  rs.next();
+		  MessageContext msgCtx =  new MessageContext();
+		  msgCtx.readExternal(new ObjectInputStream(rs.getBinaryStream("ctx")));
+		  msgCtx.activate(configContext);
+		  msgCtx.setProperty(Sandesha2Constants.POST_FAILURE_MESSAGE,Sandesha2Constants.VALUE_TRUE);
+		  rs.close();
+		  stmt.close();
+		  log.debug("RetrieveMessageContext get from DB");
+		  return msgCtx;
+		} catch ( Exception ex) {
+			log.error("RetrieveMessageContext exception " + ex);
+			throw new SandeshaStorageException(ex);
+		}
+	}
+
+	synchronized public void storeMessageContext(String key,MessageContext msgContext)
+	  throws SandeshaStorageException
+	{		
+		if ( log.isDebugEnabled() ) log.debug("Enter storeMessageContext for key " + key + " context " + msgContext);
+		storageMap.put(key,msgContext);
+		try {
+		   	PreparedStatement pstmt = getDbConnection().prepareStatement("insert into wsrm_msgctx(ctx_key,ctx)values(?,?)");
+		   	pstmt.setString(1,key);
+		    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		    ObjectOutputStream oos = new ObjectOutputStream(baos);
+		   	msgContext.writeExternal(oos);
+		    oos.close();
+		    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+		   	pstmt.setBinaryStream(2, bais, bais.available());
+		   	pstmt.execute();
+		   	pstmt.close();
+		} catch(Exception ex) {
+			throw new SandeshaStorageException(ex);
+		}
+	}
+
+	synchronized public void updateMessageContext(String key,MessageContext msgContext)
+	  throws SandeshaStorageException
+	{
+		if ( log.isDebugEnabled() ) log.debug("updateMessageContext key : " + key);
+		storageMap.put(key,msgContext);
+		PreparedStatement pstmt = null;
+		try {
+		    pstmt = getDbConnection().prepareStatement("update wsrm_msgctx set ctx=?" +
+		    		"where ctx_key='" + key + "'");
+		    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		    ObjectOutputStream oos = new ObjectOutputStream(baos);
+		   	msgContext.writeExternal(oos);
+		    oos.close();
+		    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+		   	pstmt.setBinaryStream(1, bais, bais.available());
+		   	pstmt.executeQuery();
+		   	pstmt.close();
+		} catch(Exception ex) {
+			throw new SandeshaStorageException("Exception in updateMessageContext", ex);
+		}
+	}
+	
+	public void removeMessageContext(String key)
+	  throws SandeshaStorageException
+	{
+		if ( log.isDebugEnabled() ) log.debug("removeMessageContext key : " + key);
+		try {
+		  Statement stmt = getDbConnection().createStatement();
+		  MessageContext messageInCache = (MessageContext) storageMap.get(key);
+		  if (messageInCache!=null) storageMap.remove(key);
+		  stmt.executeUpdate("delete from wsrm_msgctx where ctx_key='" + key + "'");
+		  stmt.close();
+		} catch (Exception ex ) {
+			throw new SandeshaStorageException("Exception in removeMessageContext", ex);
+		}
+	}
+			
+}

Added: webservices/sandesha/trunk/java/modules/persistence/src/resources/ddl/sandesha2-derby.ddl
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/persistence/src/resources/ddl/sandesha2-derby.ddl?rev=706650&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/modules/persistence/src/resources/ddl/sandesha2-derby.ddl (added)
+++ webservices/sandesha/trunk/java/modules/persistence/src/resources/ddl/sandesha2-derby.ddl Tue Oct 21 08:07:45 2008
@@ -0,0 +1,112 @@
+drop table wsrm_sender;
+create table wsrm_sender (
+	message_id varchar(255) not null,
+	message_context_ref_key varchar(255),
+	internal_sequence_id varchar(255),
+	sequence_id varchar(255),
+	to_address varchar(255),
+	inbound_sequence_id varchar(255),
+	send smallint,
+	sent_count integer,
+	message_number bigint,
+	resend smallint,
+	time_to_send bigint,
+	message_type integer,
+	last_message smallint,
+	inbound_message_number bigint,
+	transport_available smallint,
+	flags integer,
+	primary key (message_id)
+);
+	
+drop table wsrm_rmd;
+create table wsrm_rmd (
+	sequence_id varchar(255) not null,
+	to_epr_addr varchar(255),
+	to_epr blob,
+	reply_to_epr_addr varchar(255),
+	reply_to_epr blob,
+	acks_to_epr_addr varchar(255),
+	acks_to_epr blob,
+	rm_version varchar(255),
+	security_token_data varchar(255),
+	last_activated_time bigint,
+	closed smallint,
+	terminated_flag smallint,
+	polling_mode smallint,
+	service_name varchar(255),
+	flags integer,
+	reference_message_key varchar(255),
+	highest_in_message_id varchar(255),
+	last_in_message_id varchar(255),
+	server_completed_messages clob,
+	outof_order_ranges clob,
+	to_address varchar(255),
+	outbound_internal_sequence varchar(255),
+	next_msgno_to_process bigint,
+	highest_in_message_number bigint,
+	rmd_flags integer,
+	primary key (sequence_id)
+);
+	
+drop table wsrm_rms;
+create table wsrm_rms (
+	create_seq_msg_id varchar(255) not null,
+	sequence_id varchar(255),
+	to_epr_addr varchar(255),
+	to_epr blob,
+	reply_to_epr_addr varchar(255),
+	reply_to_epr blob,
+	acks_to_epr_addr varchar(255),
+	acks_to_epr blob,
+	rm_version varchar(255),
+	security_token_data varchar(255),
+	last_activated_time BIGINT,
+	closed smallint,
+	terminated_flag smallint,
+	polling_mode smallint,
+	service_name varchar(255),
+	flags integer,
+	id bigint,
+	internal_sequence_id varchar(255),
+	create_sequence_msg_store_key varchar(255),
+	reference_msg_store_key varchar(255),
+	last_send_error blob,
+	highest_out_relates_to varchar(255),
+	client_completed_messages clob,
+	transport_to varchar(255),
+	offered_endpoint varchar(255),
+	offered_sequence varchar(255),
+	anonymous_uuid varchar(255),
+	last_send_error_timestamp bigint,
+	last_out_message bigint,
+	highest_out_message_number bigint,
+	next_message_number bigint,
+	terminate_added smallint,
+	timed_out smallint,
+	sequence_closed_client smallint,
+	expected_replies bigint,
+	soap_version integer,
+	termination_pauser_for_cs smallint,
+	avoid_auto_termination smallint,
+	rms_flags integer,
+	primary key (create_seq_msg_id)
+);
+	
+drop table wsrm_invoker;	
+create table wsrm_invoker (
+	message_context_ref_key varchar(255) not null,
+	sequence_id varchar(255),
+	context blob,
+	msg_no bigint,
+	flags integer,
+	PRIMARY KEY (message_context_ref_key)
+);
+
+drop table wsrm_msgctx;	
+create table wsrm_msgctx (
+	ctx_key varchar(255) not null,
+	ctx blob,
+	PRIMARY KEY (ctx_key)
+);
+

Added: webservices/sandesha/trunk/java/modules/persistence/src/resources/ddl/sandesha2-mysql.ddl
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/persistence/src/resources/ddl/sandesha2-mysql.ddl?rev=706650&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/modules/persistence/src/resources/ddl/sandesha2-mysql.ddl (added)
+++ webservices/sandesha/trunk/java/modules/persistence/src/resources/ddl/sandesha2-mysql.ddl Tue Oct 21 08:07:45 2008
@@ -0,0 +1,113 @@
+drop table if exists wsrm_sender;
+create table wsrm_sender (
+	message_id varchar(255) not null,
+	message_context_ref_key varchar(255),
+	internal_sequence_id varchar(255),
+	sequence_id varchar(255),
+	to_address varchar(255),
+	inbound_sequence_id varchar(255),
+	send smallint,
+	sent_count integer,
+	message_number bigint,
+	resend smallint,
+	time_to_send bigint,
+	message_type integer,
+	last_message smallint,
+	inbound_message_number bigint,
+	transport_available smallint,
+	flags integer,
+	primary key (message_id)
+);
+	
+drop table if exists wsrm_rmd;
+create table wsrm_rmd (
+	sequence_id varchar(255) not null,
+	to_epr_addr varchar(255),
+	to_epr blob,
+	reply_to_epr_addr varchar(255),
+	reply_to_epr blob,
+	acks_to_epr_addr varchar(255),
+	acks_to_epr blob,
+	rm_version varchar(255),
+	security_token_data varchar(255),
+	last_activated_time bigint,
+	closed smallint,
+	terminated_flag smallint,
+	polling_mode smallint,
+	service_name varchar(255),
+	flags integer,
+	reference_message_key varchar(255),
+	highest_in_message_id varchar(255),
+	last_in_message_id varchar(255),
+	server_completed_messages blob,
+	outof_order_ranges blob,
+	to_address varchar(255),
+	outbound_internal_sequence varchar(255),
+	next_msgno_to_process bigint,
+	highest_in_message_number bigint,
+	rmd_flags integer,
+	primary key (sequence_id)
+);
+	
+drop table if exists wsrm_rms;
+create table wsrm_rms (
+	create_seq_msg_id varchar(255) not null,
+	sequence_id varchar(255),
+	to_epr_addr varchar(255),
+	to_epr blob,
+	reply_to_epr_addr varchar(255),
+	reply_to_epr blob,
+	acks_to_epr_addr varchar(255),
+	acks_to_epr blob,
+	rm_version varchar(255),
+	security_token_data varchar(255),
+	last_activated_time BIGINT,
+	closed smallint,
+	terminated_flag smallint,
+	polling_mode smallint,
+	service_name varchar(255),
+	flags integer,
+	id bigint,
+	internal_sequence_id varchar(255),
+	create_sequence_msg_store_key varchar(255),
+	reference_msg_store_key varchar(255),
+	last_send_error blob,
+	highest_out_relates_to varchar(255),
+	client_completed_messages blob,
+	transport_to varchar(255),
+	offered_endpoint varchar(255),
+	offered_sequence varchar(255),
+	anonymous_uuid varchar(255),
+	last_send_error_timestamp bigint,
+	last_out_message bigint,
+	highest_out_message_number bigint,
+	next_message_number bigint,
+	terminate_added smallint,
+	timed_out smallint,
+	sequence_closed_client smallint,
+	expected_replies bigint,
+	soap_version integer,
+	termination_pauser_for_cs smallint,
+	avoid_auto_termination smallint,
+	rms_flags integer,
+	primary key (create_seq_msg_id)
+);
+	
+	
+drop table if exists wsrm_invoker;
+create table wsrm_invoker (
+	message_context_ref_key varchar(255) not null,
+	sequence_id varchar(255),
+	context blob,
+	msg_no bigint,
+	flags integer,
+	PRIMARY KEY (message_context_ref_key)
+);
+
+drop table if exists wsrm_msgctx;
+create table wsrm_msgctx (
+	ctx_key varchar(255) not null,
+	ctx blob,
+	PRIMARY KEY (ctx_key)
+);
+

Added: webservices/sandesha/trunk/java/modules/persistence/src/resources/module_config_axis2.xml
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/persistence/src/resources/module_config_axis2.xml?rev=706650&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/modules/persistence/src/resources/module_config_axis2.xml (added)
+++ webservices/sandesha/trunk/java/modules/persistence/src/resources/module_config_axis2.xml Tue Oct 21 08:07:45 2008
@@ -0,0 +1,15 @@
+<!-- Add something like this in axis2.xml for the right DB -->
+    <moduleConfig name="sandesha2">
+    <!-- MySQL 
+     <parameter name="db.connectionstring">jdbc:mysql://localhost/wsrm</parameter>
+    <parameter name="db.driver">com.mysql.jdbc.Driver</parameter>
+    <parameter name="db.user"></parameter>
+    <parameter name="db.password"></parameter>
+    -->
+     <!-- Derby --> 
+    <parameter name="db.connectionstring">jdbc:derby:derby/wsrm</parameter>
+    <parameter name="db.driver">org.apache.derby.jdbc.EmbeddedDriver</parameter>
+    <parameter name="db.user"></parameter>
+    <parameter name="db.password"></parameter>
+   <!-- -->
+    </moduleConfig>

Added: webservices/sandesha/trunk/java/modules/persistence/src/test/java/org/apache/sandesha2/RMScenariosTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/persistence/src/test/java/org/apache/sandesha2/RMScenariosTest.java?rev=706650&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/modules/persistence/src/test/java/org/apache/sandesha2/RMScenariosTest.java (added)
+++ webservices/sandesha/trunk/java/modules/persistence/src/test/java/org/apache/sandesha2/RMScenariosTest.java Tue Oct 21 08:07:45 2008
@@ -0,0 +1,306 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ * Copyright 2007 International Business Machines Corp.
+ *
+ * Licensed 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.sandesha2;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.AssertionFailedError;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+public class RMScenariosTest extends SandeshaTestCase {
+
+	private boolean serverStarted = false; 
+	protected ConfigurationContext configContext = null;
+
+	protected String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+	
+	protected String repoPath = "target" + File.separator + "repos" + File.separator + "persistence-server";
+	protected String axis2_xml = "target" + File.separator + "repos" + File.separator + "persistence-server" + File.separator + "server_axis2.xml";
+
+	protected String repoPathClient = "target" + File.separator + "repos" + File.separator + "persistence-client";
+	protected String axis2_xmlClient = "target" + File.separator + "repos" + File.separator + "persistence-client" + File.separator + "client_axis2.xml";
+	
+	public RMScenariosTest () {
+		super ("RMScenariosTest");
+	}
+	
+	public RMScenariosTest (String name) {
+		super(name);
+	}
+
+	public void setUp () throws Exception {
+		super.setUp();
+
+		if (!serverStarted) {
+			startServer(repoPath, axis2_xml);
+			configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPathClient,axis2_xmlClient);
+		}
+		serverStarted = true;
+	}
+	
+	/**
+	 * Override the teardown processing
+	 */
+	public void tearDown () throws Exception {
+		super.tearDown();
+	}
+
+	public void testPing() throws Exception  {
+		// Run a ping test with sync acks
+		runPing(false, false);
+		
+		// Run a ping test with async acks
+		runPing(true, true);
+	}
+
+	public void testAsyncEcho() throws Exception {
+		// Test async echo with sync acks
+		Options clientOptions = new Options();
+		runEcho(clientOptions, true, false, false,true,false);
+		
+		// Test async echo with async acks
+		clientOptions = new Options();
+		runEcho(clientOptions, true, true, false,true,false);
+		
+		// Test async echo with async acks and offer
+		clientOptions = new Options();
+		clientOptions.setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());
+		runEcho(clientOptions, true, true, false,true,true);
+	}
+		
+	public void testSyncEchoWithOffer() throws Exception {
+		// Test sync echo with an offer, and the 1.1 spec
+		Options clientOptions = new Options();
+		clientOptions.setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());
+		clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);
+		runEcho(clientOptions, false, false, true,true,false);
+		
+//		// Test sync echo with an offer, and the 1.0 spec. The offer is not automatic as this
+//		// is a client that hasn't been built from WSDL. If the user's operations had been
+//		// modelled properly then the offer would happen automatically.
+//		clientOptions = new Options();
+//		clientOptions.setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());
+//		clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_0);
+//		runEcho(clientOptions, false, false, true,false,false);
+    }
+
+    public void testSyncEcho() throws Exception {
+		// Test sync echo with no offer, and the 1.1 spec
+		Options clientOptions = new Options();
+		clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);
+		runEcho(clientOptions, false, false, true,true,true);
+	}
+
+	public void runPing(boolean asyncAcks, boolean stopListener) throws Exception {
+		
+		Options clientOptions = new Options();
+
+		ServiceClient serviceClient = new ServiceClient (configContext,null);
+		serviceClient.setOptions(clientOptions);
+
+		String sequenceKey = SandeshaUtil.getUUID();
+
+		clientOptions.setAction(pingAction);
+		clientOptions.setTo(new EndpointReference (to));
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+		clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, Constants.VALUE_TRUE);
+		
+		if(asyncAcks) {
+			clientOptions.setUseSeparateListener(true);
+		}
+
+		serviceClient.fireAndForget(getPingOMBlock("ping1"));
+		
+		long limit = System.currentTimeMillis() + waitTime;
+		Error lastError = null;
+		while(System.currentTimeMillis() < limit) {
+			Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
+			
+			try {
+				SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+				System.out.println("Checking Outbound Sequence: " + sequenceReport.getSequenceID());
+				assertTrue("Checking completed messages", sequenceReport.getCompletedMessages().contains(new Long(1)));
+				assertEquals("Checking sequence terminated", SequenceReport.SEQUENCE_STATUS_TERMINATED, sequenceReport.getSequenceStatus());
+				assertEquals("Checking sequence direction", SequenceReport.SEQUENCE_DIRECTION_OUT, sequenceReport.getSequenceDirection());
+
+				lastError = null;
+				break;
+			} catch(Error e) {
+                e.printStackTrace();
+                System.out.println("Possible error:" + e);
+				lastError = e;
+			}
+		}
+
+		if(lastError != null) throw lastError;
+
+		if (stopListener)
+			configContext.getListenerManager().stop();
+		
+		serviceClient.cleanup();
+
+	}
+
+	public void runEcho(Options clientOptions, boolean asyncReply, boolean asyncAcks, boolean explicitTermination, boolean checkInboundTermination, boolean stopListener) throws Exception {
+		
+		String sequenceKey = SandeshaUtil.getUUID();
+
+		ServiceClient serviceClient = new ServiceClient (configContext,null);
+		serviceClient.setOptions(clientOptions);
+
+		clientOptions.setAction(echoAction);
+		clientOptions.setTo(new EndpointReference (to));
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+		clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+		if(asyncReply || asyncAcks) {
+			clientOptions.setUseSeparateListener(true);
+			
+			if(asyncAcks) {
+				String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+				clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+			} else {
+				String acksTo = AddressingConstants.Final.WSA_ANONYMOUS_URL;
+				clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+			}
+		}
+		
+		if(asyncAcks) {
+			String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+			clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+		} else {
+			String acksTo = AddressingConstants.Final.WSA_ANONYMOUS_URL;
+			clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+		}
+
+		// Establish a baseline count for inbound sequences
+		List oldIncomingReports = SandeshaClient.getIncomingSequenceReports(configContext);
+		
+		TestCallback callback1 = new TestCallback ("Callback 1");
+		serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo1",sequenceKey),callback1);
+		
+		TestCallback callback2 = new TestCallback ("Callback 2");
+		serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo2",sequenceKey),callback2);
+		
+		if (!explicitTermination 
+				&& 
+			!Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(clientOptions.getProperty(SandeshaClientConstants.RM_SPEC_VERSION))) {
+			
+			clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, Constants.VALUE_TRUE);
+		}
+		
+		TestCallback callback3 = new TestCallback ("Callback 3");		
+		serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo3",sequenceKey),callback3);
+		
+		if (explicitTermination) {
+			Thread.sleep(10000);
+			SandeshaClient.terminateSequence(serviceClient);
+		}
+		
+		long limit = System.currentTimeMillis() + waitTime;
+		Error lastError = null;
+		while(System.currentTimeMillis() < limit) {
+			Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
+			
+			try {
+				
+		        //assertions for the out sequence.
+				SequenceReport outgoingSequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+				System.out.println("Checking Outbound Sequence: " + outgoingSequenceReport.getSequenceID());
+				assertTrue("Outbound message #1", outgoingSequenceReport.getCompletedMessages().contains(new Long(1)));
+				assertTrue("Outbound message #2", outgoingSequenceReport.getCompletedMessages().contains(new Long(2)));
+				assertTrue("Outbound message #3", outgoingSequenceReport.getCompletedMessages().contains(new Long(3)));
+				assertEquals("Outbound sequence status: TERMINATED", SequenceReport.SEQUENCE_STATUS_TERMINATED, outgoingSequenceReport.getSequenceStatus());
+				assertEquals("Outbound sequence direction: OUT", SequenceReport.SEQUENCE_DIRECTION_OUT, outgoingSequenceReport.getSequenceDirection());
+				
+				//assertions for the inbound sequence. The one we care about is a new sequence,
+				//so it will not exist in the oldSequences list.
+				List incomingSequences = SandeshaClient.getIncomingSequenceReports(configContext);
+				SequenceReport incomingSequenceReport = getNewReport(incomingSequences, oldIncomingReports);
+				System.out.println("Checking Inbound Sequence: " + incomingSequenceReport.getSequenceID());
+				String offer = (String) clientOptions.getProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID);
+				if(offer != null) assertEquals("Inbound seq id", offer, incomingSequenceReport.getSequenceID());
+				assertEquals ("Inbound message count", 3, incomingSequenceReport.getCompletedMessages().size());
+				assertTrue("Inbound message #1", incomingSequenceReport.getCompletedMessages().contains(new Long(1)));
+				assertTrue("Inbound message #2", incomingSequenceReport.getCompletedMessages().contains(new Long(2)));
+				assertTrue("Inbound message #3", incomingSequenceReport.getCompletedMessages().contains(new Long(3)));
+				
+				if (checkInboundTermination)
+					assertEquals("Inbound sequence status: TERMINATED", SequenceReport.SEQUENCE_STATUS_TERMINATED, incomingSequenceReport.getSequenceStatus());
+				
+				assertEquals("Inbound sequence direction: IN", SequenceReport.SEQUENCE_DIRECTION_IN, incomingSequenceReport.getSequenceDirection());
+				
+				assertTrue("Callback #1", callback1.isComplete());
+				assertEquals("Callback #1 data", "echo1", callback1.getResult());
+				
+				assertTrue("Callback #2", callback2.isComplete());
+				assertEquals("Callback #2 data", "echo1echo2", callback2.getResult());
+				
+				assertTrue("Callback #3", callback3.isComplete());
+				assertEquals("Callback #3 data", "echo1echo2echo3", callback3.getResult());
+				
+				lastError = null;
+				break;
+			} catch(Error e) {
+                e.printStackTrace();
+                System.out.println("Possible error:" + e);
+				lastError = e;
+			}
+		}
+		if(lastError != null) throw lastError;
+		
+		if (stopListener)
+			configContext.getListenerManager().stop();
+		
+		serviceClient.cleanup();
+	}
+
+	// Scan through lists of old and new incoming sequences, to find the sequence that
+	// was established by this test. Note that some of the old sequences may have timed out.
+	private SequenceReport getNewReport(List incomingSequences, List oldIncomingReports) {
+		HashSet sequenceIds = new HashSet();
+		for(Iterator oldSequences = oldIncomingReports.iterator(); oldSequences.hasNext(); ) {
+			SequenceReport report = (SequenceReport) oldSequences.next();
+			sequenceIds.add(report.getSequenceID());
+		}
+		for(Iterator currentSequences = incomingSequences.iterator(); currentSequences.hasNext(); ) {
+			SequenceReport report = (SequenceReport) currentSequences.next();
+			if(!sequenceIds.contains(report.getSequenceID())) {
+				return report;
+			}
+		}
+		throw new AssertionFailedError("Failed to find a new reply sequence");
+	}
+
+
+}

Added: webservices/sandesha/trunk/java/modules/persistence/src/test/java/org/apache/sandesha2/SandeshaTestCase.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/persistence/src/test/java/org/apache/sandesha2/SandeshaTestCase.java?rev=706650&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/modules/persistence/src/test/java/org/apache/sandesha2/SandeshaTestCase.java (added)
+++ webservices/sandesha/trunk/java/modules/persistence/src/test/java/org/apache/sandesha2/SandeshaTestCase.java Tue Oct 21 08:07:45 2008
@@ -0,0 +1,272 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.sandesha2;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+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.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.client.async.AxisCallback;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisOperationFactory;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class SandeshaTestCase extends TestCase {
+ 
+	String resourceDir = ""; //"test-resources";
+    Properties properties = null;
+    final String PROPERTY_FILE_NAME = "sandesha2-test.properties";
+    public final int DEFAULT_SERVER_TEST_PORT = 8060;
+    public ConfigurationContext serverConfigurationContext = null;
+    private final String RMServiceName = "RMSampleService";
+	private Log log = LogFactory.getLog(getClass());
+    
+	private final static String applicationNamespaceName = "http://tempuri.org/"; 
+	private final static String echoString = "echoString";
+	private final static String ping = "ping";
+	private final static String Text = "Text";
+	private final static String Sequence = "Sequence";
+	private final static String echoStringResponse = "echoStringResponse";
+	private final static String EchoStringReturn = "EchoStringReturn";
+
+	protected SimpleHTTPServer httpServer = null;
+	protected int serverPort = DEFAULT_SERVER_TEST_PORT;
+	protected int waitTime = 70000; // Each test will wait up to 70 seconds, unless we override it here
+	protected int tickTime = 10000;  // Each wait will check the test assertions each second
+	protected String pingAction = "urn:wsrm:Ping";
+	protected String echoAction = "urn:wsrm:EchoString";
+	
+    public SandeshaTestCase(String name) {
+        super(name);
+        String testRource = "target" + File.separator + "test-classes";
+        resourceDir = new File(testRource).getPath();
+        
+        String propFileStr = resourceDir + File.separator + PROPERTY_FILE_NAME;
+        properties = new Properties ();
+        
+        try {
+			FileInputStream propertyFile = new FileInputStream (new File(propFileStr));
+			properties.load(propertyFile);
+		} catch (FileNotFoundException e) {
+			log.error(e);
+		} catch (IOException e) {
+			log.error(e);
+		}
+    }
+    
+    public void setUp () throws Exception {
+		super.setUp();
+    	
+		String serverPortStr = getTestProperty("test.server.port");
+		if (serverPortStr!=null) {
+			try {
+				serverPort = Integer.parseInt(serverPortStr);
+			} catch (NumberFormatException e) {
+				log.error(e);
+			}
+		}
+    }
+    
+	public ConfigurationContext startServer(String repoPath, String axis2_xml)
+	throws Exception {
+
+		ConfigurationContext configContext =
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+		httpServer = new SimpleHTTPServer (configContext,serverPort);
+		httpServer.start();
+		Thread.sleep(300);
+		
+		return configContext;
+	}
+
+	public void tearDown () throws Exception {
+		if (httpServer!=null) {
+			httpServer.stop();
+		}
+		
+		Thread.sleep(300);
+	}
+
+	protected InputStreamReader getResource(String relativePath, String resourceName) {
+        String resourceFile = resourceDir + relativePath + File.separator + resourceName;
+        try {
+            FileReader reader = new FileReader(resourceFile);
+            return reader;
+        } catch (FileNotFoundException e) {
+            throw new RuntimeException("cannot load the test-resource", e);
+        }
+    }
+
+    protected SOAPEnvelope getSOAPEnvelope() {
+        return OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+    }
+
+    protected SOAPEnvelope getSOAPEnvelope(String relativePath, String resourceName) {
+        try {
+            XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(
+                    getResource(relativePath, resourceName));
+            OMXMLParserWrapper wrapper = OMXMLBuilderFactory.createStAXSOAPModelBuilder(
+                    OMAbstractFactory.getSOAP11Factory(), reader);
+            return (SOAPEnvelope) wrapper.getDocumentElement();
+
+        } catch (XMLStreamException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    protected SOAPEnvelope getEmptySOAPEnvelope() {
+        return OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+    }
+
+    protected static OMElement getEchoOMBlock(String text, String sequenceKey) {
+		OMFactory fac = OMAbstractFactory.getOMFactory();
+		OMNamespace applicationNamespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+		OMElement echoStringElement = fac.createOMElement(echoString, applicationNamespace);
+		OMElement textElem = fac.createOMElement(Text,applicationNamespace);
+		OMElement sequenceElem = fac.createOMElement(Sequence,applicationNamespace);
+		
+		textElem.setText(text);
+		sequenceElem.setText(sequenceKey);
+		echoStringElement.addChild(textElem);
+		echoStringElement.addChild(sequenceElem);
+		
+		return echoStringElement;
+	}
+    
+	protected OMElement getPingOMBlock(String text) {
+		OMFactory fac = OMAbstractFactory.getOMFactory();
+		OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+		OMElement pingElem = fac.createOMElement(ping, namespace);
+		OMElement textElem = fac.createOMElement(Text, namespace);
+		
+		textElem.setText(text);
+		pingElem.addChild(textElem);
+
+		return pingElem;
+	}
+
+	protected String checkEchoOMBlock(OMElement response) {
+		assertEquals("Response namespace", applicationNamespaceName, response.getNamespace().getNamespaceURI());
+		assertEquals("Response local name", echoStringResponse, response.getLocalName());
+		
+		OMElement echoStringReturnElem = response.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+		assertNotNull("Echo String Return", echoStringReturnElem);
+		
+		String resultStr = echoStringReturnElem.getText();
+		return resultStr;
+	}
+
+    public String getTestProperty (String key) {
+    	if (properties!=null)
+    		return properties.getProperty(key);
+    	 
+    	return null;
+    }
+    
+    public void overrideConfigurationContext (ConfigurationContext context,MessageReceiver messageReceiver, String operationName, boolean newOperation, int mep) throws Exception  {
+    	
+    	
+    	AxisService rmService = context.getAxisConfiguration().getService(RMServiceName);
+    	
+    	AxisOperation operation = null;
+    	
+    	if (newOperation) {
+    		operation = rmService.getOperation(new QName (operationName));
+    		if (operation==null)
+    			throw new Exception ("Given operation not found");
+    	} else {
+    		operation = AxisOperationFactory.getAxisOperation(mep);
+    		rmService.addOperation(operation);
+    	}
+    	
+    	operation.setMessageReceiver(messageReceiver);
+    }
+
+	protected class TestCallback implements AxisCallback {
+
+		String name = null;
+		boolean completed = false;
+		boolean errorReported = false;
+		String resultStr;
+		
+		public boolean isComplete() {
+			return completed;
+		}
+		
+		public boolean isErrorReported() {
+			return errorReported;
+		}
+
+		public String getResult () {
+			return resultStr;
+		}
+		
+		public TestCallback (String name) {
+			this.name = name;
+		}
+		
+		public void onComplete() {
+			completed = true;
+		}
+
+		public void onMessage(MessageContext result) {
+			SOAPBody body = result.getEnvelope().getBody();
+			OMElement contents = body.getFirstElement();
+			this.resultStr = checkEchoOMBlock(contents);
+			System.out.println("TestCallback got text: '" + resultStr + "'");
+		}
+		
+		public void onFault(MessageContext result) {
+			errorReported = true;
+			System.out.println("TestCallback got fault: " + result.getEnvelope());
+		}
+
+		public void onError (Exception e) {
+			errorReported = true;
+			System.out.println("TestCallback got exception");
+			e.printStackTrace();
+		}
+	}
+
+}

Added: webservices/sandesha/trunk/java/modules/persistence/test-resources/client_axis2.xml
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/persistence/test-resources/client_axis2.xml?rev=706650&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/modules/persistence/test-resources/client_axis2.xml (added)
+++ webservices/sandesha/trunk/java/modules/persistence/test-resources/client_axis2.xml Tue Oct 21 08:07:45 2008
@@ -0,0 +1,362 @@
+<!--
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+ -->
+
+<axisconfig name="AxisJava2.0">
+    <!-- ================================================= -->
+    <!-- Parameters -->
+    <!-- ================================================= -->
+    <parameter name="hotdeployment">true</parameter>
+    <parameter name="hotupdate">false</parameter>
+    <parameter name="enableMTOM">false</parameter>
+    <parameter name="enableSwA">false</parameter>
+
+    <!--Uncomment if you want to enable file caching for attachments -->
+    <!--parameter name="cacheAttachments">true</parameter>
+    <parameter name="attachmentDIR"></parameter>
+    <parameter name="sizeThreshold">4000</parameter-->
+
+    <!--This will give out the timout of the configuration contexts, in milliseconds-->
+    <parameter name="ConfigContextTimeoutInterval">30000</parameter>
+
+    <!--During a fault, stack trace can be sent with the fault message. The following flag will control -->
+    <!--that behavior.-->
+    <parameter name="sendStacktraceDetailsWithFaults">false</parameter>
+
+    <!--If there aren't any information available to find out the fault reason, we set the message of the exception-->
+    <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
+    <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
+    <!--is set, then Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
+    <parameter name="DrillDownToRootCauseForFaultReason">false</parameter>
+
+    <parameter name="userName">admin</parameter>
+    <parameter name="password">axis2</parameter>
+
+    <!--To override repository/services you need to uncomment following parameter and value SHOULD be absolute file path.-->
+    <!--<parameter name="ServicesDirectory">service</parameter>-->
+    <!--To override repository/modules you need to uncomment following parameter and value SHOULD be absolute file path-->
+    <!--<parameter name="ModulesDirectory">modules</parameter>-->
+
+
+
+    <!--Following params will set the proper context paths for invocations. All the endpoints will have a commons context-->
+    <!--root which can configured using the following contextRoot parameter-->
+    <!--<parameter name="contextRoot">axis2</parameter>-->
+
+    <!--Our HTTP endpoints can handle both REST and SOAP. Following parameters can be used to distinguiush those endpoints-->
+    <!--In case of a servlet, if you change this you have to manually change the settings of your servlet container to map this -->
+    <!--context path to proper Axis2 servlets-->
+    <!--<parameter name="servicePath">services</parameter>-->
+    <!--<parameter name="restPath">rest</parameter>-->
+
+    <!-- Following parameter will completely disable REST handling in Axis2-->
+    <parameter name="disableREST" locked="true">false</parameter>
+
+    <!-- If you have a front end host which exposes this webservice using a different public URL  -->
+    <!-- use this parameter to override autodetected url -->
+    <!--<parameter name="httpFrontendHostUrl">https://someotherhost/context</parameter>-->
+
+
+    <!--    The way of adding listener to the system-->
+    <!--    <listener class="org.apache.axis2.ObserverIMPL">-->
+    <!--        <parameter name="RSS_URL">http://127.0.0.1/rss</parameter>-->
+    <!--    </listener>-->
+
+    <!-- ================================================= -->
+    <!-- Message Receivers -->
+    <!-- ================================================= -->
+    <!--This is the deafult MessageReceiver for the system , if you want to have MessageReceivers for -->
+    <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
+    <!--any operation -->
+    <!--Note : You can ovrride this for a particular service by adding the same element with your requirement-->
+     <messageReceivers>
+        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+                         class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+                         class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+        <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only"
+                         class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+        <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out"
+                         class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+    </messageReceivers>
+
+    <!-- ================================================= -->
+    <!-- Message Formatter -->
+    <!-- ================================================= -->
+    <!--Following content type to message formatter mapping can be used to implement support for different message -->
+    <!--format  serialization in Axis2. These message formats are expected to be resolved based on the content type. -->
+    <messageFormatters>
+        <messageFormatter contentType="application/x-www-form-urlencoded"
+                         class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/>
+        <messageFormatter contentType="multipart/form-data"
+                         class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
+        <messageFormatter contentType="application/xml"
+                         class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
+    </messageFormatters>
+
+    <!-- ================================================= -->
+    <!-- Message Builders -->
+    <!-- ================================================= -->
+    <!--Following content type to builder mapping can be used to implement support for different message -->
+    <!--formats in Axis2. These message formats are expected to be resolved based on the content type. -->
+    <messageBuilders>
+        <messageBuilder contentType="application/xml"
+                         class="org.apache.axis2.builder.ApplicationXMLBuilder"/>
+        <messageBuilder contentType="application/x-www-form-urlencoded"
+                         class="org.apache.axis2.builder.XFormURLEncodedBuilder"/>
+        <messageBuilder contentType="multipart/form-data"
+                         class="org.apache.axis2.builder.MultipartFormDataBuilder"/>
+    </messageBuilders>
+
+    <!-- ================================================= -->
+    <!-- Transport Ins -->
+    <!-- ================================================= -->
+    <transportReceiver name="http"
+                       class="org.apache.axis2.transport.http.SimpleHTTPServer">
+        <parameter name="port">6060</parameter>
+        <!-- Here is the complete list of supported parameters (see example settings further below):
+            port: the port to listen on (default 6060)
+            hostname:  if non-null, url prefix used in reply-to endpoint references                                 (default null)
+            originServer:  value of http Server header in outgoing messages                                         (default "Simple-Server/1.1")
+            requestTimeout:  value in millis of time that requests can wait for data                                (default 20000)
+            requestTcpNoDelay:  true to maximize performance and minimize latency                                   (default true)
+                                false to minimize bandwidth consumption by combining segments
+            requestCoreThreadPoolSize:  number of threads available for request processing (unless queue fills up)  (default 25)
+            requestMaxThreadPoolSize:  number of threads available for request processing if queue fills up         (default 150)
+                                       note that default queue never fills up:  see HttpFactory
+            threadKeepAliveTime:  time to keep threads in excess of core size alive while inactive                  (default 180)
+                                  note that no such threads can exist with default unbounded request queue
+            threadKeepAliveTimeUnit:  TimeUnit of value in threadKeepAliveTime (default SECONDS)                    (default SECONDS)
+        -->
+        <!-- <parameter name="hostname">http://www.myApp.com/ws</parameter> -->
+        <!-- <parameter name="originServer">My-Server/1.1</parameter>           -->
+        <!-- <parameter name="requestTimeout">10000</parameter>                   -->
+        <!-- <parameter name="requestTcpNoDelay">false</parameter>                   -->
+        <!-- <parameter name="requestCoreThreadPoolSize">50</parameter>                      -->
+        <!-- <parameter name="RequestMaxThreadPoolSize">100</parameter>                     -->
+        <!-- <parameter name="threadKeepAliveTime">240000</parameter>                  -->
+        <!-- <parameter name="threadKeepAliveTimeUnit">MILLISECONDS</parameter>            -->
+    </transportReceiver>
+
+    <!--Uncomment this and configure as appropriate for JMS transport support, after setting up your JMS environment (e.g. ActiveMQ)
+    <transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
+        <parameter name="myTopicConnectionFactory">
+        	<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+        	<parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
+        	<parameter name="transport.jms.ConnectionFactoryJNDIName">TopicConnectionFactory</parameter>
+        </parameter>
+
+        <parameter name="myQueueConnectionFactory">
+        	<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+        	<parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
+        	<parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</parameter>
+        </parameter>
+
+        <parameter name="default">
+        	<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+        	<parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
+        	<parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</parameter>
+        </parameter>
+    </transportReceiver>-->
+
+    <!-- ================================================= -->
+    <!-- Mail Transport Listener  -->
+    <!-- This is a sample configuration. It assumes a mail server running in localhost.
+         Listener pops  messages that comes to the email address red@localhost. Users
+         password is red. Listener connect to the server every 3000 milliseconds.
+         Parameters with "transport." prefix is Axis2 specific. Others are all from Java Mail API. 
+         http://people.apache.org/~pzf/SMTPBase64Binding-0.2.html
+     -->
+    <!-- ================================================= -->
+    <!--<transportReceiver name="mailto" class="org.apache.axis2.transport.mail.SimpleMailListener">
+        <parameter name="mail.pop3.host">localhost</parameter>
+        <parameter name="mail.pop3.user">red</parameter>
+        <parameter name="mail.store.protocol">pop3</parameter>
+        <parameter name="transport.mail.pop3.password">red</parameter>
+        <parameter name="transport.mail.replyToAddress">red@localhost</parameter>
+        <parameter name="transport.listener.interval">3000</parameter>
+    </transportReceiver>-->
+
+	<!--Uncomment if you want to have TCP transport support-->
+    <!--transportReceiver name="tcp"
+                       class="org.apache.axis2.transport.tcp.TCPServer">
+        <parameter name="port">6060</parameter-->>
+        <!--If you want to give your own host address for EPR generation-->
+        <!--uncomment the following paramter , and set it as you required.-->
+        <!--<parameter name="hostname">tcp://myApp.com/ws</parameter>-->
+    <!-- /transportReceiver -->
+
+    <!-- ================================================= -->
+    <!-- Transport Outs -->
+    <!-- ================================================= -->
+
+    <transportSender name="tcp"
+                     class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+    <transportSender name="local"
+                     class="org.apache.axis2.transport.local.LocalTransportSender"/>
+    <transportSender name="http"
+                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+        <parameter name="PROTOCOL">HTTP/1.1</parameter>
+        <parameter name="Transfer-Encoding">chunked</parameter>
+
+        <!-- If following is set to 'true', optional action part of the Content-Type will not be added to the SOAP 1.2 messages -->
+        <!--  <parameter name="OmitSOAP12Action">true</parameter>  -->
+    </transportSender>
+
+    <transportSender name="https"
+                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+        <parameter name="PROTOCOL">HTTP/1.1</parameter>
+        <parameter name="Transfer-Encoding">chunked</parameter>
+    </transportSender>
+    <!--
+    <transportSender name="jms"
+                     class="org.apache.axis2.transport.jms.JMSSender"/>
+     -->
+    <!-- ================================================= -->
+    <!-- Mail Transport Sender  -->
+    <!--Only need to uncomment the sender. Configuration is achieved with every client.
+        At any instant mail host should be given. Sample configuration has been given.
+        http://people.apache.org/~pzf/SMTPBase64Binding-0.2.html
+   -->
+    <!-- ================================================= -->
+   <!--<transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
+        <parameter name="mail.smtp.host">localhost</parameter>
+    </transportSender>-->
+
+    <!-- ================================================= -->
+    <!-- Global Modules  -->
+    <!-- ================================================= -->
+    <!-- Comment this to disable Addressing -->
+    <module ref="addressing"/>
+
+    <module ref="sandesha2"/>
+	
+    <!--Configuring module , providing parameters for modules whether they refer or not-->
+    <!--<moduleConfig name="addressing">-->
+    <!--<parameter name="addressingPara">N/A</parameter>-->
+    <!--</moduleConfig>-->
+
+    <!-- ================================================= -->
+    <!-- Clustering  -->
+    <!-- ================================================= -->
+    <!-- Configure and uncomment following for preparing Axis2 to a clustered environment -->
+    <!--
+    <cluster class="org.apache.axis2.cluster.tribes.TribesClusterManager">
+        <parameter name="param1">value1</parameter>
+    	<configurationManager class="org.apache.axis2.cluster.tribes.configuration.TribesConfigurationManager">
+    	    <listeners>
+    	    </listeners>
+    	</configurationManager>
+    	<contextManager class="org.apache.axis2.cluster.tribes.context.TribesContextManager">
+    	    <listeners>
+    	    </listeners>
+    	</contextManager>
+    </cluster>
+    -->
+
+    <!-- ================================================= -->
+    <!-- Phases  -->
+    <!-- ================================================= -->
+    <phaseOrder type="InFlow">
+        <!--  System predefined phases       -->
+        <phase name="Transport">
+            <handler name="RequestURIBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher">
+                <order phase="Transport"/>
+            </handler>
+            <handler name="SOAPActionBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher">
+                <order phase="Transport"/>
+            </handler>
+        </phase>
+        <phase name="Addressing">
+             <handler name="AddressingBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
+                 <order phase="Addressing"/>
+            </handler>
+        </phase>
+        <phase name="Security"/>
+        <phase name="PreDispatch"/>
+        <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+            <handler name="RequestURIBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
+            <handler name="SOAPActionBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
+            <handler name="RequestURIOperationDispatcher"
+                     class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
+            <handler name="SOAPMessageBodyBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
+
+            <handler name="HTTPLocationBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
+        </phase>
+        <phase name="RMPhase"/>
+    </phaseOrder>
+    <phaseOrder type="OutFlow">
+        <!--      user can add his own phases to this area  -->
+	<phase name="soapmonitorPhase"/>
+		<phase name="RMPhase"/>
+        <phase name="OperationOutPhase"/>
+        <!--system predefined phase-->
+        <!--these phase will run irrespective of the service-->
+        <phase name="PolicyDetermination"/>
+        <phase name="MessageOut"/>
+        <phase name="Security"/>
+    </phaseOrder>
+    <phaseOrder type="InFaultFlow">
+        <phase name="Transport">
+            <handler name="RequestURIBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher">
+                <order phase="Transport"/>
+            </handler>
+            <handler name="SOAPActionBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher">
+                <order phase="Transport"/>
+            </handler>
+        </phase>
+        <phase name="Addressing">
+             <handler name="AddressingBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
+                 <order phase="Addressing"/>
+            </handler>
+        </phase>
+        <phase name="Security"/>
+        <phase name="PreDispatch"/>
+        <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+            <handler name="RequestURIBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
+            <handler name="SOAPActionBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
+            <handler name="RequestURIOperationDispatcher"
+                     class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
+            <handler name="SOAPMessageBodyBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
+
+            <handler name="HTTPLocationBasedDispatcher"
+                     class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
+        </phase>
+        <phase name="RMPhase"/>
+    </phaseOrder>
+    <phaseOrder type="OutFaultFlow">
+        <!--      user can add his own phases to this area  -->
+	<phase name="soapmonitorPhase"/>
+		<phase name="RMPhase"/>
+        <phase name="OperationOutFaultPhase"/>
+        <phase name="PolicyDetermination"/>
+        <phase name="MessageOut"/>
+    </phaseOrder>
+</axisconfig>

Added: webservices/sandesha/trunk/java/modules/persistence/test-resources/commons-logging.properties
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/persistence/test-resources/commons-logging.properties?rev=706650&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/modules/persistence/test-resources/commons-logging.properties (added)
+++ webservices/sandesha/trunk/java/modules/persistence/test-resources/commons-logging.properties Tue Oct 21 08:07:45 2008
@@ -0,0 +1,30 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# This is the logging properties that goes to the war, there are two logging conf kept at the 
+# svn, one for developement (one at src/test-resources) and other for producation
+ 
+# Uncomment the next line to disable all logging.
+#org.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog
+
+# Uncomment the next line to enable the simple log based logging
+#org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
+
+# Uncomment the next line to enable log4j based logging
+org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

Added: webservices/sandesha/trunk/java/modules/persistence/test-resources/log4j.properties
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/persistence/test-resources/log4j.properties?rev=706650&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/modules/persistence/test-resources/log4j.properties (added)
+++ webservices/sandesha/trunk/java/modules/persistence/test-resources/log4j.properties Tue Oct 21 08:07:45 2008
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Set root category priority to INFO and its only appender to CONSOLE.
+log4j.rootCategory=INFO, LOGFILE
+log4j.logger.org.apache.sandesha2=INFO
+
+# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p %c - %m%n
+
+# LOGFILE is set to be a File appender using a PatternLayout.
+log4j.appender.LOGFILE=org.apache.log4j.FileAppender
+log4j.appender.LOGFILE.File=axis2.log
+log4j.appender.LOGFILE.Append=true
+log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n

Added: webservices/sandesha/trunk/java/modules/persistence/test-resources/sandesha2-test.properties
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/persistence/test-resources/sandesha2-test.properties?rev=706650&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/modules/persistence/test-resources/sandesha2-test.properties (added)
+++ webservices/sandesha/trunk/java/modules/persistence/test-resources/sandesha2-test.properties Tue Oct 21 08:07:45 2008
@@ -0,0 +1 @@
+test.server.port=8060



---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org