tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: TOMEE-1522 adding resources of resources.xml in AppModule
Date Tue, 03 Mar 2015 17:34:19 GMT
Repository: tomee
Updated Branches:
  refs/heads/develop 9e407904d -> bdff275a1


TOMEE-1522 adding resources of resources.xml in AppModule


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

Branch: refs/heads/develop
Commit: bdff275a1cc0c043f4b1624086140eacc68fdfed
Parents: 9e40790
Author: Romain Manni-Bucau <rmannibucau@apache.org>
Authored: Tue Mar 3 18:34:06 2015 +0100
Committer: Romain Manni-Bucau <rmannibucau@apache.org>
Committed: Tue Mar 3 18:34:06 2015 +0100

----------------------------------------------------------------------
 .../apache/openejb/config/DeploymentLoader.java | 16 ++++++
 .../assembler/classic/ResourcesEarTest.java     | 54 ++++++++++++++++++++
 2 files changed, 70 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/bdff275a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
index 8a24264..87db01b 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
@@ -26,6 +26,7 @@ import org.apache.openejb.cdi.CompositeBeans;
 import org.apache.openejb.classloader.ClassLoaderConfigurer;
 import org.apache.openejb.classloader.WebAppEnricher;
 import org.apache.openejb.config.event.BeforeDeploymentEvent;
+import org.apache.openejb.config.sys.Resources;
 import org.apache.openejb.core.EmptyResourcesClassLoader;
 import org.apache.openejb.core.ParentClassLoaderFinder;
 import org.apache.openejb.jee.Application;
@@ -535,6 +536,21 @@ public class DeploymentLoader implements DeploymentFilterable {
             if (applicationXmlUrl != null) {
                 appModule.getWatchedResources().add(URLs.toFilePath(applicationXmlUrl));
             }
+            if (appDescriptors.containsKey(RESOURCES_XML)) {
+                final Map<String, Object> altDd = new HashMap<String, Object>(appDescriptors);
+                ReadDescriptors.readResourcesXml(new org.apache.openejb.config.Module(false)
{
+                    @Override
+                    public Map<String, Object> getAltDDs() {
+                        return altDd;
+                    }
+
+                    @Override
+                    public void initResources(final Resources resources) {
+                        appModule.getResources().addAll(resources.getResource());
+                        appModule.getServices().addAll(resources.getService());
+                    }
+                });
+            }
 
             // EJB modules
             for (final String moduleName : ejbModules.keySet()) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/bdff275a/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ResourcesEarTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ResourcesEarTest.java
b/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ResourcesEarTest.java
new file mode 100644
index 0000000..173cb20
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ResourcesEarTest.java
@@ -0,0 +1,54 @@
+/**
+ * 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.assembler.classic;
+
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.config.AppModule;
+import org.apache.openejb.config.DeploymentLoader;
+import org.apache.openejb.loader.Files;
+import org.apache.openejb.loader.IO;
+import org.apache.openejb.util.URLs;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class ResourcesEarTest {
+    @Test
+    public void checkAppModuleGetResources() throws IOException, OpenEJBException {
+        final File root = new File("target/ResourcesEarTest/myear/");
+        final File temp = Files.mkdirs(new File(root, "META-INF/"));
+        IO.copy(URLs.toFile(Thread.currentThread().getContextClassLoader().getResource("descriptor-resources.xml")),
new File(temp, "resources.xml"));
+        Files.deleteOnExit(root);
+
+        final AtomicReference<AppModule> moduleAtomicReference = new AtomicReference<>();
+        new DeploymentLoader() {{
+            moduleAtomicReference.set(createAppModule(root.getAbsoluteFile(), root.getPath()));
+        }};
+
+        final AppModule object = moduleAtomicReference.get();
+        assertNotNull(object);
+        assertEquals(1, object.getResources().size());
+        assertEquals("jdbc/descriptors", object.getResources().iterator().next().getId());
+    }
+
+    public static class Touch {}
+}


Mime
View raw message