mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-03 03:38:33 +08:00
PL-7896 Uber-JAR deployment
This commit is contained in:
parent
457bc655fb
commit
9d1a918d85
@ -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;
|
||||
}
|
||||
}
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user