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:35:26 UTC
svn commit: r381694 [26/38] - in /incubator/ode/scratch: bpe/ ode/
ode/bpelTests/ ode/bpelTests/probeService/ ode/bpelTests/test1/
ode/bpelTests/test10/ ode/bpelTests/test12/ ode/bpelTests/test13/
ode/bpelTests/test14/ ode/bpelTests/test15/ ode/bpelTes...
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELRepositoryHandler.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELRepositoryHandler.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELRepositoryHandler.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELRepositoryHandler.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,529 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on May 13, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.util.HashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//import java.util.regex.Pattern;
+
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.definition.IPMDRoot;
+import org.apache.ode.definition.service.DefinitionService;
+import org.apache.ode.definition.service.DefinitionServiceException;
+import org.apache.ode.definition.service.DefinitionServiceFactory;
+import org.apache.ode.util.BPEProperties;
+import org.apache.ode.util.BPException;
+import org.apache.ode.uuid.UUIDService;
+import org.apache.ode.uuid.UUIDServiceException;
+import org.apache.ode.uuid.UUIDServiceFactory;
+
+
+/**
+ * @author waterman
+ *
+ * Maps BPEL documents into the runtime metadata repository. It is called by BPELSAXHandler.
+ * <p>
+ * Uses WSDL4J to parse WSDL documents.
+ * <p>
+ * Note the BPERepositoryHandler assumes that the input BPEL document is a valid
+ * BPEL as defined by the BPEL.xsd
+ * <p>
+ * @see BPELSAXHandler
+ */
+class BPELRepositoryHandler {
+
+ private static final Logger logger = Logger.getLogger(BPELRepositoryHandler.class.getName());
+// private static final Pattern wsdlPattern = Pattern.compile(".*\\.wsdl");
+
+
+ private DefinitionService m_ds;
+ private BPEProperties m_props;
+
+ private String m_bpelName; // the name of the current BPEL document being parsed
+
+ private BPELNode m_context; // A placeholder within the current process graph
+
+ private BPELDefinitionKey m_defKey; // The UUID of the root process definition
+
+ private IPMDRoot m_dRoot; // the root business process
+
+ private ExtensibilityArtifacts m_artifacts; // holds extension documents
+
+ private boolean m_insidePruneAssign = false;
+ private boolean m_insideGraftAssign = false;
+ private boolean m_insideGraftChildrenAssign = false;
+
+
+
+ BPELRepositoryHandler(String docName, HashMap supportDoc, DefinitionService ds) throws DeploymentException {
+ m_bpelName = docName;
+ m_props = new BPEProperties();
+
+ try {
+ if ( ds == null ) {
+ m_props.setDefinitionServiceClass("org.apache.ode.definition.serialimpl.DefinitionService_SerImpl");
+ UUIDService us = UUIDServiceFactory.createUUIDService(m_props);
+ m_ds = DefinitionServiceFactory.createDefinitionService(m_props,us);
+ } else {
+ m_ds = ds;
+ }
+
+ // Create the object that manages the list of supporting documents
+ m_artifacts = new ExtensibilityArtifacts(docName, supportDoc);
+
+ } catch (UUIDServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_UUIDINVALID",null,e);
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_DEFINVALID",null,e);
+ }
+
+ }
+
+ public void buildPruneAssign( BPELAttributes attributes )
+ throws DeploymentException
+ {
+ m_insidePruneAssign = true;
+ buildAssign( attributes );
+ }
+
+ public void buildGraftAssign( BPELAttributes attributes )
+ throws DeploymentException
+ {
+ m_insideGraftAssign = true;
+ buildAssign( attributes );
+ }
+
+ public void buildGraftChildrenAssign( BPELAttributes attributes )
+ throws DeploymentException
+ {
+ m_insideGraftChildrenAssign = true;
+ buildAssign( attributes );
+ }
+
+ public String getInterpretation( String activityID )
+ {
+ if ( m_artifacts != null )
+ {
+ return m_artifacts.getActivityInterpretation(activityID);
+ }
+ return null;
+ }
+
+ public void buildProcess(BPELAttributes attr) throws DeploymentException {
+
+ // this is the root node of the business process definition
+ // Note: BPEL does not support a version schema.
+ // WAIT: waiting on IO process definition versioning requirements
+ IPMDProcess bProcess=null;
+
+ try {
+ m_dRoot = m_ds.createRootDefinition(
+ (attr.getName() == null) ? "process" : attr.getName(),
+ "v1",false);
+ bProcess = m_dRoot.createProcess("Process: "+attr.getName());
+ m_defKey = new BPELDefinitionKey(attr.getName(),bProcess.getKey().getValue());
+ } catch (BPException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATEPROCESSROOT",new Object[] {m_bpelName, attr.getName()},e);
+ }
+
+ push(new BPELProcess(m_dRoot,bProcess,attr,m_artifacts));
+
+ }
+
+ public void closeProcess() throws DeploymentException {
+
+ if ( m_context instanceof BPELScope ) {
+ // the parser stack may hold an implied scope
+ pop();
+ }
+
+ m_dRoot.setIsStateless(((BPELProcess)m_context).getStateFlag());
+ m_dRoot.setProtectedInstantiation(((BPELProcess)m_context).getIsProtectedInstantiation());
+
+ pop();
+
+ if ( m_ds instanceof org.apache.ode.definition.service.unmanaged.DefinitionServiceProxy ) {
+ try {
+ ((org.apache.ode.definition.service.unmanaged.DefinitionServiceProxy)m_ds).update();
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_UPDATE",new Object[] {m_bpelName},e);
+ }
+ }
+ }
+
+ public void buildCatch(BPELAttributes attr) throws DeploymentException {
+ // A catch node can only be held by a scope or an invoke.
+ // The builder assumes the xml parser will enforce this constraint
+ // using the BPEL XMLSchema.
+
+ testInvoke();
+ push(new BPELCatch(m_context,attr,m_artifacts));
+ }
+ public void closeCatch() throws DeploymentException {
+ pop();
+ }
+
+ public void buildCatchAll(BPELAttributes attr) throws DeploymentException {
+ // A catchAll node can only be held by a scope or an invoke.
+ // The builder assumes the xml parser will enforce this constraint
+ // using the BPEL XMLSchema.
+
+ testInvoke();
+ push(new BPELCatchAll(m_context,attr,m_artifacts));
+ }
+ public void closeCatchAll() throws DeploymentException {
+ pop();
+ }
+
+ public void buildCompensationHandler(BPELAttributes attr) throws DeploymentException {
+ // A compensation handler can only be held by a scope or an invoke.
+ // The builder assumes the xml parser will enforce this constraint
+ // using the BPEL XMLSchema.
+
+ testInvoke();
+ push(new BPELCompensationHandler(m_context,attr));
+ }
+ public void closeCompensationHandler() throws DeploymentException {
+ pop();
+ }
+
+ public void buildOnMessage(BPELAttributes attr) throws DeploymentException {
+ // A message event can only be held by a scope. The builder assumes the xml
+ // parser will enforce this constraint using the BPEL XMLSchema.
+
+ if ( m_context instanceof BPELPick ) {
+ push(new BPELOnMessage(m_context,attr));
+ } else {
+ testScope(); // make sure the current context is a scope
+ push(new BPELOnMessage(m_context,attr));
+ }
+ }
+ public void closeOnMessage() throws DeploymentException {
+ pop();
+ }
+
+ public void buildOnAlarm(BPELAttributes attr) throws DeploymentException {
+ // An alarm can only be held by a scope. The builder assumes the xml
+ // parser will enforce this constraint using the BPEL XMLSchema.
+
+ testScope(); // make sure the current context is a scope
+ push( new BPELOnAlarm(m_context,attr) );
+ }
+ public void closeOnAlarm() throws DeploymentException {
+ pop();
+ }
+
+ public void buildData(String data) {
+ m_context.addData(data);
+ }
+
+ public void buildSwitch(BPELAttributes attr) throws DeploymentException {
+ push( new BPELSwitch(m_context,attr) );
+ }
+ public void closeSwitch() throws DeploymentException {
+ pop();
+ }
+
+ public void buildOtherwise(BPELAttributes attr) throws DeploymentException {
+ push( new BPELOtherwise(m_context,attr) );
+ }
+ public void closeOtherwise() throws DeploymentException {
+ pop();
+ }
+
+ public void buildCase(BPELAttributes attr) throws DeploymentException {
+ push( new BPELCase(m_context,attr) );
+ }
+ public void closeCase() throws DeploymentException {
+ pop();
+ }
+
+ public void buildWhile(BPELAttributes attr) throws DeploymentException {
+ push( new BPELWhile(m_context,attr) );
+ }
+ public void closeWhile() throws DeploymentException {
+ pop();
+ }
+
+ public void buildScope(BPELAttributes attr) throws DeploymentException {
+ push( new BPELScope(m_context,attr) );
+ }
+ public void closeScope() throws DeploymentException {
+ pop();
+ }
+
+ public void buildFlow(BPELAttributes attr) throws DeploymentException {
+ push( new BPELFlow(m_context,attr) );
+
+ }
+ public void closeFlow() throws DeploymentException {
+ pop();
+ }
+
+ public void buildPick(BPELAttributes attr) throws DeploymentException {
+ push( new BPELPick(m_context,attr) );
+ }
+ public void closePick() throws DeploymentException {
+ pop();
+ }
+
+ public void buildVariable(BPELAttributes attr) throws DeploymentException {
+ // A variable can only be held by a scope. The builder assumes the xml
+ // parser will enforce this constraint using the BPEL XMLSchema.
+
+ testScope(); // make sure the current context is a scope
+
+
+ if ( attr.getMessageType() != null ) {
+ ((BPELScope)m_context).addVariable(new BPELWSDLVariable(attr,m_artifacts,m_context));
+ } else {
+ ((BPELScope)m_context).addVariable(new BPELXMLSchemaVariable(attr,m_artifacts,m_context));
+ }
+ }
+
+ public void buildCorrelationSet(BPELAttributes attr) throws DeploymentException {
+ // A correlationSet can only be held by a scope. The builder assumes the xml
+ // parser will enforce this constraint using the BPEL XMLSchema.
+
+ testScope(); // make sure the current context is a scope
+ ((BPELScope)m_context).addCorrelationSet(new BPELCorrelationSet(attr,(BPELScope)m_context));
+ }
+
+ public void buildCorrelation(BPELAttributes attr) throws DeploymentException {
+
+ // find the correlation set
+ BPELCorrelationSet cs = m_context.getCorrelationSet(attr.getSet());
+
+ if ( cs == null ) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CORRSET",new Object[] {m_bpelName,attr.getSet()},null);
+ }
+
+ m_context.addCorrelation(new BPELCorrelation(cs,attr.getInitiate(),attr.getPattern()));
+ }
+
+ public void buildPartners(BPELAttributes attr) {
+ }
+
+ // Creates a new BPEL Linking object and adds it into the link collection
+ public void buildLink(BPELAttributes attr) throws DeploymentException {
+
+ // Note - the link name is a required field in the BPEL schema
+ ((BPELFlow)m_context).addLinkTag(new BPELLink(attr.getName()));
+ }
+
+ public void buildSequence(BPELAttributes attr) throws DeploymentException {
+ push( new BPELSequence(m_context,attr) );
+ }
+ public void closeSequence() throws DeploymentException {
+ pop();
+ }
+
+ public void buildSource(BPELAttributes attr) throws DeploymentException {
+ m_context.setLink(attr.getLinkName(),m_context,BPELLinkType.SOURCE,attr.getTransitionCondition());
+ }
+
+ public void buildTarget(BPELAttributes attr) throws DeploymentException {
+ m_context.setLink(attr.getLinkName(),m_context,BPELLinkType.TARGET,null);
+ }
+
+ /**
+ * Invoke is a BPEL activity node, and supports the
+ * @param attr
+ */
+ public void buildInvoke(BPELAttributes attr) throws DeploymentException {
+ push( new BPELInvoke(m_context,attr,m_artifacts) );
+ }
+ public void closeInvoke() throws DeploymentException {
+ pop();
+ }
+
+ public void buildFrom(BPELAttributes attr) {
+ push( new BPELFrom(m_context,attr) );
+ }
+ public void closeFrom() throws DeploymentException {
+ pop();
+ }
+ public void buildTo(BPELAttributes attr) {
+ push( new BPELTo(m_context,attr) );
+ }
+ public void closeTo() throws DeploymentException {
+ pop();
+ }
+
+ public void buildCopy(BPELAttributes attr) {
+ if ( m_insidePruneAssign == true )
+ {
+ push( new BPELPrune( m_context, attr ) );
+ }else if(m_insideGraftAssign == true)
+ {
+ push( new BPELGraft(m_context,attr) );
+ }
+ else if (m_insideGraftChildrenAssign == true)
+ {
+ push( new BPELGraftChildren(m_context,attr) );
+ }else
+ {
+ push( new BPELCopyValue(m_context,attr) );
+ }
+ }
+
+ public void closeCopy() throws DeploymentException {
+ if ( m_insidePruneAssign == true )
+ {
+ closePrune();
+ }
+ else
+ {
+ pop();
+ }
+ }
+
+ public void buildPrune(BPELAttributes attr) {
+ push( new BPELPrune(m_context, attr));
+ }
+
+ public void closePrune() throws DeploymentException{
+ pop();
+ }
+
+ public void buildAssign(BPELAttributes attr) throws DeploymentException {
+ push( new BPELAssign(m_context,BPELSchema.ASSIGN,attr,logger) );
+ }
+ public void closeAssign() throws DeploymentException {
+ pop();
+ if ( m_insidePruneAssign == true )
+ {
+ m_insidePruneAssign = false;
+ }
+ if ( m_insideGraftAssign == true)
+ m_insideGraftAssign = false;
+ if (m_insideGraftChildrenAssign == true)
+ m_insideGraftChildrenAssign = false;
+ }
+
+ public void buildReceive(BPELAttributes attr) throws DeploymentException {
+ push( new BPELReceive(m_context,attr) );
+ }
+ public void closeReceive() throws DeploymentException {
+ pop();
+ }
+
+ public void buildReply(BPELAttributes attr) throws DeploymentException {
+ push( new BPELReply(m_context,attr) );
+ }
+ public void closeReply() throws DeploymentException {
+ pop();
+ }
+
+ public void buildCompensate(BPELAttributes attr) throws DeploymentException {
+ // A compenstate node can only be held by a catch, catchAll or
+ // compensationHandler node. The builder assumes the xml
+ // parser will enforce this constraint using the BPEL XMLSchema.
+
+ push( new BPELCompensate(m_context,attr) );
+ }
+ public void closeCompensate() throws DeploymentException {
+ pop();
+ }
+
+ public void buildThrow(BPELAttributes attr) throws DeploymentException {
+ push(new BPELThrow(m_context,attr));
+ }
+ public void closeThrow() throws DeploymentException {
+ pop();
+ }
+
+ public void buildTerminate(BPELAttributes attr) throws DeploymentException {
+ push(new BPELTerminate(m_context,attr));
+ }
+ public void closeTerminate() throws DeploymentException {
+ pop();
+ }
+
+ public void buildEmpty(BPELAttributes attr) throws DeploymentException {
+ push(new BPELEmpty(m_context,attr));
+ }
+ public void closeEmpty() throws DeploymentException {
+ pop();
+ }
+
+ public void buildWait(BPELAttributes attr) throws DeploymentException {
+ push(new BPELWait(m_context,attr));
+ }
+ public void closeWait() throws DeploymentException {
+ pop();
+ }
+
+
+ /**
+ * BPEL does not require an explicit scope. If (partners,variables,
+ * correlationSets, faultHandlers, compensationHandler, eventHandlers)
+ * are defined outside an explicit scope an implicit scope is created.
+ *
+ * @throws DefinitionServiceException
+ */
+ private void testScope() throws DeploymentException {
+ if ( !(m_context instanceof BPELScope) ) {
+ buildScope(new BPELAttributes());
+ }
+ }
+
+ /** The BPEL Invoke allows for a short cut syntax where catch,catchAll
+ * and compensationHandler may be applied directly to the Invoke rather
+ * than declaring them on a scope. In this case the translator will
+ * create an implied scope.
+ *
+ * @throws DefinitionServiceException
+ */
+ private void testInvoke() throws DeploymentException {
+ if ( !(m_context instanceof BPELScope ) ) {
+ if ( m_context instanceof BPELInvoke ) {
+ BPELNode parentContext = m_context.m_parserStack;
+ if ( parentContext instanceof BPELScope ) {
+ // The Invoke has an associated scope - just pop the stack
+ m_context = m_context.pop();
+ } else {
+ // Create the implied scope and pop the invoke
+ BPELNode currentInvoke = m_context;
+ m_context = new BPELScope(parentContext,new BPELAttributes());
+ currentInvoke.m_parserStack = m_context;
+ currentInvoke.pop();
+ }
+ } else {
+ buildScope(new BPELAttributes());
+ }
+ }
+ }
+
+ // Pop a BPEL node from the parser stack
+ private void pop() throws DeploymentException {
+ m_context = m_context.pop();
+ }
+ // Push a BPEL node to the parser stack
+ private void push(BPELNode node) {
+ m_context = node;
+ }
+
+ BPELDefinitionKey getDefKey() {
+ return m_defKey;
+ }
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSAXHandler.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSAXHandler.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSAXHandler.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSAXHandler.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on May 13, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import org.apache.ode.definition.service.DefinitionService;
+import org.apache.ode.lang.ResourceGetter;
+
+
+
+/**
+ * @author waterman
+ *
+ * Adds BPEL specific methods to the SAX DefaultHandler. Tags in the BPEL document
+ * are used to generate methods on BPELRepositoryHandler.
+ *
+ * @see BPELRespositoryHandler
+ *
+ */
+class BPELSAXHandler extends DefaultHandler {
+
+ private static final Logger logger = Logger.getLogger(BPELSAXHandler.class.getName());
+
+ private BPELRepositoryHandler m_rh; // Marshalls the BPEL doc into the runtime repository
+
+ private Class[] m_paramType = new Class[] {BPELAttributes.class};
+
+ private static final String BUILD_PREFIX = "build";
+ private static final String CLOSE_PREFIX = "close";
+
+ /**
+ *
+ */
+ BPELSAXHandler(String documentName, HashMap supportDoc, DefinitionService ds) throws DeploymentException {
+ super();
+ m_rh = new BPELRepositoryHandler(documentName, supportDoc, ds);
+ }
+
+
+ /**
+ * @see org.xml.sax.ContentHandler#startDocument()
+ */
+ public void startDocument() throws SAXException {
+ super.startDocument();
+ }
+ /**
+ * @see org.xml.sax.ContentHandler#endDocument()
+ */
+ public void endDocument() throws SAXException {
+ super.endDocument();
+ }
+
+
+ /**
+ * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
+ */
+ public void startElement(
+ String uri,
+ String localName,
+ String qName,
+ Attributes attributes)
+ throws SAXException {
+ super.startElement(uri, localName, qName, attributes);
+
+ try {
+ logger.fine("Start Element: " + localName);
+ BPELAttributes ba = new BPELAttributes(attributes);
+ String methodSuffix = localName;
+ String activityName = ba.getName();
+ String interpretation = m_rh.getInterpretation( activityName );
+ if ( interpretation != null )
+ {
+ logger.fine("Interpretation found: " + interpretation);
+ methodSuffix = interpretation;
+ }
+ Method m = m_rh.getClass().getMethod(getMethodName(methodSuffix,
+ BUILD_PREFIX),m_paramType);
+ m.invoke(m_rh,new Object[] {ba});
+ } catch (SecurityException e) {
+ logger.log(Level.SEVERE,"",e);
+ throw new SAXException(e);
+ } catch (NoSuchMethodException e) {
+ logger.log(Level.FINE,ResourceGetter.getFormatted("DEPLOY_UNHANDLED_TAG",new Object[] {localName}));
+ } catch (IllegalArgumentException e) {
+ logger.log(Level.SEVERE,"",e);
+ throw new SAXException(e);
+ } catch (IllegalAccessException e) {
+ logger.log(Level.SEVERE,"",e);
+ throw new SAXException(e);
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ if (Exception.class.isAssignableFrom( t.getClass() ))
+ throw new SAXException( (Exception) t );
+ else
+ throw new SAXException( t.getLocalizedMessage() );
+ }
+
+ }
+ /**
+ * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public void endElement(String uri, String localName, String qName)
+ throws SAXException {
+ super.endElement(uri, localName, qName);
+
+ try {
+ logger.fine("End Element: " + localName);
+ Method m = m_rh.getClass().getMethod(getMethodName(localName,CLOSE_PREFIX),new Class[]{});
+ m.invoke(m_rh,new Object[]{});
+ } catch (SecurityException e) {
+ logger.log(Level.SEVERE,"",e);
+ throw new SAXException(e);
+ } catch (NoSuchMethodException e) {
+ logger.log(Level.FINE,ResourceGetter.getFormatted("DEPLOY_UNHANDLED_TAG",new Object[] {qName}));
+ } catch (IllegalArgumentException e) {
+ logger.log(Level.SEVERE,"",e);
+ throw new SAXException(e);
+ } catch (IllegalAccessException e) {
+ logger.log(Level.SEVERE,"",e);
+ throw new SAXException(e);
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ if (Exception.class.isAssignableFrom( t.getClass() ))
+ throw new SAXException( (Exception) t );
+ else
+ throw new SAXException( t.getLocalizedMessage() );
+ }
+ }
+
+
+
+ /**
+ * Uses a tag from the BPEL document to generate a BPELRepositoryHandler
+ * method name. Note all BPEL tags will not generate valid methods.
+ * ( i.e. collections like <variables>, <partners> )
+ *
+ * @param tag
+ * @return
+ */
+ private String getMethodName(String tag,String prefix) {
+ char chars[] = tag.toCharArray();
+ chars[0] = Character.toUpperCase(chars[0]);
+ StringBuffer buff = new StringBuffer(prefix);
+ buff.append(chars);
+ return buff.toString();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.ContentHandler#characters(char[], int, int)
+ */
+ public void characters(char[] ch, int start, int length)
+ throws SAXException {
+ m_rh.buildData(new String(ch,start,length));
+ }
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
+ */
+ public void fatalError(SAXParseException e) throws SAXException {
+ logger.log(Level.SEVERE,"SAXParser Error",e);
+ throw e;
+ }
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
+ */
+ public void error(SAXParseException e) throws SAXException {
+ logger.log(Level.SEVERE,"SAXParser Error",e);
+ throw e;
+ }
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
+ */
+ public void warning(SAXParseException e) throws SAXException {
+ logger.log(Level.WARNING,"SAXParser Warning",e);
+ }
+
+ public BPELDefinitionKey getDefKey() {
+ return m_rh.getDefKey();
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSchema.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSchema.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSchema.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSchema.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,192 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on May 27, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+
+/**
+ * @author waterman
+ *
+ * Enumerates the BPEL schema identifiers.
+ *
+ */
+public class BPELSchema {
+
+ private java.lang.String m_value;
+
+ public static final String BPEL_URI="http://schemas.xmlsoap.org/ws/2003/03/business-process/";
+ public static final String XMLSCHEMA2001_NS = "http://www.w3.org/2001/XMLSchema";
+ public static final String XMLSCHEMA1999_NS = "http://www.w3.org/1999/XMLSchema";
+ public static final String SOAPSCHEMA_NS = "http://schemas.xmlsoap.org/soap/encoding/";
+
+ // Elements
+ private static final String REPLY_VALUE = "reply";
+
+ public static final String PRUNE_VALUE = "prune";
+ private static final String FLOW_VALUE = "flow";
+ private static final String PROCESS_VALUE = "process";
+ private static final String SEQUENCE_VALUE = "sequence";
+ private static final String INVOKE_VALUE = "invoke";
+ private static final String ASSIGN_VALUE = "assign";
+ private static final String RECEIVE_VALUE = "receive";
+ private static final String SCOPE_VALUE = "scope";
+ private static final String COPY_VALUE = "copy";
+ private static final String WHILE_VALUE = "while";
+ private static final String SWITCH_VALUE = "switch";
+ private static final String CASE_VALUE = "case";
+ private static final String OTHERWISE_VALUE = "otherwise";
+ private static final String FROM_VALUE = "from";
+ private static final String TO_VALUE = "to";
+ private static final String CORRELATIONSET_VALUE = "correlationSet";
+ private static final String CORRELATION_VALUE = "correlation";
+ private static final String CATCH_VALUE = "catch";
+ private static final String CATCHALL_VALUE = "catchAll";
+ private static final String ONMESSAGE_VALUE = "onMessage";
+ private static final String ONALARM_VALUE = "onAlarm";
+ private static final String COMPENSATION_VALUE = "compensationHandler";
+ private static final String PICK_VALUE = "pick";
+ private static final String COMPENSATE_VALUE = "compensate";
+ private static final String THROW_VALUE = "throw";
+ private static final String TERMINATE_VALUE = "terminate";
+ private static final String EMPTY_VALUE = "empty";
+ private static final String WAIT_VALUE = "wait";
+
+ // Attributes
+ private static final String NAME_ATTR_VALUE = "name";
+ private static final String LINKNAME_ATTR_VALUE = "linkName";
+ private static final String MESSAGE_TYPE_VALUE = "messageType";
+ private static final String VARIABLE_VALUE = "variable";
+ private static final String INPUT_VARIABLE_VALUE = "inputVariable";
+ private static final String OUTPUT_VARIABLE_VALUE = "outputVariable";
+ private static final String PART_VALUE = "part";
+ private static final String TRANSITIONCONDITION_VALUE = "transitionCondition";
+ private static final String JOINCONDITION_VALUE = "joinCondition";
+ private static final String SUPPRESS_JOIN_VALUE = "suppressJoinFailure";
+ private static final String CONDITION_VALUE ="condition";
+ private static final String EXPRESSION_VALUE = "expression";
+ private static final String PARTNERLINK_VALUE = "partnerLink";
+ private static final String PROPERTIES_VALUE = "properties";
+ private static final String FAULTNAME_VALUE = "faultName";
+ private static final String FAULTVAR_VALUE = "faultVariable";
+ private static final String SET_VALUE = "set";
+ private static final String INITIATE_VALUE = "initiate";
+ private static final String CREATEINSTANCE_VALUE = "createInstance";
+ private static final String PORTTYPE_VALUE = "portType";
+ private static final String OPERATION_VALUE = "operation";
+ private static final String QUERY_VALUE = "query";
+ private static final String PROPERTY_VALUE = "property";
+ private static final String TYPE_VALUE = "type";
+ private static final String FOR_VALUE = "for";
+ private static final String UNTIL_VALUE = "until";
+ private static final String PATTERN_VALUE = "pattern";
+ private static final String QUERY_LANG_VALUE = "queryLanguage";
+ private static final String EXPR_LANG_VALUE = "expressionLanguage";
+
+ // XML
+ public static final String PREFIX_SEPERATOR = ":";
+ public static final String NAMESPACE_KEY = "xmlns";
+
+ // Faults
+ public static final String FAULT_SELECTION_FAILURE = "selectionFailure";
+ public static final String FAULT_CONFILICTING_RECEIVE = "confilictingReceive";
+ public static final String FAULT_CONFILICTING_REQUEST = "confilictingRequest";
+ public static final String FAULT_MMAF = "mismatchedAssignmentFailure";
+ public static final String FAULT_JOIN_FAILURE = "joinFailure";
+ public static final String FAULT_FORCED_TERMINATION = "forcedTermination";
+ public static final String FAULT_CORRELATION_VIOLATION = "correlationViolation";
+ public static final String FAULT_UNINIT_VAR = "uninitializedVariable";
+ public static final String FAULT_REPEAT_COMP = "repeatedCompensation";
+ public static final String FAULT_INVALID_REPLY = "invalidReply";
+
+ private BPELSchema() {}
+ private BPELSchema(String value){
+ m_value = value;
+ }
+
+ // Elements
+ static final BPELSchema PRUNE = new BPELSchema(PRUNE_VALUE);
+ static final BPELSchema REPLY = new BPELSchema(REPLY_VALUE);
+ static final BPELSchema FLOW = new BPELSchema(FLOW_VALUE);
+ static final BPELSchema PROCESS = new BPELSchema(PROCESS_VALUE);
+ static final BPELSchema SEQUENCE = new BPELSchema(SEQUENCE_VALUE);
+ static final BPELSchema INVOKE = new BPELSchema(INVOKE_VALUE);
+ static final BPELSchema ASSIGN = new BPELSchema(ASSIGN_VALUE);
+ static final BPELSchema RECEIVE = new BPELSchema(RECEIVE_VALUE);
+ static final BPELSchema SCOPE = new BPELSchema(SCOPE_VALUE);
+ static final BPELSchema COPY = new BPELSchema(COPY_VALUE);
+ static final BPELSchema WHILE = new BPELSchema(WHILE_VALUE);
+ static final BPELSchema SWITCH = new BPELSchema(SWITCH_VALUE);
+ static final BPELSchema CASE = new BPELSchema(CASE_VALUE);
+ static final BPELSchema OTHERWISE = new BPELSchema(OTHERWISE_VALUE);
+ static final BPELSchema FROM = new BPELSchema(FROM_VALUE);
+ static final BPELSchema TO = new BPELSchema(TO_VALUE);
+ static final BPELSchema CORRELATIONSET = new BPELSchema(CORRELATIONSET_VALUE);
+ static final BPELSchema CORRELATION = new BPELSchema(CORRELATION_VALUE);
+ static final BPELSchema CATCH = new BPELSchema(CATCH_VALUE);
+ static final BPELSchema CATCHALL = new BPELSchema(CATCHALL_VALUE);
+ static final BPELSchema ONMESSAGE = new BPELSchema(ONMESSAGE_VALUE);
+ static final BPELSchema ONALARM = new BPELSchema(ONALARM_VALUE);
+ static final BPELSchema COMPENSATION = new BPELSchema(COMPENSATION_VALUE);
+ static final BPELSchema PICK = new BPELSchema(PICK_VALUE);
+ static final BPELSchema COMPENSATE = new BPELSchema(COMPENSATE_VALUE);
+ static final BPELSchema THROW = new BPELSchema(THROW_VALUE);
+ static final BPELSchema TERMINATE = new BPELSchema(TERMINATE_VALUE);
+ static final BPELSchema EMPTY = new BPELSchema(EMPTY_VALUE);
+ static final BPELSchema WAIT = new BPELSchema(WAIT_VALUE);
+
+ // Attributes
+ static final BPELSchema NAME_ATTR = new BPELSchema(NAME_ATTR_VALUE);
+ static final BPELSchema LINKNAME_ATTR = new BPELSchema(LINKNAME_ATTR_VALUE);
+ static final BPELSchema MESSAGE_TYPE_ATTR = new BPELSchema(MESSAGE_TYPE_VALUE);
+ static final BPELSchema VARIABLE_ATTR = new BPELSchema(VARIABLE_VALUE);
+ static final BPELSchema INPUT_VARIABLE_ATTR = new BPELSchema(INPUT_VARIABLE_VALUE);
+
+
+ static final BPELSchema OUTPUT_VARIABLE_ATTR = new BPELSchema(OUTPUT_VARIABLE_VALUE);
+ static final BPELSchema PART_ATTR = new BPELSchema(PART_VALUE);
+ static final BPELSchema TRANSITIONCONDITION_ATTR = new BPELSchema(TRANSITIONCONDITION_VALUE);
+ static final BPELSchema JOINCONDITION_ATTR = new BPELSchema(JOINCONDITION_VALUE);
+ static final BPELSchema SUPPRESS_JOIN_ATTR = new BPELSchema(SUPPRESS_JOIN_VALUE);
+ static final BPELSchema CONDITION_ATTR = new BPELSchema(CONDITION_VALUE);
+ static final BPELSchema EXPRESSION_ATTR = new BPELSchema(EXPRESSION_VALUE);
+ static final BPELSchema PARTNERLINK_ATTR = new BPELSchema(PARTNERLINK_VALUE);
+ static final BPELSchema PROPERTIES_ATTR = new BPELSchema(PROPERTIES_VALUE);
+ static final BPELSchema FAULTNAME_ATTR = new BPELSchema(FAULTNAME_VALUE);
+ static final BPELSchema FAULTVAR_ATTR = new BPELSchema(FAULTVAR_VALUE);
+ static final BPELSchema SET_ATTR = new BPELSchema(SET_VALUE);
+ static final BPELSchema INITIATE_ATTR = new BPELSchema(INITIATE_VALUE);
+ static final BPELSchema SCOPE_ATTR = new BPELSchema(SCOPE_VALUE);
+ static final BPELSchema CREATEINSTANCE_ATTR = new BPELSchema(CREATEINSTANCE_VALUE);
+ static final BPELSchema PORTTYPE_ATTR = new BPELSchema(PORTTYPE_VALUE);
+ static final BPELSchema OPERATION_ATTR = new BPELSchema(OPERATION_VALUE);
+ static final BPELSchema QUERY_ATTR = new BPELSchema(QUERY_VALUE);
+ static final BPELSchema PROPERTY_ATTR = new BPELSchema(PROPERTY_VALUE);
+ static final BPELSchema TYPE_ATTR = new BPELSchema(TYPE_VALUE);
+ static final BPELSchema FOR_ATTR = new BPELSchema(FOR_VALUE);
+ static final BPELSchema UNITL_ATTR = new BPELSchema(UNTIL_VALUE);
+ static final BPELSchema PATTERN_ATTR = new BPELSchema( PATTERN_VALUE );
+ static final BPELSchema QUERY_LANG_ATTR = new BPELSchema( QUERY_LANG_VALUE );
+ static final BPELSchema EXPR_LANG_ATTR = new BPELSchema( EXPR_LANG_VALUE );
+
+ public java.lang.String getValue()
+ {
+ return m_value;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELScope.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELScope.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELScope.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELScope.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,350 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on May 19, 2003
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+//import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.action.bpel.EndScopeAction;
+import org.apache.ode.action.bpel.RegisterAction;
+import org.apache.ode.action.bpel.StartScopeAction;
+import org.apache.ode.definition.IPMDAction;
+import org.apache.ode.definition.IPMDChangeCondition;
+import org.apache.ode.definition.IPMDLocator;
+import org.apache.ode.definition.IPMDOperation;
+import org.apache.ode.definition.service.DefinitionServiceException;
+
+
+/**
+ * Implements the BPEL <i>scope</i> node. The scope node holds a collections of
+ * events, variables, correlation sets, faults and compensation handler.
+ * <p>
+ * See <A HREF="../../../../../BPEL4WS.xsd">BPEL4WS.xsd</A> - complexType = tScope.
+ *
+ * @author waterman
+ */
+class BPELScope extends BPELStructuredActivity {
+
+ private static final Logger logger = Logger.getLogger(BPELScope.class.getName());
+
+
+ private HashMap m_variables = new HashMap(); // BPELVariable objects
+ private HashMap m_correlationSets = new HashMap(); // BPELCorrelationSet objects
+ private HashMap m_faultHandlers = new HashMap(); // BPELCatch objects
+ private Vector m_eventHandlers = new Vector(); // BPELEvent objects
+ private ArrayList m_compLocators = new ArrayList(); // BPELVariables used within the scopes compensation handler
+ private BPELCompensationHandler m_compHandler; // BPELCompensationHandler
+ private String name; // scope name
+ private BPELNode m_activity;
+
+ // note - the BPEL name attribute for scope is not required. Therefore it is
+ // important that scope name be maintained for a unique runtime handle
+
+ /**
+ * @param previous the parent schema node
+ * @param attrs the schema attributes
+ */
+ BPELScope(BPELNode node, BPELAttributes attrs) throws DeploymentException {
+ super(node, BPELSchema.SCOPE,attrs,logger);
+
+ createProcessSequence(getAttributes(),getEndProcess());
+
+ name = attrs.getName() + "_" + getScopeCounter();
+ }
+
+ void setCompensationHandler(BPELCompensationHandler handler) {
+ m_compHandler = handler;
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#addVariable(org.apache.ode.deployment.bpel.BPELVariable)
+ */
+ void addVariable(BPELVariable var) {
+ m_variables.put(var.getName(),var);
+ var.setScope(this);
+ }
+
+ void addCorrelationSet(BPELCorrelationSet corr) {
+ m_correlationSets.put(corr.getName(),corr);
+ }
+
+ void addFaultHandler(BPELCatch fault) throws DeploymentException {
+ m_faultHandlers.put(fault.getName(),fault);
+ }
+
+ void addEventHandler(BPELEvent event) {
+ m_eventHandlers.add(event);
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#getVariable(java.lang.String)
+ */
+ BPELVariable getVariable(String varName) throws DeploymentException {
+ BPELVariable ret = null;
+
+ if ( (ret = (BPELVariable)m_variables.get(varName)) == null ) {
+ ret = m_parserStack.getVariable(varName);
+ }
+
+ return ret;
+ }
+
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#addActivity(org.apache.ode.deployment.bpel.BPELNode)
+ */
+ void addActivity(BPELNode activity) throws DeploymentException {
+
+ createProcessSequence(activity.getAttributes(),activity.getStartProcess());
+
+ linkProcess(BPELProcessType.START,(BPELLinkedActivity)activity,BPELProcessType.START,true);
+
+ ((BPELLinkedActivity)activity).linkProcess(BPELProcessType.END,this,BPELProcessType.END,false);
+
+ m_activity = activity;
+ }
+
+ String getScopeName() {
+ return name;
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#getScopePath(org.apache.ode.deployment.bpel.BPELScopePath)
+ */
+ BPELScopePath getScopePath(BPELScopePath path) {
+
+ path.pushScope(this);
+
+ return m_parserStack.getScopePath(path);
+
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#getCorrelationSet(java.lang.String)
+ */
+ BPELCorrelationSet getCorrelationSet(String name) {
+ BPELCorrelationSet ret = (BPELCorrelationSet)m_correlationSets.get(name);
+ if ( ret == null ) ret = m_parserStack.getCorrelationSet(name);
+ return ret;
+ }
+
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#pop()
+ */
+ BPELNode pop() throws DeploymentException {
+
+ // Create the start scope action
+ try {
+ IPMDChangeCondition ccB = getStartProcess().createChangeCondition("Start Scope: "+getScopeName(),
+ org.apache.ode.condition.DefaultConditional.class.getName());
+
+ IPMDAction ss = ccB.createAction("Start Scope: "+getScopeName(),
+ org.apache.ode.action.bpel.StartScopeAction.class.getName());
+ ss.addMetadata(StartScopeAction.SCOPE_NAME,getScopeName());
+
+
+ // Create the end scope action
+ IPMDChangeCondition ccE = getEndProcess().createChangeCondition("End Scope: "+getScopeName(),
+ org.apache.ode.condition.DefaultConditional.class.getName());
+ IPMDAction es = ccE.createAction("End Scope: "+getScopeName(),
+ org.apache.ode.action.bpel.EndScopeAction.class.getName());
+
+
+ // register event handlers
+ setEventHandlers(ccB, ccE);
+
+ // mark contentious variables
+ //setVariableThreadBoundries();
+
+ // register fault handlers
+ setFaultHandlers(ss);
+
+ // register the compensation handler
+ setCompensationHandler(es);
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATEACTION",new Object[] {getProcess().getAttributes().getName(), getScopeName()},e);
+ }
+
+ return super.pop();
+ }
+
+ /**
+ * If a scope variable is used in the Scopes compensation handler, the end
+ * scope needs to identify variables that require a snapshot.
+ *
+ * @param loc - the variable locator
+ *
+ */
+
+ void setCompLocatorCapture(IPMDLocator loc) {
+ m_compLocators.add(loc);
+ }
+
+ /**
+ * Identifies variables that cross thread boundries
+ *
+ */
+// private void setVariableThreadBoundries() {
+// // Iterate over the scope variables and determine if any of them
+// // cross a thread boundry. If so mark the locator as contentious
+//
+// for ( Iterator varItr = m_variables.values().iterator(); varItr.hasNext(); ) {
+// BPELVariable var = (BPELVariable)varItr.next();
+//
+// if ( var.getUsedInActivities().size() > 1 ) {
+// // Get the nodes where the variable is used
+// Iterator nodeItr = var.getUsedInActivities().iterator();
+// HashSet basis = ((BPELNode)nodeItr.next()).collectThreadBoundries(new HashSet());
+//
+// // Compare the remaining nodes - if the hashsets don't equal then
+// // the variable has crossed a thread boundry
+// while ( nodeItr.hasNext() ) {
+//
+// HashSet derive = ((BPELNode)nodeItr.next()).collectThreadBoundries(new HashSet());
+//
+// if ( !derive.equals(basis) ) {
+// for ( Iterator locatorItr = var.getUsedInLocators().iterator(); locatorItr.hasNext(); ) {
+// ((IPMDLocator)locatorItr.next()).setContentious(true);
+// }
+// break; // No reason to check the remaining activities
+// }
+// }
+// }
+//
+// }
+// }
+
+ /**
+ * Creates the scoped fault handlers
+ *
+ * @param ssa the start scope action
+ */
+ private void setFaultHandlers(IPMDAction ssa) throws DeploymentException {
+
+ HashMap faultHandlers = new HashMap();
+
+ for ( Iterator itr = m_faultHandlers.entrySet().iterator(); itr.hasNext();){
+ Map.Entry me = (Map.Entry)itr.next();
+
+ BPELCatch bpelCatch = (BPELCatch)me.getValue();
+
+ faultHandlers.put(me.getKey(),
+ bpelCatch.getStartProcess().getKey().getValue());
+ // add the scopes end process as an observer of the fault
+ try {
+ bpelCatch.getEndProcess().addObserverProcessPC(getEndProcess());
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_ADDOBSERVER",new Object[] {getProcess().getAttributes().getName()},e);
+ }
+ }
+
+ try {
+ ssa.addMetadata(StartScopeAction.FAULT_HANDLERS,faultHandlers);
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATEPROP",new Object[] {getProcess().getAttributes().getName(), StartScopeAction.FAULT_HANDLERS},e);
+ }
+
+ }
+
+ /**
+ * Creates the scope's compensation handler
+ * @param esa the end scope action
+ */
+ private void setCompensationHandler(IPMDAction esa) throws DeploymentException {
+ if ( m_compHandler != null ) {
+ try {
+ esa.addMetadata(EndScopeAction.COMP_HANLDER, m_compHandler.getStartProcess().getKey().getValue());
+ esa.addMetadata(EndScopeAction.LOCATORS,m_compLocators);
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATEPROP",new Object[] {getProcess().getAttributes().getName(), EndScopeAction.COMP_HANLDER},e);
+ }
+
+ }
+ }
+
+ private void setEventHandlers(IPMDChangeCondition ccB , IPMDChangeCondition ccE ) throws DeploymentException {
+
+ ArrayList ops = new ArrayList();
+ IPMDOperation op = null;
+
+ IPMDAction regAct = null;
+ IPMDAction unRegAct = null;
+
+ if ( !m_eventHandlers.isEmpty() ) {
+ //register action
+ regAct = createRegisterAction(ccB,getScopeName());
+ //unregister action
+ unRegAct = createUnRegisterAction(ccE,getScopeName());
+ }
+
+ for ( Iterator itr = m_eventHandlers.iterator(); itr.hasNext(); ) {
+
+ op = ((BPELEvent)itr.next()).getOperation(regAct,ccB);
+ if ( op != null ) {
+ getProcess().addNonInstanceCreatingStaticKey(op.getKey());
+ }
+ if ( op != null ) ops.add( op );
+ }
+
+ if ( regAct != null && unRegAct != null ) {
+ try {
+ regAct.addMetadata(RegisterAction.OPERATIONS,ops);
+ regAct.addMetadata(RegisterAction.BLOCK,new Boolean("false"));
+ unRegAct.addMetadata(RegisterAction.OPERATIONS,ops);
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATEACTION",new Object[] {getProcess().getAttributes().getName(), getAttributes().getName()},e);
+ }
+ }
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#getScope()
+ */
+ BPELScope getScope() {
+ if ( this.inCompensationHandler() ) return m_parserStack.getScope();
+ return this;
+ }
+
+ Vector getEventHandlers() {
+ return m_eventHandlers;
+ }
+
+ void addJoinCondtion(BPELVariable var) throws DeploymentException {
+
+ super.addJoinCondtion(var);
+
+ m_activity.addJoinCondtion(var);
+
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELLinkedActivity#getActivityDescription()
+ */
+ String getActivityDescription() {
+ return "scope is implemented by: " + org.apache.ode.action.bpel.StartScopeAction.class.getName() + ". It is used to initailize/destroy a container which holds a named execution context.";
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELScopePath.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELScopePath.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELScopePath.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELScopePath.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Jun 20, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.util.Stack;
+
+/**
+ * Holds a path to a BPELVariable
+ *
+ * @author waterman
+ * @see BPELScope
+ */
+class BPELScopePath {
+
+ static final String PATH_DELIMITER = "/";
+
+ boolean m_absolutePath;
+ Stack m_path = new Stack();
+
+ BPELScopePath(boolean inCompensationHandler) {
+ //m_absolutePath = !inCompensationHandler;
+ // make all paths absolute for now
+ m_absolutePath=true;
+ }
+
+ void pushScope(BPELNode scope) {
+ m_path.push(scope);
+ }
+
+ public String toString() {
+
+ StringBuffer buf = ( m_absolutePath ) ? new StringBuffer(PATH_DELIMITER + ((BPELScope)m_path.pop()).getScopeName()) : new StringBuffer(((BPELScope)m_path.pop()).getScopeName());
+
+
+ int size = m_path.size();
+
+ for (int i = 0; i < size; i++ ) {
+ BPELNode node = (BPELNode)m_path.pop();
+ if ( node instanceof BPELScope ) {
+ buf.append( PATH_DELIMITER + ((BPELScope)node).getScopeName() );
+ } else {
+ if ( node instanceof BPELCatch ) {
+ try {
+ buf.append( PATH_DELIMITER + ((BPELCatch)node).getName() );
+ } catch (DeploymentException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ return buf.toString();
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSequence.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSequence.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSequence.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSequence.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,208 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Jun 3, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.action.bpel.StartSequenceAction;
+import org.apache.ode.action.bpel.UnInitVariableMetaData;
+import org.apache.ode.action.internal.IInternalAction;
+import org.apache.ode.definition.IPMDAction;
+import org.apache.ode.definition.IPMDChangeCondition;
+import org.apache.ode.definition.service.DefinitionServiceException;
+import org.apache.ode.util.BPException;
+
+/**
+ * Implements the BPEL <i>sequence</i> node. The sequence node holds
+ * a collection of activities that are to be executed in sequence.
+ * <p>
+ * See <A HREF="../../../../../BPEL4WS.xsd">BPEL4WS.xsd</A> - complexType = tSequence.
+ *
+ * @author waterman
+ */
+class BPELSequence extends BPELStructuredActivity {
+ private static final Logger logger = Logger.getLogger(BPELSequence.class.getName());
+
+
+ private Vector m_activities = new Vector();
+ private Vector m_links = new Vector();
+ private IPMDAction m_ss;
+ private Properties m_ssProps = new Properties();
+
+ BPELSequence(BPELNode node, BPELAttributes attrs) throws DeploymentException {
+ super(node,BPELSchema.SEQUENCE,attrs,logger);
+
+ createProcessSequence(getAttributes(),getEndProcess());
+
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#addActivity(org.apache.ode.deployment.bpel.BPELNode)
+ */
+ void addActivity(BPELNode activity) throws DeploymentException {
+ m_activities.add(activity);
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#pop()
+ */
+ BPELNode pop() throws DeploymentException {
+
+ BPELLinkedActivity current = this;
+ BPELLinkedActivity la = null;
+
+// BPELNode proxy = null;
+
+// if ( current.getLinkCounter(BPELLinkType.SOURCE) > 0 ) {
+// for ( Iterator linkItr = current.getLinks(BPELLinkType.SOURCE); linkItr.hasNext(); ) {
+// BPELLink link = (BPELLink)linkItr.next();
+// BPELNode linkOwner = current.getLinkOwner(link);
+// proxy = current.getProxy(linkOwner);
+// if ( proxy != null ) break;
+// }
+// }
+
+ createSeqStart();
+
+ for (Iterator itr = m_activities.iterator(); itr.hasNext(); ) {
+ la = (BPELLinkedActivity)itr.next();
+
+
+ if ( la.getLinkCounter(BPELLinkType.TARGET) == 0 ) {
+ createProcessSequence(la.getAttributes(),la.getStartProcess());
+ } else {
+ la.incrementLink(BPELLinkType.TARGET);
+ createProcessSync(la.getStartProcess(),la.getAttributes().getName(),String.valueOf(la.getLinkCounter(BPELLinkType.TARGET)));
+ }
+
+ if ( current == this ) {
+ this.linkStartProcess(la);
+ } else {
+ current.linkProcess(BPELProcessType.END,la,BPELProcessType.START,true);
+ }
+
+ if ( la.getLinkCounter(BPELLinkType.SOURCE) > 0 ) {
+ la.incrementLink(BPELLinkType.SOURCE);
+ }
+ current = la;
+ }
+
+ current.linkProcess(BPELProcessType.END,this,BPELProcessType.END,false);
+
+ createSeqEnd();
+
+ m_ss.setMetadata(m_ssProps);
+
+ return super.pop();
+ }
+
+ void addJoinCondtion(BPELVariable var) throws DeploymentException {
+
+ m_ssProps.put(StartSequenceAction.JOIN_EXPRESSION_KEY,var.createLocator(m_ss,this,null,null,false));
+ m_ssProps.put(StartSequenceAction.SUPPRESS_KEY,(BPELBoolean.NO.equals(getAttributes().getSuppressJoin())) ? BPELBoolean.NO.getBooleanValue() : getSuppressJoinFailure().getBooleanValue());
+
+ try {
+ IInternalAction tmp = m_ss.getActionImpl();
+ if ( tmp != null ) tmp.init(m_ssProps);
+ } catch (BPException e) {
+ }
+
+// super.addJoinCondtion(var);
+
+// for ( Iterator itr = m_activities.iterator(); itr.hasNext(); ) {
+//
+// ((BPELNode)itr.next()).addJoinCondtion(var);
+// }
+
+ }
+
+ BPELLink notifyLink(BPELLink link, BPELFlow node) throws DeploymentException {
+ // the link has crossed the sequence boundry so capture it here
+ if ( link.getSource() != this && link.getTarget() != this ) {
+ m_links.add(link);
+ }
+ if ( m_parserStack != null ) return m_parserStack.notifyLink(link, node);
+ return null;
+ }
+
+ private void createSeqEnd() throws DeploymentException {
+
+ Vector linkLocators = new Vector();
+
+ IPMDChangeCondition ccE = null;
+ IPMDAction es = null;
+
+ // Create the end switch action
+ try {
+ ccE = getEndProcess().createChangeCondition("End Sequence: "+getAttributes().getName(),
+ org.apache.ode.condition.DefaultConditional.class.getName());
+ es = ccE.createAction("End Sequence: "+getAttributes().getName(),
+ org.apache.ode.action.bpel.EndSequenceAction.class.getName());
+ } catch (DefinitionServiceException e1) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATEACTION",new Object[] {getProcess().getAttributes().getName(), getAttributes().getName()},e1);
+ }
+
+ // iterate over the transition links and add them as metadata
+ // the runtime will set all links at the end of the switch.
+ for ( Iterator linkItr = m_links.iterator(); linkItr.hasNext(); ) {
+ BPELLink link = (BPELLink)linkItr.next();
+ BPELVariable var = link.getTransitionCondVar();
+ linkLocators.add(var.createLocator(es,this,null,null,true));
+ }
+
+ Properties md = new Properties();
+ md.put(org.apache.ode.action.bpel.EndConditionalFlowAction.LINKS,linkLocators);
+
+ es.setMetadata(md);
+
+ // link end process
+ m_ssProps.put(StartSequenceAction.END_DEF_KEY,this.getEndProcess().getKey());
+
+ }
+
+ private void createSeqStart() throws DeploymentException {
+
+ try {
+ IPMDChangeCondition ccB = getStartProcess().createChangeCondition("ChangeCondition: " + getAttributes().getName(),
+ org.apache.ode.condition.DefaultConditional.class.getName());
+ m_ss = ccB.createAction("Start Sequence: "+getAttributes().getName(),
+ org.apache.ode.action.bpel.StartSequenceAction.class.getName());
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATEACTION",new Object[] {getProcess().getAttributes().getName(), getAttributes().getName()},e);
+ }
+ }
+
+ private void linkStartProcess(BPELLinkedActivity la) {
+ m_ssProps.put(org.apache.ode.action.bpel.StartSequenceAction.START_DEF_KEY,la.getStartProcess().getKey());
+ m_ssProps.put(StartSequenceAction.UNINITVAR_KEY,new UnInitVariableMetaData(BPELSchema.BPEL_URI,BPELSchema.FAULT_UNINIT_VAR));
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELLinkedActivity#getActivityDescription()
+ */
+ String getActivityDescription() {
+ return "sequence is implemented by: " + org.apache.ode.action.bpel.SequenceAction.class.getName() + ". It is a container used to execute a series of activites.";
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSimpleUpdate.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSimpleUpdate.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSimpleUpdate.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSimpleUpdate.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.ode.deployment.bpel;
+
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.action.bpel.SimpleUpdateAction;
+import org.apache.ode.definition.IPMDAction;
+import org.apache.ode.definition.IPMDChangeCondition;
+import org.apache.ode.definition.service.DefinitionServiceException;
+import org.apache.ode.interaction.IInvocation;
+import org.apache.ode.util.BPException;
+
+
+public abstract class BPELSimpleUpdate extends BPELNode
+{
+ private static final Logger logger =
+ Logger.getLogger(BPELSimpleUpdate.class.getName());
+
+ protected BPELFrom m_from;
+
+ BPELSimpleUpdate(BPELNode previous, BPELSchema tag, BPELAttributes attrs, Logger logger)
+ {
+ super(previous, tag, attrs, logger);
+ // TODO Auto-generated constructor stub
+ }
+
+ void addActivity(BPELNode activity) throws DeploymentException
+ {
+ if ( activity instanceof BPELFrom ) m_from = (BPELFrom)activity;
+ }
+
+ BPELNode pop() throws DeploymentException
+ {
+ IPMDChangeCondition cc = null;
+
+ Iterator itr = getStartProcess().getChangeConditions();
+ IPMDAction ccact=null;
+
+ try
+ {
+ if ( itr.hasNext() ) {
+ // use the existing change condition
+ cc = (IPMDChangeCondition)itr.next();
+ }
+ else
+ {
+ // create a new change condition
+ cc = getStartProcess().createChangeCondition(
+ "ChangeCondition: " + getAttributes().getName(),
+ org.apache.ode.condition.DefaultConditional.class.getName());
+ }
+
+ // Create the copy action
+ ccact = cc.createAction(
+ "ChangeAction: " + getAttributes().getName(),
+ org.apache.ode.action.bpel.SimpleUpdateAction.class.getName());
+ }
+ catch (DefinitionServiceException e)
+ {
+ BPELUtil.throwNewException(logger,Level.SEVERE,
+ "BPEL_CREATEACTION",
+ new Object[] {getProcess().getAttributes().getName(),
+ getAttributes().getName()},e);
+ }
+
+
+ // TODO: Lance - BPEL v1.next - type checking
+
+ Properties md = new Properties(); // action metadata properties
+
+ BPELVariable var = getVariable(m_from.getAttributes().getVariable());
+
+
+ Object locator = var.createLocator(
+ ccact,this,m_from,m_from.getAttributes(),
+ BPELInvocationType.NO_INVOCATION,
+ true);
+
+ md.put(SimpleUpdateAction.TARGET_VARIABLE_KEY, locator );
+
+ try
+ {
+ md.put(SimpleUpdateAction.INVOCATION_KEY,
+ createInvocation(m_from.getAttributes().getQuery()));
+ } catch (BPException e1)
+ {
+ throw new DeploymentException(e1);
+ }
+
+ ccact.setMetadata(md);
+
+ return super.pop();
+ }
+
+ abstract protected IInvocation createInvocation(String invocationString )
+ throws BPException;
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELStructuredActivity.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELStructuredActivity.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELStructuredActivity.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELStructuredActivity.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.deployment.bpel;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.definition.IPMDAction;
+import org.apache.ode.definition.IPMDChangeCondition;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.definition.service.DefinitionServiceException;
+
+/*
+ * Created on Jun 9, 2003
+ *
+ */
+
+/**
+ * @author waterman
+ *
+ * The base class for BPLE structured activities (i.e. Flow, Sequence, While )
+ * Structured activities hold a starting process and an ending process definition.
+ *
+ */
+abstract class BPELStructuredActivity extends BPELLinkedActivity {
+ private static final Logger logger = Logger.getLogger(BPELStructuredActivity.class.getName());
+
+ //private static final String LOCATOR="SyncThreadCounterLocator";
+ //private static final String THREAD_COUNT_KEY="SyncThreadCount";
+ protected IPMDProcess m_endProcess;
+
+
+ void createProcessSync(IPMDProcess target, String name, String numberOfSources ) throws DeploymentException {
+
+ // Create the Pre Condition
+ IPMDAction preact=null;
+ try {
+ IPMDChangeCondition precc = target.createPrecondition("PreCondition: " + name,
+ org.apache.ode.condition.DefaultConditional.class.getName());
+ // Create the pre Action
+ preact =
+ precc.createAction(
+ "MergeAction: " + name,
+ org.apache.ode.action.bpel.MergeAction.class.getName());
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATEACTION",new Object[] {getProcess().getAttributes().getName(), name},e);
+ }
+
+ BPELVariable var = new BPELSystemVariable(org.apache.ode.action.bpel.MergeAction.LOCATOR,target.getKey().getValue()+":mergeCount",this);
+ var.createLocator(preact,this,null,null,true);
+
+ Properties md = new Properties();
+
+ md.put(org.apache.ode.action.bpel.MergeAction.THREAD_COUNT_KEY,numberOfSources);
+ //preact.addMetadata(THREAD_COUNT_KEY,numberOfSources);
+ md.putAll(getAttributes());
+
+ preact.setMetadata(md);
+
+ }
+
+ /**
+ * @param previous the parent schema node
+ * @param attrs the schema attributes
+ * @throws DefinitionServiceException
+ */
+ BPELStructuredActivity(
+ BPELNode previous,
+ BPELSchema tag,
+ BPELAttributes attrs, Logger logger)
+ throws DeploymentException {
+ super(previous, tag, attrs, logger);
+
+ if ( m_parserStack != null ) {
+ m_endProcess = createProcess((m_attributes.getName() == null)? "end: " + tag.getValue() : "end: " + m_attributes.getName());
+ m_endProcess.setDescription(getActivityDescription());
+ }
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#getEndProcess()
+ */
+ IPMDProcess getEndProcess() {
+ return m_endProcess;
+ }
+
+ void linkProcess(BPELProcessType parent_type, BPELLinkedActivity child, BPELProcessType child_type, boolean linkNodes) throws DeploymentException {
+ try {
+ (( parent_type == BPELProcessType.START ) ? m_process : m_endProcess).addObserverProcessPC(( child_type == BPELProcessType.START ) ? child.getStartProcess() : child.getEndProcess());
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_ADDOBSERVER",new Object[] {getProcess().getAttributes().getName()},e);
+ }
+ if ( linkNodes ) child.addParent(this);
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSwitch.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSwitch.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSwitch.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSwitch.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,210 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Jul 10, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.action.bpel.UnInitVariableMetaData;
+import org.apache.ode.action.bpel.XPathJaxenExpression;
+import org.apache.ode.action.bpel.XPathSwitchAction;
+import org.apache.ode.action.bpel.XPathSwitchTuple;
+import org.apache.ode.definition.IPMDAction;
+import org.apache.ode.definition.IPMDChangeCondition;
+import org.apache.ode.definition.service.DefinitionServiceException;
+
+/**
+ * Implements the BPEL <i>switch</i> node. The switch node holds a collection of
+ * cases.
+ * <p>
+ * See <A HREF="../../../../../BPEL4WS.xsd">BPEL4WS.xsd</A> - complexType = tSwitch.
+ *
+ * @see BPELCase
+ * @author waterman
+ */
+class BPELSwitch extends BPELStructuredActivity {
+ private static final Logger logger = Logger.getLogger(BPELStructuredActivity.class.getName());
+
+
+ private static final String XPATH_SWITCH_CLASS = org.apache.ode.action.bpel.XPathSwitchAction.class.getName();
+ private static final String DEFAULT_CONDITION_CLASS = org.apache.ode.condition.DefaultConditional.class.getName();
+ private static final String UNINITVAR_LABEL = org.apache.ode.action.bpel.XPathSwitchAction.UNINITVAR_KEY;
+ private static final String SWITCH_COND_LABEL = "Switch Condition: ";
+ private static final String SWITCH_ACTION_LABEL = "Switch Action : ";
+
+
+ private Vector cases = new Vector();
+ private BPELOtherwise otherwise;
+
+ private Vector links = new Vector();
+
+ /**
+ * @param previous the parent schema node
+ * @param attrs the schema attributes
+ * @throws DefinitionServiceException
+ */
+ BPELSwitch(BPELNode previous, BPELAttributes attrs)
+ throws DeploymentException {
+ super(previous, BPELSchema.SWITCH, attrs,logger);
+
+ createProcessSequence(getAttributes(),getEndProcess());
+ }
+
+
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#addActivity(org.apache.ode.deployment.bpel.BPELNode)
+ */
+ void addActivity(BPELNode activity) throws DeploymentException {
+
+ // Collect case statments and add them into internal collection.
+ // They will be linked together when the switch tag is closed.
+
+ // Retain case statement order.
+ if ( activity instanceof BPELOtherwise ) {
+ otherwise = (BPELOtherwise)activity;
+ } else {
+ cases.add(activity);
+ }
+
+ }
+
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#pop()
+ */
+ BPELNode pop() throws DeploymentException {
+
+ createCases();
+
+ createEnd();
+
+ return super.pop();
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELLinkedActivity#getActivityDescription()
+ */
+ String getActivityDescription() {
+ return "switch is implemented by: " + org.apache.ode.action.bpel.XPathSwitchAction.class.getName() + ". It is a container used to execute a single activity from a choice of activities.";
+ }
+
+ void createCases() throws DeploymentException {
+ Vector v = new Vector();
+
+ // Create the change condition and action that implement the switch
+ IPMDAction da=null;
+ try {
+ IPMDChangeCondition cc = getStartProcess().createChangeCondition(SWITCH_COND_LABEL + getAttributes().getName(),DEFAULT_CONDITION_CLASS);
+ da = cc.createAction(SWITCH_ACTION_LABEL + getAttributes().getName(),
+ XPATH_SWITCH_CLASS);
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATEACTION",new Object[] {getProcess().getAttributes().getName(), getAttributes().getName()},e);
+ }
+
+ // Iterate over the switch cases and add the case process definition
+ // to the switch action metadata.
+ for ( Iterator itr = cases.iterator(); itr.hasNext(); ) {
+ BPELCase caseActivity = (BPELCase)itr.next();
+
+ // parse the condition and create the context locators for all the bpws: extentions
+ BPELExpressionVariable expVar = new BPELExpressionVariable(caseActivity.getAttributes().getCondition());
+
+ // create the XPathTuple that maps the XPath Expression to a
+ // definition key. The switch action class will evaluate the XPath
+ // expression, if true a process instance is created from the definition key
+ // and then started.
+ v.add( new XPathSwitchTuple((XPathJaxenExpression)expVar.createLocator(da,this,caseActivity,null,BPELInvocationType.SELECT_VALUE,false),caseActivity.getActivity().getStartProcess().getKey()));
+
+ // Link the end of the case activity to the end of the switch activity
+ caseActivity.getActivity().linkProcess(BPELProcessType.END,this,BPELProcessType.END,false);
+ }
+
+ Properties md = new Properties();
+ md.put(UNINITVAR_LABEL,new UnInitVariableMetaData(BPELSchema.BPEL_URI,BPELSchema.FAULT_UNINIT_VAR));
+
+ // Add the case expressions as metadata to the switch action
+
+ md.put(XPathSwitchAction.CASES_KEY,v);
+ // The default value to the switch action will cause the loop to end
+ if ( otherwise == null ) {
+ md.put(XPathSwitchAction.DEFAULT_KEY,getEndProcess().getKey());
+ } else {
+ md.put(XPathSwitchAction.DEFAULT_KEY,otherwise.getActivity().getStartProcess().getKey());
+ // Link the end of the otherwise activity to the end of the switch activity
+ otherwise.getActivity().linkProcess(BPELProcessType.END,this,BPELProcessType.END,false);
+ }
+
+ da.setMetadata(md);
+ }
+
+ void createEnd() throws DeploymentException {
+
+ Vector linkLocators = new Vector();
+ //int inc=0;
+
+ IPMDChangeCondition ccE = null;
+ IPMDAction es = null;
+
+ // Create the end switch action
+ try {
+ ccE = getEndProcess().createChangeCondition("End Switch: "+getAttributes().getName(),
+ org.apache.ode.condition.DefaultConditional.class.getName());
+ es = ccE.createAction("End Switch: "+getAttributes().getName(),
+ org.apache.ode.action.bpel.EndConditionalFlowAction.class.getName());
+ } catch (DefinitionServiceException e1) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATEACTION",new Object[] {getProcess().getAttributes().getName(), getAttributes().getName()},e1);
+ }
+
+ // iterate over the transition links and add them as metadata
+ // the runtime will set all links at the end of the switch.
+ for ( Iterator linkItr = links.iterator(); linkItr.hasNext(); ) {
+ BPELLink link = (BPELLink)linkItr.next();
+ BPELVariable var = link.getTransitionCondVar();
+ linkLocators.add(var.createLocator(es,this,null,null,true));
+ }
+
+ Properties md = new Properties();
+ md.put(org.apache.ode.action.bpel.EndConditionalFlowAction.LINKS,linkLocators);
+
+ es.setMetadata(md);
+
+ }
+
+ BPELLink notifyLink(BPELLink link, BPELFlow node) throws DeploymentException {
+ // the link has crossed the switch boundry so capture it here
+ if ( link.getSource() != this && link.getTarget() != this ) {
+ links.add(link);
+ }
+ if ( m_parserStack != null ) return m_parserStack.notifyLink(link, node);
+ return null;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.ode.deployment.bpel.BPELNode#getProxy(org.apache.ode.deployment.bpel.BPELFlow, org.apache.ode.deployment.bpel.BPELNode)
+ */
+ BPELNode getProxy(BPELFlow linkOwner, BPELNode source) {
+ return this;
+ }
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSystemVariable.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSystemVariable.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSystemVariable.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELSystemVariable.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Jun 21, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.definition.IPMDLocator;
+import org.apache.ode.definition.IPMDLocatorHolder;
+import org.apache.ode.definition.service.DefinitionServiceException;
+
+/**
+ *
+ * Defines a variable used by a BPE pattern ( i.e. a merge counter )
+ *
+ * @author waterman
+ */
+class BPELSystemVariable extends BPELVariable {
+ private static final Logger logger = Logger.getLogger(BPELSystemVariable.class.getName());
+
+ private String m_part;
+ private String m_locator;
+ private boolean inCompHandler;
+
+// BPELSystemVariable(String name, String part) {
+// super(new BPELAttributes(),logger);
+//
+// m_attributes.setName(name);
+// m_part = part;
+//
+// }
+
+ BPELSystemVariable(String name, String part, BPELNode node) {
+ super(new BPELAttributes(),logger);
+
+ m_attributes.setName(name);
+ m_part = part;
+
+ inCompHandler = node.inCompensationHandler();
+
+ node.addVariable(this);
+
+ m_locator = this.getScopePath(new BPELScopePath(inCompHandler)).toString()
+ + BPELScopePath.PATH_DELIMITER+ m_part;
+
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELVariable#createLocator(org.apache.ode.definition.IPMDLocatorHolder, org.apache.ode.deployment.bpel.BPELNode, org.apache.ode.deployment.bpel.BPELAttributes, boolean)
+ */
+ Object createLocator(
+ IPMDLocatorHolder locator,
+ BPELNode node,
+ BPELNode tagNode,
+ BPELAttributes attrs,
+ BPELInvocationType type,
+ boolean forOutPut)
+ throws DeploymentException {
+
+
+ IPMDLocator loc = null;
+
+ try {
+ loc = node.createLocator(false,locator,getName(), m_locator,
+ null,null,0,forOutPut, false);
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATELOCATOR",new Object[] {node.getProcess().getAttributes().getName(), getName(),this.getScopePath(new BPELScopePath(inCompHandler)).toString()+ BPELScopePath.PATH_DELIMITER+ m_part,"query not specifed"},e);
+ }
+
+ addUsedInLocator(loc);
+
+ return getName();
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELTerminate.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELTerminate.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELTerminate.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELTerminate.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Jul 16, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.action.bpel.TerminateAction;
+import org.apache.ode.definition.IPMDChangeCondition;
+import org.apache.ode.definition.service.DefinitionServiceException;
+
+
+/**
+ * Implements the BPEL <i>terminate</i> node.
+ * <p>
+ * See <A HREF="../../../../../BPEL4WS.xsd">BPEL4WS.xsd</A> - complexType = tTerminate.
+ *
+ * @author waterman
+ */
+class BPELTerminate extends BPELLinkedActivity {
+ private static final Logger logger = Logger.getLogger(BPELTerminate.class.getName());
+
+ /**
+ * @param previous the parent schema node
+ * @param attrs the schema attributes
+ * @throws DefinitionServiceException
+ */
+ BPELTerminate(
+ BPELNode previous,
+ BPELAttributes attrs)
+ throws DeploymentException {
+ super(previous, BPELSchema.TERMINATE, attrs, logger);
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#pop()
+ */
+ BPELNode pop() throws DeploymentException {
+
+ try {
+ IPMDChangeCondition cc = getStartProcess()
+ .createChangeCondition(
+ "ChangeCondition: " + getAttributes().getName(),
+ org.apache.ode.condition.DefaultConditional.class
+ .getName());
+ cc.createAction("TerminateAction:" + getAttributes().getName(),
+ TerminateAction.class.getName());
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATEACTION",new Object[] {getProcess().getAttributes().getName(), getAttributes().getName()},e);
+ }
+
+ return super.pop();
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELLinkedActivity#getActivityDescription()
+ */
+ String getActivityDescription() {
+ return "terminate implements " + TerminateAction.class.getName() + " This action will terminate the process and remove all context.";
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELThrow.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELThrow.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELThrow.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELThrow.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Jul 16, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.action.bpel.ThrowAction;
+import org.apache.ode.definition.IPMDAction;
+import org.apache.ode.definition.IPMDChangeCondition;
+import org.apache.ode.definition.service.DefinitionServiceException;
+
+/**
+ * Implements the BPEL <i>throw</i> node.
+ * <p>
+ * See <A HREF="../../../../../BPEL4WS.xsd">BPEL4WS.xsd</A> - complexType = tThrow.
+ *
+ * @author waterman
+ */
+class BPELThrow extends BPELLinkedActivity {
+ private static final Logger logger = Logger.getLogger(BPELThrow.class.getName());
+
+ /**
+ * @param previous the parent schema node
+ * @param attrs the schema attributes
+ * @throws DefinitionServiceException
+ */
+ BPELThrow(BPELNode previous, BPELAttributes attrs)
+ throws DeploymentException {
+ super(previous, BPELSchema.THROW, attrs, logger);
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#pop()
+ */
+ BPELNode pop() throws DeploymentException {
+
+ try {
+ IPMDChangeCondition cc = getStartProcess().createChangeCondition("Throw: "+getAttributes().getName(),
+ org.apache.ode.condition.DefaultConditional.class.getName());
+ IPMDAction ccact = cc.createAction("Throw: "+getAttributes().getName(),
+ org.apache.ode.action.bpel.ThrowAction.class.getName());
+ QName faultName = getQName(getAttributes().getFaultName());
+ if ( faultName != null ) {
+ ccact.addMetadata(ThrowAction.EXCEPTION_NAME,faultName.getLocalPart());
+ ccact.addMetadata(ThrowAction.EXCEPTION_NS,faultName.getNamespaceURI());
+ }
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATEACTION",new Object[] {getProcess().getAttributes().getName(), getAttributes().getName()},e);
+ }
+
+
+ return super.pop();
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELLinkedActivity#getActivityDescription()
+ */
+ String getActivityDescription() {
+ return "throw is implemented by: " + org.apache.ode.action.bpel.ThrowAction.class.getName() + ". It is an exception thrown by the business process.";
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELTo.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELTo.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELTo.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELTo.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Jul 10, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.util.logging.Logger;
+
+
+/**
+ * Implements the BPEL <i>to</i> node. The to node holds
+ * attributes that define the to values of a <i>copy</i> node
+ * <p>
+ * The to node is held by a <i>copy</i> node.
+ * <p>
+ * See <A HREF="../../../../../BPEL4WS.xsd">BPEL4WS.xsd</A> - complexType = tTo.
+ *
+ * @author waterman
+ * @see BPELCopy
+ *
+ */
+class BPELTo extends BPELNode {
+ private static final Logger logger = Logger.getLogger(BPELTo.class.getName());
+
+
+ /**
+ * @param previous the parent schema node
+ * @param attrs the schema attributes
+ */
+ BPELTo(BPELNode previous, BPELAttributes attrs) {
+ super(previous, BPELSchema.TO, attrs, logger);
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#pop()
+ */
+ BPELNode pop() throws DeploymentException {
+ m_parserStack.addActivity(this);
+ return m_parserStack;
+ }
+
+}