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 [18/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/context/base/INoThrowDataObject.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/base/INoThrowDataObject.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/base/INoThrowDataObject.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/base/INoThrowDataObject.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,40 @@
+/*
+* 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.context.base;
+
+/**
+ * This class is a mirror of IDataObject which does not throw exceptions.
+ * ContextServiceException relies on the jdk1.4 logger.  Jaguar
+ * manager would not deploy beans which throw ContextServiceException
+ * because jaguar manager requires jdk1.3 for normal operation.
+ * Jaguar manager is buggy when run with jdk1.4.
+ */
+public interface INoThrowDataObject
+{
+	public void decrementRefCount();
+	public void incrementRefCount();
+	public long getRefCount();
+	public void setObject(Object obj);
+	public Object getObjectForRead();
+	public Object getObjectForReadWrite();
+	//public Object getObjectForReadWriteWithLock();
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/base/SuperNode.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/base/SuperNode.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/base/SuperNode.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/base/SuperNode.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,503 @@
+/*
+* 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.context.base;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.sybase.bpe.context.IAccessControl;
+import com.sybase.bpe.context.IContainer;
+import com.sybase.bpe.context.IHandle;
+import com.sybase.bpe.context.INode;
+import com.sybase.bpe.context.IPart;
+
+public abstract class SuperNode implements INode, Serializable, IAccessControl
+{
+    static final long serialVersionUID = -6214541427211735637L;
+    
+	protected SuperNode()
+	{
+	}
+
+	protected SuperNode(String iName, SuperNode iContainer)
+		throws ContextServiceException
+	{
+		init(iName, iContainer);
+	}
+
+	public void init(String iName, SuperNode iContainer)
+		throws ContextServiceException
+	{
+		setName(iName);
+		setContainer(iContainer);
+	}
+
+	// Begin implementing methods required for INode implementation
+
+	protected void setContainer(SuperNode iContainer)
+		throws ContextServiceException
+	{
+		if (iContainer != null)
+		{
+			INode child = iContainer.internalFindChild(this.getName());
+			if ( (child != null) && ( child != this ))
+			{
+				iContainer.removeNode(this.getName());
+			}
+			iContainer.addChild(this);
+		}
+	}
+
+	protected void detach() throws ContextServiceException
+	{
+		SuperNode container = (SuperNode) (getContainer());
+		if (container != null)
+		{
+			container.detachChildNode(this);
+		}
+	}
+
+	protected void setName(String iName) throws ContextServiceException
+	{
+		m_name = iName;
+	}
+
+	/**
+	 * @see com.sybase.bpe.context.INode#getParent()
+	 */
+	public IContainer getContainer()
+	{
+		return (IContainer) (m_parent);
+	}
+
+	/**
+	 * @see com.sybase.bpe.context.INode#getName()
+	 */
+	public String getName()
+	{
+		return m_name;
+	}
+
+	// Begin implementing part methods
+
+	protected void internalSetObject(Object iDataObject)
+		throws ContextServiceException
+	{
+		// Create a new handle to wrap the new data object
+		DataObject newHandle = createHandle(iDataObject);
+		setHandle(newHandle);
+	}
+
+	protected void internalSetObject(IHandle iObjectHandle)
+		throws ContextServiceException
+	{
+		setHandle((DataObject) (iObjectHandle));
+	}
+
+	protected Object internalGetObjectForRead() throws ContextServiceException
+	{
+		DataObject handle = getHandle();
+		if ( handle == null )
+		{
+			return null;
+		}
+		Object returnObject = handle.getObjectForRead();
+		ContextUtil.setReadOnly(returnObject, true);
+		return returnObject;
+	}
+
+	protected void cloneUponWrite() throws ContextServiceException
+	{
+		// Determine whether or not we need to clone the dataobject.   If the dataobject has a reference count > 1.  We need to clone the
+		// dataobject in this case because we don't want changes to one part to 
+		// affect other parts.  This the copy-on-write behaviour described in the design.		
+		if ( getHandle() == null ) {
+			return;
+		}
+		boolean weNeedToCloneDataObject =
+			(getHandle().getRefCount() > 1 || (getReadOnly() == true));
+
+		if (weNeedToCloneDataObject)
+		{
+
+			Object newDataObject =
+				ContextUtil.cloneObject(getRawObjectForRead());
+
+			internalSetObject(newDataObject);
+
+			setReadOnly(false);
+
+			setDirty(this);
+		}
+	}
+
+	protected Object internalGetObjectClone() throws ContextServiceException
+	{
+		return ContextUtil.cloneObject(getRawObjectForRead());
+	}
+
+	protected Object internalGetObjectForReadWrite()
+		throws ContextServiceException
+	{
+
+		cloneUponWrite();
+		return getRawObjectForReadWrite();
+
+	}
+
+	protected DataObject getHandle() throws ContextServiceException
+	{
+		return m_handle;
+	}
+	
+	protected DataObject getHandleForSerialization()
+	{
+		return m_handle;
+	} 
+	
+	protected void setHandleFromDeserialization( DataObject iHandle )
+	{
+		m_handle = iHandle;
+	}
+
+	protected Object getRawObjectForRead() throws ContextServiceException
+	{
+		return getHandle().getObjectForRead();
+	}
+
+	public Object getRawObjectForReadWrite() throws ContextServiceException
+	{
+		if ( getHandle() == null ) {
+			return null;
+		}
+		Object rawObject = getHandle().getObjectForReadWrite();
+		ContextUtil.setReadOnly(rawObject, false);
+		return rawObject;
+	}
+
+	protected void setHandle(DataObject iHandle) throws ContextServiceException
+	{
+		if (m_handle != null)
+		{
+			// Let other users of the current handle know that we are no longer using it
+			// by decrementing the current handle's reference count.
+			getHandle().decrementRefCount();
+		}
+		m_handle = iHandle;
+		if (m_handle != null)
+		{
+			m_handle.incrementRefCount();
+		}
+
+	}
+
+	protected abstract DataObject createHandle(Object iObject)
+		throws ContextServiceException;
+
+	// Begin implementing container methods	
+
+	protected abstract SuperNode createPartImpl()
+		throws ContextServiceException;
+
+	protected abstract SuperNode createContainerImpl()
+		throws ContextServiceException;
+
+	/**
+	 * @see com.sybase.bpe.context.IContainer#createContainer(java.lang.String)
+	 */
+	protected IContainer internalCreateContainer(String iContainerLocator)
+		throws ContextServiceException
+	{
+		SuperNode ret = (SuperNode) (getChild(iContainerLocator));
+		if (ret == null)
+		{
+			ret = createContainerImpl();
+			ret.init(iContainerLocator, this);
+		}
+		else
+		{
+			if (!(ret instanceof IContainer))
+			{
+				ContextServiceException cse = new ContextServiceException("TYPE_CAST",new Object[] { "IContainer", "IPart" });
+				cse.log(logger,Level.SEVERE);
+				throw cse;
+			}
+		}
+		return (IContainer) ret;
+
+	}
+
+	/**
+	 * @see com.sybase.bpe.context.IContainer#createPart(java.lang.String)
+	 */
+	protected IPart internalCreatePart(String iPartLocator)
+		throws ContextServiceException
+	{
+		SuperNode ret = (SuperNode) (getChild(iPartLocator));
+		if (ret == null)
+		{
+			ret = createPartImpl();
+			ret.init(iPartLocator, this);
+		}
+		else
+		{
+			if (!(ret instanceof IPart))
+			{
+				ContextServiceException cse = new ContextServiceException("TYPE_CAST",new Object[] { "IContainer", "IPart" });
+				cse.log(logger,Level.SEVERE);
+				throw cse;
+			}
+		}
+		return (IPart) ret;
+
+	}
+
+	/**
+	 * @see com.sybase.bpe.context.IContainer#findChild(java.lang.String)
+	 */
+	protected INode internalFindChild(String iChildLocator)
+		throws ContextServiceException
+	{
+		return getChild(iChildLocator);
+	}
+
+	/**
+	 * @see com.sybase.bpe.context.IContainer#removeChild(java.lang.String)
+	 */
+	protected void internalRemoveChild(String iChildLocator)
+		throws ContextServiceException
+	{
+
+		removeNode(iChildLocator);
+	}
+
+	protected void removeNotify() throws ContextServiceException
+	{
+		DataObject dataObject = (DataObject) (getHandle());
+		if (dataObject != null)
+		{
+			dataObject.decrementRefCount();
+		}
+		if (m_childCollection != null)
+		{
+			Iterator iterator = m_childCollection.values().iterator();
+			while (iterator.hasNext())
+			{
+				SuperNode sn = (SuperNode) (iterator.next());
+				sn.removeNotify();
+			}
+		}
+
+	}
+
+	/**
+	 * @see com.sybase.bpe.context.IContainer#moveNode(com.sybase.bpe.context.INode, java.lang.String)
+	 */
+	protected void internalMoveNode(INode iSourceNode, String iTargetName)
+		throws ContextServiceException
+	{
+		SuperNode aNode = (SuperNode) (iSourceNode);
+
+		// Detach the source node from it's parent container.
+		aNode.detach();
+
+		// Change the name of the node.
+		aNode.setName(iTargetName);
+
+		aNode.setContainer(this);
+	}
+
+	protected void detachChildNode(SuperNode iChild)
+		throws ContextServiceException
+	{
+		iChild.setContainer(null);
+		getInternalChildCollection().remove(iChild.getName());
+	}
+
+	/**
+	 * @see com.sybase.bpe.context.IContainer#getChildren()
+	 */
+	protected Collection internalGetChildren() throws ContextServiceException
+	{
+		// Don't return m_childCollection because doing so
+		// would break encapsulation.
+		return Collections.unmodifiableCollection(
+			getInternalChildCollection().values());
+	}
+
+	protected void addChild(SuperNode iNode) throws ContextServiceException
+	{
+		getInternalChildCollection().put(iNode.getName(), iNode);
+		iNode.setParent(this);
+		
+	}
+	
+	private void setParent( SuperNode iParent)
+	{
+		m_parent = iParent;
+	}
+	
+	private SuperNode getChild(String iChildLocator)
+	{
+		if ( m_childCollection != null )
+		{
+			return (SuperNode) m_childCollection.get(iChildLocator);
+		}
+		return null;
+	}
+
+	private void removeNode(String iChildLocator)
+		throws ContextServiceException
+	{		
+		SuperNode childNode = (SuperNode) getChild(iChildLocator);
+		if (childNode != null)
+		{
+			childNode.removeNotify();
+		}
+
+		getInternalChildCollection().remove(iChildLocator);
+	}
+
+	protected void internalCopyNode(INode iSourceNode, String iTargetName)
+		throws ContextServiceException
+	{
+		SuperNode sourceNode = (SuperNode) (iSourceNode);
+		if (sourceNode instanceof IPart)
+		{
+			copyPart(sourceNode, iTargetName);
+		}
+		else
+		{
+			copyContainer(sourceNode, iTargetName);
+		}
+
+	}
+
+	protected void copyPart(SuperNode iPart, String iTargetName)
+		throws ContextServiceException
+	{
+		SuperNode newPart = createPartImpl();
+		newPart.setName(iTargetName);
+		SuperNode sourcePart = iPart;
+		DataObject dataObject = (DataObject) (sourcePart.getHandle());
+		newPart.setHandle(dataObject);
+		newPart.setContainer(this);
+	}
+
+	protected void copyContainer(SuperNode iContainer, String iTargetName)
+		throws ContextServiceException
+	{
+//		SuperNode container = (SuperNode) (iContainer);
+		SuperNode newContainer = createContainerImpl();
+		newContainer.setName(iTargetName);
+		Iterator iterator = iContainer.internalGetChildren().iterator();
+		while (iterator.hasNext())
+		{
+			Object next = iterator.next();
+			INode node = (INode) (next);
+			newContainer.internalCopyNode(node, node.getName());
+		}
+
+		newContainer.setContainer(this);
+	}
+
+	protected HashMap getInternalChildCollection()
+	{
+		if (m_childCollection == null)
+		{
+			m_childCollection = new HashMap();
+		}
+		return m_childCollection;
+	}
+	
+	protected Collection getInternalChildCollectionForSerialization()
+	{
+		if ( m_childCollection != null )
+		{
+			return m_childCollection.values();
+		}
+		return null;
+	}
+	
+	public int getNodeType()
+	{
+		return m_nodeType;
+	}
+
+	protected void setNodeType(int iNodeType) throws ContextServiceException
+	{
+		m_nodeType = iNodeType;
+	}
+
+	protected void setDirty(SuperNode iNode) throws ContextServiceException
+	{
+	}
+
+	// Access Control method
+	public void setReadOnly(boolean iIsReadOnly)
+	{
+		m_isReadOnly = iIsReadOnly;
+	}
+
+	// Acess control method
+	public boolean getReadOnly()
+	{
+		return m_isReadOnly;
+	}
+	
+	
+	// The memento accessor and mutator methods allow for the
+	// storage and retrieval of an object which may be
+	// useful to the context service.
+	
+	public void setMemento( Object iMemento)
+	{
+		m_memento = iMemento;
+	}
+	
+	public Object getMemento()
+	{
+		return m_memento;
+	}
+	
+
+	
+	transient private  Object m_memento;
+	transient private SuperNode m_parent = null;
+	transient private int m_nodeType = PART;
+	transient private HashMap m_childCollection = null;
+	transient private String m_name = null;
+	transient protected boolean m_isReadOnly = false;
+	transient protected DataObject m_handle = null;
+
+	public static final int PART = 1;
+	public static final int CONTAINER = 2;
+		
+	private static final Logger logger =
+		Logger.getLogger(SuperNode.class.getName());
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/base/TestUtil.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/base/TestUtil.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/base/TestUtil.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/base/TestUtil.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,63 @@
+/*
+* 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.context.base;
+
+import com.sybase.bpe.context.INode;
+import com.sybase.bpe.context.ejb.EJBDataObject;
+
+// A little class that lets the test routines get at protected data. to
+// check things like reference count.
+public class TestUtil
+{
+	public static long getRefCount( INode node ) throws Exception
+	{
+		SuperNode sn = ( SuperNode ) ( node );
+		if ( sn.getHandle() == null ) {
+			return 0;
+		}
+		return sn.getHandle().getRefCount();
+	}
+	
+	public static String getDataObjectImp( INode node ) throws Exception
+	{
+		SuperNode sn = ( SuperNode ) ( node );
+		if ( sn.getHandle() == null ) {
+			return null;
+		}
+		return sn.getHandle().getClass().getName();
+	}
+	
+	public static String getDataObjectID( INode node ) throws Exception
+	{
+		SuperNode sn = ( SuperNode ) ( node );
+		DataObject handle = sn.getHandle();
+		if ( handle instanceof EJBDataObject )
+		{
+			EJBDataObject edo = ( EJBDataObject ) ( handle );
+			return edo.getLocator();
+		}
+		else
+		{
+			return "N/A";
+		}
+	}
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/BPE_CMPObjectBean.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/BPE_CMPObjectBean.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/BPE_CMPObjectBean.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/BPE_CMPObjectBean.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,629 @@
+/*
+* 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
+*/
+/***********************************************************************
+ * Module:  BPE_CMPBLOBBean.java
+ * Author:  waterman
+ * Purpose: Defines the Class BPE_CMPBLOBBean
+ ***********************************************************************/
+
+package com.sybase.bpe.context.ejb;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.ejb.EJBException;
+import javax.ejb.EntityContext;
+
+import com.sybase.bpe.context.base.INoThrowDataObject;
+import com.sybase.bpe.util.ObjectInputStreamContextClassLoader;
+import com.sybase.bpe.util.TraceLog;
+
+/**
+ * This is the CMP Object bean.  It is responsible for
+ * persisting a byte array which is tagged with an updatecount
+ * and a reference count.  Additionally it maitains a cached
+ * version of the object created by deserializing the byte
+ * array.  This caching has a significant performance impact
+ * since deserializing the object graph is expensive. 
+ * 
+ * @ejb.bean 
+ *		type="CMP"
+ *		name="BPE_CMPBLOB"
+ *		jndi-name="BPE/BPE_CMPBLOB"
+ *		local-jndi-name="BPE/BPE_CMPBLOB"
+ *		view-type="local"
+ *		cmp-version="2.x"
+ *      schema="CMPBLOB"
+ *      primkey-field="id"
+ * 
+ * @ejb.persistence 
+ * 		table-name="BPE_BPE_CMPBLOB"
+ * 
+ * @ejb.transaction type="Required"
+ * 
+ * @ejb.pk 
+ * 		class="java.lang.String"
+ * @ejb.interface 
+ *  	generate="false"
+ * 
+ * @ejb.home
+ *		local-class="com.sybase.bpe.context.ejb.BPE_ObjectLocalHome"
+ * @ejb.interface
+ *		local-class="com.sybase.bpe.context.ejb.BPE_ObjectLocal" 
+ * 
+ * @jboss.table-name table-name="CMPBLOB"
+ * 
+ *
+ *
+ */
+
+public abstract class BPE_CMPObjectBean
+implements javax.ejb.EntityBean, INoThrowDataObject {
+	
+	static final long serialVersionUID = -6675363464240432410L;
+
+    /**
+    * 
+    *@ejb.interface-method
+    * @ejb.persistence column-name="id"
+    * @ejb.pk-field
+    */
+    public abstract java.lang.String getId();
+    /**
+     * @ejb.interface-method
+     * @param id
+     */
+    public abstract void setId(java.lang.String id);
+
+    /**
+     * 
+     *@ejb.interface-method
+     * @ejb.persistence column-name="data"
+     */
+    public abstract byte[] getData();
+
+    /**
+     * @ejb.interface-method
+     */
+    public abstract void setData(byte[] data);
+
+    /**
+     * 
+     *@ejb.interface-method
+     * @ejb.persistence column-name="refcount"
+     */
+    public abstract long getRefCount();
+    /**
+     * @ejb.interface-method
+     */
+    public abstract void setRefCount(long refCount);
+
+    /**
+     * 
+     *@ejb.interface-method
+     * @ejb.persistence column-name="dataupdatecount"
+     */
+    public abstract long getDataUpdateCount();
+    /**
+     * @ejb.interface-method
+     */
+    public abstract void setDataUpdateCount(long updateCount);
+
+
+    /**
+     * Constructor.
+     */
+    public BPE_CMPObjectBean() {
+    }
+
+    /** A container invokes this method when the instance is taken out of the pool
+      * of available instances to become associated with a specific EJB object.
+      * 
+      * @exception javax.ejb.EJBException */
+    public void ejbActivate() throws javax.ejb.EJBException
+    {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::ejbActivate()");
+        init();
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::ejbActivate()");
+    }
+
+    /** A container invokes this method to instruct the instance to synchronize its state.
+      * 
+      * @exception javax.ejb.EJBException */
+    public void ejbLoad() throws javax.ejb.EJBException
+    {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::ejbLoad()");
+        restoreCachedState();
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::ejbLoad()");
+    }
+    
+    /**
+     * It's possible that the deserialized object corresponding to
+     * the blob is already held in cache.  If there is an object
+     * in cache with the same id and the same updatecount as this CMP
+     * then use the object held in the cache rather than performing
+     * and expensive deserialization of the object from the byte array.
+     */
+    private void restoreCachedState(  )
+    {
+        String id = getId();
+        long updateCount = getDataUpdateCount();
+        
+        prepareContextClassLoader();
+        CachedObject cobj = ( CachedObject )
+          objectCache.get( id );
+        
+        if ( ( cobj != null ) &&
+                ( cobj.getUpdateCount() == updateCount ) )
+        {
+            m_object = cobj.getObject();
+            
+            m_objectStale = false;
+        }
+        else
+        {
+            m_objectStale = true;
+        }
+        m_currentDataUpdateCount = updateCount;
+    }
+    
+    
+    /**
+     *  The caching mechanism assumes that the ContextClassLoader
+     *  is set on the current thread.  EAServer does not always
+     *  set the context classloader, so we need to check here and
+     *  set it if it is not set.
+     */
+    private void prepareContextClassLoader()
+    {
+
+        ClassLoader contextClassLoader = 
+            Thread.currentThread().getContextClassLoader();
+        if ( contextClassLoader == null )
+        {	
+            Thread.currentThread().
+              setContextClassLoader(m_contextClassLoader);
+        }
+    }
+    
+    /**
+     * Cache the deserialized object associated with the current CMP. The
+     * cached object may be recalled at a later date in order to avoid
+     * an expensive deserialization of the object from a byte array.
+     */
+    private void cacheState()
+    {
+        prepareContextClassLoader();
+        CachedObject co = new CachedObject(m_object, getDataUpdateCount());
+        objectCache.put( getId(), co );    
+    }
+
+    /** A container invokes this method on an instance before the instance becomes
+      * disassociated with a specific EJB object.
+      * 
+      * @exception javax.ejb.EJBException */
+    public void ejbPassivate() throws javax.ejb.EJBException
+    {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::ejbPassivate()");
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::ejbPassivate()");
+    }
+
+    /** A container invokes this method before it removes the EJB object that is currently
+      * associated with the instance.
+      * 
+      * @exception javax.ejb.RemoveException
+      * @exception javax.ejb.EJBException */
+    public void ejbRemove()
+    	throws javax.ejb.RemoveException, javax.ejb.EJBException
+    {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::ejbRemove()");
+        prepareContextClassLoader();
+        objectCache.remove( getId() );
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::ejbRemove()");
+    }
+
+    /** A container invokes this method to instruct the instance to synchronize its state
+      * by storing it to the underlying database.
+      * 
+      * @exception javax.ejb.EJBException */
+    public void ejbStore() throws javax.ejb.EJBException
+    {
+
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::ejbStore()");
+        // Update the CMP store only if the data has changed.
+        if (isDirty()) {
+            // We don't want to modify the update count if
+            // it was already set when the object
+            // was inserted via ejbCreate().
+
+            if (getShouldIncrementUpdateCountOnStore() == true) {
+                m_currentDataUpdateCount++;
+                internalSetDataUpdateCount(m_currentDataUpdateCount++); 
+            } else {
+                setShouldIncrementUpdateCountOnStore( true );
+            }
+
+
+            marshalToStorage();
+            internalClearDirtyDataBit();
+        }
+
+
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::ejbStore()");
+
+    }
+    
+    /**
+     * Set the update count associated with the CMP.  The update count
+     * is used to distinguish between cached versions of the deserialized
+     * object.  The updatecount held in the database represents the freshest
+     * version.  An updatecount different from the one held in the database
+     * indicates a stale object which must deserialized from the byte
+     * array contained in the database.
+     * @param dataUpdateCount
+     */
+    private void internalSetDataUpdateCount( long dataUpdateCount )
+    {
+        long generatedUpdateCount = ObjectCache.GetUpdateCount( dataUpdateCount );
+        setDataUpdateCount( generatedUpdateCount );
+    }
+
+    /**
+     * Serialize the object into a byte array in preparation for storage
+     * in the database.
+     * 
+     * @return
+     * @throws IOException
+     */
+    private byte[] getObjectAsByteArray() throws IOException
+    {
+        // Serialize the java object
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::getObjectAsByteArray()");
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream oos = new ObjectOutputStream(baos);
+        oos.writeObject(internalGetObject());
+        oos.close();
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::getObjectAsByteArray()");
+        return baos.toByteArray();
+    }
+
+    /**
+     * Convert the object into a byte array and store it in the database.
+     */
+    protected void marshalToStorage() {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::marshalToStorage()");
+        try {
+            byte[] byteArray = getObjectAsByteArray();
+            setData(byteArray);
+            cacheState();
+        } catch (IOException e) {
+            logger.log(Level.SEVERE, "", e);
+            if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::marshalToStorage()");
+            throw new EJBException(e);
+        }
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::marshalToStorage()");
+    }
+
+    /** Set the associated entity context.
+      * 
+      * @param ctx
+      * @exception javax.ejb.EJBException */
+    public void setEntityContext(EntityContext ctx)
+    throws javax.ejb.EJBException
+    {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::setEntityContext(EntityContext ctx)");
+        //this.ejbContext = ctx;
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::setEntityContext(EntityContext ctx)");
+    }
+
+    /** Unset the associated entity context.
+      * 
+      * @exception javax.ejb.EJBException */
+    public void unsetEntityContext() throws javax.ejb.EJBException
+    {
+        if (TraceLog.enabled()) enterTrace("unsetEntityContext()");
+        //this.ejbContext = null;
+        if (TraceLog.enabled()) exitTrace("unsetEntityContext()");
+    }
+
+    /**
+     * Create a new entity and initialize it's members.
+     * @param id
+     * @param iObject
+     * @return
+     * @throws javax.ejb.CreateException
+     */
+    public String ejbCreate(java.lang.String id, Object iObject)
+    throws javax.ejb.CreateException
+    {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::BPE_CMPObjectBean::ejbCreate(java.lang.String id, Object iObject)");
+
+
+        init();
+        setId(id);
+        internalSetDataUpdateCount(1);
+        setShouldIncrementUpdateCountOnStore(false);
+        setObjectNow(iObject);
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::BPE_CMPObjectBean::ejbCreate(java.lang.String id, Object iObject)");
+
+        return id;
+    }
+
+    /**
+     * Assign default values to members.
+     */
+    private void init() {
+        m_object = null;
+        m_currentDataUpdateCount = -1;
+        m_dirtyDataBit = false;
+        m_objectStale = true;
+        m_shouldIncrementUpdateCountOnStore = true;  
+        if ( objectCache == null )
+        {
+            objectCache = new ObjectCache();
+        }
+    }
+
+    /** @param id 
+         * @param data */
+    public void ejbPostCreate(java.lang.String id, Object iObject) {
+    }
+
+    
+    
+    /* (non-Javadoc)
+     * @see com.sybase.bpe.context.base.INoThrowDataObject#decrementRefCount()
+     */
+    public void decrementRefCount() {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::decrementRefCount()");
+        setRefCount(getRefCount() - 1);
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::decrementRefCount()");
+    }
+
+    /* (non-Javadoc)
+     * @see com.sybase.bpe.context.base.INoThrowDataObject#incrementRefCount()
+     */
+    public void incrementRefCount() {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::incrementRefCount()");
+
+        setRefCount(getRefCount() + 1);
+
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::incrementRefCount()");
+    }
+
+    /**
+     * Returns true if the deserialized object is 
+     * stale and needs to be recreated.
+     */
+    private boolean isObjectStale() {
+        return m_objectStale;
+    }
+
+    /**
+     * Returns a fresh deserialized java object.  Performs
+     * deserialization as necessary.
+     * @return
+     */
+    private Object internalGetFreshObject() {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::internalGetFreshObject()");
+        // The underlying byte array may have changed.  If it has then we
+        // need to deserialize the object from the underlying byte array.
+        if (isObjectStale()) {
+            restoreCachedState();
+            if (isObjectStale())
+            {
+                marshalFromStorage();
+                m_objectStale = false;
+            }
+        }
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::internalGetFreshObject()");
+        return m_object;
+    }
+
+    /**
+     * Deserialize the object from a byte array.
+     */
+    protected void marshalFromStorage() {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::marshalFromStorage()");
+        try {
+            ByteArrayInputStream bais = new ByteArrayInputStream(getData());
+            ObjectInputStream ois = new ObjectInputStreamContextClassLoader(bais);
+            internalSetObject(ois.readObject());
+            ois.close();
+        } catch (IOException e) {
+            logger.log(Level.SEVERE, "", e);
+            if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::marshalFromStorage()");
+            throw new EJBException(e);
+        } catch (ClassNotFoundException e) {
+            logger.log(Level.SEVERE, "", e);
+            if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::marshalFromStorage()");
+            throw new EJBException(e);
+        }
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::marshalFromStorage()");
+    }
+
+    /**
+     * Get the object with read-only intent.
+     * @ejb.interface-method
+     * @jboss.method-attributes read-only="true"
+     */
+    public Object getObjectForRead() {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::getObjectForRead()");
+        Object obj = internalGetFreshObject();
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::getObjectForRead()");
+        return obj;
+    }
+
+    /* Get the object with read-write intent.
+     * (non-Javadoc)
+     * @see com.sybase.bpe.context.base.INoThrowDataObject#getObjectForReadWrite()
+     */
+    public Object getObjectForReadWrite() {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::getObjectForReadWrite()");
+        internalSetDirtyDataBit();
+        Object obj = internalGetFreshObject();
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::getObjectForReadWrite()");
+        return obj;
+
+    }
+
+    /* Set the object associated with the CMP.  The object will be written
+     * to the database when the ejbStore method is called.
+     * (non-Javadoc)
+     * @see com.sybase.bpe.context.base.INoThrowDataObject#setObject(java.lang.Object)
+     */
+    public void setObject(Object data) {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::setObject( Object data ) ");
+        
+        if ( data instanceof FlushCommand )
+        {
+        	marshalToStorage();
+        }
+        else
+        {
+        	internalSetObject(data);
+        	internalSetDirtyDataBit();
+        }
+
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::setObject( Object data ) ");
+    }
+
+    /**
+     * Set the object associated with the CMP and immediately persist it to the
+     * database.
+     * @param data
+     */
+    public void setObjectNow(Object data) {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::setObjectNow()");
+        internalSetObject(data);
+        marshalToStorage();
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::setObjectNow()");
+    }
+
+    /**
+     * Set the object and add it to the cache.
+     * @param iData
+     */
+    protected void internalSetObject(Object iData) {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::internalSetObject()");
+        m_object = iData;
+        cacheState();
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::internalSetObject()");
+    }
+
+    /**
+     * Get the deserialized object.
+     * @return
+     */
+    protected Object internalGetObject() {
+
+        return m_object;
+    }
+
+    /**
+     * Mark the cmp as dirty which means that the object must be serialized
+     * to a byte array and written to the database when ejbStore is called.
+     */
+    protected void internalSetDirtyDataBit() {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::internalSetDirtyBit()");
+        m_dirtyDataBit = true;
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::internalSetDirtyBit()");
+    }
+
+    /**
+     * Mark the cmp as clean which means that there is no need to persist
+     * the object to the database when ejbStore() is called.
+     */
+    protected void internalClearDirtyDataBit() {
+        if (TraceLog.enabled()) enterTrace("BPE_CMPObjectBean::internalClearDirtyBit()");
+        m_dirtyDataBit = false;
+        if (TraceLog.enabled()) exitTrace("BPE_CMPObjectBean::internalClearDirtyBit()");
+    }
+
+    /**
+     * returns true if the cmp is dirty and needs to be synced with the database.
+     */
+    protected boolean isDirty() {
+
+        return m_dirtyDataBit;
+    }
+
+    protected void  enterTrace(String iFunction) {
+        if (TraceLog.enabled()) {
+            TraceLog.println(getDumpState(iFunction) + " Enter " + iFunction);
+        }
+    }
+
+    protected void  exitTrace(String iFunction) {
+
+        if (TraceLog.enabled()) {
+            TraceLog.println(getDumpState(iFunction) + " Exit " + iFunction);
+        }
+
+    }
+
+    protected String getDumpScope(String iFunction) {
+        return /*BPE_CMPObjectBean.class.toString() + "::" + */
+        iFunction + " | ";
+    }
+
+    protected String getDumpState(String iFunction) {
+		return "(TODO)";	//TODO
+    }
+
+    /**
+     * Set a value which indicates whether or not the update count
+     * should be incremented when ejbStore() is called.  There is
+     * no need to increment the update count if the object is created
+     * during this transaction.
+     * 
+     * @param shouldIncrement
+     */
+    protected void setShouldIncrementUpdateCountOnStore(boolean shouldIncrement) {
+        m_shouldIncrementUpdateCountOnStore = shouldIncrement;
+    }
+
+
+    /**
+     * Returns true if the update count should be incremented
+     * during ejbStore().
+     */
+    protected boolean getShouldIncrementUpdateCountOnStore() {
+        return m_shouldIncrementUpdateCountOnStore;
+    }
+
+    protected java.lang.Object m_object = null;
+    private ClassLoader m_contextClassLoader;
+    private long m_currentDataUpdateCount = -1;
+    private boolean m_dirtyDataBit = false;
+    private boolean m_objectStale = true;
+    private boolean m_shouldIncrementUpdateCountOnStore = true;
+//    private EntityContext ejbContext;
+    private ObjectCache objectCache;
+    protected static final Logger logger =
+    Logger.getLogger(BPE_CMPObjectBean.class.getName());
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/BPE_ObjectLocal.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/BPE_ObjectLocal.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/BPE_ObjectLocal.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/BPE_ObjectLocal.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,40 @@
+/*
+* 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
+*/
+/***********************************************************************
+ * Module:  BPE_PCLOBLocal.java
+ * Author:  waterman
+ * Purpose: Defines the Interface BPE_PCLOBLocal
+ ***********************************************************************/
+
+package com.sybase.bpe.context.ejb;
+
+import com.sybase.bpe.context.base.INoThrowDataObject;
+
+public interface BPE_ObjectLocal extends javax.ejb.EJBLocalObject, INoThrowDataObject
+{
+	/**
+	 * Returns the unique id of the data. This is the primary key field.
+	 * 
+	 * @return a UUID identifier
+	 */
+	public java.lang.String getId();	
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/BPE_ObjectLocalHome.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/BPE_ObjectLocalHome.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/BPE_ObjectLocalHome.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/BPE_ObjectLocalHome.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,42 @@
+/*
+* 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
+*/
+/***********************************************************************
+ * Module:  BPE_PCLOBLocalHome.java
+ * Author:  waterman
+ * Purpose: Defines the Interface BPE_PCLOBLocalHome
+ ***********************************************************************/
+
+package com.sybase.bpe.context.ejb;
+
+
+public interface BPE_ObjectLocalHome extends javax.ejb.EJBLocalHome
+{
+   /**
+    * Returns a reference 
+    * 
+    *  @param key
+     * @exception javax.ejb.FinderException */
+   BPE_ObjectLocal findByPrimaryKey(String key) throws javax.ejb.FinderException;
+
+   BPE_ObjectLocal create(java.lang.String ID, Object data) throws javax.ejb.CreateException;
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/CachedObject.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/CachedObject.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/CachedObject.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/CachedObject.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,64 @@
+/*
+* 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.context.ejb;
+
+/**
+ * This class represents a deserialized object which
+ * is cached by the CMP object bean for performance reasons.
+ * 
+ * The object contains a raw object and an associated 
+ * updatecount which is used to detect if the cached
+ * object is stale.
+ */
+public class CachedObject
+{
+    public CachedObject( Object object, long updateCount )
+    {
+        setObject(object);
+        setUpdateCount(updateCount);
+    }
+    
+    public Object getObject()
+    {
+        return Object;
+    }
+    
+    public void setObject(Object object)
+    {
+        Object = object;
+    }
+    
+    public long getUpdateCount()
+    {
+        return updateCount;
+    }
+    
+    public void setUpdateCount(long updateCount)
+    {
+        this.updateCount = updateCount;
+    }
+    
+    private long updateCount;
+    private Object Object;
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObject.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObject.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObject.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObject.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,99 @@
+/*
+* 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 10, 2003
+ *
+
+ */
+package com.sybase.bpe.context.ejb;
+
+import java.io.Serializable;
+
+import com.sybase.bpe.context.base.ContextServiceException;
+import com.sybase.bpe.context.persistent.PersistentDataObject;
+
+/**
+ * @author waterman
+ *
+ * A handle to an EJB persisted data object. The handle holds a reference to a piece
+ * of persisted data. The handle is on the leaf node of a process context tree and
+ * is serialized as part of the tree.
+ * <P>
+ * The handle will persist any Java Serializable/Externalizable object.<BR>
+ * 
+ */
+public class EJBDataObject extends PersistentDataObject implements Serializable
+{
+	
+    static final long serialVersionUID = 925277168317272542L;
+	
+	EJBDataObject(String id, BPE_ObjectLocal local)
+		throws ContextServiceException
+	{
+		super( id, local );
+	}
+			
+	public void setObject(Object obj) throws ContextServiceException 
+	{
+		getEJBLocal().setObject(obj);
+	}
+
+	private BPE_ObjectLocal getEJBLocal() throws ContextServiceException 
+	{
+		return ( BPE_ObjectLocal ) ( getInternals() );
+	}
+
+	public Object getObjectForRead() throws ContextServiceException 
+	{
+		return getEJBLocal().getObjectForRead();
+	}
+	
+	public Object getObjectForReadWrite() throws ContextServiceException
+	{
+		return getEJBLocal().getObjectForReadWrite();
+	}
+	
+	public void decrementRefCount() throws ContextServiceException
+	{
+		getEJBLocal().decrementRefCount();
+	}
+
+	public void incrementRefCount() throws ContextServiceException
+	{
+		getEJBLocal().incrementRefCount();
+	}
+	
+	public long getRefCount() throws ContextServiceException
+	{
+		return getEJBLocal().getRefCount();
+	}
+	
+	public void flush() throws ContextServiceException
+	{
+		FlushCommand mtsc = new FlushCommand();
+		getEJBLocal().setObject(mtsc);
+	}
+	
+
+	
+	
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObjectFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObjectFactory.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObjectFactory.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObjectFactory.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,92 @@
+/*
+* 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.context.ejb;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalObject;
+import javax.ejb.FinderException;
+import javax.ejb.RemoveException;
+
+import com.sybase.bpe.context.base.ContextServiceException;
+import com.sybase.bpe.context.base.IDataObject;
+
+public class EJBDataObjectFactory extends EJBDataObjectFactoryBase
+{
+
+
+	BPE_ObjectLocalHome getObjectHome() throws ContextServiceException
+	{
+		return (BPE_ObjectLocalHome) getLocalHome
+			(getEJBHomeJNDIName());
+	}
+	
+	protected EJBLocalObject findObject( String iLocator ) throws ContextServiceException, FinderException
+	{
+		return getObjectHome().findByPrimaryKey(iLocator);
+	}
+	
+	protected void removeObject( String iLocator ) throws RemoveException, ContextServiceException
+	{
+		try
+		{
+			EJBLocalObject ejbl = findObject(iLocator);
+			if ( ejbl != null ) {
+				getObjectHome().remove(iLocator);
+			}
+		}
+		catch( javax.ejb.EJBException e )
+		{
+			// If the object wasn't there then no worries.
+		} 
+		catch ( FinderException e ) {
+			// ignore
+		}
+	}
+
+	protected EJBLocalObject createNewLocalObject(
+		String iLocator,
+		Object iData)
+		throws CreateException, ContextServiceException
+	{
+		return getObjectHome().create(iLocator, iData);
+	}
+
+	protected IDataObject createNewDataObject(
+		String iLocator,
+		EJBLocalObject iLocalObject)
+		throws ContextServiceException
+	{
+		return new EJBDataObject(iLocator, (BPE_ObjectLocal) (iLocalObject));
+	}
+	
+	private String getEJBHomeJNDIName()
+	{
+		if ( m_home == null )
+		{
+			m_home = getProperties().getDataObjectFactoryEJBHome();
+		}
+		return m_home;
+	}
+	
+	private String m_home = null;
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObjectFactory.java.keep
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObjectFactory.java.keep?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObjectFactory.java.keep (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObjectFactory.java.keep Tue Feb 28 08:02:48 2006
@@ -0,0 +1,104 @@
+package com.sybase.bpe.context.ejb;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalObject;
+import javax.ejb.FinderException;
+import javax.ejb.RemoveException;
+
+import com.sybase.bpe.context.base.ContextServiceException;
+import com.sybase.bpe.context.base.IDataObject;
+
+public class EJBDataObjectFactory extends EJBDataObjectFactoryBase
+{
+	
+	private static Map<Thread,SortedSet<String>>  locatorIdsToRemove =
+		Collections.synchronizedMap(new HashMap<Thread,SortedSet<String>>());
+
+	BPE_ObjectLocalHome getObjectHome() throws ContextServiceException
+	{
+		return (BPE_ObjectLocalHome) getLocalHome
+			(getEJBHomeJNDIName());
+	}
+	
+	protected EJBLocalObject findObject( String iLocator ) throws ContextServiceException, FinderException
+	{
+		return getObjectHome().findByPrimaryKey(iLocator);
+	}
+	
+	public void clearRemoveObject() {
+		SortedSet<String> sset= 
+			locatorIdsToRemove.get(Thread.currentThread());
+		if ( sset != null ) {
+			sset.clear();
+		}
+	}
+	public void removeObjects() throws RemoveException, ContextServiceException
+	{
+		SortedSet<String> sset= 
+			locatorIdsToRemove.get(Thread.currentThread());
+		try
+		{
+			if ( sset != null ) {
+				for ( String loc : sset ) {
+					EJBLocalObject ejbl = findObject(loc);
+					if ( ejbl != null ) {
+						getObjectHome().remove(loc);
+					}
+				}
+				sset.clear();
+			}
+		}
+		catch( javax.ejb.EJBException e )
+		{
+			// If the object wasn't there then no worries.
+		} 
+		catch ( FinderException e ) {
+			// ignore
+		}
+	}
+	
+	protected void removeObject( String iLocator ) throws RemoveException, ContextServiceException
+	{
+		SortedSet<String> sset= 
+			locatorIdsToRemove.get(Thread.currentThread());
+		if ( sset == null ) {
+			sset = new TreeSet<String>();
+		   	locatorIdsToRemove.put(Thread.currentThread(),sset);
+		}
+		sset.add(iLocator);
+	}
+
+	protected EJBLocalObject createNewLocalObject(
+		String iLocator,
+		Object iData)
+		throws CreateException, ContextServiceException
+	{
+		return getObjectHome().create(iLocator, iData);
+	}
+
+	protected IDataObject createNewDataObject(
+		String iLocator,
+		EJBLocalObject iLocalObject)
+		throws ContextServiceException
+	{
+		return new EJBDataObject(iLocator, (BPE_ObjectLocal) (iLocalObject));
+	}
+	
+	private String getEJBHomeJNDIName()
+	{
+		if ( m_home == null )
+		{
+			m_home = getProperties().getDataObjectFactoryEJBHome();
+		}
+		return m_home;
+	}
+	
+	private String m_home = null;
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObjectFactoryBase.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObjectFactoryBase.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObjectFactoryBase.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/EJBDataObjectFactoryBase.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,218 @@
+/*
+* 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.context.ejb;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.EJBLocalObject;
+import javax.ejb.FinderException;
+import javax.ejb.RemoveException;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import com.sybase.bpe.context.base.ContextServiceException;
+import com.sybase.bpe.context.base.IDataObject;
+import com.sybase.bpe.context.persistent.PersistentDataObjectFactory;
+
+public abstract class EJBDataObjectFactoryBase
+	extends PersistentDataObjectFactory
+{
+
+	public IDataObject create(Object iData) throws ContextServiceException
+	{
+		String aUUID = getUUID();
+		IDataObject returnObject = createNewDataObject1(aUUID, iData);
+
+		return returnObject;
+	}
+
+	protected abstract IDataObject createNewDataObject(
+		String iLocator,
+		EJBLocalObject iLocal)
+		throws ContextServiceException;
+
+	protected EJBLocalHome getLocalHome(String iJNDIName)
+		throws ContextServiceException
+	{
+
+		if (m_localHome == null)
+		{
+			try
+			{
+				if (m_ictx == null)
+				{
+					m_ictx = new InitialContext();
+				}
+				m_localHome = (EJBLocalHome) m_ictx.lookup(iJNDIName);
+			}
+			catch (NamingException e)
+			{
+				ContextServiceException cse = new ContextServiceException("JNDI_LOOKUP",new Object[] { iJNDIName }, e);
+				cse.log(logger,Level.SEVERE);
+				throw cse;
+
+			}
+
+		}
+
+		return m_localHome;
+	}
+
+	protected EJBLocalObject createLocalObject(String id, Object obj)
+		throws ContextServiceException
+	{
+		EJBLocalObject ret = null;
+
+		try
+		{
+			ret = createNewLocalObject(id, obj);
+		} catch (CreateException e) {
+			ContextServiceException bpx = new ContextServiceException("NATIVE_EXCEPTION",new Object[] {"CreateException"},e);
+			bpx.log(logger,Level.SEVERE);
+			throw bpx;
+		}
+
+		return ret;
+	}
+
+	public void remove(String iLocator) throws ContextServiceException
+	{
+		try
+		{
+			m_localCache.remove(iLocator);
+			removeObject(iLocator);
+		}
+		catch (EJBException e)
+		{
+			ContextServiceException bpx = new ContextServiceException("NATIVE_EXCEPTION",new Object[] {"EJBException"},e);
+			bpx.log(logger,Level.SEVERE);
+			throw bpx;
+
+		}
+		catch (RemoveException e)
+		{
+			ContextServiceException bpx = new ContextServiceException("NATIVE_EXCEPTION",new Object[] {"RemoveException"},e);
+			bpx.log(logger,Level.SEVERE);
+			throw bpx;
+
+		}
+	}
+
+	public IDataObject create(String iLocator, Object iData)
+		throws ContextServiceException
+	{
+		IDataObject returnObject = find(iLocator);
+		if (returnObject != null)
+		{
+			returnObject.setObject(iData);
+		}
+		else
+		{
+			returnObject = createNewDataObject1(iLocator, iData);
+		}
+		return returnObject;
+
+	}
+
+	protected IDataObject createNewDataObject1(String iLocator, Object iData)
+		throws ContextServiceException
+	{
+
+		EJBLocalObject objectLocal = createLocalObject(iLocator, iData);
+
+		IDataObject newDataObject = createNewDataObject(iLocator, objectLocal);
+		m_localCache.put(iLocator, newDataObject);
+
+		return newDataObject;
+	}
+	
+	protected void flush() throws ContextServiceException
+	{
+		Iterator iter = m_localCache.values().iterator();
+		while( iter.hasNext())
+		{
+			EJBDataObject ejbdo = ( EJBDataObject)(iter.next());
+			ejbdo.flush();
+		}
+	}
+	
+
+	public IDataObject find(String iLocator) throws ContextServiceException
+	{
+		Object foundObject = m_localCache.get(iLocator);
+		if (foundObject != null)
+		{
+			return (IDataObject) (foundObject);
+		}
+
+		EJBLocalObject objectLocal = null;
+		try
+		{
+			objectLocal = findObject(iLocator);
+			IDataObject newDataObject = createNewDataObject(iLocator, objectLocal);
+			m_localCache.put(iLocator, newDataObject);
+		}
+		catch (FinderException e)
+		{
+			
+			/*
+			logger.log(
+				Level.WARNING,
+				ResourceGetter.getFormatted(
+					"EJB_FIND_PRIMARY",
+					new Object[] { iLocator }),
+				e);
+				*/
+			return null;
+
+		}
+		return createNewDataObject(iLocator, objectLocal);
+	}
+
+	protected abstract EJBLocalObject createNewLocalObject(
+		String iLocator,
+		Object iData)
+		throws CreateException, ContextServiceException;
+
+	protected abstract void removeObject(String iLocator)
+		throws RemoveException, ContextServiceException;
+
+	protected abstract EJBLocalObject findObject(String iLocator)
+		throws ContextServiceException, FinderException;
+
+	private InitialContext m_ictx;
+
+	private EJBLocalHome m_localHome;
+
+	private HashMap m_localCache = new HashMap();
+
+	// Logging
+	private static final Logger logger =
+		Logger.getLogger(EJBDataObjectFactoryBase.class.getName());
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/FlushCommand.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/FlushCommand.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/FlushCommand.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/FlushCommand.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,30 @@
+/*
+* 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.context.ejb;
+
+import java.io.Serializable;
+
+
+public class FlushCommand implements Serializable
+{
+    static final long serialVersionUID = 6082617257026241764L;
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/ObjectCache.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/ObjectCache.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/ObjectCache.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/ObjectCache.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,220 @@
+/*
+* 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.context.ejb;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.sybase.uo.util.ApplicationLocalStore;
+
+/**
+ * This class implements  a cache used by the CMP
+ * blob bean for storing deserialized objects.  The
+ * caching is necessary for performance reasons.
+ * 
+ * The cache prunes itself once a configurable
+ * maximum size is reached.  The pruning algorithm
+ * random selects cache elements for deletion.
+ */
+public class ObjectCache
+{ 
+    private final static String MAP_KEY = "OBJECT_CACHE_MAP_KEY";
+
+    // Leave the last two digits for an incremental count.
+    private static long updateCountBase = 
+        (((long)(Math.random()*100000)) + 
+                System.currentTimeMillis())*1000;
+    
+    //TODO - 
+    //Use an application-local property to 
+    //determine the cache size
+    //rather than a system-wide property.
+    private static long maxCacheSize = 
+        Long.parseLong(System.getProperty(
+            "com.sybase.bpe.context.ejb.ObjectCache.maxCacheSize", 
+              "1000" ));
+    
+    private Map cacheMap;
+        
+    public ObjectCache()
+    {
+        cacheMap = lookupMap();
+    }
+    
+    /**
+     * Get a cached object based on id.  Returns null
+     * if the cache does not contain the object.
+     * @param id
+     * @return
+     */
+    public Object get( String id )
+    {
+        Object retVal = getMap().get(id);
+        return retVal;
+    }
+    
+    /**
+     * Remove the object with the specified id from
+     * the cache if present.
+     * @param id
+     */
+    public void remove( String id )
+    {
+        getMap().remove( id );
+    }
+    
+    /**
+     * Add the specified object to the cache and
+     * index it by the specified id.
+     * @param id
+     * @param object
+     */
+    public void put( String id, 
+            Object object )
+    {
+        
+        getMap().put(id, object );
+        shrinkCache();
+    }
+    
+    /**
+     * Shrink the cache if the current cache size
+     * is less than the configured maximum.
+     * 
+     */
+    private void shrinkCache()
+    {
+        Map map = getMap();
+//        long size = map.size();
+
+        if ( map.size() > maxCacheSize )
+        {
+            Object[] keyArray = 
+                map.keySet().toArray();
+            map.keySet().toArray();
+            
+            int randomindex = 
+                (int)( Math.round(Math.floor(Math.random()*keyArray.length)) );
+            String key = (String)(keyArray[randomindex]);
+            remove(key);
+        }
+    }
+    
+    /**
+     * Return an update count which has been modified
+     * to include a cache-specific prefix.  The prefix is
+     * useful because in a cluster it prevents a bad cache entry from
+     * being incorrectly re-used if a transaction is rolledback
+     * on one node1 in the cluster but completed successfully on node2
+     * in the cluster.  If it were not for the prefix, node1 would
+     * re-use the cached object from the rolledback transaction
+     * because the updatecount would match the updatecount from the
+     * completed transaction on node2.
+     * 
+     * @param updateCount
+     * @return
+     */
+    public static long GetUpdateCount( long updateCount )
+    {
+        return updateCountBase + (updateCount & 511);
+    }
+    
+    /**
+     * Get the map which holds the cache.
+     * 
+     * @return
+     */
+    private Map getMap()
+    {
+        Map returnValue;
+        if (cacheMap == null)
+        {
+            returnValue = lookupMap();
+            if (returnValue == null)
+            {
+                returnValue = CreateMap();
+            }
+            cacheMap = returnValue;
+
+        } else
+        {
+            returnValue = cacheMap;
+        }
+        //debug(returnValue);
+        return returnValue;
+    }
+    
+    /**
+     * See if the map which holds the object cache is already
+     * in component local storage.  If it is return it, 
+     * otherwise return null.
+     * @return
+     */
+    private static Map lookupMap()
+    {
+        Map returnValue = 
+            ( Map )ApplicationLocalStore.get( MAP_KEY );
+        //debug(returnValue);
+        return returnValue;
+    }
+    
+//    private static void debug(Map map)
+//    {
+//        if ( map != null )
+//        {
+//        String debugMessage = 
+//            "Map hashcode = " + map.hashCode() + ", " +
+//            "map size = " + map.size();   
+//        debug(debugMessage);
+//        }
+//    }
+    
+//    private static void debug( String message )
+//    {
+//        if ( message != null )
+//        {
+//        String debug = "ObjectCacheDebug: " + message;
+//        System.out.println(debug);
+//        }
+//    }
+    
+    /**
+     * Create the map which holds the object cache and
+     * insert it into component local storgage.
+     * @return
+     */
+    private synchronized static Map CreateMap()
+    {
+        Map returnValue = lookupMap();
+        if ( returnValue == null)
+        {
+            returnValue =  
+                Collections.synchronizedMap(new HashMap());
+            ApplicationLocalStore.set(MAP_KEY, returnValue);
+            //debug( "Created new context local storage map." );
+        }
+        return returnValue;
+        
+    }
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/AssortedContextOperationsBase.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/AssortedContextOperationsBase.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/AssortedContextOperationsBase.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/AssortedContextOperationsBase.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,92 @@
+/*
+* 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.context.ejb.test.performance;
+
+import com.sybase.bpe.context.IContainer;
+import com.sybase.bpe.context.IContextService;
+import com.sybase.bpe.context.IHandle;
+import com.sybase.bpe.context.IPart;
+import com.sybase.bpe.interaction.IInteraction;
+
+public abstract class AssortedContextOperationsBase extends TimedTest
+{
+	
+	
+	protected abstract IContextService createContextService() throws Exception;
+	protected abstract IInteraction createInteractionObject() throws Exception;
+
+	
+	private IInteraction getInteraction1() throws Exception
+	{
+		if ( m_interaction1 == null )
+		{
+			m_interaction1 = createInteractionObject();
+		}
+		return m_interaction1;
+	}
+	
+	private IInteraction getInteraction2() throws Exception
+	{
+		if ( m_interaction2 == null )
+		{
+			m_interaction2 = createInteractionObject();
+		}
+		return m_interaction2;
+	}
+
+	protected void runIteration() throws Exception
+	{
+		
+
+		IInteraction interaction1 = getInteraction1();
+		IInteraction interaction2 = getInteraction2();
+
+		IContextService contextService = createContextService();
+
+		IHandle handle1 = contextService.createObjectHandle(interaction1);
+
+		IContainer root = contextService.getRoot();
+
+		String processInstance1UUID = "PerformanceTestBP";
+		IContainer processContext1 = root.createContainer(processInstance1UUID);
+
+		IContainer pc1C1 = processContext1.createContainer("C0");
+		IPart pc1C1P1 = pc1C1.createPart("P1");
+		pc1C1P1.setObject(handle1);
+		IPart pc1C1P2 = pc1C1.createPart("P2");
+		pc1C1P2.setObject(interaction1);
+
+
+		IContainer pc1C2 = processContext1.createContainer("C1");
+		IPart pc1C2P1 = pc1C2.createPart("P1");
+		pc1C2P1.setObject(handle1);
+		IPart pc1C2P2 = pc1C2.createPart("P2");
+		pc1C2P2.setObject(interaction2);
+
+
+	}
+	
+	private IInteraction m_interaction1 = null;
+	private IInteraction m_interaction2 = null;
+
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CallSetObjectWithContainer.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CallSetObjectWithContainer.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CallSetObjectWithContainer.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CallSetObjectWithContainer.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,96 @@
+/*
+* 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.context.ejb.test.performance;
+
+import com.sybase.bpe.context.IContainer;
+import com.sybase.bpe.context.IContextService;
+import com.sybase.bpe.context.IHandle;
+import com.sybase.bpe.context.IPart;
+import com.sybase.bpe.context.base.ContextServiceFactory;
+import com.sybase.bpe.context.base.ContextTypeEnum;
+import com.sybase.bpe.context.base.IDataObject;
+import com.sybase.bpe.context.ejb.EJBDataObjectFactory;
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.uuid.UUIDService;
+
+public class CallSetObjectWithContainer extends TimedTest
+{
+	public CallSetObjectWithContainer() throws Exception
+	{
+	}
+
+	protected void runIteration() throws Exception
+	{
+		m_userTransaction.begin();
+		m_dataObject.setObject(m_container);
+		m_userTransaction.commit();
+	}
+
+	public void init(UUIDService us) throws Exception
+	{
+		m_userTransaction.begin();
+		m_factory = new EJBDataObjectFactory();
+
+		String message1 = "aMessage1";
+		String message2 = "Test Message2";
+
+		BPEProperties props = new BPEProperties();
+
+		IContextService csP =
+			ContextServiceFactory.createContextService(
+				props,
+				us,
+				ContextTypeEnum.PERSISTENT);
+
+		IHandle handle1 = csP.createObjectHandle(message1);
+
+		IContainer root = csP.getRoot();
+
+		String processInstance1UUID = "aaa";
+		IContainer processContext1 = root.createContainer(processInstance1UUID);
+		String processInstance2UUID = "bbb";
+		IContainer processContext2 = root.createContainer(processInstance2UUID);
+
+		IContainer pc1C1 = processContext1.createContainer("myNewMessage1");
+		IPart pc1C1P1 = pc1C1.createPart("param1");
+		pc1C1P1.setObject(handle1);
+		IPart pc1C1P2 = pc1C1.createPart("param2");
+		pc1C1P2.setObject(message2);
+
+
+		IContainer pc1C2 = processContext1.createContainer("myNewMessage2");
+		IPart pc1C2P1 = pc1C2.createPart("param1");
+		pc1C2P1.setObject(handle1);
+		IPart pc1C2P2 = pc1C2.createPart("param2");
+		pc1C2P2.setObject(message2);
+
+
+		m_container = processContext2;
+		m_dataObject = m_factory.create(m_container);
+		m_userTransaction.commit();
+	}
+
+	private EJBDataObjectFactory m_factory = new EJBDataObjectFactory();
+	private IContainer m_container = null;
+	private IDataObject m_dataObject;
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CallSetObjectWithString.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CallSetObjectWithString.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CallSetObjectWithString.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CallSetObjectWithString.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,52 @@
+/*
+* 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.context.ejb.test.performance;
+
+//import com.sybase.bpe.context.IContainer;
+import com.sybase.bpe.context.base.IDataObject;
+import com.sybase.bpe.context.ejb.EJBDataObjectFactory;
+
+public class CallSetObjectWithString extends TimedTest
+{
+
+	protected void runIteration() throws Exception
+	{	
+		m_userTransaction.begin();
+		m_dataObject.setObject(m_string);
+		m_userTransaction.commit();
+	}
+
+	public void init() throws Exception
+	{
+		m_userTransaction.begin();
+		m_factory = new EJBDataObjectFactory();
+		m_dataObject = m_factory.create(m_string);
+		m_userTransaction.commit();
+	}
+
+	private EJBDataObjectFactory m_factory = new EJBDataObjectFactory();
+//	private IContainer m_container = null;
+	private IDataObject m_dataObject;
+	private String m_string = "12345678901234567890123456789012345678901234567890123456789012345678901234567890";
+	
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CreateNewDataObject.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CreateNewDataObject.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CreateNewDataObject.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CreateNewDataObject.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,38 @@
+/*
+* 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.context.ejb.test.performance;
+
+import com.sybase.bpe.context.ejb.EJBDataObjectFactory;
+
+public class CreateNewDataObject extends TimedTest
+{
+	
+	protected void runIteration() throws Exception
+	{
+		m_userTransaction.begin();
+		m_factory.create( "testMessage" );	
+		m_userTransaction.commit();	
+	}
+	
+	private EJBDataObjectFactory m_factory = new EJBDataObjectFactory();
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CreateUUID.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CreateUUID.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CreateUUID.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/CreateUUID.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,53 @@
+/*
+* 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.context.ejb.test.performance;
+
+import javax.naming.InitialContext;
+import javax.resource.cci.ConnectionFactory;
+
+import com.sybase.bpe.uuid.connector.IUUIDConnection;
+
+public class CreateUUID extends TimedTest
+{
+
+	public CreateUUID()
+	{
+		setName("CreateUUID"); 
+	}
+
+	protected void runIteration() throws Exception
+	{
+
+		if (connection == null)
+		{
+			InitialContext ctx = new InitialContext();
+			connection =
+				(IUUIDConnection) ((ConnectionFactory) ctx
+					.lookup("java:comp/env/theUUIDService"))
+					.getConnection();
+		}
+		connection.getUUID();
+	}
+
+	private IUUIDConnection connection = null;
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/EmptyTransaction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/EmptyTransaction.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/EmptyTransaction.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/EmptyTransaction.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,40 @@
+/*
+* 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.context.ejb.test.performance;
+
+
+public class EmptyTransaction extends TimedTest
+{
+	public EmptyTransaction()
+	{
+		setName( "EmptyTransaction" );
+	}
+	
+
+	protected void runIteration() throws Exception
+	{
+		m_userTransaction.begin();
+		m_userTransaction.commit();
+	}
+
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/EntityBeanHomeLookup.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/EntityBeanHomeLookup.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/EntityBeanHomeLookup.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/EntityBeanHomeLookup.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,42 @@
+/*
+* 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.context.ejb.test.performance;
+
+//import javax.ejb.EJBLocalHome;
+import javax.naming.InitialContext;
+
+public class EntityBeanHomeLookup extends TimedTest
+{
+	public EntityBeanHomeLookup()
+	{
+		setName("EntityBeanHomeLookup");
+	}
+
+	protected void runIteration() throws Exception
+	{
+
+		InitialContext ctx = new InitialContext();
+
+		ctx.lookup("java:comp/env/theCMPObjectBean");
+	}
+
+}

Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/FindAndNotThere.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/FindAndNotThere.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/FindAndNotThere.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/context/ejb/test/performance/FindAndNotThere.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,37 @@
+/*
+* 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.context.ejb.test.performance;
+
+import com.sybase.bpe.context.ejb.EJBDataObjectFactory;
+
+public class FindAndNotThere extends TimedTest
+{
+
+		protected void runIteration() throws Exception
+	{
+
+		m_factory.find( "This key better not be there." );	
+	
+	}
+	
+	private EJBDataObjectFactory m_factory = new EJBDataObjectFactory();
+}