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/01/11 21:22:21 UTC
svn commit: r495361 - in /incubator/ode/trunk:
bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/
bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/
bpel-store/src/main/java/org/apache/ode/store/
bpel-store/src/test/java/org/apache/ode/st...
Author: mszefler
Date: Thu Jan 11 12:22:20 2007
New Revision: 495361
URL: http://svn.apache.org/viewvc?view=rev&rev=495361
Log:
Tweaks to resource finder mechanism.
Backed out gnodet's fix that made the URI's that the compiler provides absolute file: uris.
Replace above with urn:/ prefix, i.e. urn:/ = deployment unit directory, made finder balk at all other URIs.
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/DefaultResourceFinder.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ResourceFinder.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/WsdlFinderXMLEntityResolver.java
incubator/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/WSDLRegistryTest.java
incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java
incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DocumentRegistry.java
incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
incubator/ode/trunk/bpel-store/src/test/java/org/apache/ode/store/DeploymentUnitTest.java
incubator/ode/trunk/bpel-store/src/test/resources/log4j.properties
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=495361&r1=495360&r2=495361
==============================================================================
--- 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 Thu Jan 11 12:22:20 2007
@@ -279,28 +279,6 @@
try {
Serializer fileHeader = new Serializer(System.currentTimeMillis());
fileHeader.writeOProcess(oprocess, _outputStream);
-
-// if (_bpelFile.toString().startsWith("file:") && _outputDir != null) {
-// String filePath = _bpelFile.getFile();
-// filePath = filePath.substring(0, filePath.lastIndexOf(".")) + ".dd";
-//
-// DDHandler ddHandler;
-// try {
-// ddHandler = new DDHandler(new File(filePath));
-// if (!ddHandler.exists()) __log.info("No deployment descriptor found, one will be generated if needed.");
-// boolean modified = ddHandler.validateAndEnhance(oprocess, compiler.getWsdlDefinitions());
-// if (ddHandler.exists() || modified)
-// ddHandler.write(new File(_outputDir, oprocess.getName() + ".dd"));
-// } catch (DDValidationException e) {
-// CompilationMessage cm = __cmsgs.errInvalidDeploymentDescriptor(e.getMessage());
-// logCompilationMessage(cm);
-// throw new CompilationException(cm);
-// } catch (DDException e) {
-// logCompilationMessage(__cmsgs.errInvalidDeploymentDescriptor(e.getMessage()));
-// }
-// } else {
-// __log.warn("Post-compilation using deployment descriptor deactivated (compilation from url or stream).");
-// }
} finally {
// close & mark myself invalid
this.invalidate();
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=495361&r1=495360&r2=495361
==============================================================================
--- 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 Thu Jan 11 12:22:20 2007
@@ -18,15 +18,90 @@
*/
package org.apache.ode.bpel.compiler;
+import java.io.File;
+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.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,18 +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.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-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
@@ -104,7 +167,7 @@
BpelCompiler(WSDLFactory4BPEL wsdlFactory) {
_wsdlFactory = wsdlFactory;
- setResourceFinder(null);
+ _wsdlRegistry = new WSDLRegistry(this);
}
public void addWsdlImport(URI from, URI wsdlImport) {
@@ -123,7 +186,7 @@
}
try {
- _wsdlRegistry.addDefinition(def);
+ _wsdlRegistry.addDefinition(def, _resourceFinder, from.resolve(wsdlImport));
if (__log.isDebugEnabled())
__log.debug("Added WSDL Definition: " + wsdlImport);
} catch (CompilationException ce) {
@@ -141,7 +204,6 @@
} else {
_resourceFinder = finder;
}
- _wsdlRegistry = new WSDLRegistry(_resourceFinder, this);
}
@@ -509,7 +571,15 @@
// in the directory that contains the file.
setResourceFinder(new DefaultResourceFinder(bpelFile.getParentFile()));
- _processURI = bpelFile.toURI();
+ 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();
+ }
_processDef = process;
_generatedDate = new Date();
_structureStack.clear();
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultResourceFinder.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultResourceFinder.java?view=diff&rev=495361&r1=495360&r2=495361
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultResourceFinder.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultResourceFinder.java Thu Jan 11 12:22:20 2007
@@ -28,17 +28,33 @@
import javax.wsdl.WSDLException;
import javax.wsdl.xml.WSDLReader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.compiler.wsdl.Definition4BPEL;
-
+/**
+ * Basic implementation of the {@link ResourceFinder} interface. Resolves
+ * URIs relative to a base URI specified at the time of construction.
+ *
+ * @author Maciej Szefler - m s z e f l e r @ g m a i l . c o m
+ *
+ */
public class DefaultResourceFinder implements ResourceFinder {
-
+ private static final Log __log = LogFactory.getLog(DefaultResourceFinder.class);
+
private File _suDir;
+ /**
+ * Default constructor: resolve relative URIs against current working directory.
+ */
public DefaultResourceFinder() {
_suDir = new File("");
}
+ /**
+ * Constructor: resolve relative URIs against specified directory.
+ * @param suDir base path for relative URIs.
+ */
public DefaultResourceFinder(File suDir) {
_suDir = suDir;
}
@@ -46,10 +62,13 @@
public InputStream openResource(URI uri) throws MalformedURLException, IOException {
URI suURI = _suDir.toURI();
+
+ // Note that if we get an absolute URI, the relativize operation will simply
+ // return the absolute URI.
URI relative = suURI.relativize(uri);
- if (relative.isAbsolute()) {
- // We don't allow absolute URIs
- return null;
+ if (relative.isAbsolute() && !relative.getScheme().equals("urn")) {
+ __log.fatal("openResource: invalid scheme (should be urn:) " + uri);
+ return null;
}
return new FileInputStream(new File(suURI.getPath(),relative.getPath()));
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ResourceFinder.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ResourceFinder.java?view=diff&rev=495361&r1=495360&r2=495361
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ResourceFinder.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ResourceFinder.java Thu Jan 11 12:22:20 2007
@@ -26,10 +26,19 @@
import javax.wsdl.xml.WSDLLocator;
/**
- * Simple wrapper for WSDL location.
+ * General interace for retrieving resources identified by a URI.
+ *
+ * @author Maciej Szefler - m s z e f l e r @ g m a i l . c o m
*/
public interface ResourceFinder {
+ /**
+ * Obtain an input stream to the resource at the given URI.
+ * @param uri resource URI
+ * @return input stream or <code>null</code> if the resource is not found
+ * @throws MalformedURLException in case of invalid URI
+ * @throws IOException in case of read error
+ */
InputStream openResource(URI uri) throws MalformedURLException, IOException;
}
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=495361&r1=495360&r2=495361
==============================================================================
--- 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 Thu Jan 11 12:22:20 2007
@@ -20,7 +20,6 @@
import java.io.StringReader;
import java.net.URI;
-import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -46,7 +45,6 @@
import org.apache.ode.bpel.compiler.wsdl.Definition4BPEL;
import org.apache.ode.bpel.compiler.wsdl.XMLSchemaType;
import org.apache.ode.utils.DOMUtils;
-import org.apache.ode.utils.fs.FileUtils;
import org.apache.ode.utils.msg.MessageBundle;
import org.apache.ode.utils.xsd.SchemaModel;
import org.apache.ode.utils.xsd.SchemaModelImpl;
@@ -71,11 +69,10 @@
private SchemaModel _model;
- private WsdlFinderXMLEntityResolver _resolver;
private CompilerContext _ctx;
- WSDLRegistry(ResourceFinder finder, CompilerContext cc) {
+ WSDLRegistry(CompilerContext cc) {
// bogus schema to force schema creation
_schemas.put(URI.create("http://fivesight.com/bogus/namespace"),
("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""
@@ -83,8 +80,6 @@
+ "<xsd:simpleType name=\"__bogusType__\">"
+ "<xsd:restriction base=\"xsd:normalizedString\"/>"
+ "</xsd:simpleType>" + "</xsd:schema>").getBytes());
- if (finder != null)
- _resolver = new WsdlFinderXMLEntityResolver(finder);
_ctx = cc;
}
@@ -119,7 +114,7 @@
* @param def WSDL definition
*/
@SuppressWarnings("unchecked")
- public void addDefinition(Definition4BPEL def) throws CompilationException {
+ public void addDefinition(Definition4BPEL def, ResourceFinder rf, URI defuri) throws CompilationException {
if (def == null)
throw new NullPointerException("def=null");
@@ -131,7 +126,7 @@
// This indicates that we imported a WSDL with the same namespace from
// two different locations. This is not an error, but should be a warning.
if (__log.isInfoEnabled()) {
- __log.info("WSDL at " + def.getDocumentBaseURI() + " is a duplicate import, your documents " +
+ __log.info("WSDL at " + defuri + " is a duplicate import, your documents " +
"should all be in different namespaces (its's not nice but will still work).");
}
}
@@ -143,7 +138,7 @@
defs.add(def);
_definitions.put(def.getTargetNamespace(), defs);
- captureSchemas(def);
+ captureSchemas(def, rf, defuri);
if (__log.isDebugEnabled())
__log.debug("Processing <imports> in " + def.getDocumentBaseURI());
@@ -181,13 +176,13 @@
}
imported.add(im.getNamespaceURI());
- addDefinition((Definition4BPEL) im.getDefinition());
+ addDefinition((Definition4BPEL) im.getDefinition(), rf, defuri.resolve(im.getLocationURI()));
}
}
}
@SuppressWarnings("unchecked")
- private void captureSchemas(Definition def) throws CompilationException {
+ private void captureSchemas(Definition def, ResourceFinder rf, URI defuri) throws CompilationException {
assert def != null;
if (__log.isDebugEnabled())
@@ -201,20 +196,15 @@
iter.hasNext();) {
ExtensibilityElement ee = iter.next();
+
if (ee instanceof XMLSchemaType) {
String schema = ((XMLSchemaType)ee).getXMLSchema();
Map<URI, byte[]> capture = null;
- URI docuri;
- try {
- docuri = new URI(FileUtils.encodePath(def.getDocumentBaseURI()));
- } catch (URISyntaxException e) {
- // This is really quite unexpected..
- __log.fatal("Internal Error: WSDL Base URI is invalid.",e);
- throw new RuntimeException(e);
- }
+ WsdlFinderXMLEntityResolver resolver = new WsdlFinderXMLEntityResolver(rf, defuri);
try {
- capture = XSUtils.captureSchema(docuri, schema, _resolver);
+
+ capture = XSUtils.captureSchema(defuri, schema, resolver);
// Add new schemas to our list.
_schemas.putAll(capture);
@@ -223,12 +213,12 @@
Document doc = DOMUtils.parse(new InputSource(new StringReader(schema)));
String schemaTargetNS = doc.getDocumentElement().getAttribute("targetNamespace");
if (schemaTargetNS != null && schemaTargetNS.length() > 0)
- _resolver.addInternalResource(schemaTargetNS, schema);
+ resolver.addInternalResource(new URI(schemaTargetNS), schema);
} catch (Exception e) {
throw new RuntimeException("Couldn't parse schema in " + def.getTargetNamespace(), e);
}
} catch (XsdException xsde) {
- __log.debug("captureSchemas: capture failed for " + docuri,xsde);
+ __log.debug("captureSchemas: capture failed for " + defuri,xsde);
LinkedList<XsdException> exceptions = new LinkedList<XsdException>();
while (xsde != null) {
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java?view=diff&rev=495361&r1=495360&r2=495361
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java Thu Jan 11 12:22:20 2007
@@ -18,21 +18,27 @@
*/
package org.apache.ode.bpel.compiler;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ode.utils.fs.FileUtils;
import org.apache.xerces.xni.XMLResourceIdentifier;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLEntityResolver;
import org.apache.xerces.xni.parser.XMLInputSource;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-
+/**
+ * Xerces {@link XMLEntityResolver} implementation that defers to our own
+ * {@link ResourceFinder} interface for loading resources. This class is
+ * used for XSD-Schema capture which uses the Xerces schema model.
+ *
+ * @author Maciej Szefler - m s z e f l e r @ g m a i l . c o m
+ *
+ */
public class WsdlFinderXMLEntityResolver implements XMLEntityResolver {
private static final Log __log = LogFactory
@@ -47,10 +53,19 @@
private boolean _failIfNotFound = true;
private ResourceFinder _wsdlFinder;
- private HashMap<String,String> _internalResources = new HashMap<String, String>();
-
- public WsdlFinderXMLEntityResolver(ResourceFinder finder) {
+ private HashMap<URI,String> _internalResources = new HashMap<URI, String>();
+ private URI _baseURI;
+
+ /**
+ * Constructor.
+ * @param finder {@link ResourceFinder} implementation.
+ * @param baseURI the base URI against which all relative URIs are to be resolved;
+ * typically this is the system URI of the WSDL containing an
+ * embedded schema
+ */
+ public WsdlFinderXMLEntityResolver(ResourceFinder finder, URI baseURI) {
_wsdlFinder = finder;
+ _baseURI = baseURI;
}
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
@@ -63,12 +78,19 @@
URI location;
try {
+ // Note: if the systemId is not specified then what we have is
+ // an import without a schemaLocation. In this case we use the
+ // namespace to stand in for the location. If we have an
+ // expandedsystemId, then we must use that, since schemas that
+ // are imported by other schemas will have their relative
+ // locations encoded here. If we only have a literal system id,
+ // then it is going to be realative to our baseURI.
if (resourceIdentifier.getLiteralSystemId() == null)
location = new URI(resourceIdentifier.getNamespace());
- else if (resourceIdentifier.getExpandedSystemId() != null)
- location = new URI(FileUtils.encodePath(resourceIdentifier.getExpandedSystemId()));
+ else if (resourceIdentifier.getExpandedSystemId() != null)
+ location = _baseURI.resolve(resourceIdentifier.getExpandedSystemId());
else
- location = new URI(FileUtils.encodePath(resourceIdentifier.getLiteralSystemId()));
+ location = _baseURI.resolve(resourceIdentifier.getLiteralSystemId());
} catch (URISyntaxException e) {
__log.debug("resolveEntity: URI syntax error", e);
throw new IOException(e.getMessage());
@@ -78,8 +100,8 @@
__log.debug("resolveEntity: Expecting to find " + resourceIdentifier.getNamespace()
+ " at " + location);
- if (_internalResources.get(location.toString()) != null) {
- src.setByteStream(new ByteArrayInputStream(_internalResources.get(location.toString()).getBytes()));
+ if (_internalResources.get(location) != null) {
+ src.setByteStream(new ByteArrayInputStream(_internalResources.get(location).getBytes()));
return src;
}
@@ -100,8 +122,14 @@
return src;
}
- public void addInternalResource(String ns, String source) {
- _internalResources.put(ns, source);
+ /**
+ * Register a previously loaded resource with the finder; this is used to make
+ * accessible the schema in-lined into a WSDL document.
+ * @param location/namespace location/namespace of the resource
+ * @param source text of the resource
+ */
+ public void addInternalResource(URI location, String source) {
+ _internalResources.put(location, source);
}
}
Modified: incubator/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/WSDLRegistryTest.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/WSDLRegistryTest.java?view=diff&rev=495361&r1=495360&r2=495361
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/WSDLRegistryTest.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/WSDLRegistryTest.java Thu Jan 11 12:22:20 2007
@@ -41,7 +41,7 @@
protected void setUp() throws Exception
{
super.setUp();
- _registry = new WSDLRegistry(null, null);
+ _registry = new WSDLRegistry(null);
}
protected void tearDown() throws Exception
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=495361&r1=495360&r2=495361
==============================================================================
--- 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 Thu Jan 11 12:22:20 2007
@@ -180,7 +180,7 @@
public DocumentRegistry getDocRegistry() {
if (_docRegistry == null) {
- _docRegistry = new DocumentRegistry(new DocumentEntityResolver(_duDirectory));
+ _docRegistry = new DocumentRegistry();
WSDLFactory4BPEL wsdlFactory = (WSDLFactory4BPEL) WSDLFactoryBPEL20.newInstance();
WSDLReader r = wsdlFactory.newWSDLReader();
Modified: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DocumentRegistry.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DocumentRegistry.java?view=diff&rev=495361&r1=495360&r2=495361
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DocumentRegistry.java (original)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/DocumentRegistry.java Thu Jan 11 12:22:20 2007
@@ -1,43 +1,23 @@
package org.apache.ode.store;
+import java.util.ArrayList;
+
+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.wsdl.Definition4BPEL;
-import org.apache.ode.utils.xsd.SchemaModel;
-import org.apache.xerces.xni.parser.XMLEntityResolver;
-
-import javax.xml.namespace.QName;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
/**
* A parsed collection of WSDL definitions, including BPEL-specific extensions.
*/
public class DocumentRegistry {
private static final Log __log = LogFactory.getLog(DocumentRegistry.class);
- private static final Messages __msgs = Messages.getMessages(Messages.class);
private final ArrayList<Definition4BPEL> _definitions = new ArrayList<Definition4BPEL>();
- private final Map<URI, byte[]> _schemas = new HashMap<URI,byte[]>();
-
- private SchemaModel _model;
- private XMLEntityResolver _resolver;
-
- public DocumentRegistry(XMLEntityResolver resolver) {
- // bogus schema to force schema creation
- _schemas.put(URI.create("http://www.apache.org/ode/bogus/namespace"),
- ("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""
- + " targetNamespace=\"http://www.apache.org/ode/bogus/namespace\">"
- + "<xsd:simpleType name=\"__bogusType__\">"
- + "<xsd:restriction base=\"xsd:normalizedString\"/>"
- + "</xsd:simpleType>" + "</xsd:schema>").getBytes());
- _resolver = resolver;
- }
-
+
/**
* Obtains an WSDL definition based on its target namespace.
*
@@ -91,10 +71,6 @@
}
_definitions.add(def);
-
- // For now the schemas are never used at runtime. Check the compiler if this needs to be
- // put back in.
-// captureSchemas(def);
}
}
Modified: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java?view=diff&rev=495361&r1=495360&r2=495361
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java (original)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java Thu Jan 11 12:22:20 2007
@@ -85,6 +85,10 @@
}
public ProcessStoreImpl(DataSource ds) {
+ this(ds, false);
+ }
+
+ public ProcessStoreImpl(DataSource ds, boolean auto) {
String persistenceType = System.getProperty("ode.persistence");
if (ds != null) {
if ("hibernate".equalsIgnoreCase(persistenceType))
@@ -92,13 +96,9 @@
else
_cf = new org.apache.ode.store.jpa.DbConfStoreConnectionFactory(ds);
} else {
-
// If the datasource is not provided, then we create a HSQL-based in-memory
// database. Makes testing a bit simpler.
- jdbcDataSource hsqlds = new jdbcDataSource();
- hsqlds.setDatabase("jdbc:hsqldb:mem:" + _guid);
- hsqlds.setUser("sa");
- hsqlds.setPassword("");
+ DataSource hsqlds = createInternalDS(_guid);
if ("hibernate".equalsIgnoreCase(persistenceType))
_cf = new org.apache.ode.store.hib.DbConfStoreConnectionFactory(hsqlds, false);
else
@@ -108,16 +108,15 @@
}
+
public void shutdown() {
if (_inMemDs != null) {
- try {
- _inMemDs.getConnection().createStatement().execute("SHUTDOWN;");
- } catch (SQLException e) {
- __log.error("Error shutting down.", e);
- }
+ shutdownInternalDB(_inMemDs);
+ _inMemDs = null;
}
}
+
@Override
protected void finalize() throws Throwable {
// force a shutdown so that HSQL cleans up its mess.
@@ -405,19 +404,22 @@
*
*/
public void loadAll() {
-
+ final ArrayList<ProcessConfImpl> loaded = new ArrayList<ProcessConfImpl>();
exec(new Callable<Object>() {
public Object call(ConfStoreConnection conn) {
Collection<DeploymentUnitDAO> dus = conn.getDeploymentUnits();
for (DeploymentUnitDAO du : dus)
try {
- load(du);
+ loaded.addAll(load(du));
} catch (Exception ex) {
__log.error("Error loading DU from store: " + du.getName(), ex);
}
return null;
}
});
+
+ for (ProcessConfImpl p : loaded)
+ fireStateChange(p.getProcessId(), p.getState());
}
@@ -529,7 +531,7 @@
* Load a deployment unit record stored in the db into memory.
* @param dudao
*/
- private void load(DeploymentUnitDAO dudao) {
+ protected List<ProcessConfImpl>load(DeploymentUnitDAO dudao) {
__log.debug("Loading deployment unit record from db: " + dudao.getName());
@@ -546,12 +548,6 @@
_rw.writeLock().lock();
try {
- // NOTE: we don't try to reload things here.
- if (_deploymentUnits.containsKey(dudao.getName())) {
- __log.debug("Skipping load of " + dudao.getName() + ", it is already loaded.");
- return;
- }
-
_deploymentUnits.put(dud.getName(),dud);
for (ProcessConfDAO p : dudao.getProcesses()) {
@@ -574,10 +570,7 @@
_rw.writeLock().unlock();
}
- // Fire the events outside of the lock
- for (ProcessConfImpl p : loaded)
- fireStateChange(p.getProcessId(), p.getState());
-
+ return loaded;
}
/**
@@ -617,6 +610,22 @@
public void setDeployDir(File depDir) {
_deployDir = depDir;
+ }
+
+ public static DataSource createInternalDS(String guid) {
+ jdbcDataSource hsqlds = new jdbcDataSource();
+ hsqlds.setDatabase("jdbc:hsqldb:mem:" + guid);
+ hsqlds.setUser("sa");
+ hsqlds.setPassword("");
+ return hsqlds;
+ }
+
+ public static void shutdownInternalDB(DataSource ds) {
+ try {
+ ds.getConnection().createStatement().execute("SHUTDOWN;");
+ } catch (SQLException e) {
+ __log.error("Error shutting down.", e);
+ }
}
}
Modified: incubator/ode/trunk/bpel-store/src/test/java/org/apache/ode/store/DeploymentUnitTest.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/test/java/org/apache/ode/store/DeploymentUnitTest.java?view=diff&rev=495361&r1=495360&r2=495361
==============================================================================
--- incubator/ode/trunk/bpel-store/src/test/java/org/apache/ode/store/DeploymentUnitTest.java (original)
+++ incubator/ode/trunk/bpel-store/src/test/java/org/apache/ode/store/DeploymentUnitTest.java Thu Jan 11 12:22:20 2007
@@ -14,6 +14,9 @@
public class DeploymentUnitTest extends TestCase {
DeploymentUnitDir du;
+ /**
+ * Test some complicated xsd/wsdl loading.
+ */
public void setUp() throws Exception {
File dir = new File(getClass().getResource("/complexImport/deploy.xml").getPath()).getParentFile();
du = new DeploymentUnitDir(dir);
Modified: incubator/ode/trunk/bpel-store/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/test/resources/log4j.properties?view=diff&rev=495361&r1=495360&r2=495361
==============================================================================
--- incubator/ode/trunk/bpel-store/src/test/resources/log4j.properties (original)
+++ incubator/ode/trunk/bpel-store/src/test/resources/log4j.properties Thu Jan 11 12:22:20 2007
@@ -11,6 +11,7 @@
log4j.category.org.apache.ode.bpel.runtime.DebuggerSupport=WARN
log4j.category.org.apache.ode.daohib.bpel.CorrelatorDaoImpl=TRACE
+log4j.category.com.intalio=DEBUG
#log4j.category.org.apache.ode.bpel.epr=INFO
# Console appender