PL-7896 Uber-JAR deployment

This commit is contained in:
Andrey Subbotin 2017-03-31 12:59:27 +04:00
parent 457bc655fb
commit 9d1a918d85
2 changed files with 11 additions and 2 deletions

View File

@ -17,10 +17,12 @@
package com.haulmont.cuba.core.sys.persistence;
import com.google.common.base.Strings;
import com.haulmont.cuba.core.sys.AppContext;
import org.springframework.util.ClassUtils;
import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@ -28,6 +30,7 @@ import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.CodeSource;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
@ -61,7 +64,7 @@ public class OrmXmlAwareClassLoader extends URLClassLoader {
@Nullable
protected URL getOrmXmlUrl(String name) {
if (name.equals("orm.xml")) {
if ("orm.xml".equals(name)) {
Path path = Paths.get(workDir, name);
if (Files.exists(path)) {
try {
@ -71,6 +74,13 @@ public class OrmXmlAwareClassLoader extends URLClassLoader {
}
}
}
boolean isUberJar = Boolean.parseBoolean(AppContext.getProperty("cuba.uberJar"));
if ("".equals(name) && isUberJar) {
CodeSource codeSource = getClass().getProtectionDomain().getCodeSource();
if (codeSource != null) {
return codeSource.getLocation();
}
}
return null;
}
}

View File

@ -45,7 +45,6 @@
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
lazy-init="false">
<property name="persistenceXmlLocation" value="file:${cuba.dataDir}/persistence.xml"/>
<property name="persistenceUnitRootLocation" value="file:${cuba.dataDir}"/>
<property name="dataSource" ref="cubaDataSource"/>
<property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
</bean>