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 [33/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/operations/DocumentOperation.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/DocumentOperation.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/DocumentOperation.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/DocumentOperation.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,85 @@
+/*
+* 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.operations;
+
+import java.io.Serializable;
+
+import org.w3c.dom.Document;
+
+import com.sybase.bpe.interaction.IDocumentAccessible;
+import com.sybase.bpe.interaction.InteractionException;
+import com.sybase.bpe.interaction.query.IDocumentQuery;
+import com.sybase.bpe.interaction.query.IQuery;
+
+public abstract class DocumentOperation implements IOperation,
+Serializable
+{
+ static final long serialVersionUID = 2889229303748016768L;
+ private boolean m_nodeCreating = false;
+
+ public DocumentOperation( boolean iIsNodeCreating )
+ {
+ setNodeCreating( iIsNodeCreating );
+ }
+
+ public Object execute(Object iTarget, IQuery query, Object iParameters, String xpath) throws Exception
+ {
+ IDocumentQuery documentQuery = ( IDocumentQuery )( query );
+
+ if ( ! ( iTarget instanceof IDocumentAccessible))
+ {
+ throw new InteractionException(
+ "UNKNOWN_INVOCATION",null);
+ }
+
+ IDocumentAccessible documentAccessible = ( IDocumentAccessible )
+ (iTarget);
+ Document document = documentAccessible.getDocument();
+ Object queryResult = documentQuery.runQuery( document );
+
+ if ((queryResult == null) ||
+ ((queryResult instanceof java.util.List) && (((java.util.List)queryResult).isEmpty())))
+ {
+ if (getNodeCreating() == true)
+ {
+ queryResult = documentQuery.buildQueriedNode(document);
+ }
+ }
+
+ Object result = execute( queryResult, iParameters, xpath);
+
+ return result;
+ }
+
+ public boolean getNodeCreating()
+ {
+ return m_nodeCreating;
+ }
+
+ public void setNodeCreating( boolean iIsNodeCreating )
+ {
+ m_nodeCreating = iIsNodeCreating;
+ }
+
+ protected abstract Object execute( Object iQueryResult, Object iParameters, String xpath)
+ throws Exception;
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/GetObjectOperation.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/GetObjectOperation.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/GetObjectOperation.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/GetObjectOperation.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
+*/
+package com.sybase.bpe.interaction.operations;
+
+import java.io.Serializable;
+
+import com.sybase.bpe.interaction.IObjectAccessible;
+import com.sybase.bpe.interaction.InvocationMismatchException;
+import com.sybase.bpe.interaction.query.IQuery;
+
+public class GetObjectOperation implements IOperation,
+Serializable
+{
+
+ static final long serialVersionUID = 5112175512042602594L;
+
+ public Object execute(Object iTargetObject,
+ IQuery query, Object iParameter, String xpath) throws Exception
+ {
+ if ( iTargetObject instanceof IObjectAccessible )
+ {
+ IObjectAccessible accessible =
+ ( IObjectAccessible )( iTargetObject );
+
+ return accessible.getObject();
+
+ }
+ else
+ {
+ throw new InvocationMismatchException();
+ }
+ }
+
+ public boolean isMutator()
+ {
+ return false;
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/GetTextValueOperation.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/GetTextValueOperation.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/GetTextValueOperation.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/GetTextValueOperation.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.interaction.operations;
+
+import java.io.Serializable;
+
+import org.w3c.dom.Node;
+
+import com.sybase.bpe.interaction.NonExistentNodeException;
+
+public class GetTextValueOperation extends DocumentOperation implements
+Serializable
+{
+ static final long serialVersionUID = -6392029466706714795L;
+
+ public GetTextValueOperation()
+ {
+ super( false );
+ }
+ protected Object execute(Object iQueryResult,
+ Object iParameters, String xpath) throws Exception
+ {
+ String stringResult = null;
+
+ if ( iQueryResult == null )
+ {
+ throw new NonExistentNodeException( xpath );
+ }
+ else if ( iQueryResult instanceof Node )
+ {
+ stringResult = DOMUtil.processNodeValue(
+ (Node)(iQueryResult) );
+ }
+ else
+ {
+ stringResult = iQueryResult.toString();
+ }
+
+ return stringResult;
+ }
+ public boolean isMutator()
+ {
+ return false;
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/IOperation.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/IOperation.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/IOperation.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/IOperation.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,33 @@
+/*
+* 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.operations;
+
+
+import com.sybase.bpe.interaction.query.IQuery;
+
+public interface IOperation
+{
+ public Object execute( Object ITargetObject,
+ IQuery query, Object iParameter, String pathExpression ) throws Exception;
+
+ public boolean isMutator();
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/PruneOperation.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/PruneOperation.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/PruneOperation.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/PruneOperation.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
+*/
+package com.sybase.bpe.interaction.operations;
+
+import java.io.Serializable;
+
+import org.w3c.dom.Node;
+
+import com.sybase.bpe.interaction.NonExistentNodeException;
+
+
+public class PruneOperation extends DocumentOperation
+implements Serializable
+{
+ static final long serialVersionUID = 1915268790008166417L;
+
+ public PruneOperation()
+ {
+ super( false );
+ }
+
+ protected Object execute(Object iQueryResult, Object iParameters, String xpath) throws Exception
+ {
+ if ( iQueryResult == null )
+ {
+ throw new NonExistentNodeException( xpath );
+ }
+ Node node = (Node)(iQueryResult);
+ DOMUtil.detachNode(node);
+
+ return null;
+ }
+
+ public boolean isMutator()
+ {
+ return true;
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/SelectTreeOperation.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/SelectTreeOperation.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/SelectTreeOperation.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/SelectTreeOperation.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,56 @@
+/*
+* 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.operations;
+
+import java.io.Serializable;
+
+import com.sybase.bpe.interaction.NonExistentNodeException;
+
+public class SelectTreeOperation extends DocumentOperation
+implements Serializable
+{
+
+ static final long serialVersionUID = -3338833121612331781L;
+
+ public SelectTreeOperation()
+ {
+ super( false );
+ }
+ protected Object execute(Object iQueryResult, Object iParameters, String xpath) throws Exception
+ {
+ /*Node resultNode = ( Node )iQueryResult;
+ if ( resultNode == null )
+ {
+ throw new NonExistentNodeException();
+ }
+ return resultNode;*/
+ if (iQueryResult == null)
+ {
+ throw new NonExistentNodeException( xpath );
+ }
+ return iQueryResult;
+ }
+ public boolean isMutator()
+ {
+ return false;
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/SetObjectOperation.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/SetObjectOperation.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/SetObjectOperation.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/SetObjectOperation.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,59 @@
+/*
+* 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.operations;
+
+import java.io.Serializable;
+
+import com.sybase.bpe.interaction.IObjectMutable;
+import com.sybase.bpe.interaction.InvocationMismatchException;
+import com.sybase.bpe.interaction.query.IQuery;
+
+public class SetObjectOperation implements IOperation,
+Serializable
+{
+
+ static final long serialVersionUID = 4130461651876689897L;
+
+ public Object execute(Object iTargetObject,
+ IQuery query, Object iParameter, String xpath) throws Exception
+ {
+ if ( iTargetObject instanceof IObjectMutable )
+ {
+ IObjectMutable mutable =
+ ( IObjectMutable )( iTargetObject );
+
+ mutable.setObject( iParameter );
+ }
+ else
+ {
+ throw new InvocationMismatchException();
+ }
+
+ return iTargetObject;
+ }
+
+ public boolean isMutator()
+ {
+ return true;
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/SetTextValueOperation.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/SetTextValueOperation.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/SetTextValueOperation.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/operations/SetTextValueOperation.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,65 @@
+/*
+* 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.operations;
+
+import java.io.Serializable;
+
+import org.w3c.dom.Node;
+
+public class SetTextValueOperation extends DocumentOperation
+implements Serializable
+{
+ static final long serialVersionUID = 7046905920497670266L;
+
+ public SetTextValueOperation( )
+ {
+ super( true );
+ }
+
+ protected Object execute(Object iQueryResult, Object iParameters, String xpath)
+ throws Exception
+ {
+ String stringValue = null;
+
+ if (iParameters instanceof String)
+ {
+ stringValue = (String) iParameters;
+ } else
+ {
+ stringValue = iParameters.toString();
+ }
+
+ Node node = (Node) (iQueryResult);
+
+ DOMUtil.setTextValue(node, stringValue);
+
+ return null;
+ }
+
+ public boolean isMutator()
+ {
+ return true;
+ }
+
+
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/CannotBuildNodeException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/CannotBuildNodeException.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/CannotBuildNodeException.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/CannotBuildNodeException.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.interaction.query;
+
+import java.io.Serializable;
+
+import com.sybase.bpe.interaction.InteractionException;
+
+public class CannotBuildNodeException extends InteractionException
+implements Serializable
+{
+
+ static final long serialVersionUID = -7079541401261316723L;
+
+ public CannotBuildNodeException() {
+ super("CAN_NOT_BUILD",null);
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/IDocumentQuery.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/IDocumentQuery.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/IDocumentQuery.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/IDocumentQuery.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,36 @@
+/*
+* 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.query;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+
+public interface IDocumentQuery extends IQuery
+{
+ Object runQuery( Document iDocument )
+ throws Exception;
+
+ Node buildQueriedNode( Document iDocument )
+ throws Exception;
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/INodeBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/INodeBuilder.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/INodeBuilder.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/INodeBuilder.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.interaction.query;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+public interface INodeBuilder
+{
+ public Node buildNode( Document iDocument) throws Exception;
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/IQuery.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/IQuery.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/IQuery.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/IQuery.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,26 @@
+/*
+* 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.query;
+public interface IQuery
+{
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/JaxenNodeBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/JaxenNodeBuilder.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/JaxenNodeBuilder.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/JaxenNodeBuilder.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,127 @@
+/*
+* 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.query;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+
+import org.jaxen.JaxenException;
+import org.jaxen.SimpleNamespaceContext;
+import org.jaxen.dom.DOMXPath;
+import org.jaxen.XPathFunctionContext;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import com.sybase.bpe.interaction.operations.DOMUtil;
+
+public class JaxenNodeBuilder implements INodeBuilder, Serializable
+{
+ static final long serialVersionUID = 9183764444392953826L;
+
+
+ private XPathParser m_XPathParser;
+ private LinkedList m_subQueries = new LinkedList();
+ private SimpleNamespaceContext m_namespaceContext = null;
+
+ public JaxenNodeBuilder()
+ {
+ }
+
+ public JaxenNodeBuilder(HashMap iURIMap, String iExpression ) throws JaxenException
+ {
+ m_namespaceContext = new SimpleNamespaceContext( iURIMap );
+ m_XPathParser = new XPathParser( iURIMap, iExpression );
+ buildSubQueries();
+ }
+
+ private void buildSubQueries() throws JaxenException
+ {
+ m_subQueries.clear();
+ Iterator iter = m_XPathParser.getNodeDescriptors().iterator();
+ DOMXPath currentQuery = null;
+ String currentQueryString = "";
+ while( iter.hasNext() )
+ {
+ NodeDescriptor nodeDescriptor =
+ ( NodeDescriptor )( iter.next() );
+
+ currentQueryString = currentQueryString + "/" +
+ nodeDescriptor.getName();
+
+ currentQuery = new DOMXPath( currentQueryString );
+ currentQuery.setNamespaceContext(m_namespaceContext);
+ currentQuery.setFunctionContext(new XPathFunctionContext());
+
+ if ( currentQuery != null )
+ {
+ m_subQueries.addFirst( new Object[]{ currentQuery, nodeDescriptor });
+ }
+
+ }
+ }
+
+
+
+ public Node buildNode(Document iDocument) throws Exception
+ {
+ Iterator iter = m_subQueries.iterator();
+ LinkedList nodesToBuild = new LinkedList();
+ Node returnNode = null;
+ while( iter.hasNext() )
+ {
+ Object[] nextPair = ( Object[] )( iter.next() );
+ DOMXPath query = ( DOMXPath )( nextPair[0] );
+ NodeDescriptor descriptor = ( NodeDescriptor )( nextPair[1] );
+
+ Object resultObject =
+ JaxenXPathSingleNodeQuery.runSingleNodeQuery(
+ query, iDocument, query.getRootExpr().getText() );
+
+ if (( resultObject == null )||
+ ((resultObject instanceof java.util.List) && (((java.util.List)resultObject).isEmpty())))
+ {
+ if ( !descriptor.canBuild() )
+ {
+ if ( !descriptor.getName().equals("*") )
+ {
+ throw new CannotBuildNodeException();
+ }
+ }
+ nodesToBuild.addFirst( descriptor );
+ }
+ else
+ {
+ returnNode = DOMUtil.buildNodes( ( Node ) resultObject, nodesToBuild );
+ break;
+ }
+
+ }
+ if ( returnNode == null )
+ {
+ returnNode = DOMUtil.buildNodes( iDocument, nodesToBuild );
+ }
+ return returnNode;
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/JaxenXPathSingleNodeQuery.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/JaxenXPathSingleNodeQuery.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/JaxenXPathSingleNodeQuery.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/JaxenXPathSingleNodeQuery.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,210 @@
+/*
+* 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.query;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Collections;
+import java.util.Map;
+
+import org.jaxen.JaxenException;
+import org.jaxen.NamespaceContext;
+import org.jaxen.SimpleNamespaceContext;
+import org.jaxen.dom.DOMXPath;
+import org.jaxen.XPathFunctionContext;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import com.sybase.bpe.interaction.AmbiguousNodeException;
+
+public class JaxenXPathSingleNodeQuery implements IDocumentQuery,
+Serializable
+{
+
+ static final long serialVersionUID = 8007784523598625657L;
+ private HashMap m_namespaceMap = null;
+ private SimpleNamespaceContext m_namespaceContext = null;
+// private DOMXPath m_locator = null;
+ private transient Map DOMXPathHM;
+ private String m_expression;
+ private boolean m_shouldCreateNode = false;
+ private INodeBuilder m_nodeBuilder = null;
+
+ public JaxenXPathSingleNodeQuery()
+ {
+ super();
+ }
+
+ public JaxenXPathSingleNodeQuery(
+ String iXPathExpression,
+ HashMap iNamespaceMap)
+ throws Exception
+ {
+ setNamespaceMap(iNamespaceMap);
+ setXPathExpression(iXPathExpression);
+
+ }
+
+ public JaxenXPathSingleNodeQuery(
+ String XPathExpression,
+ HashMap namespaceMap,
+ DOMXPath locator ) throws Exception
+ {
+ setNamespaceMap( namespaceMap );
+ setXPathExpression( XPathExpression );
+ setLocator( locator );
+ }
+
+ public void setLocator( DOMXPath locator )
+ {
+ locator.setFunctionContext(new XPathFunctionContext());
+ if ( DOMXPathHM == null ) {
+ DOMXPathHM = Collections.synchronizedMap(new HashMap());
+ }
+ DOMXPathHM.put(Thread.currentThread(),locator);
+ }
+
+ public DOMXPath createLocator() throws Exception
+ {
+ if ( DOMXPathHM == null ) {
+ DOMXPathHM = Collections.synchronizedMap(new HashMap());
+ }
+ DOMXPath locator = (DOMXPath)DOMXPathHM.get(Thread.currentThread());
+ if (locator == null)
+ {
+ if ((m_expression != null) && (m_namespaceMap != null))
+ {
+ locator = new DOMXPath(this.getXPathExpression());
+ locator.setNamespaceContext(createNamespaceContext());
+ locator.setFunctionContext(new XPathFunctionContext());
+ DOMXPathHM.put(Thread.currentThread(),locator);
+ }
+ }
+ return locator;
+ }
+
+ public String getXPathExpression() throws Exception
+ {
+ return m_expression;
+ }
+
+ public void setXPathExpression(String iExpression) throws Exception
+ {
+ m_expression = iExpression;
+ createLocator();
+ }
+
+ public void setShouldCreateNode(boolean iShouldCreateNode)
+ {
+ m_shouldCreateNode = iShouldCreateNode;
+ }
+
+ public boolean getShouldCreateNode()
+ {
+ return m_shouldCreateNode;
+ }
+
+ public NamespaceContext createNamespaceContext()
+ {
+ if (m_namespaceContext == null)
+ {
+ m_namespaceContext = new SimpleNamespaceContext(m_namespaceMap);
+ }
+
+ return m_namespaceContext;
+ }
+
+ public void setNamespaceMap(HashMap iNamespaceMap) throws Exception
+ {
+ m_namespaceMap = iNamespaceMap;
+ createNamespaceContext();
+ createLocator();
+ }
+
+ public HashMap getNamespaceMap()
+ {
+ return m_namespaceMap;
+ }
+
+ public static Object runSingleNodeQuery(
+ DOMXPath iQuery,
+ Document iDocument,
+ String xpath)
+ throws Exception
+ {
+
+ Object result = iQuery.evaluate(iDocument);
+ Object resultObject = null;
+// String stringResult = null;
+
+ if (result instanceof ArrayList)
+ {
+
+ ArrayList arrayList = (ArrayList) (result);
+ if (arrayList.size() > 1)
+ {
+ throw new AmbiguousNodeException( new Object[]{xpath} );
+ }
+
+ Iterator iterator = arrayList.iterator();
+ if (iterator.hasNext())
+ {
+ resultObject = (iterator.next());
+ }
+ } else if (result.equals(Collections.EMPTY_LIST))
+ {
+ resultObject = null;
+ }else
+ {
+ resultObject = result;
+ }
+ return resultObject;
+ }
+
+ public Object runQuery(Document iDocument) throws Exception
+ {
+ DOMXPath xpath = createLocator();
+ return runSingleNodeQuery(xpath, iDocument, m_expression);
+
+ }
+
+ synchronized private void createNodeBuilder() throws JaxenException
+ {
+ if ( m_nodeBuilder == null )
+ {
+ m_nodeBuilder = new JaxenNodeBuilder( m_namespaceMap,
+ this.m_expression );
+ }
+ }
+
+ public Node buildQueriedNode(Document iDocument) throws Exception
+ {
+ if ( m_nodeBuilder == null )
+ {
+ createNodeBuilder();
+ }
+ return m_nodeBuilder.buildNode(iDocument);
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/NodeDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/NodeDescriptor.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/NodeDescriptor.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/NodeDescriptor.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,128 @@
+/*
+* 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.query;
+
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.io.Serializable;
+import java.util.HashMap;
+
+import org.apache.xml.utils.XMLChar;
+
+public class NodeDescriptor implements Serializable
+{
+
+ static final long serialVersionUID = -7444717200424355396L;
+
+ private String m_nodeDescriptorString;
+ private String m_namespacePrefix;
+ private String m_localName;
+ private String m_URI;
+ private boolean m_canBuild;
+
+ public NodeDescriptor( HashMap iURIMap, String iNodeDescriptorString )
+ {
+ m_nodeDescriptorString = iNodeDescriptorString;
+ analyze( iURIMap );
+ }
+
+ public String getName()
+ {
+ return m_nodeDescriptorString;
+ }
+
+ public String getLocalname()
+ {
+ return m_localName;
+ }
+
+ public String getPrefix()
+ {
+ return m_namespacePrefix;
+ }
+
+ public String getNamespaceURI()
+ {
+ return m_URI;
+ }
+
+ private void analyze( HashMap iURIMap )
+ {
+ int length = m_nodeDescriptorString.length();
+ int currentIndex = 0;
+ int currentChar = 0;
+ m_localName = m_nodeDescriptorString;
+ m_namespacePrefix = "";
+ m_canBuild = true;
+ while( currentIndex < length )
+ {
+ currentChar = m_nodeDescriptorString.charAt( currentIndex );
+ if ( currentChar == XPathParser.COLON )
+ {
+ m_namespacePrefix =
+ m_nodeDescriptorString.substring( 0, currentIndex );
+ m_URI = (String)iURIMap.get(m_namespacePrefix);
+ m_localName =
+ m_nodeDescriptorString.substring( currentIndex + 1, length );
+ }
+ else if ( !( XMLChar.isName( currentChar ) ) )
+ {
+ //If the node is not simply an element name
+ //then we can't build it.
+ m_canBuild = false;
+ m_localName = null;
+ m_URI = null;
+ m_namespacePrefix=null;
+
+ break;
+ }
+ currentIndex++;
+ }
+
+ }
+
+ public String toString()
+ {
+ return m_nodeDescriptorString;
+ }
+
+ public void dump( OutputStream iOutputStream )
+ {
+ PrintStream printStream = new PrintStream( iOutputStream );
+ printStream.println( "Name = " + wrap(m_nodeDescriptorString) );
+ printStream.println( "prefix = " + wrap(m_namespacePrefix) );
+ printStream.println( "localName = " + wrap(m_localName) );
+ printStream.println( "namespaceURI = " + wrap(m_URI));
+ printStream.println( "canBuild = " + m_canBuild );
+ }
+
+ private String wrap( String iString )
+ {
+ return "<"+iString+">";
+ }
+
+ public boolean canBuild()
+ {
+ return m_canBuild;
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/XPathParser.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/XPathParser.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/XPathParser.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/XPathParser.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,196 @@
+/*
+* 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.query;
+
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+public class XPathParser implements Serializable
+{
+ static final long serialVersionUID = -8922198154683798177L;
+
+ private LinkedList m_nodeDescriptors = null;
+ private String m_expression = null;
+ private HashMap m_uriMap = null;
+
+ private int m_expressionLength;
+ private int m_currentIndex;
+ private boolean m_parseActive;
+
+ static final int QUOTE = '"';
+ static final int TICK = '\'';
+ static final int LEFT_BRACKET = '[';
+ static final int RIGHT_BRACKET = ']';
+ static final int COLON = ':';
+ static final int FORWARD_SLASH = '/';
+
+ public XPathParser()
+ {
+ }
+
+ public XPathParser(HashMap iURIMap, String iXPathExpression)
+ {
+ setURIMap( iURIMap );
+ setXPathExpression(iXPathExpression);
+ }
+
+ private synchronized void parseExpression()
+ {
+ if ( m_nodeDescriptors != null )
+ {
+ return;
+ }
+ m_expressionLength = m_expression.length();
+ m_currentIndex = 0;
+ m_parseActive = true;
+ m_nodeDescriptors = new LinkedList();
+
+ while ( m_parseActive && ( m_currentIndex < m_expressionLength ) )
+ {
+ parseNodeDescriptor();
+ }
+ m_parseActive = false;
+ }
+
+ private void parseNodeDescriptor()
+ {
+ int startIndex = m_currentIndex;
+ int stopIndex = 0;
+
+ while (true)
+ {
+ if ( m_currentIndex >= m_expressionLength )
+ {
+ stopIndex = m_expressionLength;
+ break;
+ }
+
+ int currentChar = m_expression.charAt(m_currentIndex);
+ // Skip past any literals contained in the expression.
+ if (currentChar == QUOTE || currentChar == TICK)
+ {
+ int closeIndex =
+ m_expression.indexOf(currentChar, m_currentIndex + 1);
+ if (closeIndex >= 0)
+ {
+ m_currentIndex = closeIndex + 1;
+ }
+ else
+ {
+ m_parseActive = false;
+ break;
+ }
+ }
+ else if ( currentChar == LEFT_BRACKET )
+ {
+ int closeIndex =
+ m_expression.indexOf(RIGHT_BRACKET, m_currentIndex + 1);
+
+ if (closeIndex >= 0)
+ {
+ m_currentIndex = closeIndex + 1;
+ }
+ else
+ {
+ m_parseActive = false;
+ break;
+ }
+ }
+ else if ( currentChar == FORWARD_SLASH )
+ {
+ stopIndex = m_currentIndex;
+ m_currentIndex++;
+ break;
+
+ }
+ else
+ {
+ m_currentIndex++;
+ }
+
+ }
+
+ String nodeDescriptorString = m_expression.substring( startIndex, stopIndex );
+ if ( nodeDescriptorString.length() > 0)
+ {
+ addNodeDescriptor( nodeDescriptorString );
+ }
+ }
+
+ private void addNodeDescriptor( String iDescriptorString )
+ {
+ NodeDescriptor nodeDescriptor = new NodeDescriptor( getURIMap(), iDescriptorString );
+ m_nodeDescriptors.addLast( nodeDescriptor );
+ }
+
+ public void setXPathExpression(String iExpression)
+ {
+ m_expression = iExpression;
+ }
+
+ public String getXPathExpression()
+ {
+ return m_expression;
+ }
+
+ public void setURIMap( HashMap iHashMap )
+ {
+ m_uriMap = iHashMap;
+ }
+
+ public HashMap getURIMap()
+ {
+ return m_uriMap;
+ }
+
+ public void dump( OutputStream iOutputStream )
+ {
+ PrintStream printStream = new PrintStream( iOutputStream );
+ printStream.println( "XPathExpression = " + m_expression);
+ printStream.println( "Node Descriptors:" );
+ Iterator iter = getNodeDescriptors().iterator();
+ int count = 0;
+ while( iter.hasNext() )
+ {
+ count++;
+ NodeDescriptor nodeDescriptor =
+ ( NodeDescriptor )( iter.next() );
+ printStream.println( count + ")" );
+ nodeDescriptor.dump(iOutputStream );
+ }
+
+
+ }
+
+ public LinkedList getNodeDescriptors()
+ {
+ if ( m_nodeDescriptors == null )
+ {
+ parseExpression();
+ }
+ return m_nodeDescriptors;
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/test/NodeBuilderTest.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/test/NodeBuilderTest.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/test/NodeBuilderTest.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/query/test/NodeBuilderTest.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,85 @@
+/*
+* 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.query.test;
+
+import java.util.HashMap;
+
+import com.sybase.bpe.interaction.IInteraction;
+import com.sybase.bpe.interaction.IInvocation;
+import com.sybase.bpe.interaction.InteractionException;
+import com.sybase.bpe.interaction.InvocationFactory;
+import com.sybase.bpe.interaction.builders.XMLInteractionBuilder;
+
+public class NodeBuilderTest
+{
+
+ public static void main( String iArgs[] ) throws InteractionException
+ {
+
+ HashMap uriMap = new HashMap();
+ uriMap.put( "a", "www.a.com");
+ uriMap.put( "b", "www.b.com");
+ uriMap.put( "c", "www.c.com");
+// String expression =
+// "/a:Properties/b:Property[blimey:name='CustName']/c:value";
+
+ //XPathParser chunker =
+ //new XPathParser( uriMap, "/a:Properties/b:Property[blimey:name='CustName']/c:value" );
+ //chunker.dump( System.out );
+
+
+ XMLInteractionBuilder xib =
+ new XMLInteractionBuilder();
+
+
+
+ IInteraction interaction = xib.createInteraction();
+ IInvocation invocation = InvocationFactory.newInstance().
+ createXPathSetNodeValueInvocation("/a/b/c", uriMap );
+ interaction.invoke(invocation, "someValue");
+ System.out.println( interaction.toString() );
+
+
+
+ IInteraction interaction1 = xib.createInteraction();
+ IInvocation invocation1 = InvocationFactory.newInstance().
+ createXPathSetNodeValueInvocation("/d/e/f", uriMap );
+ interaction1.invoke(invocation1, "anotherValue");
+ System.out.println( interaction1.toString() );
+
+
+
+ IInvocation selectTreeInvocation =
+ InvocationFactory.newInstance().
+ createXPathSelectTreeInvocation("/d", uriMap );
+ Object selection = interaction1.invoke(selectTreeInvocation );
+
+ IInvocation copyTreeInvocation =
+ InvocationFactory.newInstance().
+ createXPathCopyTreeInvocation("/a/b/c", uriMap );
+
+ interaction.invoke(copyTreeInvocation, selection);
+ System.out.println( interaction.toString() );
+
+
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/FormattableValueAdapter.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/FormattableValueAdapter.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/FormattableValueAdapter.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/FormattableValueAdapter.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.interaction.spiadapter;
+
+import com.sybase.bpe.client.IDescribedValue;
+import com.sybase.bpe.client.IFormat;
+import com.sybase.bpe.client.IFormattableValue;
+import com.sybase.bpe.interaction.spiimpl.MasterInteractionFactory;
+
+
+class FormattableValueAdapter
+ implements IFormattableValue
+{
+
+ static final long serialVersionUID = 3440461710830229604L;
+
+ private IDescribedValue m_describedValue;
+ private IFormattableValue m_fv;
+
+ FormattableValueAdapter( IFormattableValue fv )
+ {
+ m_fv = fv;
+ m_describedValue = m_fv.getDescribedValue();
+ }
+ FormattableValueAdapter(IDescribedValue describedValue)
+ {
+ m_describedValue = describedValue;
+ }
+ protected IFormattableValue getfv()
+ {
+ if ( m_fv == null )
+ {
+ m_fv = MasterInteractionFactory.newInstance().
+ createInteraction( m_describedValue).getValue();
+ }
+ return m_fv;
+ }
+
+ public Object getValueAs(Class clazz, IFormat format)
+ {
+ Object returnValue = getfv().
+ getValueAs( clazz, format);
+
+ return returnValue;
+ }
+ public Object getValueAs(Class clazz)
+ {
+ return getfv().getValueAs( clazz );
+ }
+ public boolean supportsGetValueAs(Class clazz, IFormat format)
+ {
+ boolean returnValue =
+ getfv().supportsGetValueAs( clazz, format);
+ return returnValue;
+ }
+ public boolean supportsGetValueAs(Class clazz)
+ {
+ boolean returnValue =
+ getfv().supportsGetValueAs( clazz );
+ return returnValue;
+ }
+ public IDescribedValue getDescribedValue()
+ {
+ IDescribedValue dv = getfv().getDescribedValue();
+ return dv;
+ }
+
+ public String toString()
+ {
+ return m_fv.toString();
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/JaxenQuery.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/JaxenQuery.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/JaxenQuery.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/JaxenQuery.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,76 @@
+/*
+* 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.spiadapter;
+
+import java.util.HashMap;
+
+import org.jaxen.dom.DOMXPath;
+import org.jaxen.NamespaceContext;
+
+import com.sybase.bpe.client.spi.interaction.ISPIJaxenXPathQuery;
+import com.sybase.bpe.interaction.query.JaxenXPathSingleNodeQuery;
+
+
+public class JaxenQuery
+ implements ISPIJaxenXPathQuery
+{
+ public JaxenXPathSingleNodeQuery m_engineQuery;
+ public JaxenQuery( JaxenXPathSingleNodeQuery query )
+ {
+ m_engineQuery = query;
+ }
+ public DOMXPath getDOMXPath()
+ {
+ DOMXPath xpath;
+ try
+ {
+ xpath = m_engineQuery.createLocator();
+ } catch (Exception e)
+ {
+ throw new RuntimeException( e );
+ }
+ return xpath;
+ }
+ public String getXPathExpressionAsString()
+ {
+ try
+ {
+ // TODO Auto-generated method stub
+ String expression = m_engineQuery.getXPathExpression();
+ return expression;
+ } catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public HashMap getNamespaceMap()
+ {
+ return m_engineQuery.getNamespaceMap();
+ }
+
+ public NamespaceContext getNamespaceContext()
+ {
+ return m_engineQuery.createNamespaceContext();
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/SPIAdapterInteraction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/SPIAdapterInteraction.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/SPIAdapterInteraction.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/SPIAdapterInteraction.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,408 @@
+/*
+* 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.spiadapter;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+import org.w3c.dom.Document;
+
+import com.sybase.bpe.client.DescribedValue;
+import com.sybase.bpe.client.IDescribedValue;
+import com.sybase.bpe.client.IFormattableValue;
+import com.sybase.bpe.client.spi.interaction.ISPIInteraction;
+import com.sybase.bpe.client.spi.interaction.ISPIQuery;
+import com.sybase.bpe.context.ICloneable;
+import com.sybase.bpe.context.base.ContextServiceException;
+import com.sybase.bpe.interaction.IInteraction;
+import com.sybase.bpe.interaction.IInvocation;
+import com.sybase.bpe.interaction.IInvocationTypes;
+import com.sybase.bpe.interaction.IObjectAccessible;
+import com.sybase.bpe.interaction.IObjectMutable;
+import com.sybase.bpe.interaction.InteractionException;
+import com.sybase.bpe.interaction.query.IQuery;
+import com.sybase.bpe.interaction.query.JaxenXPathSingleNodeQuery;
+import com.sybase.bpe.interaction.spiimpl.CannedFormattableValue;
+import com.sybase.bpe.interaction.spiimpl.MasterInteractionFactory;
+import com.sybase.bpe.util.ObjectInputStreamContextClassLoader;
+
+
+public class SPIAdapterInteraction implements
+ IInteraction, Serializable, ICloneable, IObjectAccessible, IObjectMutable
+{
+ static final long serialVersionUID = -6159197689519493325L;
+
+ private ISPIInteraction m_spi;
+ public SPIAdapterInteraction()
+ {
+ }
+ public SPIAdapterInteraction ( ISPIInteraction interaction )
+ {
+ m_spi = interaction;
+ }
+
+ public Object invoke(IInvocation iInvocation) throws InteractionException
+ {
+ Object returnValue =
+ invoke( iInvocation, null);
+ return returnValue;
+ }
+
+ public Object invoke(IInvocation iInvocation, Object iInput)
+ throws InteractionException
+ {
+ if ( ! (iInput instanceof IFormattableValue) )
+ {
+ if ( iInput != null )
+ {
+ iInput = new CannedFormattableValue( iInput );
+ }
+ }
+ Object returnValue = internalInvoke( iInvocation,
+ ( IFormattableValue )iInput );
+ return returnValue;
+ }
+
+ public void releaseResources() throws InteractionException
+ {
+ m_spi.releaseHeldResources();
+ }
+
+ protected Object internalInvoke( IInvocation invocation,
+ IFormattableValue input )
+ {
+ IFormattableValue returnValue = null;
+ ISPIQuery query = createSPIQuery(invocation.getQuery());
+ switch( invocation.getType())
+ {
+ case( IInvocationTypes.GET_SIMPLE_VALUE ):
+ {
+ if ( m_spi == null )
+ {
+ returnValue = null;
+ }
+ else
+ {
+ if ( !m_spi.supportsGetSimpleValue( query ) )
+ {
+ normalizeInteraction();
+ }
+ returnValue = m_spi.getSimpleValue( query );
+ }
+
+ break;
+ }
+ case( IInvocationTypes.GET_COMPLEX_VALUE):
+ {
+ if ( m_spi == null )
+ {
+ returnValue = null;
+ }
+ else
+ {
+ if ( !m_spi.supportsGetComplexValue( query ) )
+ {
+ normalizeInteraction();
+ }
+ returnValue = m_spi.getComplexValue(query);
+ }
+ break;
+ }
+ case( IInvocationTypes.GET_OBJECT ):
+ {
+ returnValue = ( IFormattableValue ) getContentObject();
+
+ break;
+ }
+ case( IInvocationTypes.COPY_SUB_ELEMENTS ):
+ {
+ if ( m_spi == null )
+ {
+ createEmptyInteraction();
+ }
+
+ if ( !m_spi.supportsCopySubElements( query, input ) )
+ {
+ normalizeInteraction();
+ }
+ m_spi.copySubElements( query,
+ input);
+
+ break;
+ }
+ case( IInvocationTypes.SET_SIMPLE_VALUE ):
+ {
+ if ( m_spi == null )
+ {
+ createEmptyInteraction();
+ }
+ if ( !m_spi.supportsSetSimpleValue( query, input ) )
+ {
+ normalizeInteraction();
+ }
+ m_spi.setSimpleValue( query, input);
+ break;
+ }
+ case( IInvocationTypes.SET_COMPLEX_VALUE):
+ {
+ if ( m_spi == null )
+ {
+ createEmptyInteraction();
+ }
+ if ( !m_spi.supportsSetComplexValue(query,
+ input) )
+ {
+ normalizeInteraction();
+ }
+
+ m_spi.setComplexValue(query,
+ input);
+ break;
+ }
+ case( IInvocationTypes.REMOVE_VALUE ):
+ {
+ if ( m_spi == null )
+ {
+ returnValue = null;
+ }
+ if( !m_spi.supportsRemoveValue(query))
+ {
+ normalizeInteraction();
+ }
+ m_spi.removeValue(query);
+
+ break;
+ }
+ case( IInvocationTypes.SET_OBJECT ):
+ {
+ setContentObject( input );
+
+ break;
+ }
+
+
+ }
+ if ( returnValue != null )
+ {
+ // All formattable values are decorated
+ // with our internal formattable value
+ // adapter. This adapter may house
+ // translation facilities in the future.
+ returnValue =
+ new FormattableValueAdapter( returnValue );
+ }
+
+ return returnValue;
+
+
+
+ }
+
+ private IFormattableValue getContentObject()
+ {
+ IFormattableValue returnValue;
+ if ( m_spi == null )
+ {
+ returnValue = null;
+ }
+ else
+ {
+ returnValue = m_spi.getValue();
+ }
+ return returnValue;
+ }
+ private void normalizeInteraction()
+ {
+ // TODO:
+ // Convert the interaction to a document interaction.
+ //
+ // We can put an XStream adapter in here at some point
+ // which can convert any described object into xml.
+ // For now, let's just hit the 80% case.
+ //
+ // A runtime exception will occur if the interaction
+ // can not provide a document representation.
+ Document documentValue =
+ ( Document )m_spi.getValue().getValueAs( Document.class );
+ DescribedValue dv = new DescribedValue( documentValue );
+ m_spi = MasterInteractionFactory.newInstance().createInteraction(dv);
+ }
+
+ private void createEmptyInteraction()
+ {
+ m_spi =
+ MasterInteractionFactory.newInstance().createAnyTypeInteraction();
+ }
+ protected ISPIQuery createSPIQuery( IQuery query )
+ {
+
+ JaxenQuery jq = null;
+ if ( query != null )
+ {
+ jq = new JaxenQuery(
+ ( JaxenXPathSingleNodeQuery ) query );
+ }
+ return jq;
+ }
+
+ public Object cloneObject() throws ContextServiceException
+ {
+ ISPIInteraction newspi;
+ if (!m_spi.supportsCloneSPIInteraction())
+ {
+ newspi = cloneSPI();
+ } else
+ {
+ newspi = m_spi.cloneSPIInteraction();
+ }
+ return new SPIAdapterInteraction(newspi);
+ }
+
+ /**
+ * This method is called when the interaction object does not provide a
+ * custom clone implementation.
+ *
+ * @return
+ */
+ private ISPIInteraction cloneSPI()
+ {
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(m_spi);
+ oos.close();
+ byte[] bytes = baos.toByteArray();
+ baos.close();
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream ois = new ObjectInputStreamContextClassLoader(bais);
+ ISPIInteraction newInteraction = (ISPIInteraction) ois.readObject();
+ ois.close();
+ bais.close();
+ return newInteraction;
+ } catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object getObject() throws InteractionException
+ {
+ return getContentObject();
+ }
+
+ /*
+ * This method is called by the param object
+ * to harvest parameters in a requested format
+ * before invoking an external action.
+ *
+ * I really want to get rid of this method in favor of
+ * the getFormattableValue() method.
+ *
+ * We'll leave it here for now for the sake of backward
+ * compatibility since there are external actions
+ * which rely on the type specifications contained
+ * in the external action binding information.
+ */
+ public Object getObject(String iPreference) throws InteractionException
+ {
+ Object returnValue = null;
+ if (iPreference == null || iPreference.equals("") ||
+ IInteraction.FORMATTABLE_VALUE_TYPE.equalsIgnoreCase(
+ iPreference.toLowerCase()))
+ {
+ returnValue = getUserValue();
+ }
+ else if ( IInteraction.OBJECT_TYPE.equalsIgnoreCase( iPreference ))
+ {
+ returnValue =
+ getUserValue().getDescribedValue().getData();
+ }
+ else if (IInteraction.BUFFER_TYPE.equalsIgnoreCase(
+ iPreference))
+ {
+ returnValue = m_spi.toString().getBytes();
+ } else if (IInteraction.INTERACTION_TYPE.equalsIgnoreCase(
+ iPreference))
+ {
+ returnValue = this;
+ }
+ else
+ {
+ // If we really don't know what's being
+ // asked for, give them the raw data.
+ returnValue =
+ getUserValue().getDescribedValue().getData();
+ }
+ return returnValue;
+ }
+
+ public String toString()
+ {
+ String returnValue;
+
+ returnValue = m_spi.getValue().toString();
+
+ return returnValue;
+ }
+
+ public ISPIInteraction getSPIInteraction()
+ {
+ return m_spi;
+ }
+
+ public void setSPIInteraction( ISPIInteraction spiinteraction)
+ {
+ m_spi = spiinteraction;
+ }
+
+ public IFormattableValue getUserValue()
+ {
+ return new FormattableValueAdapter( m_spi.getValue() );
+ }
+ public void setObject(Object iObject) throws InteractionException
+ {
+ setContentObject( iObject );
+
+ }
+ private void setContentObject(Object object)
+ {
+ IDescribedValue dv;
+ if (object instanceof IFormattableValue)
+ {
+ dv = ((IFormattableValue) (object)).getDescribedValue();
+ }
+ else if (object instanceof IDescribedValue)
+ {
+ dv = (IDescribedValue) (object);
+ }
+ else
+ {
+ dv = new DescribedValue(object);
+ }
+ m_spi = MasterInteractionFactory.newInstance().createInteraction(dv);
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/SPIAdapterInteractionFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/SPIAdapterInteractionFactory.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/SPIAdapterInteractionFactory.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiadapter/SPIAdapterInteractionFactory.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.interaction.spiadapter;
+
+import java.util.Properties;
+
+import org.w3c.dom.Document;
+
+import com.sybase.bpe.client.DescribedValue;
+import com.sybase.bpe.client.formats.INativeFormat;
+import com.sybase.bpe.client.spi.interaction.ISPIInteraction;
+import com.sybase.bpe.interaction.IInteraction;
+import com.sybase.bpe.interaction.InteractionException;
+import com.sybase.bpe.interaction.InteractionFactory;
+import com.sybase.bpe.interaction.PropertiesInteractionObject;
+import com.sybase.bpe.interaction.spiimpl.MasterInteractionFactory;
+
+
+public class SPIAdapterInteractionFactory extends InteractionFactory
+{
+ public IInteraction createXMLInteraction(byte[] iBuffer) throws InteractionException
+ {
+ DescribedValue dv = new DescribedValue( iBuffer, INativeFormat.XML );
+ ISPIInteraction spi = MasterInteractionFactory.newInstance().createInteraction(dv);
+ SPIAdapterInteraction adapter = new SPIAdapterInteraction(spi);
+ return adapter;
+ }
+
+ public IInteraction createPropertiesInteraction(Properties iProperties) throws InteractionException
+ {
+ return new PropertiesInteractionObject(iProperties);
+ }
+
+ public IInteraction createDocumentInteraction(Document iDocument) throws InteractionException
+ {
+ DescribedValue dv = new DescribedValue( iDocument );
+ ISPIInteraction spi = MasterInteractionFactory.newInstance().createInteraction(dv);
+ SPIAdapterInteraction adapter = new SPIAdapterInteraction( spi );
+ return adapter;
+ }
+
+ public IInteraction createDocumentInteraction() throws InteractionException
+ {
+ SPIAdapterInteraction adapter = new SPIAdapterInteraction( );
+ return adapter;
+ }
+
+ public IInteraction createObjectInteraction( Object iObject )
+ {
+ DescribedValue dv = new DescribedValue( iObject );
+ ISPIInteraction spi = MasterInteractionFactory.newInstance().createInteraction(dv);
+ SPIAdapterInteraction adapter = new SPIAdapterInteraction( spi );
+ return adapter;
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/CannedFormattableValue.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/CannedFormattableValue.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/CannedFormattableValue.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/CannedFormattableValue.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.interaction.spiimpl;
+
+import java.io.Serializable;
+
+import com.sybase.bpe.client.DescribedValue;
+import com.sybase.bpe.client.IDescribedValue;
+import com.sybase.bpe.client.IFormat;
+import com.sybase.bpe.client.IFormattableValue;
+
+
+public class CannedFormattableValue implements IFormattableValue, Serializable
+{
+
+ static final long serialVersionUID = -2315555599530458988L;
+
+ IDescribedValue m_describedValue;
+
+ public CannedFormattableValue( Object rawData )
+ {
+ if ( rawData instanceof IDescribedValue )
+ {
+ m_describedValue = ( IDescribedValue )rawData;
+ }
+ else
+ {
+ m_describedValue = new DescribedValue( rawData );
+ }
+ }
+ public CannedFormattableValue( IDescribedValue describedValue )
+ {
+ m_describedValue = describedValue;
+ }
+ public Object getValueAs(Class clazz, IFormat format)
+ {
+ if ( format != null &&
+ !format.equals(m_describedValue.getFormat()))
+ {
+ throw new UnsupportedOperationException();
+ }
+ return getValueAs( clazz);
+
+ }
+ public Object getValueAs(Class clazz)
+ {
+ Object data = m_describedValue.getData();
+ if ( data == null )
+ {
+ return null;
+ }
+ if ( clazz.isAssignableFrom( data.getClass() ) )
+ {
+ return data;
+ }
+ else
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+ public boolean supportsGetValueAs(Class clazz, IFormat format)
+ {
+ if ( format != null &&
+ !format.equals(m_describedValue.getFormat()))
+ {
+ return false;
+ }
+ return supportsGetValueAs( clazz);
+ }
+ public boolean supportsGetValueAs(Class clazz)
+ {
+ Object data = m_describedValue.getData();
+ if ( data == null )
+ {
+ return true;
+ }
+ if ( clazz.isAssignableFrom( data.getClass() ) )
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ public IDescribedValue getDescribedValue()
+ {
+ return m_describedValue;
+ }
+ public String toString()
+ {
+ Object data = m_describedValue.getData();
+ if ( data != null )
+ {
+ return data.toString();
+ }
+ return "";
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/MasterInteractionFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/MasterInteractionFactory.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/MasterInteractionFactory.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/MasterInteractionFactory.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,171 @@
+/*
+* 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;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import com.sybase.bpe.client.IDescribedValue;
+import com.sybase.bpe.client.spi.interaction.ISPIInteraction;
+import com.sybase.bpe.client.spi.interaction.ISPIInteractionFactory;
+import com.sybase.bpe.util.BPEProperties;
+
+public class MasterInteractionFactory implements ISPIInteractionFactory
+{
+
+ static final long serialVersionUID = 3229334691771274257L;
+
+ private LinkedList m_factoryList = new LinkedList();
+ private static MasterInteractionFactory MasterInstance = null;
+
+ private MasterInteractionFactory()
+ {
+
+ BPEProperties props;
+ try
+ {
+ props = new BPEProperties( true,
+ new InitialContext());
+
+ } catch (NamingException e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ String factoriesString =
+ props.getInteractionFactories();
+ String externalFactoriesString =
+ props.getExternalInteractionFactories();
+
+ // Give the external interaction factories precedence.
+ addInteractionFactories( externalFactoriesString );
+ addInteractionFactories( factoriesString );
+
+ }
+
+ private void addInteractionFactories( String factoriesString )
+ {
+ if ( factoriesString == null || factoriesString.equals("") )
+ {
+ return;
+ }
+ String[] factories = factoriesString.split(",");
+ for ( int i = 0; i< factories.length; i++ )
+ {
+ ISPIInteractionFactory
+ factory;
+ try
+ {
+ factory = (ISPIInteractionFactory)Class.forName( factories[i] ).newInstance();
+ } catch (Exception e)
+ {
+ throw new RuntimeException( e );
+ }
+
+ m_factoryList.add ( factory );
+ }
+ }
+ private static synchronized ISPIInteractionFactory CreateMasterInstance()
+ {
+ if ( MasterInstance == null )
+ {
+ MasterInstance = new MasterInteractionFactory();
+ }
+ return MasterInstance;
+ }
+
+ public ISPIInteraction createAnyTypeInteraction()
+ {
+ Iterator iter = m_factoryList.iterator();
+ while( iter.hasNext() )
+ {
+ ISPIInteractionFactory f =
+ ( ISPIInteractionFactory ) iter.next();
+ if ( f.supportsAnyType() )
+ {
+ return f.createAnyTypeInteraction();
+ }
+ }
+ throw new UnsupportedOperationException();
+ }
+
+
+ public ISPIInteraction createInteraction(IDescribedValue describedValue)
+ {
+ Iterator iter = m_factoryList.iterator();
+ ISPIInteractionFactory f = null;
+ while( iter.hasNext() )
+ {
+ f =
+ ( ISPIInteractionFactory ) iter.next();
+ if ( f.supportsInteraction(describedValue) )
+ {
+ return f.createInteraction(describedValue);
+ }
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean supportsInteraction(IDescribedValue describedValue)
+ {
+ Iterator iter = m_factoryList.iterator();
+ while( iter.hasNext() )
+ {
+ ISPIInteractionFactory f =
+ ( ISPIInteractionFactory ) iter.next();
+ if ( f.supportsInteraction(describedValue) )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean supportsAnyType()
+ {
+ Iterator iter = m_factoryList.iterator();
+ while( iter.hasNext() )
+ {
+ ISPIInteractionFactory f =
+ ( ISPIInteractionFactory ) iter.next();
+ if ( f.supportsAnyType() )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static ISPIInteractionFactory newInstance()
+ {
+ if ( MasterInstance == null )
+ {
+ return CreateMasterInstance();
+ }
+ return MasterInstance;
+
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/atomic/AtomicInteraction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/atomic/AtomicInteraction.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/atomic/AtomicInteraction.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/atomic/AtomicInteraction.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,116 @@
+/*
+* 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.atomic;
+
+import com.sybase.bpe.client.IDescribedValue;
+import com.sybase.bpe.client.IFormattableValue;
+import com.sybase.bpe.client.spi.interaction.ISPIInteraction;
+import com.sybase.bpe.client.spi.interaction.ISPIQuery;
+import com.sybase.bpe.interaction.spiimpl.CannedFormattableValue;
+
+public class AtomicInteraction implements ISPIInteraction
+{
+ static final long serialVersionUID = -899325809844440914L;
+
+ private IDescribedValue m_describedValue;
+ public AtomicInteraction(IDescribedValue describedValue)
+ {
+ m_describedValue = describedValue;
+ }
+ public IFormattableValue getSimpleValue(ISPIQuery query)
+
+ {
+ throw new UnsupportedOperationException();
+ }
+ public void setSimpleValue(ISPIQuery query, IFormattableValue iValue)
+
+ {
+ throw new UnsupportedOperationException();
+ }
+ public IFormattableValue getComplexValue(ISPIQuery query)
+
+ {
+ throw new UnsupportedOperationException();
+ }
+ public void setComplexValue(ISPIQuery query, IFormattableValue iValue)
+
+ {
+ throw new UnsupportedOperationException();
+ }
+ public void removeValue(ISPIQuery query)
+ {
+ throw new UnsupportedOperationException();
+ }
+ public void copySubElements(ISPIQuery query, IFormattableValue source)
+
+ {
+ throw new UnsupportedOperationException();
+ }
+ public ISPIInteraction cloneSPIInteraction()
+ {
+ throw new UnsupportedOperationException();
+ }
+ public void releaseHeldResources()
+ {
+
+ }
+ public boolean supportsSetSimpleValue(ISPIQuery query, ISPIInteraction iValue)
+ {
+ return false;
+ }
+ public boolean supportsGetComplexValue(ISPIQuery query)
+ {
+ return false;
+ }
+ public boolean supportsSetComplexValue(ISPIQuery query, ISPIInteraction iValue)
+ {
+ return false;
+ }
+ public boolean supportsRemoveValue(ISPIQuery query)
+ {
+ return false;
+ }
+ public boolean supportsCopySubElements(ISPIQuery query, IFormattableValue source)
+ {
+ return false;
+ }
+ public boolean supportsCloneSPIInteraction()
+ {
+ return false;
+ }
+ public boolean supportsSetSimpleValue(ISPIQuery query, IFormattableValue iValue)
+ {
+ return false;
+ }
+ public boolean supportsSetComplexValue(ISPIQuery query, IFormattableValue iValue)
+ {
+ return false;
+ }
+ public IFormattableValue getValue()
+ {
+ return new CannedFormattableValue( m_describedValue );
+ }
+ public boolean supportsGetSimpleValue(ISPIQuery query)
+ {
+ return false;
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/atomic/AtomicInteractionFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/atomic/AtomicInteractionFactory.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/atomic/AtomicInteractionFactory.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/atomic/AtomicInteractionFactory.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,83 @@
+/*
+* 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.atomic;
+
+import java.util.Properties;
+
+import com.sybase.bpe.client.IDescribedValue;
+import com.sybase.bpe.client.IFormat;
+import com.sybase.bpe.client.formats.INativeFormat;
+import com.sybase.bpe.client.spi.interaction.ISPIInteraction;
+import com.sybase.bpe.client.spi.interaction.ISPIInteractionFactory;
+
+
+public class AtomicInteractionFactory
+ implements ISPIInteractionFactory
+{
+
+ static final long serialVersionUID = -2590787466188228009L;
+
+ public ISPIInteraction createAnyTypeInteraction()
+ {
+ return null;
+ }
+
+ public ISPIInteraction createInteraction(IDescribedValue describedValue)
+ {
+ return new AtomicInteraction( describedValue );
+ }
+
+ public boolean supportsInteraction(IDescribedValue value)
+ {
+ IFormat format = value.getFormat();
+// Object data = value.getData();
+ Properties contentType = value.getContentType();
+
+ boolean contentInfoEmpty = ( contentType == null ) ||
+ ( contentType.isEmpty() );
+
+ // This interaction does not support content type validation
+ // so return false.
+ if ( ! contentInfoEmpty )
+ {
+ return false;
+ }
+
+ boolean formatOK = ( format == null ) ||
+ format.equals( INativeFormat.ATOMIC );
+
+ if ( ! formatOK )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean supportsAnyType()
+ {
+ return false;
+ }
+
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/atomic/LazyObject.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/atomic/LazyObject.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/atomic/LazyObject.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/atomic/LazyObject.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.interaction.spiimpl.atomic;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+import com.thoughtworks.xstream.XStream;
+
+// The LazyObject performs lazy XStream serialization
+// and deserialization on an arbitrary java object
+// regardless of whether the java object implements
+// the serializable interface or not. The LazyObject
+// is held in the business process context and enables
+// the serialization of objects which do not
+// implement the Serializable interface.
+public class LazyObject implements Serializable
+{
+ static final long serialVersionUID = -2181661690231270298L;
+
+ private transient Object rawObject;
+ private String xmlString;
+ public LazyObject( Object rawObject )
+ {
+ this.rawObject = rawObject;
+ }
+
+ private void writeObject(ObjectOutputStream s) throws IOException
+ {
+ if ( (xmlString == null) && (rawObject != null) )
+ {
+ XStream xstream = new XStream();
+ xmlString = xstream.toXML(rawObject);
+ }
+ s.defaultWriteObject();
+ }
+
+ public Object getObject()
+ {
+ if ( (rawObject == null) && (xmlString != null) )
+ {
+ XStream xstream = new XStream();
+ ClassLoader contextClassLoader =
+ Thread.currentThread().getContextClassLoader();
+ xstream.setClassLoader(contextClassLoader);
+ rawObject = xstream.fromXML(xmlString);
+ }
+
+ return rawObject;
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/DocumentFormattableValue.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/DocumentFormattableValue.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/DocumentFormattableValue.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/interaction/spiimpl/document/DocumentFormattableValue.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,114 @@
+/*
+* 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.Serializable;
+
+import org.w3c.dom.Document;
+
+import com.sybase.bpe.client.DescribedValue;
+import com.sybase.bpe.client.IDescribedValue;
+import com.sybase.bpe.client.IFormat;
+import com.sybase.bpe.client.IFormattableValue;
+import com.sybase.bpe.client.formats.INativeFormat;
+
+
+public class DocumentFormattableValue implements IFormattableValue, Serializable
+{
+ static final long serialVersionUID = -4078647545776489807L;
+
+ private LazyDocument m_lo;
+
+ public DocumentFormattableValue( Document document )
+ {
+ m_lo = new LazyDocument( document );
+ }
+
+ public DocumentFormattableValue( LazyDocument lo )
+ {
+ m_lo = lo;
+ }
+
+ public Object getValueAs(Class clazz, IFormat format)
+ {
+ if ( format.equals(INativeFormat.XML) ||
+ (format == null))
+ {
+ return getValueAs( clazz );
+ }
+ else
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+ public Object getValueAs(Class clazz)
+ {
+ if (clazz.isAssignableFrom(byte[].class))
+ {
+ return m_lo.getXMLBuffer();
+ }
+ else if ( clazz.isAssignableFrom(Document.class))
+ {
+ return m_lo.getDocument();
+ }
+ throw new UnsupportedOperationException();
+ }
+ public boolean supportsGetValueAs(Class clazz, IFormat format)
+ {
+ if ( format.equals(INativeFormat.XML) ||
+ (format == null))
+ {
+ return supportsGetValueAs( clazz );
+ }
+ return false;
+ }
+ public boolean supportsGetValueAs(Class clazz)
+ {
+ if (clazz.isAssignableFrom(byte[].class))
+ {
+ return true;
+ }
+ else if ( clazz.isAssignableFrom(Document.class))
+ {
+ return true;
+ }
+ return false;
+ }
+ public IDescribedValue getDescribedValue()
+ {
+ Object convenientForm = m_lo.getConvenientForm();
+ if (convenientForm instanceof Document)
+ {
+ return new DescribedValue(convenientForm);
+ } else
+ {
+ return new DescribedValue(convenientForm, INativeFormat.XML);
+ }
+ }
+ public String toString()
+ {
+ byte[] xmlbytes = ( byte[] )getValueAs( byte[].class );
+ String string = new String(xmlbytes);
+ return string;
+ }
+}