[jboss-svn-commits] JBL Code SVN: r15943 - in labs/jbossesb/workspace/bramley/product/rosetta: src/org/jboss/soa/esb/addressing/eprs and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Oct 19 10:41:38 EDT 2007


Author: mark.little at jboss.com
Date: 2007-10-19 10:41:38 -0400 (Fri, 19 Oct 2007)
New Revision: 15943

Added:
   labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/InVMUnitTest.java
Modified:
   labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/actions/PreparedStatementAction.java
   labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/InVMEpr.java
Log:
Updated URI creation mechanism for InVMEpr to support lockstep.

Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/actions/PreparedStatementAction.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/actions/PreparedStatementAction.java	2007-10-19 14:39:50 UTC (rev 15942)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/actions/PreparedStatementAction.java	2007-10-19 14:41:38 UTC (rev 15943)
@@ -21,10 +21,16 @@
  */
 public class PreparedStatementAction extends AbstractActionLifecycle {
 
-	public static final String DATA_SOURCE = "org.jboss.soa.esb.actions.preparedStatement.dataSource";
-	public static final String SQL_STATEMENT = "org.jboss.soa.esb.actions.preparedStatement.sqlStatement";
-	public static final String SQL_PREPARED_FIELDS = "org.jboss.soa.esb.actions.preparedStatement.preparedFields";
+	public static final String TARGET_CATEGORY = "target-service-category";
+	public static final String TARGET_NAME = "target-service-name";
 	
+	public static final String SQL_STATEMENT = "sql-statement";	
+	public static final String DATA_SOURCE = "data-source";
+	
+	// comma separated list of fields to be inserted with the insert statement in the correct sequence (used in prepared statement)
+	//public static final String SQL_INSERT_FIELDS = "sql-insert-fields";
+	public static final String SQL_PREPARED_FIELDS = "sql-prepared-fields";
+	
 	public PreparedStatementAction(ConfigTree config) { 
 		  this._config = config; 
 	} 

Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/InVMEpr.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/InVMEpr.java	2007-10-19 14:39:50 UTC (rev 15942)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/InVMEpr.java	2007-10-19 14:41:38 UTC (rev 15943)
@@ -37,7 +37,7 @@
 /**
  * A helper class for using in-VM communication.
  * 
- * EPR: local://servicename
+ * EPR: invm://servicename[?lockstep<true|false>[#waittime<milliseconds>]]
  * 
  * You can have a lockstep service, where the sender thread is tied to
  * the one that does the execution (equivalent to the sender thread doing
@@ -52,7 +52,7 @@
 
 public class InVMEpr extends EPR
 {
-	public static final long DEFAULT_LOCKSTEP_WAIT_TIME = 10000; // 10 seconds
+	public static final long DEFAULT_LOCKSTEP_WAIT_TIME = 10000; // in millis, 10 seconds
 	
 	public static final String INVM_PROTOCOL = "invm";
 	public static final String SERVICE_TAG = "serviceId";
@@ -111,6 +111,8 @@
 		super(uri);
 
 		String serviceId = uri.getHost();
+		String lockstep = uri.getQuery();
+		String lockstepTime = uri.getFragment();
 		
 		if (serviceId == null)
 			throw new URISyntaxException(uri.toString(), "No serviceId specified!");
@@ -119,6 +121,23 @@
 			getAddr().addExtension(SERVICE_TAG, serviceId);
 			_serviceId = true;
 		}
+		
+		if ("true".equalsIgnoreCase(lockstep))
+		{
+			setLockstep(true);
+			
+			if (lockstepTime != null)
+			{
+				try
+				{
+					setLockstepWaitTime(Long.parseLong(lockstepTime));
+				}
+				catch (Exception ex)
+				{
+					ex.printStackTrace();
+				}
+			}
+		}
 	}
 	
 	public String getServiceId ()
@@ -196,6 +215,11 @@
 		_lockstepTime = true;
 	}
 	
+	public String toString ()
+	{
+		return "InVMEpr [ "+super.getAddr().extendedToString()+" ]";
+	}
+	
 	public static URI type ()
 	{
 	    return _type;

Added: labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/InVMUnitTest.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/InVMUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/InVMUnitTest.java	2007-10-19 14:41:38 UTC (rev 15943)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.addressing.helpers.tests;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.addressing.eprs.InVMEpr;
+
+/**
+ * Unit tests for the InVM EPR class.
+ * 
+ * @author Mark Little
+ */
+
+public class InVMUnitTest extends TestCase
+{
+
+	public void testConstructor ()
+	{
+		try
+		{
+			new InVMEpr(new URI("invm://myservice?true#1234"));
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetGet ()
+	{
+		try
+		{
+			InVMEpr em = new InVMEpr(new URI("invm://myservice?true#1234"));
+			
+			assertEquals(em.getServiceId(), "myservice");
+			assertEquals(em.getLockstep(), true);
+			assertEquals(em.getLockstepWaitTime(), 1234);
+			
+			em = new InVMEpr(new URI("invm://myservice"));
+			
+			assertEquals(em.getServiceId(), "myservice");
+			assertEquals(em.getLockstep(), false);
+			assertEquals(em.getLockstepWaitTime(), InVMEpr.DEFAULT_LOCKSTEP_WAIT_TIME);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+
+}




More information about the jboss-svn-commits mailing list