tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: moving ScanJarService + fixing DependenceValidationTest
Date Thu, 05 Mar 2015 10:48:54 GMT
Repository: tomee
Updated Branches:
  refs/heads/develop 5583c7037 -> 83c6ebfe4


moving ScanJarService + fixing DependenceValidationTest


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

Branch: refs/heads/develop
Commit: 83c6ebfe4b1f95dc2610d967c3130fe726138944
Parents: 5583c70
Author: Romain Manni-Bucau <rmannibucau@apache.org>
Authored: Thu Mar 5 11:48:44 2015 +0100
Committer: Romain Manni-Bucau <rmannibucau@apache.org>
Committed: Thu Mar 5 11:48:44 2015 +0100

----------------------------------------------------------------------
 .../openejb/config/service/ScanJarService.java  | 113 -------------------
 .../apache/openejb/service/ScanJarService.java  | 113 +++++++++++++++++++
 .../openejb/DependenceValidationTest.java       |   5 +-
 3 files changed, 117 insertions(+), 114 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/83c6ebfe/container/openejb-core/src/main/java/org/apache/openejb/config/service/ScanJarService.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/service/ScanJarService.java
b/container/openejb-core/src/main/java/org/apache/openejb/config/service/ScanJarService.java
deleted file mode 100644
index 06e16ad..0000000
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/service/ScanJarService.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.config.service;
-
-import org.apache.openejb.cdi.CompositeBeans;
-import org.apache.openejb.config.EjbModule;
-import org.apache.openejb.config.FinderFactory;
-import org.apache.openejb.config.ReadDescriptors;
-import org.apache.openejb.config.event.BeforeAppInfoBuilderEvent;
-import org.apache.openejb.core.ParentClassLoaderFinder;
-import org.apache.openejb.jee.Beans;
-import org.apache.openejb.observer.Observes;
-import org.apache.openejb.util.URLs;
-import org.apache.xbean.finder.archive.FileArchive;
-import org.apache.xbean.finder.archive.JarArchive;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Designed to easily add a container jar in scanning.
- *
- * Definition can look like:
- *
- * 1. scanner = new://Service?class-name=org.apache.openejb.config.service.ScanJarService
- * 2. scanner.url = cdi-lib/foo.jar
- * 
- */
-public class ScanJarService {
-    private URL url;
-    private final List<String> beans = new ArrayList<>();
-    private Beans beansModel;
-
-    public void addScanningResult(@Observes final BeforeAppInfoBuilderEvent event) {
-        for (final EjbModule ejbModule : event.getAppModule().getEjbModules()) {
-            if (ejbModule.getModuleId().startsWith("ear-scoped-cdi-beans")) {
-                final Beans beans = ejbModule.getBeans();
-                if (CompositeBeans.class.isInstance(beans)) {
-                    final CompositeBeans cb = CompositeBeans.class.cast(beans);
-                    cb.getManagedClasses().put(url, new ArrayList<>(this.beans));
-
-                    if (beansModel != null) {
-                        if (beansModel.getAlternativeClasses() != null) {
-                            cb.getAlternativesByUrl().put(url, beansModel.getAlternativeClasses());
-                        }
-                        if (beansModel.getAlternativeStereotypes() != null) {
-                            cb.getAlternativeStereotypesByUrl().put(url, beansModel.getAlternativeStereotypes());
-                        }
-                        if (beansModel.getInterceptors() != null) {
-                            cb.getInterceptorsByUrl().put(url, beansModel.getInterceptors());
-                        }
-                        if (beansModel.getDecorators() != null) {
-                            cb.getDecoratorsByUrl().put(url, beansModel.getDecorators());
-                        }
-                    }
-                }
-                return;
-            }
-        }
-    }
-
-    public void setUrl(final String url) throws Exception {
-        final File f = new File(url);
-        if (f.exists()) {
-            this.url = f.toURI().toURL();
-        } else {
-            this.url = new URL(url);
-        }
-
-        final File file = URLs.toFile(this.url);
-        final ClassLoader loader = ParentClassLoaderFinder.Helper.get();
-        beans.addAll(
-                new FinderFactory.OpenEJBAnnotationFinder(
-                        file.isDirectory() ? new FileArchive(loader, file) : new JarArchive(loader,
this.url))
-                        .getAnnotatedClassNames());
-
-        if (file.isDirectory()) {
-            final File beansXml = new File(file, "META-INF/beans.xml");
-            if (beansXml.exists()) {
-                final FileInputStream inputStream = new FileInputStream(beansXml);
-                beansModel = ReadDescriptors.readBeans(inputStream);
-                inputStream.close();
-            }
-        } else {
-            final URLClassLoader cl = new URLClassLoader(new URL[] { this.url });
-            final InputStream is = cl.getResourceAsStream("META-INF/beans.xml");
-            if (is != null) {
-                beansModel = ReadDescriptors.readBeans(is);
-                is.close();
-            }
-            cl.close();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/tomee/blob/83c6ebfe/container/openejb-core/src/main/java/org/apache/openejb/service/ScanJarService.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/service/ScanJarService.java
b/container/openejb-core/src/main/java/org/apache/openejb/service/ScanJarService.java
new file mode 100644
index 0000000..cc09e5b
--- /dev/null
+++ b/container/openejb-core/src/main/java/org/apache/openejb/service/ScanJarService.java
@@ -0,0 +1,113 @@
+/*
+ * 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.service;
+
+import org.apache.openejb.cdi.CompositeBeans;
+import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.config.FinderFactory;
+import org.apache.openejb.config.ReadDescriptors;
+import org.apache.openejb.config.event.BeforeAppInfoBuilderEvent;
+import org.apache.openejb.core.ParentClassLoaderFinder;
+import org.apache.openejb.jee.Beans;
+import org.apache.openejb.observer.Observes;
+import org.apache.openejb.util.URLs;
+import org.apache.xbean.finder.archive.FileArchive;
+import org.apache.xbean.finder.archive.JarArchive;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Designed to easily add a container jar in scanning.
+ *
+ * Definition can look like:
+ *
+ * 1. scanner = new://Service?class-name=org.apache.openejb.service.ScanJarService
+ * 2. scanner.url = cdi-lib/foo.jar
+ * 
+ */
+public class ScanJarService {
+    private URL url;
+    private final List<String> beans = new ArrayList<>();
+    private Beans beansModel;
+
+    public void addScanningResult(@Observes final BeforeAppInfoBuilderEvent event) {
+        for (final EjbModule ejbModule : event.getAppModule().getEjbModules()) {
+            if (ejbModule.getModuleId().startsWith("ear-scoped-cdi-beans")) {
+                final Beans beans = ejbModule.getBeans();
+                if (CompositeBeans.class.isInstance(beans)) {
+                    final CompositeBeans cb = CompositeBeans.class.cast(beans);
+                    cb.getManagedClasses().put(url, new ArrayList<>(this.beans));
+
+                    if (beansModel != null) {
+                        if (beansModel.getAlternativeClasses() != null) {
+                            cb.getAlternativesByUrl().put(url, beansModel.getAlternativeClasses());
+                        }
+                        if (beansModel.getAlternativeStereotypes() != null) {
+                            cb.getAlternativeStereotypesByUrl().put(url, beansModel.getAlternativeStereotypes());
+                        }
+                        if (beansModel.getInterceptors() != null) {
+                            cb.getInterceptorsByUrl().put(url, beansModel.getInterceptors());
+                        }
+                        if (beansModel.getDecorators() != null) {
+                            cb.getDecoratorsByUrl().put(url, beansModel.getDecorators());
+                        }
+                    }
+                }
+                return;
+            }
+        }
+    }
+
+    public void setUrl(final String url) throws Exception {
+        final File f = new File(url);
+        if (f.exists()) {
+            this.url = f.toURI().toURL();
+        } else {
+            this.url = new URL(url);
+        }
+
+        final File file = URLs.toFile(this.url);
+        final ClassLoader loader = ParentClassLoaderFinder.Helper.get();
+        beans.addAll(
+                new FinderFactory.OpenEJBAnnotationFinder(
+                        file.isDirectory() ? new FileArchive(loader, file) : new JarArchive(loader,
this.url))
+                        .getAnnotatedClassNames());
+
+        if (file.isDirectory()) {
+            final File beansXml = new File(file, "META-INF/beans.xml");
+            if (beansXml.exists()) {
+                final FileInputStream inputStream = new FileInputStream(beansXml);
+                beansModel = ReadDescriptors.readBeans(inputStream);
+                inputStream.close();
+            }
+        } else {
+            final URLClassLoader cl = new URLClassLoader(new URL[] { this.url });
+            final InputStream is = cl.getResourceAsStream("META-INF/beans.xml");
+            if (is != null) {
+                beansModel = ReadDescriptors.readBeans(is);
+                is.close();
+            }
+            cl.close();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/83c6ebfe/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java
b/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java
index 02e2456..a1e66f5 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java
@@ -63,7 +63,10 @@ public class DependenceValidationTest extends TestCase {
         assertNotDependentOn("org.apache.openejb", dynamicAssembler);
 
         // Nothing may depend on the JAXB Tree except the Config code
-        assertNotDependentOn("org.apache.openejb", "org.apache.openejb.jee", "org.apache.openejb.config",
"org.apache.openejb.config.rules", "org.apache.openejb.config.sys", "org.apache.openejb.cdi",
"org.apache.openejb.junit", "org.apache.openejb.testng", "org.apache.openejb.testing");
+        assertNotDependentOn("org.apache.openejb", "org.apache.openejb.jee",
+                "org.apache.openejb.config", "org.apache.openejb.config.rules", "org.apache.openejb.config.sys",
+                "org.apache.openejb.cdi", "org.apache.openejb.junit", "org.apache.openejb.testng",
"org.apache.openejb.testing",
+                "org.apache.openejb.service");
 
         // Nothing may depend on the Config code except it's subpackages
         assertNotDependentOn("org.apache.openejb", "org.apache.openejb.config", "org.apache.openejb.config.event",
"org.apache.openejb.config.typed.util", "org.apache.openejb.config.rules", "org.apache.openejb.config.sys",
"org.apache.openejb.assembler", "org.apache.openejb.cdi", "org.apache.openejb.junit", "org.apache.openejb.testng",
"org.apache.openejb.testing", dynamicAssembler);


Mime
View raw message