mirror of https://github.com/apache/openjpa.git
Die in ProductDerivations.load() if given resource/file can't be parsed by any
ProductDerivations in the system. git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@448625 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d85ea93d3a
commit
68572a9197
|
@ -751,7 +751,7 @@ public class ConfigurationImpl
|
||||||
*/
|
*/
|
||||||
public void setProperties(String resourceName) throws IOException {
|
public void setProperties(String resourceName) throws IOException {
|
||||||
ProductDerivations.load(resourceName, null,
|
ProductDerivations.load(resourceName, null,
|
||||||
getClass().getClassLoader()).setInto(this);
|
getClass().getClassLoader()).setInto(this);
|
||||||
_auto = resourceName;
|
_auto = resourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -761,8 +761,8 @@ public class ConfigurationImpl
|
||||||
* <code>propertiesFile</code> value with the name of a file.
|
* <code>propertiesFile</code> value with the name of a file.
|
||||||
*/
|
*/
|
||||||
public void setPropertiesFile(File file) throws IOException {
|
public void setPropertiesFile(File file) throws IOException {
|
||||||
ProductDerivations.load(file, null,
|
ProductDerivations.load(file, null, getClass().getClassLoader()).
|
||||||
getClass().getClassLoader()).setInto(this);
|
setInto(this);
|
||||||
_auto = file.toString();
|
_auto = file.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,8 @@ public class ProductDerivations {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reportErrors(errs, resource);
|
reportErrors(errs, resource);
|
||||||
return null;
|
throw new MissingResourceException(resource,
|
||||||
|
ProductDerivations.class.getName(), resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,7 +163,8 @@ public class ProductDerivations {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reportErrors(errs, file.getAbsolutePath());
|
reportErrors(errs, file.getAbsolutePath());
|
||||||
return null;
|
throw new MissingResourceException(file.getAbsolutePath(),
|
||||||
|
ProductDerivations.class.getName(), file.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -48,6 +48,8 @@ import org.apache.openjpa.util.ClassResolver;
|
||||||
public class PersistenceUnitInfoImpl
|
public class PersistenceUnitInfoImpl
|
||||||
implements PersistenceUnitInfo, SourceTracker {
|
implements PersistenceUnitInfo, SourceTracker {
|
||||||
|
|
||||||
|
public static final String KEY_PROVIDER = "javax.persistence.provider";
|
||||||
|
|
||||||
private static final Localizer s_loc = Localizer.forPackage
|
private static final Localizer s_loc = Localizer.forPackage
|
||||||
(PersistenceUnitInfoImpl.class);
|
(PersistenceUnitInfoImpl.class);
|
||||||
|
|
||||||
|
@ -181,8 +183,8 @@ public class PersistenceUnitInfoImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<URL> getJarFileUrls() {
|
public List<URL> getJarFileUrls() {
|
||||||
return (_jarFiles == null)
|
return (_jarFiles == null) ? (List<URL>) Collections.EMPTY_LIST
|
||||||
? (List<URL>) Collections.EMPTY_LIST : _jarFiles;
|
: _jarFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addJarFile(URL jar) {
|
public void addJarFile(URL jar) {
|
||||||
|
@ -215,8 +217,8 @@ public class PersistenceUnitInfoImpl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException(s_loc.get("bad-jar-name", name)
|
throw new IllegalArgumentException(s_loc.get("bad-jar-name", name).
|
||||||
.getMessage());
|
getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getManagedClassNames() {
|
public List<String> getManagedClassNames() {
|
||||||
|
@ -269,13 +271,13 @@ public class PersistenceUnitInfoImpl
|
||||||
for (Object o : map.entrySet()) {
|
for (Object o : map.entrySet()) {
|
||||||
key = ((Map.Entry) o).getKey();
|
key = ((Map.Entry) o).getKey();
|
||||||
val = ((Map.Entry) o).getValue();
|
val = ((Map.Entry) o).getValue();
|
||||||
if ("javax.persistence.provider".equals(key))
|
if (KEY_PROVIDER.equals(key))
|
||||||
setPersistenceProviderClassName((String) val);
|
setPersistenceProviderClassName((String) val);
|
||||||
else if ("javax.persistence.transactionType".equals(key)) {
|
else if ("javax.persistence.transactionType".equals(key)) {
|
||||||
PersistenceUnitTransactionType ttype;
|
PersistenceUnitTransactionType ttype;
|
||||||
if (val instanceof String)
|
if (val instanceof String)
|
||||||
ttype = Enum.valueOf
|
ttype = Enum.valueOf(PersistenceUnitTransactionType.class,
|
||||||
(PersistenceUnitTransactionType.class, (String) val);
|
(String) val);
|
||||||
else
|
else
|
||||||
ttype = (PersistenceUnitTransactionType) val;
|
ttype = (PersistenceUnitTransactionType) val;
|
||||||
setTransactionType(ttype);
|
setTransactionType(ttype);
|
||||||
|
@ -320,11 +322,9 @@ public class PersistenceUnitInfoImpl
|
||||||
map.put("openjpa.ConnectionFactoryMode", "managed");
|
map.put("openjpa.ConnectionFactoryMode", "managed");
|
||||||
hasJta = true;
|
hasJta = true;
|
||||||
} else if (info instanceof PersistenceUnitInfoImpl
|
} else if (info instanceof PersistenceUnitInfoImpl
|
||||||
&& ((PersistenceUnitInfoImpl) info).getJtaDataSourceName() != null)
|
&& ((PersistenceUnitInfoImpl) info).getJtaDataSourceName() != null){
|
||||||
{
|
map.put("openjpa.ConnectionFactoryName", ((PersistenceUnitInfoImpl)
|
||||||
map.put("openjpa.ConnectionFactoryName",
|
info).getJtaDataSourceName());
|
||||||
((PersistenceUnitInfoImpl)
|
|
||||||
info).getJtaDataSourceName());
|
|
||||||
map.put("openjpa.ConnectionFactoryMode", "managed");
|
map.put("openjpa.ConnectionFactoryMode", "managed");
|
||||||
hasJta = true;
|
hasJta = true;
|
||||||
}
|
}
|
||||||
|
@ -343,8 +343,7 @@ public class PersistenceUnitInfoImpl
|
||||||
if (!hasJta)
|
if (!hasJta)
|
||||||
map.put("openjpa.ConnectionFactoryName", nonJtaName);
|
map.put("openjpa.ConnectionFactoryName", nonJtaName);
|
||||||
else
|
else
|
||||||
map.put("openjpa.ConnectionFactory2Name",
|
map.put("openjpa.ConnectionFactory2Name", nonJtaName);
|
||||||
nonJtaName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.getClassLoader() != null)
|
if (info.getClassLoader() != null)
|
||||||
|
@ -354,13 +353,13 @@ public class PersistenceUnitInfoImpl
|
||||||
Properties props = info.getProperties();
|
Properties props = info.getProperties();
|
||||||
if (props != null) {
|
if (props != null) {
|
||||||
map.putAll(props);
|
map.putAll(props);
|
||||||
// this isn't a real config property; remove it.
|
// this isn't a real config property; remove it
|
||||||
map.remove(PersistenceProviderImpl.CLASS_TRANSFORMER_OPTIONS);
|
map.remove(PersistenceProviderImpl.CLASS_TRANSFORMER_OPTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
Properties metaFactoryProps = new Properties();
|
Properties metaFactoryProps = new Properties();
|
||||||
if (info.getManagedClassNames() != null &&
|
if (info.getManagedClassNames() != null
|
||||||
!info.getManagedClassNames().isEmpty()) {
|
&& !info.getManagedClassNames().isEmpty()) {
|
||||||
StringBuffer types = new StringBuffer();
|
StringBuffer types = new StringBuffer();
|
||||||
for (String type : info.getManagedClassNames()) {
|
for (String type : info.getManagedClassNames()) {
|
||||||
if (types.length() > 0)
|
if (types.length() > 0)
|
||||||
|
@ -404,8 +403,7 @@ public class PersistenceUnitInfoImpl
|
||||||
}
|
}
|
||||||
if (!metaFactoryProps.isEmpty()) {
|
if (!metaFactoryProps.isEmpty()) {
|
||||||
// set persistent class locations as properties of metadata factory
|
// set persistent class locations as properties of metadata factory
|
||||||
String factory =
|
String factory = (String) map.get("openjpa.MetaDataFactory");
|
||||||
(String) map.get("openjpa.MetaDataFactory");
|
|
||||||
if (factory == null)
|
if (factory == null)
|
||||||
factory = Configurations.serializeProperties(metaFactoryProps);
|
factory = Configurations.serializeProperties(metaFactoryProps);
|
||||||
else {
|
else {
|
||||||
|
@ -417,6 +415,9 @@ public class PersistenceUnitInfoImpl
|
||||||
}
|
}
|
||||||
map.put("openjpa.MetaDataFactory", factory);
|
map.put("openjpa.MetaDataFactory", factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// always record provider name for product derivations to access
|
||||||
|
map.put(KEY_PROVIDER, info.getPersistenceProviderClassName());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue