You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2015/05/27 15:48:49 UTC
[1/5] tomee git commit: TOMEE-1593 using a linked set instead of a
list for resources.xml
Repository: tomee
Updated Branches:
refs/heads/tomee-1.7.x d98d834af -> dc461c514
TOMEE-1593 using a linked set instead of a list for resources.xml
Conflicts:
container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/32ffd568
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/32ffd568
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/32ffd568
Branch: refs/heads/tomee-1.7.x
Commit: 32ffd568e0dce1251dd0902570de3a10af56f960
Parents: d98d834
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Wed May 27 05:22:48 2015 +0200
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed May 27 13:56:31 2015 +0100
----------------------------------------------------------------------
.../org/apache/openejb/config/AppModule.java | 4 +-
.../openejb/resource/ResourceSortingTest.java | 121 +++++++++++++++++++
2 files changed, 124 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/32ffd568/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
index 7d71a80..9461f1f 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
@@ -36,6 +36,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -59,7 +60,8 @@ public class AppModule implements DeploymentModule {
private final List<PersistenceModule> persistenceModules = new ArrayList<PersistenceModule>();
private final Map<String, TransactionType> txTypeByUnit = new HashMap<String, TransactionType>();
// TODO We could turn this into the Resources JAXB object and support containers and other things as well
- private final Collection<Resource> resources = new HashSet<Resource>();
+ private final Collection<Resource> resources = new LinkedHashSet<Resource>();
+ private final Collection<Container> containers = new HashSet<Container>();
private final Collection<Service> services = new HashSet<Service>();
private final ClassLoader classLoader;
private EntityMappings cmpMappings;
http://git-wip-us.apache.org/repos/asf/tomee/blob/32ffd568/container/openejb-core/src/test/java/org/apache/openejb/resource/ResourceSortingTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/ResourceSortingTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/ResourceSortingTest.java
new file mode 100644
index 0000000..8da1009
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/ResourceSortingTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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.openejb.resource;
+
+import org.apache.openejb.assembler.classic.ResourceInfo;
+import org.apache.openejb.config.ConfigurationFactory;
+import org.apache.openejb.config.sys.JaxbOpenejb;
+import org.apache.openejb.config.sys.Resources;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Module;
+import org.apache.openejb.testing.SimpleLog;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.xml.sax.SAXException;
+
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import javax.xml.bind.JAXBException;
+import javax.xml.parsers.ParserConfigurationException;
+
+import static java.util.Arrays.asList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+@SimpleLog
+@RunWith(ApplicationComposer.class)
+public class ResourceSortingTest {
+
+ public static final List<Character> LETTERS = asList('A', 'B', 'C', 'D', 'E');
+ public static final String BASE_NAME = "foo:bar=Hello";
+
+ @Module
+ public Resources r() throws JAXBException, SAXException, ParserConfigurationException {
+ final StringBuilder resourcesXml = new StringBuilder()
+ .append("<Resources>\n");
+ for (final Character c : LETTERS) {
+ resourcesXml.append("<Resource id=\"Hello").append(c)
+ .append("\" class-name=\"org.apache.openejb.resource.ResourceSortingTest$Foo\">")
+ .append("name foo:bar=Hello").append(c).append("</Resource>");
+ }
+ resourcesXml.append("</Resources>");
+ return JaxbOpenejb.unmarshal(Resources.class, new ByteArrayInputStream(resourcesXml.toString().getBytes()));
+ }
+
+ @Test
+ public void checkOrder() {
+ final Iterator<Character> letters = LETTERS.iterator();
+ final Iterator<String> ids = Foo.IDS.iterator();
+ while (letters.hasNext()) {
+ assertTrue(ids.hasNext());
+ assertEquals(BASE_NAME + letters.next(), ids.next());
+ }
+ assertFalse(letters.hasNext());
+ }
+
+ @Test
+ public void testRealWorld4() throws Exception {
+ final List<ResourceInfo> resources = new ArrayList<>();
+
+ resources.add(new ResourceInfo());
+ resources.get(0).id = "My JMS Connection Factory";
+ resources.get(0).properties = new Properties();
+ resources.get(0).properties.put("ResourceAdapter", "My JMS Resource Adapter");
+
+ resources.add(new ResourceInfo());
+ resources.get(1).id = "My Unmanaged DataSource";
+ resources.get(1).properties = new Properties();
+
+ resources.add(new ResourceInfo());
+ resources.get(2).id = "Test Resource";
+ resources.get(2).properties = new Properties();
+ resources.get(2).properties.put("ResourceAdapter", "My JMS Connection Factory");
+
+ resources.add(new ResourceInfo());
+ resources.get(3).id = "My DataSource";
+ resources.get(3).properties = new Properties();
+
+ resources.add(new ResourceInfo());
+ resources.get(4).id = "My JMS Resource Adapter";
+ resources.get(4).properties = new Properties();
+ resources.get(4).properties.put("DataSource", "My Unmanaged DataSource");
+
+ Collections.sort(resources, new ConfigurationFactory.ResourceInfoComparator(resources));
+
+ for (ResourceInfo i : resources) System.out.println(i.id);
+ assertEquals("My Unmanaged DataSource", resources.get(0).id);
+ assertEquals("My DataSource", resources.get(1).id);
+ assertEquals("My JMS Resource Adapter", resources.get(2).id);
+ assertEquals("My JMS Connection Factory", resources.get(3).id);
+ assertEquals("Test Resource", resources.get(4).id);
+ }
+
+ public static class Foo {
+ private static final List<String> IDS = new ArrayList<>();
+ private String name;
+
+ public void setName(String name) {
+ this.name = name;
+ IDS.add(name);
+ }
+ }
+}
[2/5] tomee git commit: TOMEE-1594 fixing resource ordering for
dependency management. Thanks Jon to have pointed it out and David for its
References reference
Posted by jg...@apache.org.
TOMEE-1594 fixing resource ordering for dependency management. Thanks Jon to have pointed it out and David for its References reference
Conflicts:
container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/2da3139f
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/2da3139f
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/2da3139f
Branch: refs/heads/tomee-1.7.x
Commit: 2da3139ff136412d647dfe3fbc2349426586b365
Parents: 32ffd56
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Wed May 27 07:44:29 2015 +0200
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed May 27 14:02:25 2015 +0100
----------------------------------------------------------------------
.../org/apache/openejb/config/AutoConfig.java | 2 +-
.../openejb/config/ConfigurationFactory.java | 103 +++++--------------
.../org/apache/openejb/util/References.java | 2 +-
.../classic/ResourceInfoComparatorTest.java | 81 ++++++++++++---
.../openejb/resource/ResourceSortingTest.java | 41 +-------
5 files changed, 94 insertions(+), 135 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/2da3139f/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
index 7b7e8d2..1dcd1f8 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
@@ -952,7 +952,7 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
resourcesMap.put(resourceInfo, resource);
}
- Collections.sort(resourceInfos, new ConfigurationFactory.ResourceInfoComparator(resourceInfos));
+ ConfigurationFactory.sort(resourceInfos, module.getModuleId() + "/");
for (final ResourceInfo resourceInfo : resourceInfos) {
final int originalSize = resourceInfo.aliases.size();
final String id = installResource(module.getModuleId(), resourceInfo);
http://git-wip-us.apache.org/repos/asf/tomee/blob/2da3139f/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
index 6e011ea..96b5cf0 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
@@ -88,6 +88,7 @@ import org.apache.openejb.util.LogCategory;
import org.apache.openejb.util.Logger;
import org.apache.openejb.util.Messages;
import org.apache.openejb.util.PropertyPlaceHolderHelper;
+import org.apache.openejb.util.References;
import org.apache.openejb.util.SuperProperties;
import org.apache.openejb.util.URISupport;
import org.apache.openejb.util.URLs;
@@ -109,7 +110,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -486,7 +486,7 @@ public class ConfigurationFactory implements OpenEjbConfigurationFactory {
final ResourceInfo resourceInfo = configureService(resource, ResourceInfo.class);
resources.add(resourceInfo);
}
- Collections.sort(resources, new ResourceInfoComparator(resources));
+ sort(resources, null);
sys.facilities.resources.addAll(resources);
@@ -1603,95 +1603,44 @@ public class ConfigurationFactory implements OpenEjbConfigurationFactory {
}
}
- public static class ResourceInfoComparator implements Comparator<ResourceInfo> {
-
- private final List<String> ids;
- private static final int EQUAL = 0;
- private static final int GREATER = 1;
- private static final int LESS = -1;
-
- public ResourceInfoComparator(final List<ResourceInfo> resources) {
- ids = new ArrayList<String>();
- for (final ResourceInfo info : resources) {
- ids.add(info.id);
- }
- }
-
- @Override
- public int compare(final ResourceInfo a, final ResourceInfo b) {
- final String refA = getReference(a);
- final String refB = getReference(b);
-
- // both null or the same id
- if (refA == null && refB == null ||
- refA != null && refA.equals(refB)) {
- return EQUAL;
- }
-
- // b is referencing a
- if (a.id.equals(refB)) {
- return LESS;
+ public static List<ResourceInfo> sort(final List<ResourceInfo> infos, final String prefix) {
+ final Collection<String> ids = new HashSet<>();
+ return References.sort(infos, new References.Visitor<ResourceInfo>() {
+ @Override // called first so we can rely on it to ensure we have ids full before any getReferences call
+ public String getName(final ResourceInfo resourceInfo) {
+ final String name = prefix != null && resourceInfo.id.startsWith(prefix) ? resourceInfo.id.substring(prefix.length()) : resourceInfo.id;
+ ids.add(name);
+ return name;
}
- // a is referencing b
- if (b.id.equals(refA)) {
- return GREATER;
- }
-
- // a has a ref and b doesn't
- if (refA != null && refB == null) {
- return GREATER;
- }
-
- // b has a ref and a doesn't
- if (refA == null) {
- return LESS;
- }
-
- return EQUAL;
- }
-
- public int hasReference(final ResourceInfo info) {
- for (final Object value : info.properties.values()) {
- if (String.class.isInstance(value)) {
- //noinspection SuspiciousMethodCalls
- if (ids.contains(value)) {
- return GREATER;
+ @Override
+ public Set<String> getReferences(final ResourceInfo resourceInfo) {
+ final Set<String> refs = new HashSet<>();
+ for (final Object value : resourceInfo.properties.values()) {
+ if (!String.class.isInstance(value)) {
+ continue;
}
- }
- }
- return EQUAL;
- }
-
- public String getReference(final ResourceInfo info) {
- for (final Object value : info.properties.values()) {
- if (String.class.isInstance(value)) {
final String string = String.class.cast(value).trim();
if (string.isEmpty()) {
continue;
}
-
- if (ids.contains(string)) {
- return (String) value;
- }
-
if (string.contains(",")) { // multiple references
for (final String s : string.split(",")) {
- final String trimmed = s.trim();
- if (ids.contains(trimmed)) {
- return s;
+ final String trim = s.trim();
+ if (ids.contains(trim)) {
+ refs.add(trim);
}
}
- }
-
- for (final String s : ids) {
- if (s.endsWith("/" + string)) { // submodule resources
- return s;
+ } else {
+ final String trim = String.valueOf(value).trim();
+ if (ids.contains(trim)) {
+ refs.add(trim);
}
}
}
+ return refs;
}
- return null;
- }
+ });
}
+
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/2da3139f/container/openejb-core/src/main/java/org/apache/openejb/util/References.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/References.java b/container/openejb-core/src/main/java/org/apache/openejb/util/References.java
index 477ac93..eac118c 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/References.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/References.java
@@ -67,7 +67,7 @@ public class References {
}
boolean circuitFounded = false;
for (final Node node : nodes.values()) {
- final Set<Node> visitedNodes = new HashSet<Node>();
+ final Set<Node> visitedNodes = new HashSet<>();
if (!normalizeNodeReferences(node, node, visitedNodes)) {
circuitFounded = true;
break;
http://git-wip-us.apache.org/repos/asf/tomee/blob/2da3139f/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ResourceInfoComparatorTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ResourceInfoComparatorTest.java b/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ResourceInfoComparatorTest.java
index 3c89fc2..0fa95b8 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ResourceInfoComparatorTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ResourceInfoComparatorTest.java
@@ -18,9 +18,10 @@ package org.apache.openejb.assembler.classic;
import junit.framework.TestCase;
import org.apache.openejb.config.ConfigurationFactory;
+import org.apache.openejb.util.Join;
+import org.junit.Test;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Properties;
@@ -51,12 +52,19 @@ public class ResourceInfoComparatorTest extends TestCase {
resources.get(3).properties = new Properties();
resources.get(3).properties.put("foo", "Green");
- Collections.sort(resources, new ConfigurationFactory.ResourceInfoComparator(resources));
+ final List<ResourceInfo> sorted = ConfigurationFactory.sort(resources, null);
- assertEquals("Green", resources.get(0).id);
- assertEquals("Blue", resources.get(1).id);
- assertEquals("Red", resources.get(2).id);
- assertEquals("Yellow", resources.get(3).id);
+ final String error = Join.join(",", new Join.NameCallback<ResourceInfo>() {
+ @Override
+ public String getName(ResourceInfo object) {
+ return object.id;
+ }
+ }, resources);
+
+ assertEquals(error, "Green", sorted.get(0).id);
+ assertEquals(error, "Blue", sorted.get(1).id);
+ assertEquals(error, "Red", sorted.get(2).id);
+ assertEquals(error, "Yellow", sorted.get(3).id);
}
@@ -81,12 +89,12 @@ public class ResourceInfoComparatorTest extends TestCase {
resources.get(3).properties = new Properties();
resources.get(3).properties.put("ResourceAdapter", "My JMS Resource Adapter");
- Collections.sort(resources, new ConfigurationFactory.ResourceInfoComparator(resources));
+ final List<ResourceInfo> sorted = ConfigurationFactory.sort(resources, null);
- assertEquals("My DataSource", resources.get(0).id);
- assertEquals("My Unmanaged DataSource", resources.get(1).id);
- assertEquals("My JMS Resource Adapter", resources.get(2).id);
- assertEquals("My JMS Connection Factory", resources.get(3).id);
+ assertEquals("My DataSource", sorted.get(0).id);
+ assertEquals("My Unmanaged DataSource", sorted.get(1).id);
+ assertEquals("My JMS Resource Adapter", sorted.get(2).id);
+ assertEquals("My JMS Connection Factory", sorted.get(3).id);
}
@@ -111,14 +119,55 @@ public class ResourceInfoComparatorTest extends TestCase {
resources.get(3).id = "My DataSource";
resources.get(3).properties = new Properties();
+ final List<ResourceInfo> sorted = ConfigurationFactory.sort(resources, null);
- Collections.sort(resources, new ConfigurationFactory.ResourceInfoComparator(resources));
+ final String error = Join.join(",", new Join.NameCallback<ResourceInfo>() {
+ @Override
+ public String getName(ResourceInfo object) {
+ return object.id;
+ }
+ }, sorted);
// since unmanaged is first in the "file" it should be first here
- assertEquals("My Unmanaged DataSource", resources.get(0).id);
- assertEquals("My DataSource", resources.get(1).id);
- assertEquals("My JMS Resource Adapter", resources.get(2).id);
- assertEquals("My JMS Connection Factory", resources.get(3).id);
+ assertEquals(error, "My Unmanaged DataSource", sorted.get(0).id);
+ assertEquals(error, "My JMS Resource Adapter", sorted.get(1).id);
+ assertEquals(error, "My JMS Connection Factory", sorted.get(2).id);
+ assertEquals(error, "My DataSource", sorted.get(3).id);
+ }
+
+ @Test
+ public void testRealWorld4() throws Exception {
+ final List<ResourceInfo> resources = new ArrayList<>();
+
+ resources.add(new ResourceInfo());
+ resources.get(0).id = "My JMS Connection Factory";
+ resources.get(0).properties = new Properties();
+ resources.get(0).properties.put("ResourceAdapter", "My JMS Resource Adapter");
+
+ resources.add(new ResourceInfo());
+ resources.get(1).id = "My Unmanaged DataSource";
+ resources.get(1).properties = new Properties();
+
+ resources.add(new ResourceInfo());
+ resources.get(2).id = "Test Resource";
+ resources.get(2).properties = new Properties();
+ resources.get(2).properties.put("ResourceAdapter", "My JMS Connection Factory");
+
+ resources.add(new ResourceInfo());
+ resources.get(3).id = "My DataSource";
+ resources.get(3).properties = new Properties();
+
+ resources.add(new ResourceInfo());
+ resources.get(4).id = "My JMS Resource Adapter";
+ resources.get(4).properties = new Properties();
+ resources.get(4).properties.put("DataSource", "My Unmanaged DataSource");
+
+ final List<ResourceInfo> sorted = ConfigurationFactory.sort(resources, null);
+ assertEquals("My Unmanaged DataSource", sorted.get(0).id);
+ assertEquals("My DataSource", sorted.get(1).id);
+ assertEquals("My JMS Resource Adapter", sorted.get(2).id);
+ assertEquals("My JMS Connection Factory", sorted.get(3).id);
+ assertEquals("Test Resource", sorted.get(4).id);
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/2da3139f/container/openejb-core/src/test/java/org/apache/openejb/resource/ResourceSortingTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/ResourceSortingTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/ResourceSortingTest.java
index 8da1009..02537b1 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/resource/ResourceSortingTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/ResourceSortingTest.java
@@ -16,8 +16,6 @@
*/
package org.apache.openejb.resource;
-import org.apache.openejb.assembler.classic.ResourceInfo;
-import org.apache.openejb.config.ConfigurationFactory;
import org.apache.openejb.config.sys.JaxbOpenejb;
import org.apache.openejb.config.sys.Resources;
import org.apache.openejb.junit.ApplicationComposer;
@@ -29,10 +27,8 @@ import org.xml.sax.SAXException;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
import javax.xml.bind.JAXBException;
import javax.xml.parsers.ParserConfigurationException;
@@ -41,7 +37,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-@SimpleLog
+@SimpleLog // close to org.apache.openejb.assembler.classic.ResourceInfoComparatorTest but with a real case!
@RunWith(ApplicationComposer.class)
public class ResourceSortingTest {
@@ -72,42 +68,7 @@ public class ResourceSortingTest {
assertFalse(letters.hasNext());
}
- @Test
- public void testRealWorld4() throws Exception {
- final List<ResourceInfo> resources = new ArrayList<>();
-
- resources.add(new ResourceInfo());
- resources.get(0).id = "My JMS Connection Factory";
- resources.get(0).properties = new Properties();
- resources.get(0).properties.put("ResourceAdapter", "My JMS Resource Adapter");
-
- resources.add(new ResourceInfo());
- resources.get(1).id = "My Unmanaged DataSource";
- resources.get(1).properties = new Properties();
-
- resources.add(new ResourceInfo());
- resources.get(2).id = "Test Resource";
- resources.get(2).properties = new Properties();
- resources.get(2).properties.put("ResourceAdapter", "My JMS Connection Factory");
- resources.add(new ResourceInfo());
- resources.get(3).id = "My DataSource";
- resources.get(3).properties = new Properties();
-
- resources.add(new ResourceInfo());
- resources.get(4).id = "My JMS Resource Adapter";
- resources.get(4).properties = new Properties();
- resources.get(4).properties.put("DataSource", "My Unmanaged DataSource");
-
- Collections.sort(resources, new ConfigurationFactory.ResourceInfoComparator(resources));
-
- for (ResourceInfo i : resources) System.out.println(i.id);
- assertEquals("My Unmanaged DataSource", resources.get(0).id);
- assertEquals("My DataSource", resources.get(1).id);
- assertEquals("My JMS Resource Adapter", resources.get(2).id);
- assertEquals("My JMS Connection Factory", resources.get(3).id);
- assertEquals("Test Resource", resources.get(4).id);
- }
public static class Foo {
private static final List<String> IDS = new ArrayList<>();
[5/5] tomee git commit: Fixing compile errors after merge
Posted by jg...@apache.org.
Fixing compile errors after merge
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/dc461c51
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/dc461c51
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/dc461c51
Branch: refs/heads/tomee-1.7.x
Commit: dc461c514c074a634dc44a1db65000af4f92f5f8
Parents: db43535
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed May 27 14:31:36 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed May 27 14:31:36 2015 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/openejb/config/AppModule.java | 1 -
.../java/org/apache/openejb/config/ConfigurationFactory.java | 6 +++---
.../src/main/java/org/apache/openejb/util/References.java | 2 +-
.../openejb/assembler/classic/ResourceInfoComparatorTest.java | 2 +-
.../java/org/apache/openejb/resource/ResourceSortingTest.java | 2 +-
5 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/dc461c51/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
index 9461f1f..ffa3e4e 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
@@ -61,7 +61,6 @@ public class AppModule implements DeploymentModule {
private final Map<String, TransactionType> txTypeByUnit = new HashMap<String, TransactionType>();
// TODO We could turn this into the Resources JAXB object and support containers and other things as well
private final Collection<Resource> resources = new LinkedHashSet<Resource>();
- private final Collection<Container> containers = new HashSet<Container>();
private final Collection<Service> services = new HashSet<Service>();
private final ClassLoader classLoader;
private EntityMappings cmpMappings;
http://git-wip-us.apache.org/repos/asf/tomee/blob/dc461c51/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
index b9d75f8..021867c 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
@@ -481,7 +481,7 @@ public class ConfigurationFactory implements OpenEjbConfigurationFactory {
sys.facilities.transactionService = configureService(openejb.getTransactionManager(), TransactionServiceInfo.class);
- List<ResourceInfo> resources = new ArrayList<>();
+ List<ResourceInfo> resources = new ArrayList<ResourceInfo>();
for (final Resource resource : openejb.getResource()) {
final ResourceInfo resourceInfo = configureService(resource, ResourceInfo.class);
resources.add(resourceInfo);
@@ -1604,7 +1604,7 @@ public class ConfigurationFactory implements OpenEjbConfigurationFactory {
}
public static List<ResourceInfo> sort(final List<ResourceInfo> infos, final String prefix) {
- final Collection<String> ids = new HashSet<>();
+ final Collection<String> ids = new HashSet<String>();
return References.sort(infos, new References.Visitor<ResourceInfo>() {
@Override // called first so we can rely on it to ensure we have ids full before any getReferences call
public String getName(final ResourceInfo resourceInfo) {
@@ -1615,7 +1615,7 @@ public class ConfigurationFactory implements OpenEjbConfigurationFactory {
@Override
public Set<String> getReferences(final ResourceInfo resourceInfo) {
- final Set<String> refs = new HashSet<>();
+ final Set<String> refs = new HashSet<String>();
for (final Object value : resourceInfo.properties.values()) {
if (!String.class.isInstance(value)) {
continue;
http://git-wip-us.apache.org/repos/asf/tomee/blob/dc461c51/container/openejb-core/src/main/java/org/apache/openejb/util/References.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/References.java b/container/openejb-core/src/main/java/org/apache/openejb/util/References.java
index eac118c..477ac93 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/References.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/References.java
@@ -67,7 +67,7 @@ public class References {
}
boolean circuitFounded = false;
for (final Node node : nodes.values()) {
- final Set<Node> visitedNodes = new HashSet<>();
+ final Set<Node> visitedNodes = new HashSet<Node>();
if (!normalizeNodeReferences(node, node, visitedNodes)) {
circuitFounded = true;
break;
http://git-wip-us.apache.org/repos/asf/tomee/blob/dc461c51/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ResourceInfoComparatorTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ResourceInfoComparatorTest.java b/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ResourceInfoComparatorTest.java
index 0fa95b8..43dabb6 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ResourceInfoComparatorTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ResourceInfoComparatorTest.java
@@ -137,7 +137,7 @@ public class ResourceInfoComparatorTest extends TestCase {
@Test
public void testRealWorld4() throws Exception {
- final List<ResourceInfo> resources = new ArrayList<>();
+ final List<ResourceInfo> resources = new ArrayList<ResourceInfo>();
resources.add(new ResourceInfo());
resources.get(0).id = "My JMS Connection Factory";
http://git-wip-us.apache.org/repos/asf/tomee/blob/dc461c51/container/openejb-core/src/test/java/org/apache/openejb/resource/ResourceSortingTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/ResourceSortingTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/ResourceSortingTest.java
index 02537b1..00486ad 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/resource/ResourceSortingTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/ResourceSortingTest.java
@@ -71,7 +71,7 @@ public class ResourceSortingTest {
public static class Foo {
- private static final List<String> IDS = new ArrayList<>();
+ private static final List<String> IDS = new ArrayList<String>();
private String name;
public void setName(String name) {
[4/5] tomee git commit: using the intended instance of the sorted list
Posted by jg...@apache.org.
using the intended instance of the sorted list
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/db43535f
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/db43535f
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/db43535f
Branch: refs/heads/tomee-1.7.x
Commit: db43535fa83fab2346e4e6e0e22ab80eee9eb6c1
Parents: 507e56e
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Wed May 27 08:47:46 2015 +0200
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed May 27 14:02:48 2015 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/openejb/config/AutoConfig.java | 4 ++--
.../java/org/apache/openejb/config/ConfigurationFactory.java | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/db43535f/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
index 1dcd1f8..c525b80 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
@@ -878,7 +878,7 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
Collections.addAll(jndiConsumers, ejbModule.getEjbJar().getEnterpriseBeans());
}
- final List<ResourceInfo> resourceInfos = new ArrayList<ResourceInfo>();
+ List<ResourceInfo> resourceInfos = new ArrayList<ResourceInfo>();
final Map<ResourceInfo, Resource> resourcesMap = new HashMap<ResourceInfo, Resource>(resources.size());
for (final Resource resource : resources) {
final String originalId = PropertyPlaceHolderHelper.value(resource.getId());
@@ -952,7 +952,7 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
resourcesMap.put(resourceInfo, resource);
}
- ConfigurationFactory.sort(resourceInfos, module.getModuleId() + "/");
+ resourceInfos = ConfigurationFactory.sort(resourceInfos, module.getModuleId() + "/");
for (final ResourceInfo resourceInfo : resourceInfos) {
final int originalSize = resourceInfo.aliases.size();
final String id = installResource(module.getModuleId(), resourceInfo);
http://git-wip-us.apache.org/repos/asf/tomee/blob/db43535f/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
index 5282276..b9d75f8 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
@@ -481,12 +481,12 @@ public class ConfigurationFactory implements OpenEjbConfigurationFactory {
sys.facilities.transactionService = configureService(openejb.getTransactionManager(), TransactionServiceInfo.class);
- final List<ResourceInfo> resources = new ArrayList<ResourceInfo>();
+ List<ResourceInfo> resources = new ArrayList<>();
for (final Resource resource : openejb.getResource()) {
final ResourceInfo resourceInfo = configureService(resource, ResourceInfo.class);
resources.add(resourceInfo);
}
- sort(resources, null);
+ resources = sort(resources, null);
sys.facilities.resources.addAll(resources);
[3/5] tomee git commit: avoid circular exception cause of std
ServiceId and potentially other common cases like Name
Posted by jg...@apache.org.
avoid circular exception cause of std ServiceId and potentially other common cases like Name
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/507e56e3
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/507e56e3
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/507e56e3
Branch: refs/heads/tomee-1.7.x
Commit: 507e56e3dff14b30de5c29a58e7e89ffb7024a03
Parents: 2da3139
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Wed May 27 08:17:27 2015 +0200
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed May 27 14:02:36 2015 +0100
----------------------------------------------------------------------
.../main/java/org/apache/openejb/config/ConfigurationFactory.java | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/507e56e3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
index 96b5cf0..5282276 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
@@ -1638,6 +1638,7 @@ public class ConfigurationFactory implements OpenEjbConfigurationFactory {
}
}
}
+ refs.remove(getName(resourceInfo)); // can happen with serviceId for instance, avoid cicular dep issue
return refs;
}
});