You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ms...@apache.org on 2007/03/13 20:34:07 UTC
svn commit: r517825 - in /incubator/ode/trunk/bpel-compiler/src:
main/java/org/apache/ode/bpel/compiler/
main/java/org/apache/ode/bpel/compiler/api/
main/java/org/apache/ode/bpel/compiler/bom/
main/java/org/apache/ode/bpel/compiler/wsdl/ main/java/org/...
Author: mszefler
Date: Tue Mar 13 12:34:06 2007
New Revision: 517825
URL: http://svn.apache.org/viewvc?view=rev&rev=517825
Log:
Better reporting of errors from compiler (programmatic access to
location, lineno, etc..)
Added:
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/SourceLocationImpl.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/SourceLocation.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath10/compiler/SourceLoacatorWrapper.java
incubator/ode/trunk/bpel-compiler/src/test/resources/log4j.properties
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-compiler/src/main/java/org/apache/ode/bpel/compiler/FlowGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/CompilationMessage.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/CompilerContext.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObject.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObjectFactory.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/wsdl/BpelExtensionSerializer.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath10/compiler/XslCompilationErrorListener.java
incubator/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/CompilationMessageTest.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=517825&r1=517824&r2=517825
==============================================================================
--- 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 Mar 13 12:34:06 2007
@@ -23,6 +23,7 @@
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.SourceLocation;
import org.apache.ode.bpel.compiler.bom.BpelObject;
import org.apache.ode.bpel.compiler.bom.BpelObjectFactory;
import org.apache.ode.bpel.compiler.bom.Process;
@@ -43,7 +44,7 @@
* Wrapper for {@link org.apache.ode.bpel.compiler.BpelCompiler} implementations,
* providing basic utility methods and auto-detection of BPEL version.
* </p>
- */
+s */
public class BpelC {
private static final Log __log = LogFactory.getLog(BpelC.class);
private static final CommonCompilationMessages __cmsgs =
@@ -182,7 +183,7 @@
* @throws CompilationException
* if one occurs while compiling.
*/
- public void compile(Process process) throws CompilationException, IOException {
+ public void compile(final Process process) throws CompilationException, IOException {
if (process == null)
throw new NullPointerException("Attempt to compile NULL process.");
@@ -199,12 +200,9 @@
CompileListener clistener = new CompileListener() {
public void onCompilationMessage(CompilationMessage compilationMessage) {
- Object location = compilationMessage.source;
+ SourceLocation location = compilationMessage.source;
if (location == null) {
- compilationMessage.source = _bpelFile + ":";
- }
- if (location instanceof BpelObject) {
- compilationMessage.source = _bpelFile + ":" + ((BpelObject)location).getLineNo();
+ compilationMessage.source = process;
}
logCompilationMessage(compilationMessage);
}
@@ -224,7 +222,7 @@
compiler = new BpelCompiler11();
compiler.setResourceFinder(wf);
if (_bpel11wsdl != null) {
- compiler.addWsdlImport(new URI(_bpelFile.getName()), _bpel11wsdl);
+ compiler.addWsdlImport(new URI(_bpelFile.getName()), _bpel11wsdl,null);
} else {
CompilationMessage cmsg = __cmsgs.errBpel11RequiresWsdl();
logCompilationMessage(cmsg);
@@ -255,7 +253,7 @@
OProcess oprocess;
try {
- oprocess = compiler.compile(_bpelFile, process);
+ oprocess = compiler.compile(process,wf);
}
catch (CompilationException cex) {
this.invalidate();
@@ -311,11 +309,11 @@
InputSource isrc = new InputSource(new ByteArrayInputStream(StreamUtils.read(bpelFile.toURL())));
isrc.setSystemId(bpelFile.getAbsolutePath());
- process = BpelObjectFactory.getInstance().parse(isrc);
+ process = BpelObjectFactory.getInstance().parse(isrc,_bpelFile.toURI());
} catch (Exception e) {
- CompilationMessage cmsg = __cmsgs.errBpelParseErr().setSource(bpelFile.getAbsolutePath());
+ CompilationMessage cmsg = __cmsgs.errBpelParseErr().setSource(new SourceLocationImpl(bpelFile.toURI()));
this.invalidate();
throw new CompilationException(cmsg, e);
}
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=517825&r1=517824&r2=517825
==============================================================================
--- 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 Mar 13 12:34:06 2007
@@ -18,15 +18,90 @@
*/
package org.apache.ode.bpel.compiler;
+import java.io.IOException;
+import java.io.InputStream;
+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.*;
-import org.apache.ode.bpel.compiler.bom.*;
+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.api.SourceLocation;
+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.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.*;
+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.OConstantVarType;
+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.utils.GUID;
import org.apache.ode.utils.NSContext;
import org.apache.ode.utils.StreamUtils;
@@ -37,16 +112,6 @@
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.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-
/**
* Compiler for converting BPEL process descriptions (and their associated WSDL
* and XSD documents) into compiled representations suitable for execution by
@@ -105,7 +170,7 @@
_wsdlRegistry = new WSDLRegistry(this);
}
- public void addWsdlImport(URI from, URI wsdlImport) {
+ public void addWsdlImport(URI from, URI wsdlImport, SourceLocation sloc) {
Definition4BPEL def;
@@ -114,10 +179,10 @@
WSDLLocatorImpl locator = new WSDLLocatorImpl(_resourceFinder, from.resolve(wsdlImport));
def = (Definition4BPEL) r.readWSDL(locator);
} catch (WSDLException e) {
- recoveredFromError(wsdlImport.toASCIIString(), new CompilationException(__cmsgs.errWsdlParseError(e
+ recoveredFromError(sloc, new CompilationException(__cmsgs.errWsdlParseError(e
.getFaultCode(), e.getLocation(), e.getMessage())));
throw new CompilationException(__cmsgs.errWsdlImportFailed(wsdlImport.toASCIIString(), e.getFaultCode())
- .setSource(wsdlImport), e);
+ .setSource(sloc), e);
}
try {
@@ -125,11 +190,11 @@
if (__log.isDebugEnabled())
__log.debug("Added WSDL Definition: " + wsdlImport);
} catch (CompilationException ce) {
- recoveredFromError(wsdlImport.toASCIIString(), ce);
+ recoveredFromError(sloc, ce);
}
}
- public void addXsdImport(URI from, URI location) {
+ public void addXsdImport(URI from, URI location, SourceLocation sloc) {
// TODO: implement.
}
@@ -467,7 +532,7 @@
return _oprocess;
}
- public void recoveredFromError(Object where, CompilationException bce) throws CompilationException {
+ public void recoveredFromError(SourceLocation where, CompilationException bce) throws CompilationException {
if (bce.getCompilationMessage().source == null)
bce.getCompilationMessage().source = where;
@@ -501,24 +566,12 @@
/**
* Compile a process.
*/
- public OProcess compile(File bpelFile, final Process process) throws CompilationException {
+ public OProcess compile(final Process process, ResourceFinder rf) throws CompilationException {
if (process == null)
throw new NullPointerException("Null process parameter");
-
- // If we are asked to compile a file, we set the resource finder to be
- // based
- // in the directory that contains the file.
- setResourceFinder(new DefaultResourceFinder(bpelFile.getParentFile()));
- try {
- // We don't want the URI to be a file: URL, we resolve all URIs
- // explicitly using the finder mechanism! Note we need the "urn:/"
- // otherwise the XSD loading will assume a file relative to CWD.
- _processURI = new URI("urn:/" + bpelFile.getName());
- } catch (URISyntaxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ setResourceFinder(rf);
+ _processURI = process.getURI();
_processDef = process;
_generatedDate = new Date();
_structureStack.clear();
@@ -708,9 +761,9 @@
throw new CompilationException(__cmsgs.errUnspecifiedImportType().setSource(imprt));
if (Import.IMPORTTYPE_WSDL11.equals(imprt.getImportType())) {
- addWsdlImport(current, imprt.getLocation());
+ addWsdlImport(current, imprt.getLocation(), imprt);
} else if (Import.IMPORTTYPE_XMLSCHEMA10.equals(imprt.getImportType())) {
- addXsdImport(current, imprt.getLocation());
+ addXsdImport(current, imprt.getLocation(), imprt);
} else
throw new CompilationException(__cmsgs.errUnknownImportType(imprt.getImportType()).setSource(imprt));
} catch (CompilationException ce) {
@@ -975,8 +1028,8 @@
boolean newValue = src.getAtomicScope().booleanValue();
if (_atomicScope)
throw new CompilationException(__cmsgs.errAtomicScopeNesting(newValue));
- else
- oscope.atomicScope = _atomicScope = newValue;
+
+ oscope.atomicScope = _atomicScope = newValue;
}
try {
compile(oscope, src, new Runnable() {
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/FlowGenerator.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/FlowGenerator.java?view=diff&rev=517825&r1=517824&r2=517825
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/FlowGenerator.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/FlowGenerator.java Tue Mar 13 12:34:06 2007
@@ -49,14 +49,14 @@
OLink olink = i.next();
try {
if (olink.source == null)
- throw new CompilationException(__cmsgs.errLinkMissingSourceActivity(olink.name).setSource(olink));
+ throw new CompilationException(__cmsgs.errLinkMissingSourceActivity(olink.name).setSource(flowAct));
} catch (CompilationException ce) {
_context.recoveredFromError(src, ce);
}
try {
if (olink.target == null)
- throw new CompilationException(__cmsgs.errLinkMissingTargetActivity(olink.name).setSource(olink));
+ throw new CompilationException(__cmsgs.errLinkMissingTargetActivity(olink.name).setSource(flowAct));
} catch (CompilationException ce) {
_context.recoveredFromError(src, ce);
}
Added: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/SourceLocationImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/SourceLocationImpl.java?view=auto&rev=517825
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/SourceLocationImpl.java (added)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/SourceLocationImpl.java Tue Mar 13 12:34:06 2007
@@ -0,0 +1,34 @@
+package org.apache.ode.bpel.compiler;
+
+import java.net.URI;
+
+import org.apache.ode.bpel.compiler.api.SourceLocation;
+
+class SourceLocationImpl implements SourceLocation {
+
+ private int _col;
+ private int _line;
+ private String _path;
+ private URI _uri;
+
+ SourceLocationImpl(URI uri) {
+ _uri = uri;
+ }
+
+ public int getColumnNo() {
+ return _col;
+ }
+
+ public int getLineNo() {
+ return _line;
+ }
+
+ public String getPath() {
+ return _path;
+ }
+
+ public URI getURI() {
+ return _uri;
+ }
+
+}
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java?view=diff&rev=517825&r1=517824&r2=517825
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java Tue Mar 13 12:34:06 2007
@@ -166,11 +166,11 @@
if (importDef == null) {
CompilationException ce = new CompilationException(
__cmsgs.errWsdlImportNotFound(im.getNamespaceURI(),
- im.getLocationURI()).setSource(def.getDocumentBaseURI()));
+ im.getLocationURI()).setSource(new SourceLocationImpl(defuri)));
if (_ctx == null)
throw ce;
- _ctx.recoveredFromError(def.getDocumentBaseURI(), ce);
+ _ctx.recoveredFromError(new SourceLocationImpl(defuri), ce);
continue;
}
@@ -230,9 +230,9 @@
// TODO: the line number here is going to be wrong for the in-line schema.
String location = ex.getSystemId() + ":" + ex.getLineNumber();
CompilationException ce = new CompilationException(
- __cmsgs.errSchemaError(ex.getDetailMessage()).setSource(location));
+ __cmsgs.errSchemaError(ex.getDetailMessage()).setSource(new SourceLocationImpl(defuri)));
if (_ctx != null)
- _ctx.recoveredFromError(location,ce);
+ _ctx.recoveredFromError(new SourceLocationImpl(defuri),ce);
else
throw ce;
}
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/CompilationMessage.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/CompilationMessage.java?view=diff&rev=517825&r1=517824&r2=517825
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/CompilationMessage.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/CompilationMessage.java Tue Mar 13 12:34:06 2007
@@ -47,7 +47,7 @@
public String messageText;
/** The location in the source that caused this error/message/warning */
- public Object source;
+ public SourceLocation source;
/** Common internationalized words. */
private static final CommonMessages __commonMsgs = MessageBundle.getMessages(CommonMessages.class);
@@ -58,7 +58,7 @@
__commonMsgs.strError().toLowerCase() + ": "
};
- public CompilationMessage setSource(Object source) {
+ public CompilationMessage setSource(SourceLocation source) {
this.source = source;
return this;
}
@@ -67,7 +67,9 @@
public String toErrorString() {
StringBuffer buf = new StringBuffer();
if (source != null) {
- buf.append(source);
+ buf.append(source.getURI());
+ buf.append(':');
+ buf.append(source.getLineNo());
buf.append(": ");
}
buf.append(SEVERITY_LEVELS[severity]);
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/CompilerContext.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/CompilerContext.java?view=diff&rev=517825&r1=517824&r2=517825
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/CompilerContext.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/CompilerContext.java Tue Mar 13 12:34:06 2007
@@ -98,7 +98,7 @@
OProcess.OPropertyAlias resolvePropertyAlias(OScope.Variable variable, QName property)
throws CompilationException;
- void recoveredFromError(Object where, CompilationException bce)
+ void recoveredFromError(SourceLocation where, CompilationException bce)
throws CompilationException;
OLink resolveLink(String linkName)
Added: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/SourceLocation.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/SourceLocation.java?view=auto&rev=517825
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/SourceLocation.java (added)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/SourceLocation.java Tue Mar 13 12:34:06 2007
@@ -0,0 +1,36 @@
+package org.apache.ode.bpel.compiler.api;
+
+import java.net.URI;
+
+/**
+ * Interface for objects that have some relation to a particular
+ * location in a source file.
+ *
+ * @author Maciej Szefler - m s z e f l e r @ g m a i l . c o m
+ *
+ */
+public interface SourceLocation {
+ /**
+ * URI of the source file.
+ * @return
+ */
+ URI getURI();
+
+ /**
+ * Line number.
+ * @return
+ */
+ int getLineNo();
+
+ /**
+ * Column number.
+ * @return
+ */
+ int getColumnNo();
+
+ /**
+ * Location path (not a file path, but a path in an expression).
+ * @return
+ */
+ String getPath();
+}
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObject.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObject.java?view=diff&rev=517825&r1=517824&r2=517825
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObject.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObject.java Tue Mar 13 12:34:06 2007
@@ -18,6 +18,7 @@
*/
package org.apache.ode.bpel.compiler.bom;
+import org.apache.ode.bpel.compiler.api.SourceLocation;
import org.apache.ode.utils.DOMUtils;
import org.apache.ode.utils.NSContext;
import org.apache.ode.utils.stl.CollectionsX;
@@ -30,6 +31,7 @@
import javax.xml.namespace.QName;
+import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -40,7 +42,7 @@
* location information (i.e. line numbers) and namespace context (XML namespace
* prefix maps).
*/
-public class BpelObject {
+public class BpelObject implements SourceLocation {
public static final QName ATTR_LINENO = new QName("urn:org.apache.ode.bpel.compiler", "lineno");
@@ -52,6 +54,9 @@
private List<BpelObject> _children = null;
+ /** URI of the source document. */
+ private URI _docURI;
+
public BpelObject(Element el) {
_element = el;
@@ -186,7 +191,7 @@
}
protected BpelObject createBpelObject(Element element) {
- return BpelObjectFactory.getInstance().createBpelObject(element);
+ return BpelObjectFactory.getInstance().createBpelObject(element,_docURI);
}
protected String getAttribute(QName name, String dflt) {
@@ -260,4 +265,19 @@
return DOMUtils.domToString(_element);
}
+ public int getColumnNo() {
+ return 0;
+ }
+
+ public String getPath() {
+ return null;
+ }
+
+ public URI getURI() {
+ return _docURI;
+ }
+
+ public void setURI(URI uri) {
+ _docURI = uri;
+ }
}
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObjectFactory.java?view=diff&rev=517825&r1=517824&r2=517825
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObjectFactory.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObjectFactory.java Tue Mar 13 12:34:06 2007
@@ -20,6 +20,7 @@
import java.io.IOException;
import java.lang.reflect.Constructor;
+import java.net.URI;
import java.util.HashMap;
import java.util.Map;
@@ -187,7 +188,7 @@
return __instance;
}
- public BpelObject createBpelObject(Element el) {
+ public BpelObject createBpelObject(Element el, URI uri) {
QName type = new QName(el.getNamespaceURI(), el.getLocalName());
Class cls = _mappings.get(type);
if (cls == null) {
@@ -195,8 +196,10 @@
return new BpelObject(el);
}
try {
- Constructor ctor = cls.getConstructor(__CTOR);
- return (BpelObject) ctor.newInstance(new Object[]{el});
+ Constructor ctor = cls.getConstructor(__CTOR);
+ BpelObject bo =(BpelObject) ctor.newInstance(new Object[]{el});
+ bo.setURI(uri);
+ return bo;
} catch (Exception ex) {
throw new RuntimeException("Internal compiler error", ex);
}
@@ -208,7 +211,7 @@
* @return
* @throws SAXException
*/
- public Process parse(InputSource isrc) throws IOException, SAXException {
+ public Process parse(InputSource isrc, URI systemURI) throws IOException, SAXException {
XMLReader _xr = XMLParserUtils.getXMLReader();
LocalEntityResolver resolver = new LocalEntityResolver();
resolver.register(Bpel11QNames.NS_BPEL4WS_2003_03, getClass().getResource("/bpel4ws_1_1-fivesight.xsd"));
@@ -223,7 +226,7 @@
_xr.setFeature("http://xml.org/sax/features/namespaces",true);
_xr.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
_xr.parse(isrc);
- return (Process) createBpelObject(doc.getDocumentElement());
+ return (Process) createBpelObject(doc.getDocumentElement(), systemURI);
}
}
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/wsdl/BpelExtensionSerializer.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/wsdl/BpelExtensionSerializer.java?view=diff&rev=517825&r1=517824&r2=517825
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/wsdl/BpelExtensionSerializer.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/wsdl/BpelExtensionSerializer.java Tue Mar 13 12:34:06 2007
@@ -19,6 +19,8 @@
package org.apache.ode.bpel.compiler.wsdl;
import java.io.PrintWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
import org.apache.ode.bpel.compiler.bom.BpelObject4WSDL;
import org.apache.ode.bpel.compiler.bom.BpelObjectFactory;
@@ -71,7 +73,13 @@
validateExtensibilityElementContext(el);
- BpelObject4WSDL obj = (BpelObject4WSDL) _factory.createBpelObject(el);
+ BpelObject4WSDL obj;
+ try {
+ obj = (BpelObject4WSDL) _factory.createBpelObject(el,new URI(def.getDocumentBaseURI()));
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ }
+
obj.setElementType(eltype);
obj.setRequired(false); // ? what does this do
obj.setTargetNamespace(def.getTargetNamespace());
Added: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath10/compiler/SourceLoacatorWrapper.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath10/compiler/SourceLoacatorWrapper.java?view=auto&rev=517825
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath10/compiler/SourceLoacatorWrapper.java (added)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath10/compiler/SourceLoacatorWrapper.java Tue Mar 13 12:34:06 2007
@@ -0,0 +1,38 @@
+package org.apache.ode.bpel.elang.xpath10.compiler;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.xml.transform.SourceLocator;
+
+import org.apache.ode.bpel.compiler.api.SourceLocation;
+
+public class SourceLoacatorWrapper implements SourceLocation {
+
+ private SourceLocator _sloc;
+
+ public SourceLoacatorWrapper(SourceLocator sloc) {
+ _sloc = sloc;
+ }
+
+ public int getColumnNo() {
+ return _sloc.getColumnNumber();
+ }
+
+ public int getLineNo() {
+ return _sloc.getLineNumber();
+ }
+
+ public String getPath() {
+ return "";
+ }
+
+ public URI getURI() {
+ try {
+ return new URI(_sloc.getSystemId());
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+}
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath10/compiler/XslCompilationErrorListener.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath10/compiler/XslCompilationErrorListener.java?view=diff&rev=517825&r1=517824&r2=517825
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath10/compiler/XslCompilationErrorListener.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath10/compiler/XslCompilationErrorListener.java Tue Mar 13 12:34:06 2007
@@ -76,6 +76,6 @@
cmsg.phase = 0;
cmsg.messageText = exception.getMessageAndLocation();
CompilationException ce = new CompilationException(cmsg, exception);
- _cc.recoveredFromError(XslTransformHandler.getInstance(), ce);
+ _cc.recoveredFromError(new SourceLoacatorWrapper(exception.getLocator()),ce);
}
}
Modified: incubator/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/CompilationMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/CompilationMessageTest.java?view=diff&rev=517825&r1=517824&r2=517825
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/CompilationMessageTest.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/CompilationMessageTest.java Tue Mar 13 12:34:06 2007
@@ -22,6 +22,7 @@
import org.apache.ode.bpel.compiler.api.CompilationMessage;
import org.apache.ode.utils.msg.MessageBundle;
+import java.net.URI;
import java.util.Locale;
import junit.framework.TestCase;
@@ -35,11 +36,12 @@
private static String WRONG_PARAMETER_CODE = "WrongParameter";
private CompilationTestMessages _bundle;
-
+ private SourceLocationImpl sloc;
@Override
protected void setUp() throws Exception {
super.setUp();
_bundle = MessageBundle.getMessages(CompilationTestMessages.class);
+ sloc = new SourceLocationImpl(new URI("urn:foo"));
}
@Override
@@ -49,58 +51,58 @@
}
public void testNoParameter() {
- CompilationMessage msg = _bundle.infNoParameter().setSource(this);
+ CompilationMessage msg = _bundle.infNoParameter().setSource(sloc);
assertEquals(NO_PARAMETER, msg.messageText);
assertEquals(CompilationMessage.INFO, msg.severity);
assertEquals(NO_PARAMETER_CODE, msg.code);
- assertSame(this, msg.source);
+ assertSame(sloc, msg.source);
- msg = _bundle.warnNoParameter().setSource(this);
+ msg = _bundle.warnNoParameter().setSource(sloc);
assertEquals("No parameter!", msg.messageText);
assertEquals(CompilationMessage.WARN, msg.severity);
assertEquals(NO_PARAMETER_CODE, msg.code);
- assertSame(this, msg.source);
+ assertSame(sloc, msg.source);
- msg = _bundle.errNoParameter().setSource(this);
+ msg = _bundle.errNoParameter().setSource(sloc);
assertEquals(NO_PARAMETER, msg.messageText);
assertEquals(CompilationMessage.ERROR, msg.severity);
assertEquals(NO_PARAMETER_CODE, msg.code);
- assertSame(this, msg.source);
+ assertSame(sloc, msg.source);
}
public void testNoParameterLocalized() {
CompilationTestMessages bundle = MessageBundle.getMessages(
CompilationTestMessages.class, Locale.GERMAN);
- CompilationMessage msg = bundle.infNoParameter().setSource(this);
+ CompilationMessage msg = bundle.infNoParameter().setSource(sloc);
assertEquals(NO_PARAMETER_DE, msg.messageText);
assertEquals(CompilationMessage.INFO, msg.severity);
assertEquals(NO_PARAMETER_CODE, msg.code);
- assertSame(this, msg.source);
+ assertSame(sloc, msg.source);
}
public void testWrongParameter() {
- CompilationMessage msg = _bundle.infWrongParameter(":-)").setSource(this);
+ CompilationMessage msg = _bundle.infWrongParameter(":-)").setSource(sloc);
assertEquals(WRONG_PARAMETER, msg.messageText);
assertEquals(CompilationMessage.INFO, msg.severity);
assertEquals(WRONG_PARAMETER_CODE, msg.code);
- assertSame(this, msg.source);
+ assertSame(sloc, msg.source);
- msg = _bundle.warnWrongParameter(":-)").setSource(this);
+ msg = _bundle.warnWrongParameter(":-)").setSource(sloc);
assertEquals(WRONG_PARAMETER, msg.messageText);
assertEquals(CompilationMessage.WARN, msg.severity);
assertEquals(WRONG_PARAMETER_CODE, msg.code);
- assertSame(this, msg.source);
+ assertSame(sloc, msg.source);
- msg = _bundle.errWrongParameter(":-)").setSource(this);
+ msg = _bundle.errWrongParameter(":-)").setSource(sloc);
assertEquals(WRONG_PARAMETER, msg.messageText);
assertEquals(CompilationMessage.ERROR, msg.severity);
assertEquals(WRONG_PARAMETER_CODE, msg.code);
- assertSame(this, msg.source);
+ assertSame(sloc, msg.source);
}
public void testWrongMethod() {
try {
- _bundle.msgWrongMethod().setSource(this);
+ _bundle.msgWrongMethod().setSource(sloc);
fail("should have failed on msgWrongMethod()");
}
catch (UnsupportedOperationException uop) {
Added: incubator/ode/trunk/bpel-compiler/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/test/resources/log4j.properties?view=auto&rev=517825
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/test/resources/log4j.properties (added)
+++ incubator/ode/trunk/bpel-compiler/src/test/resources/log4j.properties Tue Mar 13 12:34:06 2007
@@ -0,0 +1,17 @@
+# Set root logger level to WARN and its only appender to CONSOLE
+log4j.rootLogger=WARN, CONSOLE
+
+# log4j properties to work with commandline tools.
+log4j.category.org.mortbay=ERROR
+log4j.category.org.hibernate.type=WARN
+log4j.category.org.objectweb=ERROR
+log4j.category.org.apache.ode.axis2=DEBUG
+log4j.category.org.apache.ode.bpel.engine=DEBUG
+log4j.category.org.apache.ode.daohib.bpel.CorrelatorDaoImpl=DEBUG
+log4j.category.org.apache.ode.bpel.epr=INFO
+log4j.category.org.apache.ode.bpel.compiler=DEBUG
+
+# Console appender
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%p - %C{1}.%M(%L) | %m%n