cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject cayenne git commit: CAY-2043 ServerRuntimeBuilder: use DataDomain name for the default DataNode
Date Mon, 28 Dec 2015 14:35:14 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 1448a194c -> fb1985422


CAY-2043 ServerRuntimeBuilder: use DataDomain name for the default DataNode


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/fb198542
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/fb198542
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/fb198542

Branch: refs/heads/master
Commit: fb198542248c07cba6e632d96d7257c2c651a23f
Parents: 1448a19
Author: aadamchik <aadamchik@apache.org>
Authored: Mon Dec 28 09:28:02 2015 -0500
Committer: aadamchik <aadamchik@apache.org>
Committed: Mon Dec 28 09:31:25 2015 -0500

----------------------------------------------------------------------
 .../server/SyntheticNodeDataDomainProvider.java | 11 ++++-
 .../SyntheticNodeDataDomainProviderTest.java    | 42 ++++++++++++++++++++
 docs/doc/src/main/resources/RELEASE-NOTES.txt   |  1 +
 3 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/fb198542/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/SyntheticNodeDataDomainProvider.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/SyntheticNodeDataDomainProvider.java
b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/SyntheticNodeDataDomainProvider.java
index ba6c9dc..ae13bf5 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/SyntheticNodeDataDomainProvider.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/SyntheticNodeDataDomainProvider.java
@@ -39,7 +39,7 @@ class SyntheticNodeDataDomainProvider extends DataDomainProvider {
 
 			DataChannelDescriptor channelDescriptor = new DataChannelDescriptor();
 
-			DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor(ServerRuntimeBuilder.DEFAULT_NAME);
+			DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor(createSyntheticDataNodeName(dataDomain));
 
 			for (DataMap map : dataDomain.getDataMaps()) {
 				nodeDescriptor.getDataMapNames().add(map.getName());
@@ -53,4 +53,13 @@ class SyntheticNodeDataDomainProvider extends DataDomainProvider {
 		return dataDomain;
 	}
 
+	protected String createSyntheticDataNodeName(DataDomain domain) {
+
+		// using Domain's name for the node name.. distinguishing nodes by name
+		// may be useful in case of multiple stacks used in the same
+		// transaction...
+
+		return domain.getName() != null ? domain.getName() : ServerRuntimeBuilder.DEFAULT_NAME;
+	}
+
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fb198542/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/SyntheticNodeDataDomainProviderTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/SyntheticNodeDataDomainProviderTest.java
b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/SyntheticNodeDataDomainProviderTest.java
new file mode 100644
index 0000000..28b5608
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/SyntheticNodeDataDomainProviderTest.java
@@ -0,0 +1,42 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.configuration.server;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.cayenne.access.DataDomain;
+import org.junit.Test;
+
+public class SyntheticNodeDataDomainProviderTest {
+
+	@Test
+	public void testCreateSyntheticDataNodeName() {
+
+		DataDomain ddMock = mock(DataDomain.class);
+
+		SyntheticNodeDataDomainProvider p = new SyntheticNodeDataDomainProvider();
+		assertEquals("cayenne", p.createSyntheticDataNodeName(ddMock));
+
+		when(ddMock.getName()).thenReturn("n");
+		assertEquals("n", p.createSyntheticDataNodeName(ddMock));
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fb198542/docs/doc/src/main/resources/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/RELEASE-NOTES.txt b/docs/doc/src/main/resources/RELEASE-NOTES.txt
index e577b15..81f7d51 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -36,6 +36,7 @@ CAY-2028 Wrap DataChannelFilter calls in the main transaction
 CAY-2029 Allow out-of-order insertion into DI lists
 CAY-2030 Capturing a stream of commit changes
 CAY-2035 Autobind items added to collections (Cayenne DI)
+CAY-2043 ServerRuntimeBuilder: use DataDomain name for the default DataNode
 
 Bug Fixes:
 


Mime
View raw message