Author: rr
Date: Fri Aug 14 00:24:42 2009
New Revision: 804065
URL: http://svn.apache.org/viewvc?rev=804065&view=rev
Log:
ODE-650: Provide expression validation interface for bpel compiler
Added:
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ExpressionValidatorFactory.java
(with props)
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/ExpressionValidator.java
(with props)
Modified:
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGenerator.java
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/CompilerContext.java
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/ExpressionCompiler.java
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xquery10/compiler/XQuery10ExpressionCompilerImpl.java
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/XPathTest.java
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/MockCompilerContext.java
Modified:
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGenerator.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGenerator.java?rev=804065&r1=804064&r2=804065&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGenerator.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGenerator.java
Fri Aug 14 00:24:42 2009
@@ -34,6 +34,7 @@
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.OVarType;
import org.apache.ode.bpel.o.OAssign.RValue;
import org.apache.ode.bpel.o.OMessageVarType;
import org.apache.ode.utils.DOMUtils;
@@ -71,13 +72,15 @@
ocopy.debugInfo = new DebugInfo(_context.getSourceLocation(),
scopy.getLineNo(),
source.getExtensibilityElements());
try {
- if (scopy.getFrom() == null)
- throw new
CompilationException(__cmsgs.errMissingFromSpec().setSource(scopy));
- ocopy.from = compileFrom(scopy.getFrom());
if (scopy.getTo() == null)
throw new
CompilationException(__cmsgs.errMissingToSpec().setSource(scopy));
- ocopy.to = compileTo(scopy.getTo());
+ Object[] toResultType = new Object[1];
+ ocopy.to = compileTo(scopy.getTo(), toResultType);
+ if (scopy.getFrom() == null)
+ throw new
CompilationException(__cmsgs.errMissingFromSpec().setSource(scopy));
+ ocopy.from = compileFrom(scopy.getFrom(), toResultType[0]);
+
verifyCopy(ocopy);
oassign.copy.add(ocopy);
@@ -150,7 +153,7 @@
__log.debug("Copy verified OK: " + ocopy);
}
- private OAssign.RValue compileFrom(From from) {
+ private OAssign.RValue compileFrom(From from, Object requestedResultType) {
assert from != null;
try {
if (from.isExtensionVal()) {
@@ -167,16 +170,19 @@
VariableVal vv = from.getAsVariableVal();
OAssign.VariableRef vref = new
OAssign.VariableRef(_context.getOProcess());
vref.variable = _context.resolveVariable(vv.getVariable());
+ OVarType rootNodeType = vref.variable.type;
if (vv.getPart() != null) {
vref.part = _context.resolvePart(vref.variable,
vv.getPart());
+ rootNodeType = vref.part.type;
}
if (vv.getHeader() != null) {
vref.headerPart =
_context.resolveHeaderPart(vref.variable, vv.getHeader());
if (vref.headerPart == null)
vref.headerPart = new
OMessageVarType.Part(_context.getOProcess(), vv.getHeader(), null);
+ rootNodeType = vref.headerPart.type;
}
if (vv.getLocation() != null &&
vv.getLocation().getExpression() != null)
- vref.location = _context.compileExpr(vv.getLocation());
+ vref.location = _context.compileExpr(vv.getLocation(),
rootNodeType, requestedResultType, new Object[1]);
return vref;
} else if (from.isPartnerLinkVal()) {
PartnerLinkVal plv = from.getAsPartnerLinkVal();
@@ -185,7 +191,7 @@
plref.isMyEndpointReference = (plv.getEndpointReference() ==
PartnerLinkVal.EndpointReference.MYROLE);
return plref;
} else if (from.getAsExpression() != null) {
- return new OAssign.Expression(_context.getOProcess(),
_context.compileExpr(from.getAsExpression()));
+ return new OAssign.Expression(_context.getOProcess(),
_context.compileExpr(from.getAsExpression(), null, requestedResultType, new
Object[1]));
}
throw new
CompilationException(__cmsgs.errUnkownFromSpec().setSource(from));
@@ -219,7 +225,7 @@
return new OAssign.Literal(_context.getOProcess(), newDoc);
}
- private OAssign.LValue compileTo(To to) {
+ private OAssign.LValue compileTo(To to, Object[] resultType) {
assert to != null;
try {
@@ -232,16 +238,20 @@
VariableVal vv = to.getAsVariableVal();
OAssign.VariableRef vref = new
OAssign.VariableRef(_context.getOProcess());
vref.variable = _context.resolveVariable(vv.getVariable());
+ OVarType rootNodeType = vref.variable.type;
if (to.getAsVariableVal().getPart() != null) {
vref.part = _context.resolvePart(vref.variable,
vv.getPart());
+ rootNodeType = vref.part.type;
}
if (to.getAsVariableVal().getHeader() != null) {
vref.headerPart =
_context.resolveHeaderPart(vref.variable, vv.getHeader());
if (vref.headerPart == null)
vref.headerPart = new
OMessageVarType.Part(_context.getOProcess(), to.getAsVariableVal().getHeader(),
null);
+ rootNodeType = vref.headerPart.type;
}
+ resultType[0] = rootNodeType;
if (vv.getLocation() != null &&
vv.getLocation().getExpression() != null)
- vref.location = _context.compileExpr(vv.getLocation());
+ vref.location = _context.compileExpr(vv.getLocation(),
rootNodeType, null, resultType);
return vref;
} else if (to.isPartnerLinkVal()) {
OAssign.PartnerLinkRef plref = new
OAssign.PartnerLinkRef(_context.getOProcess());
@@ -249,7 +259,7 @@
return plref;
} else if (to.getAsExpression() != null){
return new OAssign.LValueExpression(_context.getOProcess(),
_context
- .compileLValueExpr(to.getAsExpression()));
+ .compileLValueExpr(to.getAsExpression(), null, null,
resultType));
}
throw new
CompilationException(__cmsgs.errUnknownToSpec().setSource(to));
Modified:
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java?rev=804065&r1=804064&r2=804065&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
Fri Aug 14 00:24:42 2009
@@ -52,6 +52,7 @@
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.api.ExpressionValidator;
import org.apache.ode.bpel.compiler.api.SourceLocation;
import org.apache.ode.bpel.compiler.bom.Activity;
import org.apache.ode.bpel.compiler.bom.Bpel11QNames;
@@ -171,6 +172,8 @@
private final HashMap<String, ExpressionCompiler> _expLanguageCompilers =
new HashMap<String, ExpressionCompiler>();
private final HashMap<String, OExpressionLanguage> _expLanguages = new
HashMap<String, OExpressionLanguage>();
+
+ private ExpressionValidatorFactory _expressionValidatorFactory = new
ExpressionValidatorFactory(System.getProperties());
private WSDLFactory4BPEL _wsdlFactory;
@@ -532,30 +535,45 @@
}
public OLValueExpression compileLValueExpr(Expression expression) throws
CompilationException {
- return (OLValueExpression) compileExpr(expression, false, true);
+ return compileLValueExpr(expression, null, null, new Object[1]);
+ }
+
+ public OLValueExpression compileLValueExpr(Expression expression, OVarType
rootNodeType, Object requestedResultType, Object[] resultType) throws
CompilationException {
+ return (OLValueExpression) compileExpr(expression, false, true,
rootNodeType, requestedResultType, resultType);
}
public OExpression compileJoinCondition(Expression expression) throws
CompilationException {
- return compileExpr(expression, true, false);
+ return compileExpr(expression, true, false, null, null, new Object[1]);
}
public OExpression compileExpr(Expression expression) throws
CompilationException {
- return compileExpr(expression, false, false);
+ return compileExpr(expression, null, null, new Object[1]);
+ }
+
+ public OExpression compileExpr(Expression expression, OVarType
rootNodeType, Object requestedResultType, Object[] resultType) throws
CompilationException {
+ return compileExpr(expression, false, false, rootNodeType,
requestedResultType, resultType);
}
public OExpression compileExpr(String expr, NSContext nc) {
// Does this really work?
BpelObject cur = _structureStack.topSource();
- return compileExpr(new
Expression11(cur.getElement(),cur.getElement().getOwnerDocument().createTextNode(expr)),false,false);
+ return compileExpr(new
Expression11(cur.getElement(),cur.getElement().getOwnerDocument().createTextNode(expr)),
false, false, null, null, new Object[1]);
}
- private OExpression compileExpr(Expression expression, boolean
isJoinCondition, boolean isLValue) {
+ private OExpression compileExpr(Expression expression, boolean
isJoinCondition, boolean isLValue, OVarType rootNodeType, Object
requestedResultType, Object[] resultType) {
String expLang = getExpressionLanguage(expression);
ExpressionCompiler ec = findExpLangCompiler(expLang);
ec.setCompilerContext(this);
+ ExpressionValidator ev = _expressionValidatorFactory.getValidator();
try {
- OExpression oexpr = (isJoinCondition) ?
ec.compileJoinCondition(expression) : ec.compile(expression);
+ OExpression oexpr;
+ if (isJoinCondition) {
+ oexpr = ec.compileJoinCondition(expression);
+ } else {
+ oexpr = ec.compile(expression);
+ resultType[0] = ev.validate(expression, rootNodeType,
requestedResultType);
+ }
oexpr.debugInfo = createDebugInfo(expression,
expression.toString());
@@ -683,6 +701,8 @@
}
}
+
_expressionValidatorFactory.getValidator().bpelImportsLoaded(_processDef, this);
+
switch (_processDef.getSuppressJoinFailure()) {
case NO:
case NOTSET:
@@ -748,6 +768,8 @@
XslTransformHandler.getInstance().clearXSLSheets(_oprocess.getQName());
+
_expressionValidatorFactory.getValidator().bpelCompilationCompleted(_processDef);
+
if (hasErrors) {
throw new
CompilationException(__cmsgs.errCompilationErrors(_errors.size(),
sb.toString()));
}
@@ -781,7 +803,7 @@
}
private String getOdeNamespace() {
- return Namespaces.ODE_EXTENSION_NS;
+ return Namespaces.ODE_EXTENSION_NS;
}
// TODO unused?
@@ -975,6 +997,7 @@
}
OMessageVarType messageType = resolveMessageType(src.getMessageType());
+ OVarType rootNodeType = messageType;
alias.varType = messageType;
// bpel 2.0 excludes declaration of part;
// bpel 1.1 requires it
@@ -983,9 +1006,10 @@
if (alias.part == null)
throw new
CompilationException(__cmsgs.errUnknownPartInAlias(src.getPart(),
messageType.messageType.toString()));
+ rootNodeType = alias.part.type;
}
if (src.getQuery() != null)
- alias.location = compileExpr(src.getQuery());
+ alias.location = compileExpr(src.getQuery(), rootNodeType, null,
new Object[1]);
property.aliases.add(alias);
alias.debugInfo = createDebugInfo(_processDef, src.getMessageType() +
" --> " + src.getPropertyName());
return alias;
@@ -1298,12 +1322,12 @@
Set<String> csetNames = new HashSet<String>(); // prevents
duplicate cset in on one set of correlations
for (Correlation correlation : onEvent.getCorrelations()) {
- if( csetNames.contains(correlation.getCorrelationSet()
) ) {
+ if( csetNames.contains(correlation.getCorrelationSet() ) )
{
throw new
CompilationException(__cmsgs.errDuplicateUseCorrelationSet(correlation
.getCorrelationSet()));
- }
+ }
- OScope.CorrelationSet cset =
resolveCorrelationSet(correlation.getCorrelationSet());
+ OScope.CorrelationSet cset =
resolveCorrelationSet(correlation.getCorrelationSet());
switch (correlation.getInitiate()) {
case UNSET:
@@ -1315,7 +1339,7 @@
oevent.initCorrelations.add(cset);
break;
case JOIN:
- cset.hasJoinUseCases = true;
+ cset.hasJoinUseCases = true;
oevent.joinCorrelations.add(cset);
oevent.partnerLink.addCorrelationSetForOperation(oevent.operation, cset, true);
}
@@ -1678,26 +1702,20 @@
return rval;
}
- public Map<URI, Source> getSchemaSources() {
- Map<URI, Document> schemaBytes = _wsdlRegistry.getSchemaDocuments();
- Map<URI, Source> schemaSources = new HashMap<URI, Source>();
- for (URI uri : schemaBytes.keySet()) {
- Document document = schemaBytes.get(uri);
- schemaSources.put(uri, new DOMSource(document));
- }
- return schemaSources;
+ public Map<URI, Source> getSchemaSources() {
+ return _wsdlRegistry.getSchemaSources();
}
- /**
- * Retrieves the base URI that the BPEL Process execution contextis
running relative to.
- *
- * @return URI - the URI representing the absolute physical file path
location that this process is defined within.
- * @throws IOException
- * @throws MalformedURLException
- */
- public URI getBaseResourceURI() {
- return _resourceFinder.getBaseResourceURI();
- }
+ /**
+ * Retrieves the base URI that the BPEL Process execution contextis
running relative to.
+ *
+ * @return URI - the URI representing the absolute physical file path
location that this process is defined within.
+ * @throws IOException
+ * @throws MalformedURLException
+ */
+ public URI getBaseResourceURI() {
+ return _resourceFinder.getBaseResourceURI();
+ }
/**
@@ -1714,10 +1732,10 @@
oextvar.debugInfo = createDebugInfo(src, null);
if (src.getExternalId() == null)
- throw new
CompilationException(__cmsgs.errMustSpecifyExternalVariableId(src.getName()));
-
+ throw new
CompilationException(__cmsgs.errMustSpecifyExternalVariableId(src.getName()));
+
if (src.getRelated() == null)
- throw new
CompilationException(__cmsgs.errMustSpecifyRelatedVariable(src.getName()));
+ throw new
CompilationException(__cmsgs.errMustSpecifyRelatedVariable(src.getName()));
oextvar.related = resolveVariable(src.getRelated());
return oextvar;
Added:
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ExpressionValidatorFactory.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ExpressionValidatorFactory.java?rev=804065&view=auto
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ExpressionValidatorFactory.java
(added)
+++
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ExpressionValidatorFactory.java
Fri Aug 14 00:24:42 2009
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.compiler;
+
+import java.util.Properties;
+
+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.CompilerContext;
+import org.apache.ode.bpel.compiler.api.ExpressionValidator;
+import org.apache.ode.bpel.compiler.bom.Process;
+import org.apache.ode.bpel.compiler.bom.Expression;
+import org.apache.ode.bpel.o.OVarType;
+
+public class ExpressionValidatorFactory {
+ private static final Log __log =
LogFactory.getLog(ExpressionValidatorFactory.class);
+ private ExpressionValidator _validator = new EmptyValidator();
+
+ public ExpressionValidatorFactory(Properties config) {
+ String propertyName = "org.apache.ode.validator";
+ String validatorClass = (String)
config.getProperty(propertyName, "");
+ __log.debug("Trying property " + propertyName + " got value: "
+ validatorClass);
+ if (!validatorClass.equals("")) {
+ try {
+ _validator = (ExpressionValidator)
getClass().forName(validatorClass).newInstance();
+ } catch (Exception e) {
+ __log.warn("Cannot instantiate expression
validator of class " + validatorClass);
+ }
+ }
+ }
+
+ public ExpressionValidator getValidator() {
+ return _validator;
+ }
+
+ private static class EmptyValidator implements ExpressionValidator {
+ public void bpelImportsLoaded(Process source, CompilerContext
compilerContext) throws CompilationException {}
+ public void bpelCompilationCompleted(Process source) throws
CompilationException {}
+ public Object validate(Expression source, OVarType rootNodeType,
Object requestedResultType) throws CompilationException { return null; }
+ }
+}
Propchange:
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ExpressionValidatorFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java?rev=804065&r1=804064&r2=804065&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
Fri Aug 14 00:24:42 2009
@@ -41,7 +41,10 @@
import javax.wsdl.extensions.ExtensibilityElement;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+import java.io.ByteArrayInputStream;
import java.io.StringReader;
import java.io.IOException;
import java.net.URI;
@@ -296,8 +299,27 @@
return null;
}
+ /**
+ * @return All parsed schemas. This doesn't include schemas from bpel
imports.
+ */
Map<URI, Document> getSchemaDocuments() {
return _documentSchemas;
}
+ /**
+ * @return All captured schema sources including those from bpel
imports.
+ */
+ Map<URI, Source> getSchemaSources() {
+ Map<URI, Source> schemaSources = new HashMap<URI, Source>();
+ for (URI uri : _documentSchemas.keySet()) {
+ Document document = _documentSchemas.get(uri);
+ schemaSources.put(uri, new DOMSource(document));
+ }
+
+ for (URI uri : _schemas.keySet()) {
+ schemaSources.put(uri, new StreamSource(new
ByteArrayInputStream(_schemas.get(uri))));
+ }
+
+ return schemaSources;
+ }
}
Modified:
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/CompilerContext.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/CompilerContext.java?rev=804065&r1=804064&r2=804065&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/CompilerContext.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/CompilerContext.java
Fri Aug 14 00:24:42 2009
@@ -37,6 +37,7 @@
import org.apache.ode.bpel.o.OPartnerLink;
import org.apache.ode.bpel.o.OProcess;
import org.apache.ode.bpel.o.OScope;
+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.OScope.Variable;
@@ -56,9 +57,15 @@
throws CompilationException;
OExpression compileExpr(Expression expr)
+ throws CompilationException;
+
+ OExpression compileExpr(Expression expr, OVarType rootNodeType, Object
requestedResultType, Object[] resultType)
throws CompilationException;
OLValueExpression compileLValueExpr(Expression expr)
+ throws CompilationException;
+
+ OLValueExpression compileLValueExpr(Expression expr, OVarType
rootNodeType, Object requestedResultType, Object[] resultType)
throws CompilationException;
/**
Modified:
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/ExpressionCompiler.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/ExpressionCompiler.java?rev=804065&r1=804064&r2=804065&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/ExpressionCompiler.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/ExpressionCompiler.java
Fri Aug 14 00:24:42 2009
@@ -20,6 +20,7 @@
import org.apache.ode.bpel.o.OExpression;
import org.apache.ode.bpel.o.OLValueExpression;
+import org.apache.ode.bpel.o.OVarType;
import java.util.Map;
Added:
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/ExpressionValidator.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/ExpressionValidator.java?rev=804065&view=auto
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/ExpressionValidator.java
(added)
+++
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/ExpressionValidator.java
Fri Aug 14 00:24:42 2009
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.compiler.api;
+
+import org.apache.ode.bpel.o.OVarType;
+import org.apache.ode.bpel.compiler.bom.Process;
+import org.apache.ode.bpel.compiler.bom.Expression;
+
+public interface ExpressionValidator {
+ /**
+ * Notifies process compilation began
+ *
+ * @param compilerContext
+ */
+ void bpelImportsLoaded(Process source, CompilerContext compilerContext)
throws CompilationException;
+
+ /**
+ * Notifies process compilation completed.
+ * Mainly for cleaning up resources.
+ *
+ * @param compilerContext
+ */
+ void bpelCompilationCompleted(Process source) throws CompilationException;
+
+ /**
+ * Validate given expression.
+ * @param source It's a Query or Expression
+ * @param requestedResultType It's OVarType or underlying Expression
Validator's type.
+ * It may be null if there are no constrains for result type
+ * @return Evaluated expression's type
+ */
+ Object validate(Expression source, OVarType rootNodeType, Object
requestedResultType) throws CompilationException;
+
+}
Propchange:
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/ExpressionValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xquery10/compiler/XQuery10ExpressionCompilerImpl.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xquery10/compiler/XQuery10ExpressionCompilerImpl.java?rev=804065&r1=804064&r2=804065&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xquery10/compiler/XQuery10ExpressionCompilerImpl.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xquery10/compiler/XQuery10ExpressionCompilerImpl.java
Fri Aug 14 00:24:42 2009
@@ -162,7 +162,7 @@
}
try {
- XQDataSource xqds = new SaxonXQDataSource();
+ XQDataSource xqds = new SaxonXQDataSource(new Configuration());
XQConnection xqconn = xqds.getConnection();
__log.debug("Compiling expression " + xqueryStr);
@@ -196,12 +196,12 @@
declarations.declareVariable(
getQName(nsContext, Namespaces.ODE_EXTENSION_NS,
"pid"),
getQName(nsContext, Namespaces.XML_SCHEMA, "integer"));
- Map<URI, Source> schemaDocuments =
_compilerContext.getSchemaSources();
- for (URI schemaUri : schemaDocuments.keySet()) {
- Source schemaSource = schemaDocuments.get(schemaUri);
- // Don't add schema sources, since our Saxon library is not
schema-aware.
- // configuration.addSchemaSource(schemaSource);
- }
+// Map<URI, Source> schemaDocuments =
_compilerContext.getSchemaSources();
+// for (URI schemaUri : schemaDocuments.keySet()) {
+// Source schemaSource = schemaDocuments.get(schemaUri);
+// // Don't add schema sources, since our Saxon library is not
schema-aware.
+// // configuration.addSchemaSource(schemaSource);
+// }
configuration.setSchemaValidationMode(Validation.SKIP);
List<OScope.Variable> variables =
_compilerContext.getAccessibleVariables();
Map<QName, QName> variableTypes = new HashMap<QName, QName>();
Modified:
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/XPathTest.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/XPathTest.java?rev=804065&r1=804064&r2=804065&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/XPathTest.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/XPathTest.java
Fri Aug 14 00:24:42 2009
@@ -53,6 +53,7 @@
import org.apache.ode.bpel.o.OPartnerLink;
import org.apache.ode.bpel.o.OProcess;
import org.apache.ode.bpel.o.OScope;
+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.OMessageVarType.Part;
@@ -282,4 +283,18 @@
// TODO Auto-generated method stub
return null;
}
+
+ public OExpression compileExpr(Expression expr, OVarType rootNodeType,
+ Object requestedResultType, Object[] resultType)
+ throws CompilationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public OLValueExpression compileLValueExpr(Expression expr,
+ OVarType rootNodeType, Object requestedResultType,
+ Object[] resultType) throws CompilationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
Modified:
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/MockCompilerContext.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/MockCompilerContext.java?rev=804065&r1=804064&r2=804065&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/MockCompilerContext.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/MockCompilerContext.java
Fri Aug 14 00:24:42 2009
@@ -44,6 +44,7 @@
import org.apache.ode.bpel.o.OPartnerLink;
import org.apache.ode.bpel.o.OProcess;
import org.apache.ode.bpel.o.OScope;
+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.OMessageVarType.Part;
@@ -218,4 +219,16 @@
// TODO Auto-generated method stub
return null;
}
+ public OExpression compileExpr(Expression expr, OVarType rootNodeType,
+ Object requestedResultType, Object[] resultType)
+ throws CompilationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public OLValueExpression compileLValueExpr(Expression expr,
+ OVarType rootNodeType, Object requestedResultType,
+ Object[] resultType) throws CompilationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
}