This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit cbbe84a19f0544ee38c5d101624c5a1a43539741 Author: Andrus Adamchik <[email protected]> AuthorDate: Sun Jul 26 19:03:31 2026 +0300 DataDomainProvider stack exception signatire cleanup --- .../runtime/DataDomainLoadException.java | 38 +++++++--------------- .../configuration/runtime/DataDomainProvider.java | 29 +++++------------ .../configuration/runtime/DataNodeFactory.java | 2 +- .../runtime/SyntheticNodeDataDomainProvider.java | 5 +-- 4 files changed, 24 insertions(+), 50 deletions(-) diff --git a/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataDomainLoadException.java b/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataDomainLoadException.java index fafe01761..6d09da121 100644 --- a/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataDomainLoadException.java +++ b/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataDomainLoadException.java @@ -27,33 +27,19 @@ import org.apache.cayenne.configuration.DataChannelDescriptor; */ public class DataDomainLoadException extends ConfigurationException { - private static final long serialVersionUID = 7969847819485380271L; - - private ConfigurationTree<DataChannelDescriptor> configurationTree; + private static final long serialVersionUID = 7969847819485380271L; - public DataDomainLoadException() { - } + private final ConfigurationTree<DataChannelDescriptor> configurationTree; - public DataDomainLoadException(String messageFormat, Object... messageArgs) { - super(messageFormat, messageArgs); - } - - public DataDomainLoadException(ConfigurationTree<DataChannelDescriptor> configurationTree, String messageFormat, - Object... messageArgs) { - super(messageFormat, messageArgs); - this.configurationTree = configurationTree; - } - - public DataDomainLoadException(Throwable cause) { - super(cause); - } - - public DataDomainLoadException(String messageFormat, Throwable cause, Object... messageArgs) { - super(messageFormat, cause, messageArgs); - } - - public ConfigurationTree<DataChannelDescriptor> getConfigurationTree() { - return configurationTree; - } + public DataDomainLoadException( + ConfigurationTree<DataChannelDescriptor> configurationTree, + String messageFormat, + Object... messageArgs) { + super(messageFormat, messageArgs); + this.configurationTree = configurationTree; + } + public ConfigurationTree<DataChannelDescriptor> getConfigurationTree() { + return configurationTree; + } } diff --git a/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataDomainProvider.java b/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataDomainProvider.java index c405ebc31..002cf130f 100644 --- a/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataDomainProvider.java +++ b/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataDomainProvider.java @@ -18,7 +18,6 @@ ****************************************************************/ package org.apache.cayenne.configuration.runtime; -import org.apache.cayenne.ConfigurationException; import org.apache.cayenne.DataChannel; import org.apache.cayenne.DataChannelQueryFilter; import org.apache.cayenne.DataChannelSyncFilter; @@ -38,6 +37,7 @@ import org.apache.cayenne.configuration.DataChannelDescriptorMerger; import org.apache.cayenne.configuration.DataNodeDescriptor; import org.apache.cayenne.configuration.RuntimeProperties; import org.apache.cayenne.di.AdhocObjectFactory; +import org.apache.cayenne.di.DIRuntimeException; import org.apache.cayenne.di.Inject; import org.apache.cayenne.di.Injector; import org.apache.cayenne.di.Provider; @@ -132,20 +132,7 @@ public class DataDomainProvider implements Provider<DataDomain> { protected EntitySorterFactory entitySorterFactory; @Override - public DataDomain get() throws ConfigurationException { - - try { - return createAndInitDataDomain(); - } catch (ConfigurationException e) { - throw e; - } catch (Exception e) { - String causeMessage = e.getMessage(); - String message = causeMessage != null && !causeMessage.isEmpty() ? causeMessage : e.getClass().getName(); - throw new DataDomainLoadException("DataDomain startup failed: %s", e, message); - } - } - - protected DataDomain createAndInitDataDomain() throws Exception { + public DataDomain get() { DataChannelDescriptor descriptor = loadDescriptor(); EntityResolver entityResolver = createEntityResolver(descriptor); @@ -264,7 +251,7 @@ public class DataDomainProvider implements Provider<DataDomain> { /** * @since 4.0 */ - protected DataNode addDataNode(DataDomain dataDomain, DataNodeDescriptor nodeDescriptor) throws Exception { + protected DataNode addDataNode(DataDomain dataDomain, DataNodeDescriptor nodeDescriptor) { DataNode dataNode = dataNodeFactory.createDataNode(nodeDescriptor); // DataMaps @@ -289,22 +276,22 @@ public class DataDomainProvider implements Provider<DataDomain> { String location = locations.get(i); Collection<Resource> configurations = resourceLocator.findResources(location); - if (configurations.isEmpty()) { - throw new DataDomainLoadException("Configuration resource \"%s\" is not found.", location); + throw new DIRuntimeException("Configuration resource \"%s\" is not found.", location); } Resource configurationResource = configurations.iterator().next(); // no support for multiple configs yet, but this is not a hard error if (configurations.size() > 1) { - LOGGER.info("found {} configurations for {}, will use the first one: {}", configurations.size(), - location, configurationResource.getURL()); + LOGGER.info("found {} configurations for {}, will use the first one: {}", + configurations.size(), + location, + configurationResource.getURL()); } ConfigurationTree<DataChannelDescriptor> tree = loader.load(configurationResource); if (!tree.getLoadFailures().isEmpty()) { - // TODO: andrus 03/10/2010 - log the errors before throwing? throw new DataDomainLoadException(tree, "Error loading DataChannelDescriptor"); } diff --git a/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataNodeFactory.java b/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataNodeFactory.java index 36a4283c3..58d385390 100644 --- a/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataNodeFactory.java +++ b/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataNodeFactory.java @@ -28,5 +28,5 @@ import org.apache.cayenne.configuration.DataNodeDescriptor; */ public interface DataNodeFactory { - DataNode createDataNode(DataNodeDescriptor nodeDescriptor) throws Exception; + DataNode createDataNode(DataNodeDescriptor nodeDescriptor); } diff --git a/cayenne/src/main/java/org/apache/cayenne/runtime/SyntheticNodeDataDomainProvider.java b/cayenne/src/main/java/org/apache/cayenne/runtime/SyntheticNodeDataDomainProvider.java index b04531858..a33fe8868 100644 --- a/cayenne/src/main/java/org/apache/cayenne/runtime/SyntheticNodeDataDomainProvider.java +++ b/cayenne/src/main/java/org/apache/cayenne/runtime/SyntheticNodeDataDomainProvider.java @@ -18,6 +18,7 @@ ****************************************************************/ package org.apache.cayenne.runtime; +import org.apache.cayenne.ConfigurationException; import org.apache.cayenne.access.DataDomain; import org.apache.cayenne.access.DataNode; import org.apache.cayenne.configuration.DataChannelDescriptor; @@ -31,9 +32,9 @@ import org.apache.cayenne.map.DataMap; class SyntheticNodeDataDomainProvider extends DataDomainProvider { @Override - protected DataDomain createAndInitDataDomain() throws Exception { + public DataDomain get() throws ConfigurationException { - DataDomain dataDomain = super.createAndInitDataDomain(); + DataDomain dataDomain = super.get(); // no nodes... add a synthetic node... it will become the default if (dataDomain.getDataNodes().isEmpty()) {
