You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by ro...@apache.org on 2019/11/22 22:03:50 UTC

[aries-cdi] 04/19: spi

This is an automated email from the ASF dual-hosted git repository.

rotty3000 pushed a commit to branch rotty3000/cdi-spi
in repository https://gitbox.apache.org/repos/asf/aries-cdi.git

commit 85f06de05eb85c1a048801be964456f46efc2a6f
Author: Raymond Augé <ro...@apache.org>
AuthorDate: Wed Nov 20 17:34:33 2019 -0500

    spi
    
    Signed-off-by: Raymond Augé <ro...@apache.org>
---
 cdi-spi/pom.xml                                    | 77 ++++++++++++++++++++++
 .../main/java/org/apache/aries/cdi/spi/Keys.java   | 41 ++++++++++++
 .../aries/cdi/spi/loader/BundleClassLoader.java    | 42 ++++++++++++
 .../apache/aries/cdi/spi/loader/package-info.java  | 17 +++++
 pom.xml                                            |  1 +
 5 files changed, 178 insertions(+)

diff --git a/cdi-spi/pom.xml b/cdi-spi/pom.xml
new file mode 100644
index 0000000..f7dd0c2
--- /dev/null
+++ b/cdi-spi/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/**
+ * Licensed 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.
+ */
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<groupId>org.apache.aries.cdi</groupId>
+		<artifactId>org.apache.aries.cdi</artifactId>
+		<version>1.0.3-SNAPSHOT</version>
+		<relativePath>..</relativePath>
+	</parent>
+
+	<artifactId>org.apache.aries.cdi.spi</artifactId>
+	<name>Apache Aries CDI - SPI</name>
+	<description>Apache Aries CDI - SPI</description>
+
+	<licenses>
+		<license>
+			<name>ASL 2.0</name>
+			<url>https://www.apache.org/licenses/LICENSE-2.0</url>
+		</license>
+	</licenses>
+
+	<scm>
+		<connection>scm:git:git@github.com:apache/aries-cdi.git</connection>
+		<developerConnection>scm:git:git@github.com:apache/aries-cdi.git</developerConnection>
+		<tag>HEAD</tag>
+		<url>https://github.com/apache/aries-cdi</url>
+	</scm>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>biz.aQute.bnd</groupId>
+				<artifactId>bnd-maven-plugin</artifactId>
+				<configuration>
+					<bnd><![CDATA[
+						-cdiannotations:
+					]]></bnd>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-jcdi_2.0_spec</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>osgi.annotation</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>osgi.core</artifactId>
+		</dependency>
+	</dependencies>
+
+</project>
\ No newline at end of file
diff --git a/cdi-spi/src/main/java/org/apache/aries/cdi/spi/Keys.java b/cdi-spi/src/main/java/org/apache/aries/cdi/spi/Keys.java
new file mode 100644
index 0000000..e2fb32b
--- /dev/null
+++ b/cdi-spi/src/main/java/org/apache/aries/cdi/spi/Keys.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.aries.cdi.spi;
+
+import java.net.URL;
+
+import javax.enterprise.inject.se.SeContainerInitializer;
+
+public class Keys {
+
+	private Keys() {}
+
+	private static final String ROOT_PREFIX = "org.apache.aries.cdi.spi.";
+
+	/**
+	 * Key used for passing a {@code Collection<URL>} containing the list of {@code beans.xml}
+	 * {@link URL urls} using {@link SeContainerInitializer#addProperty(String, Object)} or
+	 * {@link SeContainerInitializer#setProperties(java.util.Map)}.
+	 */
+	public static final String BEANS_XML_PROPERTY = ROOT_PREFIX + "beansXml";
+
+	/**
+	 * Key used for passing a {@code BundleContext} of the CDI bundle using
+	 * {@link SeContainerInitializer#addProperty(String, Object)} or
+	 * {@link SeContainerInitializer#setProperties(java.util.Map)}.
+	 */
+	public static final String BUNDLECONTEXT_PROPERTY = ROOT_PREFIX + "bundleContext";
+
+
+}
diff --git a/cdi-spi/src/main/java/org/apache/aries/cdi/spi/loader/BundleClassLoader.java b/cdi-spi/src/main/java/org/apache/aries/cdi/spi/loader/BundleClassLoader.java
new file mode 100644
index 0000000..c450bbb
--- /dev/null
+++ b/cdi-spi/src/main/java/org/apache/aries/cdi/spi/loader/BundleClassLoader.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed 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.aries.cdi.spi.loader;
+
+import java.net.URL;
+import java.security.ProtectionDomain;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
+import org.osgi.framework.Bundle;
+
+public abstract class BundleClassLoader extends ClassLoader {
+
+	public abstract List<Bundle> getBundles();
+
+	public abstract Class<?> getOrRegister(
+		final String proxyClassName, final byte[] proxyBytes,
+		final Package pck, final ProtectionDomain protectionDomain);
+
+	public abstract BundleClassLoader handleResources(
+		final Predicate<String> predicate,
+		final Function<String, Enumeration<URL>> function);
+
+	public abstract BundleClassLoader findClass(
+		final Predicate<String> predicate,
+		final Function<String, Class<?>> function);
+
+}
diff --git a/cdi-spi/src/main/java/org/apache/aries/cdi/spi/loader/package-info.java b/cdi-spi/src/main/java/org/apache/aries/cdi/spi/loader/package-info.java
new file mode 100644
index 0000000..0499ce7
--- /dev/null
+++ b/cdi-spi/src/main/java/org/apache/aries/cdi/spi/loader/package-info.java
@@ -0,0 +1,17 @@
+/**
+ * Licensed 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.
+ */
+
+@org.osgi.annotation.bundle.Export
+@org.osgi.annotation.versioning.Version("1.0.0")
+package org.apache.aries.cdi.spi.loader;
diff --git a/pom.xml b/pom.xml
index 2d32411..f4045ea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -57,6 +57,7 @@
 
 	<modules>
 		<module>cdi-extra</module>
+		<module>cdi-spi</module>
 		<module>cdi-extender</module>
 		<module>cdi-extension-el-jsp</module>
 		<module>cdi-extension-http</module>