You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2010/10/23 01:29:49 UTC
svn commit: r1026527 - in
/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb:
config/ReadDescriptors.java persistence/PersistenceUnitInfoImpl.java
Author: dblevins
Date: Fri Oct 22 23:29:48 2010
New Revision: 1026527
URL: http://svn.apache.org/viewvc?rev=1026527&view=rev
Log:
OPENEJB-1371: Double encoding of persistence-unit root-url leads to issues in paths with spaces
Modified:
openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceUnitInfoImpl.java
Modified: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java?rev=1026527&r1=1026526&r2=1026527&view=diff
==============================================================================
--- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java (original)
+++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java Fri Oct 22 23:29:48 2010
@@ -37,6 +37,7 @@ import org.apache.openejb.jee.oejb2.Jaxb
import org.apache.openejb.jee.oejb2.OpenejbJarType;
import org.apache.openejb.jee.oejb3.JaxbOpenejbJar3;
import org.apache.openejb.jee.oejb3.OpenejbJar;
+import org.apache.openejb.util.URLs;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -90,17 +91,16 @@ public class ReadDescriptors implements
List<URL> persistenceUrls = (List<URL>) appModule.getAltDDs().get("persistence.xml");
if (persistenceUrls != null) {
for (URL persistenceUrl : persistenceUrls) {
- String moduleName = persistenceUrl.toExternalForm().replaceFirst("!/?META-INF/.*persistence.xml$", "");
- moduleName = moduleName.replaceFirst("/?META-INF/.*persistence.xml$", "/");
- if (moduleName.startsWith("jar:")) moduleName = moduleName.substring("jar:".length());
- if (moduleName.startsWith("file:")) moduleName = moduleName.substring("file:".length());
-// if (moduleName1.endsWith("/")) moduleName1 = moduleName1.substring(0, moduleName1.length() - 1);
+
+ final String path = URLs.toFilePath(persistenceUrl);
+ String moduleName = path.replaceFirst("/?META-INF/.*persistence.xml$", "/");
+
try {
Persistence persistence = JaxbPersistenceFactory.getPersistence(persistenceUrl);
PersistenceModule persistenceModule = new PersistenceModule(moduleName, persistence);
persistenceModule.getWatchedResources().add(moduleName);
if ("file".equals(persistenceUrl.getProtocol())) {
- persistenceModule.getWatchedResources().add(toFilePath(persistenceUrl));
+ persistenceModule.getWatchedResources().add(path);
}
appModule.getPersistenceModules().add(persistenceModule);
} catch (Exception e1) {
Modified: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceUnitInfoImpl.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceUnitInfoImpl.java?rev=1026527&r1=1026526&r2=1026527&view=diff
==============================================================================
--- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceUnitInfoImpl.java (original)
+++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceUnitInfoImpl.java Fri Oct 22 23:29:48 2010
@@ -16,16 +16,10 @@
*/
package org.apache.openejb.persistence;
-import org.apache.openejb.util.Join;
-
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.IllegalClassFormatException;
import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.List;
@@ -212,24 +206,7 @@ public class PersistenceUnitInfoImpl imp
}
private URL toUrl(File root) throws MalformedURLException {
- URL url = root.toURI().toURL();
-
- try {
- url.toURI();
- } catch (URISyntaxException e) {
- // Likely has spaces in it.
- try {
- String s = url.toExternalForm();
- URL fixed = new URL(s.replaceAll(" ", "%20"));
- fixed.toURI();
- url = fixed;
- } catch (MalformedURLException e1) {
- } catch (URISyntaxException e1) {
- // oh well, we tried.
- }
- }
-
- return url;
+ return root.toURI().toURL();
}
public List<String> getManagedClassNames() {