You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ad...@apache.org on 2006/02/28 17:05:47 UTC

svn commit: r381686 [34/40] - in /incubator/ode/scratch/bpe: ./ bpelTests/ bpelTests/probeService/ bpelTests/test1/ bpelTests/test10/ bpelTests/test12/ bpelTests/test13/ bpelTests/test14/ bpelTests/test15/ bpelTests/test16/ bpelTests/test17/ bpelTests/...

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/DocumentInteraction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/DocumentInteraction.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/DocumentInteraction.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/DocumentInteraction.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,227 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.interaction.spiimpl.document;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import com.sybase.bpe.client.IFormattableValue;
+import com.sybase.bpe.client.spi.interaction.ISPIInteraction;
+import com.sybase.bpe.client.spi.interaction.ISPIJaxenXPathQuery;
+import com.sybase.bpe.client.spi.interaction.ISPIQuery;
+import com.sybase.bpe.client.spi.interaction.ISPIXPathQuery;
+import com.sybase.bpe.interaction.operations.CopyChildrenOperation;
+import com.sybase.bpe.interaction.operations.CopyTreeOperation;
+import com.sybase.bpe.interaction.operations.GetTextValueOperation;
+import com.sybase.bpe.interaction.operations.IOperation;
+import com.sybase.bpe.interaction.operations.PruneOperation;
+import com.sybase.bpe.interaction.operations.SelectTreeOperation;
+import com.sybase.bpe.interaction.operations.SetTextValueOperation;
+import com.sybase.bpe.interaction.query.JaxenXPathSingleNodeQuery;
+import com.sybase.bpe.interaction.spiimpl.CannedFormattableValue;
+
+
+/**
+ * This class implements a full featured interaction for a DOM
+ * document.  Interactions which are not full featured will
+ * be converted by the BPE to this interaction if the BPE requires
+ * features they do not implement.
+ * 
+ * Note:
+ * It's interesting to note that XStream or other xml serialization 
+ * technology allows any object to be serialized as an xml document
+ * and consequently accessible via xpath.   
+ * 
+ * In the presence of XStream technology, the DocumentInteraction 
+ * becomes a rather painless and complete interoperability solution.  
+ * 
+ * Of course we still need to consider the type of xml which
+ * XStream generates and the performance implications.  XStream
+ * undoubtedly stuffs class names and other things in it's xml
+ * which you wouldn't expect in a pure content representation.
+ */
+class DocumentInteraction implements ISPIInteraction
+{
+	
+    static final long serialVersionUID = 6173403782746777645L;
+    
+	private LazyDocument m_documentHolder = new LazyDocument();
+	
+	DocumentInteraction()
+	{
+	}
+	DocumentInteraction( byte[] xmlbuffer )
+	{
+		m_documentHolder = new LazyDocument( xmlbuffer );
+	}
+	DocumentInteraction( Document document )
+	{
+		m_documentHolder = new LazyDocument( document );
+	}
+
+	public IFormattableValue getSimpleValue(ISPIQuery query)
+		
+	{
+		IOperation operation  = new GetTextValueOperation();
+		Object returnValue = 
+			executeOperation( operation, query, null );
+		return createFormattableValue( returnValue );
+	}
+
+	protected Object executeOperation(IOperation operation, ISPIQuery query,
+			Object argument)
+	{
+		try
+		{
+			JaxenXPathSingleNodeQuery jnq = new JaxenXPathSingleNodeQuery();
+			if (query instanceof ISPIJaxenXPathQuery)
+			{
+				ISPIJaxenXPathQuery jq = (ISPIJaxenXPathQuery) (query);
+				jnq.setLocator(jq.getDOMXPath());
+				jnq.setNamespaceMap(jq.getNamespaceMap());
+				jnq.setXPathExpression(jq.getXPathExpressionAsString());
+			} else if (query instanceof ISPIXPathQuery)
+			{
+				ISPIXPathQuery xq = (ISPIXPathQuery) (query);
+				jnq.setNamespaceMap(xq.getNamespaceMap());
+				jnq.setXPathExpression(xq.getXPathExpressionAsString());
+			}
+			Object operationResult = operation.execute(
+					m_documentHolder, jnq,
+					argument, jnq.getXPathExpression());
+			return operationResult;
+		} catch (Exception e)
+		{
+			throw new RuntimeException(e);
+		}
+	}
+	
+	public void setSimpleValue(ISPIQuery query, IFormattableValue iValue)
+			
+	{
+		IOperation operation  = new SetTextValueOperation();
+		String arg = ( String )iValue.getValueAs( String.class );
+		executeOperation( operation, query, arg );
+		m_documentHolder.setDirty(true);
+	}
+	public IFormattableValue getComplexValue(ISPIQuery query)
+			
+	{
+		IOperation operation  = new SelectTreeOperation();
+		Object returnValue = executeOperation( operation, query, null );
+		IFormattableValue value = createFormattableValue( returnValue );
+		return value;
+	}
+	public void setComplexValue(ISPIQuery query, 
+			IFormattableValue iValue)
+			
+	{
+		if (iValue.supportsGetValueAs(Node.class))
+		{
+			IOperation operation  = new CopyTreeOperation();
+			Node arg = ( Node )iValue.getValueAs( Node.class );
+			executeOperation( operation, query, arg );
+			m_documentHolder.setDirty(true);
+		}
+		else
+			setSimpleValue(query, iValue);
+	}
+	public void removeValue(ISPIQuery query) 
+	{
+		IOperation operation  = new PruneOperation();
+		executeOperation( operation, query, null );
+		m_documentHolder.setDirty(true);
+	}
+	public void copySubElements(ISPIQuery query, IFormattableValue source)
+			
+	{
+		IOperation operation  = new CopyChildrenOperation();
+		Node arg = ( Node )source.getValueAs( Node.class );
+		executeOperation( operation, query, arg );
+		m_documentHolder.setDirty(true);
+	}
+	public ISPIInteraction cloneSPIInteraction() 
+	{
+		throw new UnsupportedOperationException();
+	}
+	public void releaseHeldResources() 
+	{
+	}
+
+	public boolean supportsSetSimpleValue(ISPIQuery query, ISPIInteraction iValue)
+	{
+		return true;
+	}
+	public boolean supportsGetComplexValue(ISPIQuery query)
+	{
+		return true;
+	}
+	public boolean supportsSetComplexValue(ISPIQuery query, ISPIInteraction iValue)
+	{
+		return true;
+	}
+	public boolean supportsRemoveValue(ISPIQuery query)
+	{
+		return true;
+	}
+	public boolean supportsCopySubElements(ISPIQuery query, IFormattableValue source)
+	{
+		return true;
+	}
+	public boolean supportsCloneSPIInteraction() 
+	{
+		// Defer clone to the framework
+		return false;
+	}
+	
+	protected IFormattableValue createFormattableValue( Object value )
+	{
+		if ( value instanceof Document )
+		{
+			return new DocumentFormattableValue(
+					(Document)value );
+		}
+		else
+		{
+			return new CannedFormattableValue( value );
+		}
+	}
+	public boolean supportsSetSimpleValue(ISPIQuery query, 
+			IFormattableValue iValue)
+	{
+		return true;
+	}
+	public boolean supportsSetComplexValue(ISPIQuery query, 
+			IFormattableValue iValue)
+	{
+		return true;
+	}
+	public IFormattableValue getValue()
+	{
+		return new DocumentFormattableValue(m_documentHolder);
+	}
+	public boolean supportsGetSimpleValue(ISPIQuery query)
+	{
+		return true;
+	}
+	
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/DocumentInteractionFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/DocumentInteractionFactory.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/DocumentInteractionFactory.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/DocumentInteractionFactory.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,125 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+
+package com.sybase.bpe.interaction.spiimpl.document;
+
+import java.util.Properties;
+
+import org.w3c.dom.Document;
+
+import com.sybase.bpe.client.IDescribedValue;
+import com.sybase.bpe.client.IFormat;
+import com.sybase.bpe.client.formats.XMLFormat;
+import com.sybase.bpe.client.spi.interaction.ISPIInteraction;
+import com.sybase.bpe.client.spi.interaction.ISPIInteractionFactory;
+
+
+public class DocumentInteractionFactory 
+  implements ISPIInteractionFactory
+{
+	
+    static final long serialVersionUID = -4030617350592369896L;
+    
+
+	public ISPIInteraction createAnyTypeInteraction() 
+	{
+		return new DocumentInteraction();
+	}
+
+	public ISPIInteraction 
+	  createInteraction(IDescribedValue describedValue) 
+	{
+		Object data = describedValue.getData();
+		if ( data instanceof byte[] )
+		{
+			return new DocumentInteraction( (byte[])(data));
+		}
+		if ( data instanceof String )
+		{
+			return new DocumentInteraction( ((String)(data)).getBytes());
+		}
+		if ( data instanceof Document )
+		{
+			return new DocumentInteraction( (Document)(data));
+		}
+		if ( data == null )
+		{
+			return createAnyTypeInteraction();
+		}
+		throw new UnsupportedOperationException();
+		
+	}
+
+	public boolean supportsInteraction(IDescribedValue describedValue)
+	{
+		Object data = describedValue.getData();
+		IFormat format = describedValue.getFormat();
+		boolean formatIsXML = ( format != null ) 
+		  && ( format instanceof XMLFormat);
+		Properties contentType = 
+			describedValue.getContentType();
+		
+		// This factory doesn't support content
+		// type specifiers, so if the user supplied
+		// content type specifiers, we must
+		// return false.
+		if ( contentType != null && 
+		   !(	contentType.isEmpty() ) )
+		{
+			return false;
+		}
+		
+		if ( data instanceof Document )
+		{
+			return true;
+		}
+		
+		// Format must match if it exists.
+		if ( format != null && ( ! ( format instanceof XMLFormat ) ) )
+		{
+			return false;
+		}
+		
+		if ( data instanceof byte[] && formatIsXML )
+		{
+			return true;
+		}
+		
+		if ( data instanceof String && formatIsXML )
+		{
+			return true;
+		}
+		
+		if ( data == null )
+		{
+			return true;
+		}
+		
+		return false;
+	}
+
+	public boolean supportsAnyType()
+	{
+		// TODO Auto-generated method stub
+		return true;
+	}
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/LazyDocument.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/LazyDocument.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/LazyDocument.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/LazyDocument.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,200 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+
+package com.sybase.bpe.interaction.spiimpl.document;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+
+import org.apache.xml.serializer.Method;
+import org.apache.xml.serializer.OutputPropertiesFactory;
+import org.apache.xml.serializer.Serializer;
+import org.apache.xml.serializer.SerializerFactory;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+
+import com.sybase.bpe.interaction.IDocumentAccessible;
+import com.sybase.bpe.interaction.InteractionException;
+import com.sybase.bpe.util.XMLDocBuilderByThread;
+
+
+/**
+ * A class that defers deserialization of its contained
+ * object until it is requested.  This facility is useful
+ * for cases where the process context tree is brought in
+ * and out memory but the business process does not need
+ * access to all the parts of its context.
+ */
+public class LazyDocument implements Serializable, IDocumentAccessible
+{
+    static final long serialVersionUID = -279092603880466152L;
+    
+	private transient Document m_document;
+	private transient boolean m_dirty;
+	private transient Serializer m_serializer;
+	//private transient SerializerToXML m_serializer;
+	private byte[] m_xmlbuffer= new byte[0];
+	
+	public LazyDocument()
+	{
+	}
+	
+	public LazyDocument( byte[] xmlbytes )
+	{
+		m_xmlbuffer = xmlbytes;
+	}
+	
+	protected void setEmptyDocument()
+	{
+		m_document = 
+			getDocBuilder().newDocument();
+	}
+	
+	protected DocumentBuilder getDocBuilder()
+	{
+		try
+		{
+			// TODO: Need a better way to obtain a document
+			// builder.
+			return XMLDocBuilderByThread.getDocBuilder();
+		} catch (InteractionException e)
+		{
+			throw new RuntimeException(e);
+		}
+	}
+	
+	public LazyDocument( Document iDocument )
+	{
+		m_document = iDocument;
+	}
+	
+	public Document getDocument() 
+	{
+		if ( m_document == null )
+		{
+			deserializeDocument();
+		}
+		return m_document;
+	}
+	
+	
+	private void deserializeDocument() 
+	{
+		try
+		{
+			if ( m_xmlbuffer.length > 0 )
+			{
+				ByteArrayInputStream bai = 
+					new ByteArrayInputStream(m_xmlbuffer);
+				InputSource in = new InputSource(bai);
+				m_document = 
+					XMLDocBuilderByThread.getDocBuilder().parse(in);
+			}
+			else
+			{
+				setEmptyDocument();
+			}
+		}
+		catch( Exception e )
+		{
+			throw new RuntimeException( e );
+		}
+		
+	}
+
+	private void writeObject(ObjectOutputStream s) throws IOException
+	{
+		serializeDocument();
+		s.defaultWriteObject();
+	}
+	
+	public void setDirty( boolean dirty )
+	{
+		m_dirty = dirty;
+	}
+	
+	public byte[] getXMLBuffer()
+	{
+		try
+		{
+			serializeDocument();
+		} catch (IOException e)
+		{
+			throw new UnsupportedOperationException( e.toString());
+		}
+		return m_xmlbuffer;
+	}
+
+	private void serializeDocument() throws IOException
+	{
+		if ( (m_xmlbuffer.length == 0) || m_dirty )
+		{	
+			// If the document has no child nodes, 
+			// we don't want to serialize it because
+			// a sax parse error occurs when 
+			// reconstructing an empty document
+			// from the buffer.
+			if (m_document != null && m_document.hasChildNodes())
+			{	
+				if (m_serializer == null)
+				{
+					Properties props = OutputPropertiesFactory.getDefaultMethodProperties(Method.XML);
+					m_serializer = SerializerFactory.getSerializer(props);
+
+				}
+
+				ByteArrayOutputStream bao = 
+					new ByteArrayOutputStream();
+				m_serializer.setOutputStream(bao);
+				m_serializer.asDOMSerializer().serialize(m_document);
+				//m_serializer.setOutputStream(bao);
+				//m_serializer.serialize(m_document);
+				m_xmlbuffer=bao.toByteArray();
+				setDirty(false);
+			}
+			else
+			{
+				// The document either does not exist or is
+				// empty, so clear the buffer.
+				m_xmlbuffer = new byte[0];
+			}
+		}
+	}
+	
+	public Object getConvenientForm()
+	{
+		if ( m_dirty == true )
+		{
+			return getDocument();
+		}
+		else
+		{
+			return getXMLBuffer();
+		}
+	}
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/lang/ResourceGetter.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/lang/ResourceGetter.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/lang/ResourceGetter.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/lang/ResourceGetter.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,109 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.lang;
+
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Gets messages from the ResourceBundle.
+ */
+public final class ResourceGetter
+{
+	
+	private static Logger logger = 
+		Logger.getLogger(ResourceGetter.class.getName());
+		
+    private static final ResourceBundle RESOURCE_BUNDLE = 
+    	ResourceBundle.getBundle("com/sybase/bpe/lang/ResourceBundle");
+    private static final MessageFormat BAD_MESSAGE = 
+    	new MessageFormat("{0} [illegal message format in resource bundle]");
+
+   /**
+     * Returns a string from the ResourceBundles.
+     *
+     * @param s the key for the string to get
+     *
+     * @return the string
+     */
+    public static String getString ( String s )
+    {
+    	String s1 = s;
+        try
+        {
+            s1 = RESOURCE_BUNDLE.getString(s);
+            return s1;
+        }
+        catch ( Exception e )
+        {
+        	
+        }
+        return s1;
+    }
+
+    /**
+     * Get a formatted string from the ResourceBundles.
+     *
+     * @param s     the key for the format in the bundle
+     * @param aobj  the array of objects to push into the format
+     *
+     * @return      the formatted string
+     */
+    public static String getFormatted(String s, Object aobj[])
+    {
+        if(aobj == null)
+        {
+            return getString(s);
+        } else
+        {
+            MessageFormat messageformat = getFormat(s);
+        return messageformat.format(((Object) (aobj)));
+        }
+    }
+
+    /**
+     * Check the format string out and return it as a MessageFormat.
+     *
+     * @param s     the format string
+     *
+     * @return      the MessageFormat
+     */
+    public static MessageFormat getFormat(String s)
+    {
+        String s1 = getString(s);
+        try
+        {
+//            MessageFormat messageformat = new MessageFormat(s1);
+            return new MessageFormat(s1);
+        }
+            catch(IllegalArgumentException illegalargumentexception)
+        {
+        	logger.log(Level.SEVERE,
+        		"BAD_MESSAGE Format",
+        		illegalargumentexception);
+            return new MessageFormat(BAD_MESSAGE.format(s));
+        }
+    }
+    
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/DBLockingService.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/DBLockingService.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/DBLockingService.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/DBLockingService.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,277 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+
+package com.sybase.bpe.locking;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.ResultSet;
+
+import com.sybase.bpe.util.BPEProperties;
+
+/**
+ *
+ * @author cpotter
+ *
+ * This class is used by BPE code that needs an exclusive lock on a shared
+ * resource.
+ *
+ * This class uses the locking capabilities of the RDBMS to acquire an 
+ * exclusive lock on a resource identifier.
+ *
+ * is dependent on the table BPEMUTEX <BR>
+ * {<BR>
+ *       ID int - an integer value between -999 and 999 inclusive <BR>
+ *       MUTEX char[1] - the update column <BR>
+ * }<BR>
+ *
+ */
+public class DBLockingService implements LockingService {
+	
+	private static Logger logger =
+		Logger.getLogger(DBLockingService.class.getName());
+		
+	/* (non-Javadoc)
+	 * @see com.sybase.bpe.locking.LockingService#lock()
+	 */
+	public void lock(String aKey) {
+		int hashCode = aKey.hashCode() % 1000;
+		update(hashCode);
+	}
+
+	/* (non-Javadoc)
+	 * @see com.sybase.bpe.locking.LockingService#init(com.sybase.bpe.util.BPEProperties)
+	 */
+	public void init(BPEProperties props) {
+		
+		try {
+			int hashBuckets = Integer.valueOf(props.getLockingServiceHashBuckets()).intValue();
+			InitialContext ictx = new InitialContext();
+			Object obj = ictx.lookup(DB_LOCKING_SERVICE_THE_DB);
+			m_dataSource = (DataSource) obj;
+			if ( ! initialized ) {
+				initDB(hashBuckets);
+				initialized = true;
+			}
+		} catch (NamingException ne) {
+			logger.log(Level.SEVERE, "", ne);
+		}
+	
+	}
+
+	private void  insertMetaData(Connection aConn, int  aHashBucketsSize) {
+		PreparedStatement stmt = null,
+		                   stmt2 = null;
+//		int rowCount = 0;
+
+		try {
+			
+			// Delete any existing meta-data
+			
+			stmt = aConn.prepareStatement(DB_LOCKING_SERVICE_DELETE);
+			stmt.executeUpdate();
+			stmt.close();
+			
+			// Insert the positive half of the hash buckets individually
+			
+			stmt = aConn.prepareStatement(DB_LOCKING_SERVICE_INSERT);
+			
+			for (int cntr=1; cntr<aHashBucketsSize; cntr++) {
+				stmt.setInt(1, cntr);
+				stmt.setString(2, "I");
+				stmt.executeUpdate();
+			}
+			
+			// Mass insert the negative half of the hash buckets
+			
+			stmt2 = aConn.prepareStatement(DB_LOCKING_SERVICE_BATCH_INSERT);
+			stmt2.executeUpdate();
+			
+			// Insert the hash bucket for the 0 key
+			
+			stmt.setInt(1, 0);
+			stmt.setString(2, "I");
+			stmt.executeUpdate();
+		} catch (SQLException se) {
+			logger.log(Level.SEVERE, "", se);
+		} finally {
+			if (stmt != null) {
+				try {
+					stmt.close();
+				} catch (SQLException se) {
+				
+					// Don't really care if there is a problem closing
+				}
+				stmt = null;
+			}
+			
+			if (stmt2 != null) {
+				try {
+					stmt2.close();
+				} catch (SQLException se) {
+				
+					// Don't really care if there is a problem closing
+				}
+				stmt2 = null;
+			}
+		}
+	}
+	
+	private void  createTable(Connection aConn, int  aHashBucketsSize) {
+		PreparedStatement stmt = null;
+//		int rowCount = 0;
+
+		try {
+			stmt = aConn.prepareStatement(DB_LOCKING_SERVICE_CREATE);
+			stmt.executeUpdate();
+			stmt.close();
+			
+			stmt = aConn.prepareStatement(DB_LOCKING_SERVICE_INDEX);
+			stmt.executeUpdate();
+		} catch (SQLException se) {
+			logger.log(Level.SEVERE, "", se);
+		} finally {
+			if (stmt != null) {
+				try {
+					stmt.close();
+				} catch (SQLException se) {
+				
+					// Don't really care if there is a problem closing
+				}
+				stmt = null;
+			}
+		}
+	}
+	
+	private void  initDB(int  aHashBucketsSize) {
+		Connection conn = null;
+		PreparedStatement stmt = null;
+		int rowCount = 0;
+
+		try {
+			conn = m_dataSource.getConnection();
+			stmt = conn.prepareStatement(DB_LOCKING_SERVICE_SELECT);
+			ResultSet rs = stmt.executeQuery();
+
+			if (rs.next()) {
+				rowCount = rs.getInt(1);
+			}
+			
+			rs.close();
+			
+			// Number of hash buckets changed
+			
+			if (rowCount != (2*(aHashBucketsSize-1))+1) {
+				
+				// Re-created hash bucket meta-data
+				
+				insertMetaData(conn, aHashBucketsSize);
+			}
+		} catch (SQLException se) {
+		
+			// Assume table doesn't exist and create it
+			
+			createTable(conn, aHashBucketsSize);
+			insertMetaData(conn, aHashBucketsSize);
+		} finally {
+			if (stmt != null) {
+				try {
+					stmt.close();
+				} catch (SQLException se) {
+				
+					// Don't really care if there is a problem closing
+				}
+				stmt = null;
+			}
+
+			if (conn != null) {
+				try {
+					conn.close();
+				} catch (SQLException se) {
+				
+					// Don't really care if there is a problem closing
+				}
+				conn = null;
+			}
+		}
+	}
+	
+	private void  update(int  aKey) {
+		Connection conn = null;
+		PreparedStatement stmt = null;
+		int rowCount = 0;
+
+		try {
+			conn = m_dataSource.getConnection();
+			stmt = conn.prepareStatement(DB_LOCKING_SERVICE_UPDATE);
+			stmt.setString(1, "U");
+			stmt.setInt(2, aKey);
+			rowCount = stmt.executeUpdate();
+
+			if (rowCount != 1) {
+				logger.log(Level.SEVERE, "", new LockingServiceException("DB_LOCKING_SERVICE", new Object[] {"update"}));
+			}
+		} catch (SQLException se) {
+			logger.log(Level.SEVERE, "", se);
+		} finally {
+			if (stmt != null) {
+				try {
+					stmt.close();
+				} catch (SQLException se) {
+				
+					// Don't really care if there is a problem closing
+				}
+				stmt = null;
+			}
+
+			if (conn != null) {
+				try {
+					conn.close();
+				} catch (SQLException se) {
+				
+					// Don't really care if there is a problem closing
+				}
+				conn = null;
+			}
+		}
+	}
+	
+	private DataSource m_dataSource = null;
+	
+	private static final String DB_LOCKING_SERVICE_THE_DB = "java:comp/env/jdbc/theDB";
+	private static final String DB_LOCKING_SERVICE_UPDATE = "update BPE_MUTEX set touch = ? where id = ?";
+	private static final String DB_LOCKING_SERVICE_SELECT = "select count(*) from BPE_MUTEX";
+	private static final String DB_LOCKING_SERVICE_DELETE = "delete from BPE_MUTEX";
+	private static final String DB_LOCKING_SERVICE_INSERT = "insert into BPE_MUTEX (id, touch) values (?, ?)";
+	private static final String DB_LOCKING_SERVICE_BATCH_INSERT = "insert into BPE_MUTEX select 0-id, touch from BPE_MUTEX";
+	private static final String DB_LOCKING_SERVICE_CREATE = "create table BPE_MUTEX(id integer, touch char(1))";
+	private static final String DB_LOCKING_SERVICE_INDEX = "create unique index pk_BPE_MUTEX on BPE_MUTEX(id)";
+	
+	private static boolean initialized = false;
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/IMLockingService.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/IMLockingService.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/IMLockingService.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/IMLockingService.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,60 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+
+package com.sybase.bpe.locking;
+
+//import java.util.logging.Logger;
+
+import com.sybase.bpe.util.BPEProperties;
+
+/**
+ *
+ * @author cpotter
+ *
+ * This class is used by BPE code that needs an exclusive lock on a shared
+ * resource.  This class is intended for use with the in-memory BPE
+ * configuration.
+ *
+ */
+public class IMLockingService implements LockingService {
+	
+//	private static Logger logger =
+//		Logger.getLogger(IMLockingService.class.getName());
+		
+	/* (non-Javadoc)
+	 * @see com.sybase.bpe.locking.LockingService#lock()
+	 */
+	public void lock(String aKey) {
+
+		// No implementation for in-memory configuration
+
+	}
+
+	/* (non-Javadoc)
+	 * @see com.sybase.bpe.locking.LockingService#init(com.sybase.bpe.util.BPEProperties)
+	 */
+	public void init(BPEProperties props) {
+
+		// No implementation for in-memory configuration
+
+	}
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/LockingService.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/LockingService.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/LockingService.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/LockingService.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,35 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.locking;
+
+import com.sybase.bpe.util.BPEProperties;
+
+/**
+ * @author cpotter
+ *
+ * Produces locks for serialized execution.
+ * 
+ */
+public interface LockingService {
+	public void lock(String aKey);
+	public void init(BPEProperties props) throws LockingServiceException;
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/LockingServiceException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/LockingServiceException.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/LockingServiceException.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/LockingServiceException.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,57 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.locking;
+
+import com.sybase.bpe.util.BPException;
+
+/**
+ * @author cpotter
+ *
+ * 
+ * 
+ */
+public class LockingServiceException extends BPException {
+	
+	static final long serialVersionUID = -1788410114530593675L;
+
+
+	/**
+	 * @param message_id
+	 * @param msgParams
+	 */
+	public LockingServiceException(String message_id, Object[] msgParams) {
+		super(message_id, msgParams);
+	}
+
+	/**
+	 * @param message_id
+	 * @param msgParams
+	 * @param cause
+	 */
+	public LockingServiceException(
+		String message_id,
+		Object[] msgParams,
+		Throwable cause) {
+		super(message_id, msgParams, cause);
+	}
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/LockingServiceFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/LockingServiceFactory.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/LockingServiceFactory.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/locking/LockingServiceFactory.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,71 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.locking;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * @author cpotter
+ *
+ * Instantiates an implementation of LockingService
+ * 
+ */
+public class LockingServiceFactory {
+	
+private static Logger logger = 
+		Logger.getLogger(LockingServiceFactory.class.getName());
+
+	public static LockingService createLockingService(BPEProperties props)
+		throws LockingServiceException {
+		LockingService ls = null;
+
+		try {
+			// load the implementation
+			Class lockClass = java.lang.Class.forName(props.getLockingServiceClass());
+			// try to instantiate the subclass
+			ls = (LockingService) lockClass.newInstance();
+			ls.init(props);
+
+		} catch (ClassNotFoundException e) {
+			LockingServiceException lse = new LockingServiceException("CLASS_NOT_FOUND",new Object[] {props.getEventDirectorClass()});
+			lse.log(logger,Level.SEVERE);
+			throw lse;
+		} catch (InstantiationException e) {
+			LockingServiceException lse = new LockingServiceException("NATIVE_EXCEPTION",new Object[] {"InstantiationException"},e);
+			lse.log(logger,Level.SEVERE);
+			throw lse;
+		} catch (IllegalAccessException e) {
+			LockingServiceException lse = new LockingServiceException("NATIVE_EXCEPTION",new Object[] {"IllegalAccessException"},e);
+			lse.log(logger,Level.SEVERE);
+			throw lse;
+		} catch (BPException e) {
+			throw new LockingServiceException("BPE_EXCEPTION",new Object[]{},e);
+		}
+
+	  return ls;
+
+	}
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/MinMaxObjPool.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/MinMaxObjPool.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/MinMaxObjPool.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/MinMaxObjPool.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,405 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.pool;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An ObjPool abstract class that has an initial size and an
+ * optional max size.  The pool will grow as needed by blocks
+ * until the max size is reached.
+ *
+ * if max pool size is set to -1, the pool grows
+ * forever.  if max pool and min pool are the same,
+ * the pool does not grow beyond what was initialized
+ * unless specifically told to do so.
+ *
+ * @author Bill Flood
+ * @version 1.1
+ * @see ObjPool
+ * @see SimpleObjPool
+ * @since 1.1
+ */
+public abstract class MinMaxObjPool extends SimpleObjPool {
+	private int maxPoolSize = -1;
+	private int initialPoolSize = 1;
+	private int createWaitTime = 0;
+	private int growBlock = 1;
+	// Passed in by subclass (don't care if it is a Set or List).
+	protected Collection pool;
+	
+	private static Logger logger = 
+			Logger.getLogger(MinMaxObjPool.class.getName());
+	
+	/**
+	 * Types of objects for which this pool
+	 * has been initialized.  If we did not check this
+	 * the object type requested might not be found in the
+	 * pool and the user would wait forever for one of this
+	 * type to be checked in.
+	 */
+	Set supportedTypes = Collections.synchronizedSet(new HashSet());
+
+	/**
+	 * User Supplied routine to identify which object
+	 * in the pool to use.  Allows the user to supply
+	 * which object in the pool they determine is
+	 * "best" suited at this time.
+	 *
+	 * @param factory factory used to match, if necessary. This is the
+	 *                same factory passed into checkout (by the user)
+	 *                that resulted in this method being called.
+	 * @param auth    Authorization object passed into the checkout
+	 *                method that resulted in this method being called.
+	 * @param objSpec Object specification passed into checkout that
+	 *                resulted in this object being called.
+	 * @return
+	 * @exception Exception
+	 * @since 1.1
+	 */
+	abstract protected ObjPoolObject getUserIdentifiedObject(Object factory, Object auth, Object objSpec) throws PoolException;
+
+	/**
+	 * Initialize the object pool.  Checked out
+	 * objects will be monitored if monitorCheckedOutObjects
+	 * is true.
+	 *
+	 * @param pool   The collection to use.  It must be empty.
+	 * @param monitorCheckedOutObjects
+	 *               If true, the pool monitors objects (retain a reference)
+	 *               to objects that have been checked out from the
+	 *               pool.
+	 * @since 1.1
+	 */
+	public MinMaxObjPool(Collection pool, boolean monitorCheckedOutObjects) throws PoolException {
+		super(monitorCheckedOutObjects);
+		if (pool.isEmpty() == false) {
+			PoolException pe = new PoolException("POOL_INIT_1",null);
+			pe.log(logger,Level.SEVERE);
+			throw pe;
+		}
+		this.pool = pool;
+	}
+
+	/**
+	 * Initialize the object pool.  Checked out
+	 * objects will be monitored.
+	 *
+	 * The Collection used to initialize the pool must
+	 * be empty.
+	 *
+	 * @param pool
+	 * @since 1.1
+	 */
+	public MinMaxObjPool(Collection pool) throws PoolException {
+		super();
+		if (pool.isEmpty() == false) {
+			PoolException pe = new PoolException("POOL_INIT_1",null);
+			pe.log(logger,Level.SEVERE);
+			throw pe;
+		}
+		this.pool = pool;
+	}
+
+	/**
+	 * Overridden method to ensure that we don't block on objects that this
+	 * pool has not been initialized to contain based on the objectSpec argument.
+	 *
+	 * @param factory    factory used to match, if necessary. This is the
+	 *                   same factory passed into checkout (by the user)
+	 *                   that resulted in this method being called.
+	 * @param auth       Authorization object passed into the checkout
+	 *                   method that resulted in this method being called.
+	 * @param objectSpec
+	 * @return
+	 * @exception Exception
+	 * @since 1.1
+	 */
+	public ObjPoolObject checkout(Object factory, Object auth, Object objectSpec) throws PoolException {
+		if (supportedTypes.contains(objectSpec) == false) {
+			PoolException pe = new PoolException("POOL_INIT_2",null);
+			pe.log(logger,Level.SEVERE);
+			throw pe;
+		}
+		return super.checkout(factory, auth, objectSpec);
+	}
+
+	/**
+	 * Get the number of objects in the pool that are available.
+	 *
+	 * @return
+	 */
+	public int getObjPoolSize() {
+		return this.pool.size();
+	}
+
+	/**
+	 * Get the current size of the pool.  Returns (objects available
+	 * + objects in use)
+	 *
+	 * @return
+	 */
+	public int getCurrentPoolSize() {
+		int size = 0;
+		synchronized (sync) {
+			size = getObjPoolSize() + getObjectsInUse();
+		}
+		return size;
+	}
+
+	/**
+	 * Gets the next object from the pool.  If the pool is
+	 * empty, it is grown by not more than poolGrowBlock elements
+	 * up to maxPoolSize total.
+	 *
+	 * @param factory
+	 * @param auth
+	 * @param objSpec
+	 * @return
+	 * @exception Exception If there is a problem getting the next object from the pool -- could be caused by the createObjPoolObject() throwing an exception.
+	 */
+	protected ObjPoolObject getNextPoolObject(Object factory, Object auth, Object objSpec) throws PoolException
+	{
+		// pool's not empty -- just get one from there
+		ObjPoolObject ret = null;
+		synchronized (sync) {
+
+			// Let the implementation tell if it's already in the pool
+			// and the best one to use if it is.
+			ret = getUserIdentifiedObject(factory, auth, objSpec);
+			if (ret != null) {
+				return ret;
+			}
+			// grow the pool by "growBlock" elements.
+			else if (getCurrentPoolSize() < maxPoolSize) {
+				int currentPoolSize = getCurrentPoolSize();
+				for (int i=1; i<growBlock && maxPoolSize >= currentPoolSize; i++) {
+					pool.add(createObjPoolObject(factory, auth, objSpec));
+					doCreateWait();
+				}
+				return createObjPoolObject(factory, auth, objSpec);
+			}
+			// special case -- if pool size == -1, grow forever.
+			else if (maxPoolSize == -1) {
+				for (int i=1; i<growBlock; i++) {
+					pool.add(createObjPoolObject(factory, auth, objSpec));
+					doCreateWait();
+				}
+				return createObjPoolObject(factory, auth, objSpec);
+			}
+		}
+		// null - nothing in pool that matches right now.
+		return ret;
+	}
+
+	/**
+	 * Change the maximum size of the object pool.
+	 *
+	 * @param size
+	 * @exception PoolException
+	 *                   If the number of objects in use is
+	 *                   greater than the desired size of the pool, or if the
+	 *                   desired size is smaller than the initial size for
+	 *                   this pool, or if we would need to evict objects
+	 *                   from the pool.
+	 */
+	public void setMaxObjPoolSize(int size) throws PoolException
+	{
+		synchronized (sync) {
+			if (size < getObjectsInUse()) {
+				PoolException pe = new PoolException("POOL_ADJ_1",null);
+				pe.log(logger,Level.SEVERE);
+				throw pe;
+			}
+			if (size < initialPoolSize) {
+				PoolException pe = new PoolException("POOL_ADJ_2",null);
+				pe.log(logger,Level.SEVERE);
+				throw pe;
+			}
+			// Would objects get evicted?
+			if (getCurrentPoolSize() - size > 0) {
+				PoolException pe = new PoolException("POOL_ADJ_3",null);
+				pe.log(logger,Level.SEVERE);
+				throw pe;
+			}
+			maxPoolSize = size;
+		}
+	}
+
+	private void doCreateWait() {
+		if (createWaitTime > 0) {
+			try {
+				Thread.sleep(createWaitTime);
+			}
+			catch (InterruptedException x) {
+				;
+			}
+		}
+	}
+
+	/**
+	 * Initialize the pool.
+	 * Reads the following from the Properties:
+	 *
+	 * pool.initialSize(Integer)
+	 * The initial pool size (default is 1).
+	 *
+	 * pool.maxSize (Integer)
+	 * The max pool size (default is -1).  If the max
+	 * pool size is -1, the pool grows infinitely.
+	 *
+	 * pool.growBlock (Integer)
+	 * The grow size (default is 1).  When a new
+	 * object is needed, this many are created.
+	 *
+	 * pool.createWaitTime (Integer)
+	 * The time (in ms) to sleep between pool object creates
+	 * (default is 0).
+	 *
+	 * @param prop
+	 * @param factory
+	 * @param auth
+	 * @param objSpec
+	 * @exception Exception If there is an exception initializing the pool.
+	 */
+	public void init(Properties prop, Object factory, Object auth, Object objSpec)
+	throws PoolException
+	{
+		if (pool.isEmpty() == false) {
+			PoolException pe = new PoolException("POOL_INIT_3",null);
+			pe.log(logger,Level.SEVERE);
+			throw pe;
+		}
+		
+		String value = prop.getProperty("pool.initialSize");
+		if (value != null) initialPoolSize = Integer.parseInt(value);
+		value = prop.getProperty("pool.maxSize");
+		if (value != null) maxPoolSize = Integer.parseInt(value);
+		value = prop.getProperty("pool.growBlock");
+		if (value != null) growBlock = Integer.parseInt(value);
+		value = prop.getProperty("pool.createWaitTime");
+		if (value != null) createWaitTime = Integer.parseInt(value);
+
+		// load up the pool.
+		for (int i=0; i<initialPoolSize; i++) {
+			pool.add(createObjPoolObject(factory, auth, objSpec));
+		}
+		supportedTypes.add(objSpec);
+	}
+
+	/**
+	 *  Calls deleteObjPoolObject() on all objects
+	 *  currently in the pool, and then re-creates the initial
+	 *  number of them.
+	 *
+	 *  @exception Exception If there is an exception re-initializing the pool.
+	 */
+	public void reInitializeObjPool(Object factory, Object auth, Object objSpec)
+	throws Exception
+	{
+		synchronized (sync) {
+			Iterator it = pool.iterator();
+			while (it.hasNext()) {
+				ObjPoolObject obj = (ObjPoolObject)it.next();
+				obj.deleteObjPoolObject();
+			}
+			pool.clear();
+
+			for (int i=0; i<initialPoolSize; i++) {
+				pool.add(createObjPoolObject(factory, auth, objSpec));
+				doCreateWait();
+			}
+		}
+		// Synchronized object.
+		supportedTypes.add(objSpec);
+	}
+
+	/**
+	 *  @exception Exception If there is an exception re-initializing the pool.
+	 */
+	public void growObjPool(int additionalSize, Object factory, Object auth, Object objSpec)
+	throws Exception
+	{
+		synchronized (sync) {
+		    setMaxObjPoolSize(getInitialObjPoolSize() + additionalSize);
+			for (int i=0; i<additionalSize; i++) {
+				pool.add(createObjPoolObject(factory, auth, objSpec));
+				doCreateWait();
+			}
+		}
+		// Synchronized object.
+		supportedTypes.add(objSpec);
+	}
+
+
+	/**
+	 *  @see SimpleObjPool
+	 */
+	//protected void checkinPoolObject(ObjPoolObject o) {
+	//	pool.add(o);
+	//}
+
+	/**
+	 *  Get the initial size of the pool.
+	 */
+	public int getInitialObjPoolSize() {
+		return this.initialPoolSize;
+	}
+
+	/**
+	 *  Get the maximum number of objects this pool will hold.
+	 */
+	public int getMaxObjPoolSize() {
+		return this.maxPoolSize;
+	}
+
+	/**
+	 *  Get the number of objects the pool should grow by when
+	 *  it needs to grow.
+	 */
+	public int getObjPoolGrowSize() {
+		return this.growBlock;
+	}
+
+	/**
+	 *  Get the number of milliseconds to sleep between
+	 *  creates of new objects for the pool.
+	 */
+	public int getCreateWaitTime() {
+		return this.createWaitTime;
+	}
+	
+	/**
+	 * Add a supported type
+	 */
+	public void addSupportedType(Object objectSpec) {
+		supportedTypes.add(objectSpec);
+	}
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/ObjPool.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/ObjPool.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/ObjPool.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/ObjPool.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,113 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.pool;
+
+import java.util.Properties;
+
+/**
+ * The interface for a generic object pool. Implemented
+ * by subclasses that want to take advantage of 
+ * pooling mechanisms.
+ * 
+ * @author Bill Flood
+ * @version 1.1
+ * @see ObjPoolObject
+ * @since 1.1
+ */
+public interface ObjPool {
+	/**
+	 * Get an object out of the pool.
+	 * 
+	 * @param factory    The factory used to create the pooled object.
+	 *                   This is not used internally other than to pass
+	 *                   it out to methods implemented by the user.
+	 * @param auth       A user-defined object that the user-implemented
+	 *                   methods will be supplied.  Not used internally
+	 *                   by the pooling code.
+	 * @param objectSpec A user-defined object that may be checked for
+	 *                   equality at some level of the pool to see if
+	 *                   we have an object that matches the specification.
+	 * @return 
+	 * @exception Exception If there is a problem checking something out of the pool.
+	 * @since 1.1
+	 */
+	public ObjPoolObject checkout(Object factory, Object auth, Object objectSpec) throws Exception;
+
+	/**
+	 * Put an object back into the pool.
+	 * 
+	 * @param object
+	 * @exception Exception
+	 * @since 1.1
+	 */
+	public void checkin(ObjPoolObject object) throws Exception;
+
+	/**
+	 *  Initialize the pool.
+	 * 
+	 * @param prop
+	 * @param factory    The factory used to create the pooled object.
+	 *                   This is not used internally other than to pass
+	 *                   it out to methods implemented by the user.
+	 * @param auth       A user-defined object that the user-implemented
+	 *                   methods will be supplied.  Not used internally
+	 *                   by the pooling code.
+	 * @param objectSpec A user-defined object that may be checked for
+	 *                   equality at some level of the pool to see if
+	 *                   we have an object that matches the specification.
+	 *                   
+	 *                   @exception Exception If there is a problem initializing the pool.
+	 * @exception Exception
+	 * @since 1.1
+	 */
+	public void init(Properties prop, Object factory, Object auth, Object objectSpec) throws Exception;
+
+	/**
+	 * Re-initialize the object pool.
+	 * 
+	 * @param factory    The factory used to create the pooled object.
+	 *                   This is not used internally other than to pass
+	 *                   it out to methods implemented by the user.
+	 * @param auth       A user-defined object that the user-implemented
+	 *                   methods will be supplied.  Not used internally
+	 *                   by the pooling code.
+	 * @param objectSpec A user-defined object that may be checked for
+	 *                   equality at some level of the pool to see if
+	 *                   we have an object that matches the specification.
+	 *                   
+	 *                   @exception Exception If there is a problem re-initializing the pool.
+	 * @exception Exception
+	 * @since 1.1
+	 */
+	public void reInitializeObjPool(Object factory, Object auth, Object objectSpec) throws Exception;
+
+	/**
+	 * Get the current number of objects that
+	 * have been checked out.
+	 * 
+	 * Valid only if we are monitoring.
+	 * 
+	 * @return 
+	 * @since 1.1
+	 */
+	public int getObjectsInUse();
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/ObjPoolObject.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/ObjPoolObject.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/ObjPoolObject.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/ObjPoolObject.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,61 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.pool;
+
+/**
+ * An object that's to be used within the context
+ * of an ObjPool.
+ * 
+ * @author Bill Flood
+ * @version 1.1
+ * @see ObjPool
+ * @since 1.1
+ */
+public interface ObjPoolObject {
+	/**
+	 *  Called when this object has expired or
+	 *  is otherwise not going to be re-used
+	 *  by the pool.
+	 */
+	public void deleteObjPoolObject();
+
+	/**
+	 *  Determines if this object should be
+	 *  put back in the pool or not.
+	 */
+	public boolean isObjPoolObjectValid();
+
+	/**
+	 *  This method is called after the object has been removed
+	 *  from the pool, and before it has been given to whoever
+	 *  is checking it out of the pool.
+	 */
+	public void beforeObjPoolObjectCheckout();
+
+	/**
+	 *  This method is called after an object has been checked
+	 *  back in, but before the <tt>isObjPoolObjectValid()</tt>
+	 *  method is called and before it is made available for
+	 *  checkout again.
+	 */
+	public void afterObjPoolObjectCheckin();
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/PoolException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/PoolException.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/PoolException.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/PoolException.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,58 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Apr 25, 2003
+ *
+ */
+package com.sybase.bpe.pool;
+
+import com.sybase.bpe.util.BPException;
+
+/**
+ * @author waterman
+ *
+ */
+public class PoolException extends BPException {
+
+	static final long serialVersionUID = -3526923457667217863L;
+
+	/**
+	 * @param message_id
+	 * @param msgParams
+	 */
+	public PoolException(String message_id, Object[] msgParams) {
+		super(message_id, msgParams);
+	}
+
+	/**
+	 * @param message_id
+	 * @param msgParams
+	 * @param cause
+	 */
+	public PoolException(
+		String message_id,
+		Object[] msgParams,
+		Throwable cause) {
+		super(message_id, msgParams, cause);
+	}
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/SimpleObjPool.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/SimpleObjPool.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/SimpleObjPool.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/pool/SimpleObjPool.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,241 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.pool;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *  A minimal implementation of an ObjPool.
+ *  This class provides a non-growing pool that
+ *  sleeps the threads that are trying to check
+ *  something out of the pool, and wakes them
+ *  up in-order when something is checked back in.
+ *
+ *  @see ObjPool
+ */
+public abstract class SimpleObjPool implements ObjPool {
+	private List waiters = new ArrayList();
+	private List checkedOutObjects = new ArrayList();
+	protected Object sync = new Object();
+	private boolean monitorCheckedOutObjects = true;
+	
+	private static Logger logger = 
+			Logger.getLogger(SimpleObjPool.class.getName());
+
+	/**
+	 *  This method needs to be implemented by sub-classes.
+	 *  It should return the next element in the pool, or
+	 *  null if the pool is empty.  Growable implementations
+	 *  should use this method to add more elements to the
+	 *  pool.
+	 *
+	 *  @exception Exception If there is a problem getting the
+	 *   next object for the pool -- this is implementation specific.
+	 */
+	protected abstract ObjPoolObject getNextPoolObject(Object factory, Object auth, Object objectSpec) throws PoolException;
+
+	/**
+	 *  This method needs to be implemented by sub-classes.
+	 *  It should add the given ObjPoolObject to the pool.
+	 *
+	 *  @exception Exception If there is a problem checking in the
+	 *   object -- this is implementation specific.
+	 */
+	protected abstract void checkinPoolObject(ObjPoolObject o) throws PoolException;
+
+	/**
+	 *  This method needs to be implemented by sub-classes.
+	 *  It should remove the given ObjPoolObject from the pool or
+	 *  mark it as in use.
+	 *
+	 *  @exception Exception If there is a problem checking in the
+	 *   object -- this is implementation specific.
+	 */
+	protected abstract void checkoutPoolObject(ObjPoolObject o) throws PoolException;
+
+	/**
+	 *  To be implemented by sub-classes.  This is a factory
+	 *  method for creating objects that go in this pool.
+	 *
+	 *  @exception Exception If there is a problem creating the next object for the pool -- this is implementation specific.
+	 */
+	protected abstract ObjPoolObject createObjPoolObject(Object factory, Object auth, Object objectSpec) throws PoolException;
+
+
+	/**
+	 *  Initialize the object pool.  Checked out
+	 *  objects will be monitored.
+	 */
+	public SimpleObjPool() {
+		this(true);
+	}
+
+	/**
+	 *  Initialize the object pool.  Checked out
+	 *  objects will be monitored if monitorCheckedOutObjects
+	 *  is true.
+	 */
+	public SimpleObjPool(boolean monitorCheckedOutObjects) {
+		super();
+		this.monitorCheckedOutObjects = monitorCheckedOutObjects;
+	}
+
+	/**
+	 *  Get a reference to the object being used
+	 *  as a synchronization lock.  Subclasses that
+	 *  need to lock the operation of the pool while
+	 *  they perform maintenance should synchronize
+	 *  on this object and then manipulate the pool.
+	 */
+	protected Object getSyncObject() {
+		return this.sync;
+	}
+
+	/**
+	 *  Get the number of threads waiting for an object to become available.
+	 */
+	public int getNumWaiters() {
+		return this.waiters.size();
+	}
+
+	/**
+	 *  Get the number of objects that are currently checked out.
+	 */
+	public int getObjectsInUse() {
+		return this.checkedOutObjects.size();
+	}
+
+	/**
+	 * Add a thread to the queue of threads waiting for the shared object.
+	 * If, for some reason, the thread is already in the queue, then this
+	 * call will be ignored --- the thread can only be in the queue once
+	 * via this method.
+	 */
+	private final void addToWaiters(Thread t) {
+		synchronized (waiters) {
+			if (!waiters.contains(t)) {
+				waiters.add(t);
+				//Syslog.debug(this, "Adding waiter " + t);
+			}
+		}
+	}
+
+	/**
+	 *  Get the next thread in line and remove it from the waiters.
+	 */
+	private final Thread getNextWaiter() {
+		synchronized (waiters) {
+			if (waiters.size() != 0)
+				return(Thread)waiters.remove(0);
+			return null;
+		}
+	}
+
+	/**
+	 *  Implements a first in, first out reservation scheme.  If no
+	 *  threads are waiting for the object, then the caller never blocks.
+	 *  If there are waiters, then the caller "get's in line," and waits
+	 *  for their turn with the object.
+	 *
+	 *  @exception Exception If there is a problem checking an object out of the pool.
+	 */
+	public ObjPoolObject checkout(Object factory, Object auth, Object objSpec) throws PoolException
+	{
+		Thread thread = Thread.currentThread();
+
+		ObjPoolObject obj = null;
+		while (true) { // mmmm.... infinity
+			synchronized (sync) {
+				obj = getNextPoolObject(factory, auth, objSpec); // can throw exception
+
+				if (obj != null) {
+					obj.beforeObjPoolObjectCheckout();
+					checkoutPoolObject(obj);
+					if (monitorCheckedOutObjects)
+						checkedOutObjects.add(obj);
+					return obj;
+				}
+			}
+
+			// if we got here it's because we didn't get
+			// anything from the pool.  We'll just wait
+			// till someone wakes us up and give it another
+			// try.
+			synchronized (thread) {
+				addToWaiters(thread);
+				try {
+					thread.wait();
+				}catch (InterruptedException e) {
+					PoolException pe = new PoolException("NATIVE_EXECEPTION",new Object[] {"InterruptedException"},e);
+					pe.log(logger,Level.SEVERE);
+					throw pe;
+				}
+			}
+		}
+	}
+
+	/**
+	 *  Check an object back into the pool.  If there are
+	 *  threads in the wait queue, the thread that has been waiting
+	 *  longest will get the shared object next.  The waiter may not receive
+	 *  the shared object immediately, however.
+	 *
+	 *  @exception Exception If there was a problem checking in the object.
+	 */
+	public void checkin(ObjPoolObject opo) throws PoolException
+	{
+		opo.afterObjPoolObjectCheckin();
+		synchronized(sync) {
+			try {
+				if (opo.isObjPoolObjectValid())
+					checkinPoolObject(opo);	// can throw Exception
+				else
+					opo.deleteObjPoolObject();
+			}
+			finally {
+				// make sure to remove it from the list of
+				// checked out objects.
+				if (monitorCheckedOutObjects)
+					this.checkedOutObjects.remove(opo);
+
+				// wake up the next guy in line.
+				Thread waiter = getNextWaiter();
+				if (waiter != null) {
+					synchronized (waiter) {
+						waiter.notify();
+					}
+				}
+			}
+		}
+	}
+
+	/**
+	 *  Get the list of objects that are currently checked out of the pool.
+	 */
+	protected List getCheckedOutObjects() {
+		return this.checkedOutObjects;
+	}
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/BPRuntimeException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/BPRuntimeException.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/BPRuntimeException.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/BPRuntimeException.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,119 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.scope.service;
+
+import java.util.HashMap;
+
+import com.sybase.bpe.action.internal.ActionException;
+
+/**
+ *
+ * All runtime exceptions should throw this
+ * 
+ */
+public class BPRuntimeException extends ActionException {
+	
+	static final long serialVersionUID = -3191176170122334709L;
+	
+	private String faultName;
+	private String faultType;
+	private String nameSpace;
+	private HashMap errorMessage = new HashMap();
+	
+	public BPRuntimeException( String name, String detailMessage )
+	{
+	    super( detailMessage );
+	    faultName = name;
+	}
+	
+	public BPRuntimeException( String name, Throwable cause)
+	{
+	    super( cause );
+	    faultName = name;
+	}
+	
+	/**
+	 * @param message_id
+	 * @param msgParams
+	 */
+	public BPRuntimeException(String name, String message_id, Object[] msgParams) {
+		super(message_id, msgParams);
+		faultName = name;
+	}
+
+	/**
+	 * @param message_id
+	 * @param msgParams
+	 * @param cause
+	 */
+	public BPRuntimeException(
+		String name,
+		String message_id,
+		Object[] msgParams,
+		Throwable cause) {
+		super(message_id, msgParams, cause);
+		faultName = name;
+	}
+
+	public String getBPException() {
+		String retVal = faultName;
+		if ( nameSpace != null ) {
+			retVal = nameSpace + ":" + faultName;
+		}
+		return retVal;
+	}
+
+	public void addPartMessage(String partName, Object msg) {
+		errorMessage.put(partName,msg);
+	}
+	
+	public Object getPartMessage(String partName) {
+		return errorMessage.get(partName);
+	}
+	
+	public HashMap getMessageParts() {
+		return errorMessage;
+	}
+	
+	public void setNameSpace(String nameSpace) {
+		this.nameSpace = nameSpace;
+	}
+	
+	public String getNameSpace()
+	{
+		return this.nameSpace;
+	}
+
+	public String getName()
+	{
+		return faultName;
+	}
+	public String getType() {
+		return faultType;
+	}
+	
+	public String toString() {
+		return "BPRuntimeException(nameSpace:"+this.nameSpace+
+			" faultName:"+this.faultName+
+			" fualtType:"+this.faultType+")";
+	}
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/IFCScopeInstance.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/IFCScopeInstance.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/IFCScopeInstance.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/IFCScopeInstance.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,214 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.scope.service;
+
+import java.util.List;
+
+import com.sybase.bpe.action.bpel.TimerAction;
+import com.sybase.bpe.context.resolver.ContextResolver;
+import com.sybase.bpe.correlation.Registration;
+import com.sybase.bpe.definition.IPMDProcess;
+import com.sybase.bpe.engine.IEvaluationContext;
+import com.sybase.bpe.engine.IProcessCallBack;
+import com.sybase.bpe.instance.IPMIProcess;
+import com.sybase.bpe.timerservice.IBPETimer;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * This is a scope instance which is stored in the scope
+ * service.
+ */
+public interface IFCScopeInstance {
+	
+	public final static String CATCH_ALL = "catchAll";
+	public final static String BPWS_NS = "http://schemas.xmlsoap.org/ws/2003/03/business-process/";
+	public final static String FORCED_TERMINATION = BPWS_NS+":forcedTermination";
+	public final static String CURRENT_FAULT = "currentFault";
+	public final static String CURRENT_EXCEPTION = "currentException";
+	public final static String FAULT_HANDLER = "faultHandler";
+	public final static String COMP_HANDLER = "compensatinHandler";
+	public final static String PROCESS = "process";
+	
+	/**
+	 * Create a new scope instance
+	 * @param scopePath the scope path in which to create this scope
+	 * @param newScopeName the new scope's name
+	 * @param newScopeId the new scope's id
+	 * @param ctxId the context id in which this scope executes
+	 * @return a scope instance
+	 * @throws BPException
+	 */
+	public IFCScopeInstance createScope(String newScopeName, String newScopeId, 
+			String ctxId) throws BPException;
+
+	
+	/**
+	 * Add a fault handler to the scope instance.
+	 * @param faultName then fault to catch
+	 * @param faultType the fault type to catch
+	 * @param defintionId the defintion that is executed for handling
+	 * @throws BPException
+	 */
+	public void addFaultHandler(String faultName, String faultType, String defintionId) throws BPException;
+	
+	/**
+	 * After a fault handler executes for this scope instance
+	 * execution will pick up at this specified point.
+	 * @param defintionId defintion where execution picks up
+	 * @throws BPException
+	 */
+	public void setFaultHandlerObserver(String defintionId) throws BPException;
+
+	/**
+	 * When the execution point for the compensation handler for this
+	 * scope is installed a snap shot of the current state will also
+	 * be taken.
+	 * @param defintionId defintion where compensation processing starts
+	 * @param locators list of locators to capture for compenstaion
+	 * @param resolver resolver used for building snap shot
+	 * @param ctx id to hang the compensation snap shot off of in context
+	 * @throws BPException
+	 */
+	public void setCompensationHandler(String defintionId, List locators, 
+			ContextResolver resolver, String ctxId) throws BPException;
+	
+	/**
+	 * Mark this process as inactive.
+	 * @param proc where compensation was called
+	 * @param ec evaluation context to run compensation in
+	 * @param pcb process call back
+	 */
+	public void setInactive(IPMIProcess proc, 
+			IEvaluationContext ec, IProcessCallBack pcb)  throws BPException;
+	/**
+	 * 
+	 * @return is this scope active
+	 */
+	public boolean isActive();
+	
+	/**
+	 * 
+	 * @return has this scope been faulted
+	 */
+	public boolean isFaulted();
+	
+	/**
+	 * 
+	 * @return has this scope been compensated
+	 */
+	public boolean isCompensated();
+	
+	/**
+	 * Add a process that needs to be cleaned up
+	 * after the scope completes.
+	 * @param proc
+	 */
+	public void addProcess(IPMIProcess proc);
+	
+	/**
+	 * Add a registration to this scope.  Registrations are canceled
+	 * when an active scope is terminated.
+	 * @param registration 
+	 */
+	public void addRegistration(Registration registration);
+	
+	/**
+	 * Remove a registation from this scope.
+	 * @param registration
+	 */
+	public void removeRegistration(Registration registration);
+	
+	/**
+	 * Add a timer to this scope.  Timers are canceled when an 
+	 * active scope is terminated.
+	 * @param timer
+	 */
+	public void addTimer(IBPETimer timer);
+	
+	/**
+	 * Remove a timer from this scope
+	 * @param timer
+	 */
+	public void removeTimer(IBPETimer timer);
+	
+	/**
+	 * Get the fully qualified scope path.
+	 * @return scope path
+	 */
+	public ScopePath getScopePath();
+	
+	/**
+	 * Handle a fault thrown with this scope.
+	 * @param exception the runtime exception thrown
+	 * @param proc where fault was  thrown
+	 * @param ec evaluation context to run fault handling in
+	 * @param pcb process call back
+	 * @throws BPException
+	 */
+	public void handleFault(Throwable exception, IPMIProcess proc, 
+			IEvaluationContext ec, IProcessCallBack pcb) throws BPException;
+	
+	/**
+	 * Terminate all active scopes enclosed in this scope.
+	 * @param proc where termination was called
+	 * @param ec evaluation context to termination in
+	 * @param pcb process call back
+	 * @throws BPException
+	 */
+	public void terminate(IPMIProcess proc, 
+			IEvaluationContext ec, IProcessCallBack pcb) throws BPException;
+	
+	/**
+	 * Compensate this scope.  
+	 * @param proc where compensation was called
+	 * @param ec evaluation context to run compensation in
+	 * @param pcb process call back
+	 * @throws BPException
+	 */
+	public void compensate(IPMIProcess proc, 
+			IEvaluationContext ec, IProcessCallBack pcb) throws BPException;
+	
+	/**
+	 * This is used to capture a onAlarm at the root scope that
+	 * uses data from an incoming message to register a timer.  This
+	 * is a special case.
+	 * @param act
+	 * @param resolver
+	 * 
+	 */
+	public void setTimerAction(TimerAction act,ContextResolver resolver);
+	
+	/**
+	 * Execute the timer action.
+	 * @param ec
+	 * @param pcb
+	 * @param processInstance
+	 * @param processDefinition
+	 * @return
+	 */
+	public void executeTimerAction(IEvaluationContext ec,
+			IProcessCallBack pcb,
+			IPMIProcess processInstance,
+			IPMDProcess processDefinition) throws BPException;
+
+}
+

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/IScopeService.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/IScopeService.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/IScopeService.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/IScopeService.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,75 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+
+package com.sybase.bpe.scope.service;
+
+import com.sybase.bpe.context.IContextService;
+import com.sybase.bpe.engine.IEvaluationContext;
+import com.sybase.bpe.engine.IProcessCallBack;
+import com.sybase.bpe.instance.IPMIProcess;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * Service which manages scope instances.
+ */
+public interface IScopeService {
+	
+	/**
+	 * Initialize the scope service.
+	 * @param cs the scope service state is stored in the context service
+	 * @param ctxId the element id to hang the scope data structure off of
+	 * in the context tree
+	 * @throws BPException
+	 */
+	public void init(IContextService cs, String ctxId) throws BPException;
+	
+	/**
+	 * Get the root scope.
+	 * @return
+	 * @throws BPException
+	 */
+	public IFCScopeInstance getRootScope() throws BPException;
+		
+	/**
+	 * Get a scope instance.
+	 * @param scopePath  the fully qualified scope path
+	 * @return the scope instance
+	 * @throws BPException
+	 */
+	public IFCScopeInstance getScope(ScopePath scopePath) throws BPException;
+
+	/**
+	 * Compensate a given scope based on a design time scope path.  This will
+	 * compensate all instances of that design time scope path.
+	 * @param scopeName this is a design time scope name, so all scopes with 
+	 * this scope name will be compensated
+	 * @param proc where fault was  thrown
+	 * @param ec evaluation context to run fault handling in
+	 * @param pcb process call back
+	 * @throws BPException
+	 */
+	public void compensate(String scopeName, IPMIProcess proc, 
+			IEvaluationContext ec, IProcessCallBack pcb) throws BPException;
+	
+
+}
+

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/ScopePath.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/ScopePath.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/ScopePath.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/ScopePath.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,243 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+
+package com.sybase.bpe.scope.service;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Scope path.
+ */
+public class ScopePath implements Serializable, Cloneable {
+	
+    static final long serialVersionUID = 4835994200408519001L;
+    
+	public static final transient String DELIMITER = "/";
+	private ArrayList scopePath;
+	
+	public ScopePath() {
+		scopePath = new ArrayList();
+	}
+	
+	private ScopePath(ArrayList scopePath) {
+		this.scopePath = scopePath;
+	}
+	
+	private ScopePath ( List list ) {
+		this.scopePath = new ArrayList(list);
+	}
+	
+	/**
+	 * Add a new scope to this path.
+	 * @param scopeName design time scope name
+	 * @param scopeId runtime scope id
+	 * @return this scope path
+	 */
+	public ScopePath addScope(String scopeName, String scopeId) {
+		scopePath.add(new ScopeNameId(scopeName,scopeId));
+		return this;
+	}
+	
+	/**
+	 * Get the current scope name.
+	 * @return the current scope name
+	 */
+	public String getCurrentScope() {
+		if ( scopePath.size() < 1 ) {
+			return "";
+		} else {
+			return ((ScopeNameId)scopePath.get(scopePath.size()-1)).getName();
+		}	
+	}
+	
+	/**
+	 * Get the enclosing scope path.
+	 * @return enclosing scope path
+	 */
+	public ScopePath getEnclosingScopePath() {
+		if ( scopePath.isEmpty() ) {
+			return this;
+		} else {
+			return new ScopePath(this.scopePath.subList(0,this.scopePath.size()-1));
+		}
+	}
+	
+	/**
+	 * Returns the scope path sans the scope ids.
+	 * @return
+	 */
+	public String getScopeNamePath() {
+		if ( scopePath.isEmpty() ) {
+			return DELIMITER;
+		}
+		String path = "";
+		Iterator it = scopePath.iterator();
+		while ( it.hasNext() ) {
+			ScopeNameId sni= (ScopeNameId)it.next();
+			path+=DELIMITER.concat(sni.getName());
+		}
+		return path;
+	}
+	
+	/**
+	 * Apply this ScopePath to a design time scope path which doesn't have
+	 * scope ids.
+	 * @param path path to apply this scope to
+	 * @return new path
+	 */
+	public String applyPathIdsToPath(String path) {
+
+		// if this is a relative path just return it
+		if ( !path.startsWith(DELIMITER)) {
+			return path;
+		}
+		
+		String newPath = "";
+		String[] pathArray = path.split(DELIMITER);
+		for ( int i = 1; i < pathArray.length ; i++ ) 
+		{
+			if ( i <= scopePath.size() && pathArray[i].equals(
+					((ScopeNameId)scopePath.get(i-1)).getName())) {
+				newPath+=DELIMITER.concat(
+						((ScopeNameId)scopePath.get(i-1)).getNameId());
+			} else {
+				for ( int j = i; j < pathArray.length; j++) {
+					newPath+=DELIMITER.concat(pathArray[j]);
+				}
+				break;
+			}
+		}
+		return newPath;
+	}
+	
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	public String toString() {
+		if ( scopePath.isEmpty() ) {
+			return DELIMITER;
+		}
+		String path = "";
+		Iterator it = scopePath.iterator();
+		while ( it.hasNext() ) {
+			ScopeNameId sni= (ScopeNameId)it.next();
+			path+=DELIMITER.concat(sni.getNameId());
+		}
+		return path;
+	}
+	
+	/* (non-Javadoc)
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	public boolean equals(Object obj) {
+		if ( obj instanceof ScopePath ) {
+			return obj.toString().equals(this.toString());
+		} else {
+			return false;
+		}
+	}
+	
+	/* (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() throws CloneNotSupportedException {
+		return new ScopePath((ArrayList)scopePath.clone());
+	}
+	
+	public static void main(String[] args) {
+		ScopePath sp = new ScopePath();
+		sp.addScope("a","1");
+		sp.addScope("b","1");
+		sp.addScope("c","1");
+		sp.addScope("d","1");
+		System.out.println(sp);
+		System.out.println(sp.getCurrentScope());
+		System.out.println(sp.getEnclosingScopePath());
+		ScopePath sp2 = new ScopePath();
+		sp2.addScope("a","1");
+		sp2.addScope("b","1");
+		sp2.addScope("c","1");
+		sp2.addScope("d","1");
+		System.out.println(sp.equals(sp2));
+		System.out.println(sp2.applyPathIdsToPath("/container/part"));
+		System.out.println(sp2.applyPathIdsToPath("/a/container/part"));
+		System.out.println(sp2.applyPathIdsToPath("/a/b/c/container/part"));
+		System.out.println(sp2.applyPathIdsToPath("/c/d/container/part"));
+		System.out.println(sp.getScopeNamePath());
+		ScopePath sp3 = new ScopePath();
+		sp3.addScope("scope_0","12345");
+		System.out.println(sp3.applyPathIdsToPath("/scope_0/request/message"));
+		System.out.println(sp3.applyPathIdsToPath("junk"));
+		ScopePath sp4 = new ScopePath();
+		sp4.addScope("a","1");
+		System.out.println(sp4.getEnclosingScopePath());
+
+	}
+	
+	
+	private class ScopeNameId implements Serializable {
+		
+	    static final long serialVersionUID = -5709053091263193526L;
+	    
+		private String name;
+		private String id;
+		
+		public ScopeNameId(String name, String id) {
+			this.name = name;
+			this.id = id;
+		}
+		
+		public String getNameId() {
+			return name.concat(id);
+		}
+		
+		/**
+		 * @return Returns the id.
+		 */
+		public String getId() {
+			return id;
+		}
+		/**
+		 * @param id The id to set.
+		 */
+		public void setId(String id) {
+			this.id = id;
+		}
+		/**
+		 * @return Returns the name.
+		 */
+		public String getName() {
+			return name;
+		}
+		/**
+		 * @param name The name to set.
+		 */
+		public void setName(String name) {
+			this.name = name;
+		}
+
+	}
+
+}