You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2006/12/05 16:54:32 UTC

svn commit: r482693 - in /incubator/ode/trunk: bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ bpel-obj/src/main/java/org/apache/ode/bpel/o/ bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ bpel-schemas/src/main/xsd/ bpel-store/src/mai...

Author: mriou
Date: Tue Dec  5 07:54:29 2006
New Revision: 482693

URL: http://svn.apache.org/viewvc?view=rev&rev=482693
Log:
Made process properties accessible as BPEL variables.

Added:
    incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OConstantVarType.java
Modified:
    incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java
    incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
    incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ExprEvaluationContextImpl.java
    incubator/ode/trunk/bpel-schemas/src/main/xsd/dd.xsd
    incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java

Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java?view=diff&rev=482693&r1=482692&r2=482693
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java Tue Dec  5 07:54:29 2006
@@ -18,14 +18,6 @@
  */
 package org.apache.ode.bpel.compiler;
 
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URI;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ode.bpel.compiler.api.CompilationException;
@@ -38,8 +30,14 @@
 import org.apache.ode.bpel.o.Serializer;
 import org.apache.ode.utils.StreamUtils;
 import org.apache.ode.utils.msg.MessageBundle;
+import org.w3c.dom.Node;
 import org.xml.sax.InputSource;
 
+import javax.xml.namespace.QName;
+import java.io.*;
+import java.net.URI;
+import java.util.Map;
+
 /**
  * <p>
  * Wrapper for {@link org.apache.ode.bpel.compiler.BpelCompiler} implementations,
@@ -47,245 +45,258 @@
  * </p>
  */
 public class BpelC {
-  private static final Log __log = LogFactory.getLog(BpelC.class);
-  private static final CommonCompilationMessages __cmsgs =
-          MessageBundle.getMessages(CommonCompilationMessages.class);
-
-  private CompileListener _compileListener;
-  public OutputStream _outputStream = null;
-  private File _outputDir = null;
-
-  private File _bpelFile;
-  private WsdlFinder _wsdlFinder;
-  private XsltFinder _xsltFinder;
-  private URI _bpel11wsdl;
-
-  public static BpelC newBpelCompiler() {
-    return new BpelC();
-  }
-
-  private BpelC() {
-  }
-
-  protected void finalize() throws Throwable
-  {
-    this.invalidate();
-    super.finalize();
-  }
-
-  private void invalidate() {
-    this.setWsdlFinder(null);
-    this.setCompileListener(null);
-    this.setOutputStream(null);
-    this.setOutputDirectory(null);
-  }
-
-  /**
-   * <p>
-   * Set a non-default target {@link CompileListener} implementation.
-   * </p>
-   * @param cl the listener.
-   */
-  public void setCompileListener(CompileListener cl) {
-    _compileListener = cl;
-  }
-
-  /**
-   * <p>
-   * Tell the compiler how to locate WSDL imports for a BPEL process.  Setting this
-   * to <code>null</code> will cause the default behavior.
-   * </p>
-   * @param finder the {@link WsdlFinder} implementation to use.
-   */
-  public void setWsdlFinder(WsdlFinder finder) {
-    _wsdlFinder = finder;
-  }
-
-  /**
-   * <p>
-   * Tell the compiler how to locate XSLT sheets used in assignment withn a BPEL process.
-   * Setting this to <code>null</code> will cause the default behavior.
-   * </p>
-   * @param finder the {@link XsltFinder} implementation to use.
-   */
-  public void setXsltFinder(XsltFinder finder) {
-    _xsltFinder = finder;
-  }
-
-  /**
-   * Register a "global" WSDL import for compilation. This is used to specify WSDL
-   * imports for BPEL 1.1 processes that do not support the <code>&lt;import&gt;</code>
-   * BPEL construct.
-   * @param wsdl the WSDL URI (resolvable against the resource repository)
-   */
-  public void setProcessWSDL(URI wsdl) {
-    if (__log.isDebugEnabled()) {
-      __log.debug("Adding WSDL import: \"" + wsdl.toASCIIString() + "\".");
-    }
-    _bpel11wsdl = wsdl;
-  }
-
-  /**
-   * Set the output stream to which the compiled representation will be generated. 
-   * @param os compiled representation output stream
-   */
-  public void setOutputStream(OutputStream os) {
-    if (_outputStream != null) {
-      try {
-        _outputStream.close();
-      }
-      catch (IOException ioex) {
-        // ignore
-      }
-    }
-
-    _outputStream = os;
-
-    if (__log.isDebugEnabled()) {
-      __log.debug("Sett output to stream " + os);
-    }
-  }
-
-  /**
-   * <p>
-   * Set the target directory for output.  This overrides {@link #setOutputStream(OutputStream)}.
-   * </p>
-   * @param outputDir the filesystem directory to write the compiled process to.
-   * @see #setOutputStream(OutputStream)
-   */
-  public void setOutputDirectory(File outputDir) {
-    // override any outputStream setting
-    this.setOutputStream(null);
-
-    // check if this is suitable for output
-    if (outputDir != null) {
-      if (outputDir.exists() && outputDir.isDirectory() && outputDir.canWrite()) {
-        _outputDir = outputDir;
+    private static final Log __log = LogFactory.getLog(BpelC.class);
+    private static final CommonCompilationMessages __cmsgs =
+            MessageBundle.getMessages(CommonCompilationMessages.class);
+
+    public static final String PROCESS_CUSTOM_PROPERTIES = "customProps";
+
+    private CompileListener _compileListener;
+    public OutputStream _outputStream = null;
+    private File _outputDir = null;
+
+    private File _bpelFile;
+    private WsdlFinder _wsdlFinder;
+    private XsltFinder _xsltFinder;
+    private URI _bpel11wsdl;
+    private Map<String,Object> _compileProperties;
+
+    public static BpelC newBpelCompiler() {
+        return new BpelC();
+    }
+
+    private BpelC() {
+    }
+
+    protected void finalize() throws Throwable
+    {
+        this.invalidate();
+        super.finalize();
+    }
+
+    private void invalidate() {
+        this.setWsdlFinder(null);
+        this.setCompileListener(null);
+        this.setOutputStream(null);
+        this.setOutputDirectory(null);
+    }
+
+    /**
+     * <p>
+     * Set a non-default target {@link CompileListener} implementation.
+     * </p>
+     * @param cl the listener.
+     */
+    public void setCompileListener(CompileListener cl) {
+        _compileListener = cl;
+    }
+
+    /**
+     * <p>
+     * Tell the compiler how to locate WSDL imports for a BPEL process.  Setting this
+     * to <code>null</code> will cause the default behavior.
+     * </p>
+     * @param finder the {@link WsdlFinder} implementation to use.
+     */
+    public void setWsdlFinder(WsdlFinder finder) {
+        _wsdlFinder = finder;
+    }
+
+    /**
+     * <p>
+     * Tell the compiler how to locate XSLT sheets used in assignment withn a BPEL process.
+     * Setting this to <code>null</code> will cause the default behavior.
+     * </p>
+     * @param finder the {@link XsltFinder} implementation to use.
+     */
+    public void setXsltFinder(XsltFinder finder) {
+        _xsltFinder = finder;
+    }
+
+    /**
+     * Register a "global" WSDL import for compilation. This is used to specify WSDL
+     * imports for BPEL 1.1 processes that do not support the <code>&lt;import&gt;</code>
+     * BPEL construct.
+     * @param wsdl the WSDL URI (resolvable against the resource repository)
+     */
+    public void setProcessWSDL(URI wsdl) {
         if (__log.isDebugEnabled()) {
-          __log.debug("Set output directory to " + outputDir.toURI());
+            __log.debug("Adding WSDL import: \"" + wsdl.toASCIIString() + "\".");
         }
-      } else {
-        throw new IllegalArgumentException("outputDirectory not writeable: " + outputDir.toURI());
-      }
-    }
-  }
-
-  /**
-   * <p>
-   * Compile a BPEL process from a BOM {@link Process} object.
-   * </p>
-   * 
-   * @param process
-   *          the BOM <code>Process</code> to compile.
-   * 
-   * @throws IOException
-   *           if one occurs while processing (e.g., getting imports) or writing
-   *           output.
-   * @throws CompilationException
-   *           if one occurs while compiling.
-   */
-  public void compile(Process process) throws CompilationException, IOException {
+        _bpel11wsdl = wsdl;
+    }
+
+    /**
+     * Compilation properties ebentually retrieved by the compiler 
+     * @param compileProperties
+     */
+    public void setCompileProperties(Map<String, Object> compileProperties) {
+        _compileProperties = compileProperties;
+    }
+
+    /**
+     * Set the output stream to which the compiled representation will be generated.
+     * @param os compiled representation output stream
+     */
+    public void setOutputStream(OutputStream os) {
+        if (_outputStream != null) {
+            try {
+                _outputStream.close();
+            }
+            catch (IOException ioex) {
+                // ignore
+            }
+        }
+
+        _outputStream = os;
+
+        if (__log.isDebugEnabled()) {
+            __log.debug("Sett output to stream " + os);
+        }
+    }
+
+    /**
+     * <p>
+     * Set the target directory for output.  This overrides {@link #setOutputStream(OutputStream)}.
+     * </p>
+     * @param outputDir the filesystem directory to write the compiled process to.
+     * @see #setOutputStream(OutputStream)
+     */
+    public void setOutputDirectory(File outputDir) {
+        // override any outputStream setting
+        this.setOutputStream(null);
+
+        // check if this is suitable for output
+        if (outputDir != null) {
+            if (outputDir.exists() && outputDir.isDirectory() && outputDir.canWrite()) {
+                _outputDir = outputDir;
+                if (__log.isDebugEnabled()) {
+                    __log.debug("Set output directory to " + outputDir.toURI());
+                }
+            } else {
+                throw new IllegalArgumentException("outputDirectory not writeable: " + outputDir.toURI());
+            }
+        }
+    }
+
+    /**
+     * <p>
+     * Compile a BPEL process from a BOM {@link Process} object.
+     * </p>
+     *
+     * @param process
+     *          the BOM <code>Process</code> to compile.
+     *
+     * @throws IOException
+     *           if one occurs while processing (e.g., getting imports) or writing
+     *           output.
+     * @throws CompilationException
+     *           if one occurs while compiling.
+     */
+    public void compile(Process process) throws CompilationException, IOException {
         if (process == null)
             throw new NullPointerException("Attempt to compile NULL process.");
-          
-    logCompilationMessage(__cmsgs.infCompilingProcess());
 
-    BpelCompiler compiler;
-    WsdlFinder wf;
-    XsltFinder xf;
-
-      if (_wsdlFinder != null) {
-        wf = _wsdlFinder;
-      } else {
-        wf = new DefaultWsdlFinder(_bpelFile.getParentFile());
-      }
-
-      if (_xsltFinder != null) {
-        xf = _xsltFinder;
-      } else {
-        xf = new DefaultXsltFinder(_bpelFile.getParentFile());
-      }
-
-    CompileListener clistener = new CompileListener() {
-      public void onCompilationMessage(CompilationMessage compilationMessage) {
-        Object location = compilationMessage.source;
-        if (location == null) {
-          compilationMessage.source = _bpelFile + ":";
-        }
-        if (location instanceof BpelObject) {
-          compilationMessage.source = _bpelFile + ":" + ((BpelObject)location).getLineNo();
-        }
-        logCompilationMessage(compilationMessage);
-      }
-    };
-
-    try {
-    switch (process.getBpelVersion()) {
-      case BPEL20:
-        compiler = new BpelCompiler20();
-        compiler.setCompileListener(clistener);
-        compiler.setWsdlFinder(wf);
-        compiler.setXsltFinder(xf);
-        if (_bpel11wsdl != null) {
-          CompilationMessage cmsg = __cmsgs.warnWsdlUriIgnoredFor20Process();
-          logCompilationMessage(cmsg);
-        }
-        break;
-      case BPEL11:
-        compiler = new BpelCompiler11();
-        compiler.setCompileListener(clistener);
-        compiler.setWsdlFinder(wf);
-        if (_bpel11wsdl != null) {
-          compiler.addWsdlImport(_bpelFile, _bpel11wsdl);
+        logCompilationMessage(__cmsgs.infCompilingProcess());
+
+        BpelCompiler compiler;
+        WsdlFinder wf;
+        XsltFinder xf;
+
+        if (_wsdlFinder != null) {
+            wf = _wsdlFinder;
         } else {
-          CompilationMessage cmsg = __cmsgs.errBpel11RequiresWsdl();
-          logCompilationMessage(cmsg);
-          this.invalidate();
-          throw new CompilationException(cmsg);
-        }
-        break;
-      default:
-        CompilationMessage cmsg = __cmsgs.errUnrecognizedBpelVersion();
-        logCompilationMessage(cmsg);
-        this.invalidate();
-        throw new CompilationException(cmsg);
-    }
-    } catch (CompilationException ce) {
-        this.invalidate();
-        throw ce;
-    } catch (Exception ex) {
-        CompilationMessage cmsg = __cmsgs.errBpelParseErr();
-        logCompilationMessage(cmsg);
-        this.invalidate();
-        throw new CompilationException(cmsg,ex);
-    }
-    
-    OProcess oprocess;
-    try {
-      oprocess = compiler.compile(_bpelFile, process);
-    }
-    catch (CompilationException cex) {
-      this.invalidate();
-      throw cex;
-    }
-
-    if (_outputStream != null) {
-      if (__log.isDebugEnabled()) {
-        __log.debug("Writing compilation results to " + _outputStream.getClass().getName());
-      }
-    } else if (_outputDir != null) {
-      File outFile = new File(_outputDir, oprocess.getName() + ".cbp");
-      this.setOutputStream(new BufferedOutputStream(new FileOutputStream(outFile)));
-      if (__log.isDebugEnabled()) {
-        __log.debug("Writing compilation results to " + outFile.toURI().toString());
-      }
-    } else {
-      throw new IllegalStateException("must setOutputStream() or setOutputDirectory()!");
-    }
-
-    try {
-      Serializer fileHeader = new Serializer(System.currentTimeMillis());
-      fileHeader.writeOProcess(oprocess, _outputStream);
+            wf = new DefaultWsdlFinder(_bpelFile.getParentFile());
+        }
+
+        if (_xsltFinder != null) {
+            xf = _xsltFinder;
+        } else {
+            xf = new DefaultXsltFinder(_bpelFile.getParentFile());
+        }
+
+        CompileListener clistener = new CompileListener() {
+            public void onCompilationMessage(CompilationMessage compilationMessage) {
+                Object location = compilationMessage.source;
+                if (location == null) {
+                    compilationMessage.source = _bpelFile + ":";
+                }
+                if (location instanceof BpelObject) {
+                    compilationMessage.source = _bpelFile + ":" + ((BpelObject)location).getLineNo();
+                }
+                logCompilationMessage(compilationMessage);
+            }
+        };
+
+        try {
+            switch (process.getBpelVersion()) {
+                case BPEL20:
+                    compiler = new BpelCompiler20();
+                    compiler.setXsltFinder(xf);
+                    if (_bpel11wsdl != null) {
+                        CompilationMessage cmsg = __cmsgs.warnWsdlUriIgnoredFor20Process();
+                        logCompilationMessage(cmsg);
+                    }
+                    break;
+                case BPEL11:
+                    compiler = new BpelCompiler11();
+                    if (_bpel11wsdl != null) {
+                        compiler.addWsdlImport(_bpelFile, _bpel11wsdl);
+                    } else {
+                        CompilationMessage cmsg = __cmsgs.errBpel11RequiresWsdl();
+                        logCompilationMessage(cmsg);
+                        this.invalidate();
+                        throw new CompilationException(cmsg);
+                    }
+                    break;
+                default:
+                    CompilationMessage cmsg = __cmsgs.errUnrecognizedBpelVersion();
+                    logCompilationMessage(cmsg);
+                    this.invalidate();
+                    throw new CompilationException(cmsg);
+            }
+            compiler.setCompileListener(clistener);
+            compiler.setWsdlFinder(wf);
+            if (_compileProperties != null) {
+                if (_compileProperties.get(PROCESS_CUSTOM_PROPERTIES) != null)
+                    compiler.setCustomProperties((Map<QName, Node>) _compileProperties.get(PROCESS_CUSTOM_PROPERTIES));
+            }
+        } catch (CompilationException ce) {
+            this.invalidate();
+            throw ce;
+        } catch (Exception ex) {
+            CompilationMessage cmsg = __cmsgs.errBpelParseErr();
+            logCompilationMessage(cmsg);
+            this.invalidate();
+            throw new CompilationException(cmsg,ex);
+        }
+
+        OProcess oprocess;
+        try {
+            oprocess = compiler.compile(_bpelFile, process);
+        }
+        catch (CompilationException cex) {
+            this.invalidate();
+            throw cex;
+        }
+
+        if (_outputStream != null) {
+            if (__log.isDebugEnabled()) {
+                __log.debug("Writing compilation results to " + _outputStream.getClass().getName());
+            }
+        } else if (_outputDir != null) {
+            File outFile = new File(_outputDir, oprocess.getName() + ".cbp");
+            this.setOutputStream(new BufferedOutputStream(new FileOutputStream(outFile)));
+            if (__log.isDebugEnabled()) {
+                __log.debug("Writing compilation results to " + outFile.toURI().toString());
+            }
+        } else {
+            throw new IllegalStateException("must setOutputStream() or setOutputDirectory()!");
+        }
+
+        try {
+            Serializer fileHeader = new Serializer(System.currentTimeMillis());
+            fileHeader.writeOProcess(oprocess, _outputStream);
 
 //      if (_bpelFile.toString().startsWith("file:") && _outputDir != null) {
 //        String filePath = _bpelFile.getFile();
@@ -308,76 +319,76 @@
 //      } else {
 //        __log.warn("Post-compilation using deployment descriptor deactivated (compilation from url or stream).");
 //      }
-    } finally {
-      // close & mark myself invalid
-      this.invalidate();
-    }
-  }
-
-  /**
-   * <p>
-   * Compile a BPEL process from a URL.  This method uses a {@link BpelProcessBuilder}
-   * to parse the XML and then calls {@link #compile(Process)}.
-   * </p>
-   * @param bpelFile the URL of the BPEL process to be compiled.
-   * @throws IOException if one occurs while reading the BPEL process or writing the
-   * output.
-   * @throws CompilationException if one occurs while compiling the process.
-   */
-  public void compile(File bpelFile) throws CompilationException, IOException {
-    if (__log.isDebugEnabled()) {
-      __log.debug("compile(URL)");
-    }
-
-    if (bpelFile == null) {
-      this.invalidate();
-      throw new IllegalArgumentException("Null bpelFile");
-    }
-
-    _bpelFile = bpelFile;
-    Process process;
-    try {
-      InputSource isrc = new InputSource(new ByteArrayInputStream(StreamUtils.read(bpelFile.toURL())));
-      isrc.setSystemId(bpelFile.getAbsolutePath());
-      
-      process = BpelObjectFactory.getInstance().parse(isrc);
-      
-
-    } catch (Exception e) {
-      CompilationMessage cmsg = __cmsgs.errBpelParseErr().setSource(bpelFile.getAbsolutePath());
-      this.invalidate();
-      throw new CompilationException(cmsg, e);
-    }
-
-    assert process != null;
-    
-    compile(process);
-    this.invalidate();
-  }
-
-
-  /**
-   * Log a compilation message, both to the log, and to the listener (if any).
-   * @param cmsg
-   */
-  private void logCompilationMessage(CompilationMessage cmsg) {
-    if (_compileListener != null) {
-      _compileListener.onCompilationMessage(cmsg);
-    } else {
-      switch (cmsg.severity) {
-        case CompilationMessage.ERROR:
-          if (__log.isErrorEnabled())
-            __log.error(cmsg.toErrorString());
-          break;
-        case CompilationMessage.INFO:
-          if (__log.isInfoEnabled())
-            __log.info(cmsg.toErrorString());
-          break;
-        case CompilationMessage.WARN:
-          if (__log.isWarnEnabled())
-            __log.warn(cmsg.toErrorString());
-      }
+        } finally {
+            // close & mark myself invalid
+            this.invalidate();
+        }
+    }
+
+    /**
+     * <p>
+     * Compile a BPEL process from a URL.  This method uses a {@link BpelProcessBuilder}
+     * to parse the XML and then calls {@link #compile(Process)}.
+     * </p>
+     * @param bpelFile the URL of the BPEL process to be compiled.
+     * @throws IOException if one occurs while reading the BPEL process or writing the
+     * output.
+     * @throws CompilationException if one occurs while compiling the process.
+     */
+    public void compile(File bpelFile) throws CompilationException, IOException {
+        if (__log.isDebugEnabled()) {
+            __log.debug("compile(URL)");
+        }
+
+        if (bpelFile == null) {
+            this.invalidate();
+            throw new IllegalArgumentException("Null bpelFile");
+        }
+
+        _bpelFile = bpelFile;
+        Process process;
+        try {
+            InputSource isrc = new InputSource(new ByteArrayInputStream(StreamUtils.read(bpelFile.toURL())));
+            isrc.setSystemId(bpelFile.getAbsolutePath());
+
+            process = BpelObjectFactory.getInstance().parse(isrc);
+
+
+        } catch (Exception e) {
+            CompilationMessage cmsg = __cmsgs.errBpelParseErr().setSource(bpelFile.getAbsolutePath());
+            this.invalidate();
+            throw new CompilationException(cmsg, e);
+        }
+
+        assert process != null;
+
+        compile(process);
+        this.invalidate();
+    }
+
+
+    /**
+     * Log a compilation message, both to the log, and to the listener (if any).
+     * @param cmsg
+     */
+    private void logCompilationMessage(CompilationMessage cmsg) {
+        if (_compileListener != null) {
+            _compileListener.onCompilationMessage(cmsg);
+        } else {
+            switch (cmsg.severity) {
+                case CompilationMessage.ERROR:
+                    if (__log.isErrorEnabled())
+                        __log.error(cmsg.toErrorString());
+                    break;
+                case CompilationMessage.INFO:
+                    if (__log.isInfoEnabled())
+                        __log.info(cmsg.toErrorString());
+                    break;
+                case CompilationMessage.WARN:
+                    if (__log.isWarnEnabled())
+                        __log.warn(cmsg.toErrorString());
+            }
+        }
     }
-  }
 
 }

Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java?view=diff&rev=482693&r1=482692&r2=482693
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java Tue Dec  5 07:54:29 2006
@@ -18,87 +18,15 @@
  */
 package org.apache.ode.bpel.compiler;
 
-import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Stack;
-
-import javax.wsdl.Definition;
-import javax.wsdl.Message;
-import javax.wsdl.Operation;
-import javax.wsdl.Part;
-import javax.wsdl.PortType;
-import javax.wsdl.WSDLException;
-import javax.wsdl.xml.WSDLReader;
-import javax.xml.namespace.QName;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.compiler.api.CompilationException;
-import org.apache.ode.bpel.compiler.api.CompilationMessage;
-import org.apache.ode.bpel.compiler.api.CompileListener;
-import org.apache.ode.bpel.compiler.api.CompilerContext;
-import org.apache.ode.bpel.compiler.api.ExpressionCompiler;
-import org.apache.ode.bpel.compiler.bom.Activity;
-import org.apache.ode.bpel.compiler.bom.Bpel11QNames;
-import org.apache.ode.bpel.compiler.bom.Bpel20QNames;
-import org.apache.ode.bpel.compiler.bom.BpelObject;
-import org.apache.ode.bpel.compiler.bom.Catch;
-import org.apache.ode.bpel.compiler.bom.CompensationHandler;
-import org.apache.ode.bpel.compiler.bom.Correlation;
-import org.apache.ode.bpel.compiler.bom.CorrelationSet;
-import org.apache.ode.bpel.compiler.bom.Expression;
-import org.apache.ode.bpel.compiler.bom.FaultHandler;
+import org.apache.ode.bpel.compiler.api.*;
+import org.apache.ode.bpel.compiler.bom.*;
 import org.apache.ode.bpel.compiler.bom.Import;
-import org.apache.ode.bpel.compiler.bom.LinkSource;
-import org.apache.ode.bpel.compiler.bom.LinkTarget;
-import org.apache.ode.bpel.compiler.bom.OnAlarm;
-import org.apache.ode.bpel.compiler.bom.OnEvent;
-import org.apache.ode.bpel.compiler.bom.PartnerLink;
-import org.apache.ode.bpel.compiler.bom.PartnerLinkType;
 import org.apache.ode.bpel.compiler.bom.Process;
-import org.apache.ode.bpel.compiler.bom.Property;
-import org.apache.ode.bpel.compiler.bom.PropertyAlias;
-import org.apache.ode.bpel.compiler.bom.Scope;
-import org.apache.ode.bpel.compiler.bom.ScopeActivity;
-import org.apache.ode.bpel.compiler.bom.ScopeLikeActivity;
-import org.apache.ode.bpel.compiler.bom.TerminationHandler;
-import org.apache.ode.bpel.compiler.bom.Variable;
 import org.apache.ode.bpel.compiler.wsdl.Definition4BPEL;
 import org.apache.ode.bpel.compiler.wsdl.WSDLFactory4BPEL;
-import org.apache.ode.bpel.o.DebugInfo;
-import org.apache.ode.bpel.o.OActivity;
-import org.apache.ode.bpel.o.OAssign;
-import org.apache.ode.bpel.o.OCatch;
-import org.apache.ode.bpel.o.OCompensate;
-import org.apache.ode.bpel.o.OCompensationHandler;
-import org.apache.ode.bpel.o.OConstantExpression;
-import org.apache.ode.bpel.o.OConstants;
-import org.apache.ode.bpel.o.OElementVarType;
-import org.apache.ode.bpel.o.OEventHandler;
-import org.apache.ode.bpel.o.OExpression;
-import org.apache.ode.bpel.o.OExpressionLanguage;
-import org.apache.ode.bpel.o.OFaultHandler;
-import org.apache.ode.bpel.o.OFlow;
-import org.apache.ode.bpel.o.OLValueExpression;
-import org.apache.ode.bpel.o.OLink;
-import org.apache.ode.bpel.o.OMessageVarType;
-import org.apache.ode.bpel.o.OPartnerLink;
-import org.apache.ode.bpel.o.OProcess;
-import org.apache.ode.bpel.o.ORethrow;
-import org.apache.ode.bpel.o.OScope;
-import org.apache.ode.bpel.o.OSequence;
-import org.apache.ode.bpel.o.OTerminationHandler;
-import org.apache.ode.bpel.o.OVarType;
-import org.apache.ode.bpel.o.OXsdTypeVarType;
-import org.apache.ode.bpel.o.OXslSheet;
+import org.apache.ode.bpel.o.*;
 import org.apache.ode.utils.GUID;
 import org.apache.ode.utils.NSContext;
 import org.apache.ode.utils.fs.FileUtils;
@@ -106,6 +34,15 @@
 import org.apache.ode.utils.stl.CollectionsX;
 import org.apache.ode.utils.stl.MemberOfFunction;
 import org.apache.ode.utils.stl.UnaryFunction;
+import org.w3c.dom.Node;
+
+import javax.wsdl.*;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.*;
 
 
 /**
@@ -154,6 +91,8 @@
     private WSDLFactory4BPEL _wsdlFactory;
     private OExpressionLanguage _konstExprLang;
 
+    private Map<QName,Node> _customProcessProperties;
+
     BpelCompiler(WSDLFactory4BPEL wsdlFactory) {
         _wsdlFactory = wsdlFactory;
         setWsdlFinder(null);
@@ -204,6 +143,10 @@
         return _compileListener;
     }
 
+    public void setCustomProperties(Map<QName, Node> customProperties) {
+        _customProcessProperties = customProperties;
+    }
+
     /**
      * Get the process definition.
      *
@@ -216,7 +159,7 @@
     public PortType resolvePortType(final QName portTypeName) {
         if (portTypeName == null)
             throw new NullPointerException("Null portTypeName argument!");
-        
+
         PortType portType = _wsdlRegistry.getPortType(portTypeName);
         if (portType == null)
             throw new CompilationException(__cmsgs.errUndeclaredPortType(portTypeName));
@@ -244,6 +187,10 @@
             if (var != null)
                 return var;
         }
+        // A "real" variable couldn't be found, checking if we're dealing with a process custom property
+        if (_customProcessProperties != null && _customProcessProperties.get(varName) != null) {
+
+        }
         throw new CompilationException(__cmsgs.errUndeclaredVariable(varName));
     }
 
@@ -614,9 +561,23 @@
         procesScope.debugInfo = createDebugInfo(process, null);
         _oprocess.procesScope = compileScope(procesScope, process, new Runnable() {
             public void run() {
-            	if (process.getRootActivity() == null) {
+                if (process.getRootActivity() == null) {
                     throw new CompilationException(__cmsgs.errNoRootActivity());
-            	}            		
+                }
+                // Process custom properties are created as variables associated with the top scope
+                if (_customProcessProperties != null) {
+                    for (Map.Entry<QName, Node> customVar : _customProcessProperties.entrySet()) {
+                        final OScope oscope = _structureStack.topScope();
+                        OVarType varType = new OConstantVarType(_oprocess, customVar.getValue());
+                        OScope.Variable ovar = new OScope.Variable(_oprocess, varType);
+                        ovar.name = customVar.getKey().getLocalPart();
+                        ovar.declaringScope = oscope;
+                        ovar.debugInfo = createDebugInfo(null, "Process custom property variable");
+                        oscope.addLocalVariable(ovar);
+                        if (__log.isDebugEnabled())
+                            __log.debug("Compiled custom property variable " + ovar);
+                    }
+                }
                 _structureStack.topScope().activity = compile(process.getRootActivity());
             }
         });
@@ -778,7 +739,7 @@
 
         return implicitScope;
     }
-    
+
     private OActivity compileActivity(final boolean doLinks, final Activity source) {
         final ActivityGenerator actgen = findActivityGen(source);
         final OActivity oact = actgen.newInstance(source);
@@ -1213,7 +1174,6 @@
         if (oscope.getLocalVariable(src.getName()) != null)
             throw new CompilationException(__cmsgs.errDuplicateVariableDecl(src.getName()).setSource(src));
 
-
         OVarType varType;
         switch (src.getKind()) {
             case ELEMENT:
@@ -1229,7 +1189,6 @@
                 throw new CompilationException(__cmsgs.errUnrecognizedVariableDeclaration(src.getName()));
         }
 
-
         OScope.Variable ovar = new OScope.Variable(_oprocess, varType);
         ovar.name = src.getName();
         ovar.declaringScope = oscope;
@@ -1486,6 +1445,11 @@
             return scopeStack.isEmpty() ? null : scopeStack.get(scopeStack.size() -1);
         }
 
+        public OScope rootScope() {
+            for (OActivity oActivity : _stack)
+                if (oActivity instanceof OScope) return (OScope) oActivity;
+            return null;
+        }
 
         public OActivity pop() {
             return _stack.pop();

Added: incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OConstantVarType.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OConstantVarType.java?view=auto&rev=482693
==============================================================================
--- incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OConstantVarType.java (added)
+++ incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OConstantVarType.java Tue Dec  5 07:54:29 2006
@@ -0,0 +1,33 @@
+package org.apache.ode.bpel.o;
+
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+public class OConstantVarType extends OVarType {
+    private String value;
+    private transient Node nodeValue;
+
+    public OConstantVarType(OProcess owner, Node value) {
+        super(owner);
+        this.value = DOMUtils.domToString(value);
+    }
+
+    public Node newInstance(Document doc) {
+        return getValue();
+    }
+
+    public Node getValue() {
+        if (nodeValue == null)
+            try {
+                nodeValue = DOMUtils.stringToDOM(value);
+            } catch (Exception e) {
+                // Highly unexpected
+                throw new RuntimeException(e);
+            }
+        return nodeValue;
+    }
+}

Modified: incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ExprEvaluationContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ExprEvaluationContextImpl.java?view=diff&rev=482693&r1=482692&r2=482693
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ExprEvaluationContextImpl.java (original)
+++ incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ExprEvaluationContextImpl.java Tue Dec  5 07:54:29 2006
@@ -22,12 +22,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.ode.bpel.common.FaultException;
 import org.apache.ode.bpel.explang.EvaluationContext;
-import org.apache.ode.bpel.o.OExpression;
-import org.apache.ode.bpel.o.OLink;
-import org.apache.ode.bpel.o.OMessageVarType;
+import org.apache.ode.bpel.o.*;
 import org.apache.ode.bpel.o.OMessageVarType.Part;
-import org.apache.ode.bpel.o.OProcess;
-import org.apache.ode.bpel.o.OScope;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
@@ -76,9 +72,13 @@
         // TODO: check for null _scopeInstance
 
         Node ret;
-        VariableInstance varInstance = _scopeInstance.resolve(variable);
-        if (varInstance == null) return null;
-        ret = _native.fetchVariableData(varInstance, part, false);
+        if (variable.type instanceof OConstantVarType) {
+            ret = ((OConstantVarType)variable.type).getValue();
+        } else {
+            VariableInstance varInstance = _scopeInstance.resolve(variable);
+            if (varInstance == null) return null;
+            ret = _native.fetchVariableData(varInstance, part, false);
+        }
         return ret;
     }
 

Modified: incubator/ode/trunk/bpel-schemas/src/main/xsd/dd.xsd
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-schemas/src/main/xsd/dd.xsd?view=diff&rev=482693&r1=482692&r2=482693
==============================================================================
--- incubator/ode/trunk/bpel-schemas/src/main/xsd/dd.xsd (original)
+++ incubator/ode/trunk/bpel-schemas/src/main/xsd/dd.xsd Tue Dec  5 07:54:29 2006
@@ -96,6 +96,7 @@
                     </xs:sequence>
 
                     <xs:attribute name="name" type="xs:QName" use="required"/>
+                    <xs:attribute name="fileName" type="xs:string" use="optional"/>
 
                 </xs:complexType>
             </xs:element>

Modified: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java?view=diff&rev=482693&r1=482692&r2=482693
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java (original)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java Tue Dec  5 07:54:29 2006
@@ -1,21 +1,5 @@
 package org.apache.ode.store;
 
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
-
-import javax.wsdl.Definition;
-import javax.wsdl.WSDLException;
-import javax.wsdl.xml.WSDLReader;
-import javax.xml.namespace.QName;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ode.bpel.compiler.BpelC;
@@ -29,6 +13,14 @@
 import org.apache.ode.bpel.dd.TDeployment.Process;
 import org.apache.ode.bpel.iapi.ContextException;
 import org.apache.ode.bpel.o.Serializer;
+import org.w3c.dom.Node;
+
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import java.io.*;
+import java.util.*;
 
 /**
  * Container providing various functions on the deployment directory.
@@ -43,7 +35,7 @@
     private String _name;
     private File _duDirectory;
     private File _descriptorFile;
-    
+
     private HashMap<QName, CBPInfo> _processes = new HashMap<QName,CBPInfo>();
     private HashMap<QName, TDeployment.Process> _processInfo = new HashMap<QName,TDeployment.Process>();
 
@@ -119,11 +111,11 @@
         for (TDeployment.Process p : getDeploymentDescriptor().getDeploy().getProcessList()) {
             processInfo.put(p.getName(), p);
         }
-        
+
         _processInfo = processInfo;
 
     }
-    
+
     boolean isRemoved() {
         return !_duDirectory.exists();
     }
@@ -133,6 +125,7 @@
         bpelc.setOutputDirectory(_duDirectory);
         bpelc.setWsdlFinder(new DefaultWsdlFinder(_duDirectory));
         bpelc.setXsltFinder(new DefaultXsltFinder(_duDirectory));
+        bpelc.setCompileProperties(prepareCompileProperties(bpelFile));
         try {
             bpelc.compile(bpelFile);
         } catch (IOException e) {
@@ -140,7 +133,6 @@
         }
     }
 
-
     /**
      * Load the parsed and compiled BPEL process definition.
      */
@@ -271,16 +263,30 @@
         return result;
     }
 
-    
+
     public final class CBPInfo {
         final QName processName;
         final String guid;
         final File cbp;
-        
+
         CBPInfo(QName processName, String guid, File cbp) {
             this.processName = processName;
             this.guid = guid;
             this.cbp = cbp;
         }
     }
+
+    private Map<String, Object> prepareCompileProperties(File bpelFile) {
+        List<Process> plist = getDeploymentDescriptor().getDeploy().getProcessList();
+        for (Process process : plist) {
+            if (bpelFile.getName().equals(process.getFileName())) {
+                Map<QName, Node> props = ProcessStoreImpl.calcInitialProperties(process);
+                Map<String, Object> result = new HashMap<String, Object>();
+                result.put(BpelC.PROCESS_CUSTOM_PROPERTIES, props);
+                return result;
+            }
+        }
+        return null;
+    }
+
 }