geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1796645 - in /geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/se: ./ SeContainer.java SeContainerInitializer.java
Date Mon, 29 May 2017 15:08:03 GMT
Author: struberg
Date: Mon May 29 15:08:03 2017
New Revision: 1796645

URL: http://svn.apache.org/viewvc?rev=1796645&view=rev
Log:
GERONIMO-6553 adding SE support for CDI

Patch from John Ament (johndament).
Thanks for the work!

Added:
    geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/se/
    geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/se/SeContainer.java
  (with props)
    geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/se/SeContainerInitializer.java
  (with props)

Added: geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/se/SeContainer.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/se/SeContainer.java?rev=1796645&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/se/SeContainer.java
(added)
+++ geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/se/SeContainer.java
Mon May 29 15:08:03 2017
@@ -0,0 +1,49 @@
+/*
+ *  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 javax.enterprise.inject.se;
+
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.spi.BeanManager;
+
+/**
+ * A representation of the SeContainer that was bootstrapped from a SeContainerInitializer
+ */
+public interface SeContainer extends Instance<Object>,AutoCloseable
+{
+    /**
+     * Shuts down this SeContainer instance.  This is invoked automatically when used with
a try-with-resources block
+     *
+     * @throws IllegalStateException if the container is already shutdown
+     */
+    @Override
+    void close();
+
+    /**
+     * @return true if invoked before calling close(), false if it was shut down
+     */
+    boolean isRunning();
+
+    /**
+     * @return the BeanManager that is backing this SeContainer
+     * @throws IllegalStateException if the container was already shut down
+     */
+    BeanManager getBeanManager();
+
+}
\ No newline at end of file

Propchange: geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/se/SeContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/se/SeContainerInitializer.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/se/SeContainerInitializer.java?rev=1796645&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/se/SeContainerInitializer.java
(added)
+++ geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/se/SeContainerInitializer.java
Mon May 29 15:08:03 2017
@@ -0,0 +1,187 @@
+/*
+ *  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 javax.enterprise.inject.se;
+
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+import java.util.ServiceLoader;
+
+import javax.enterprise.inject.spi.Extension;
+
+/**
+ * This is a builder class for a synthetic bean archive that will be used in an SE Deployment
of CDI.
+ *
+ * Invoking newInstance() creates a new one from a ServiceLoader, and by default will load
all JARs from the classpath
+ * unless you invoke disableDiscovery() and manually load classes in to the archive.
+ */
+@SuppressWarnings("unchecked")
+public abstract class SeContainerInitializer
+{
+
+    /**
+     * Instantiates a new SeContainerInitializer via ServiceLoader
+     * @return the SeContainerInitializer implementation found via ServiceLoader
+     * @throws IllegalStateException if 0 or more than 1 SeContainerInitializer found.
+     */
+    public static SeContainerInitializer newInstance()
+    {
+        ServiceLoader<SeContainerInitializer> serviceLoader =
+                ServiceLoader.load(SeContainerInitializer.class, SeContainerInitializer.class.getClassLoader());
+        long exactSize = serviceLoader.spliterator().getExactSizeIfKnown();
+        if(exactSize == 0)
+        {
+            throw new IllegalStateException("No valid implementation of SeContainerInitializer
found via ServiceLoader");
+        }
+        else if(exactSize > 1)
+        {
+            throw new IllegalStateException("Multiple implementations ("+exactSize+") of
SeContainerInitializer found via ServiceLoader");
+        }
+        return serviceLoader.iterator().next();
+    }
+
+    /**
+     * Adds the listed classes to the resulting synthetic bean archive
+     * @param classes
+     * @return this
+     */
+    public abstract SeContainerInitializer addBeanClasses(Class<?>... classes);
+
+    /**
+     * Adds packages of the given classes to the synthetic bean archive, the result of packageClass.getPackage()
+     *
+     * @param packageClasses
+     * @return this
+     */
+    public abstract SeContainerInitializer addPackages(Class<?>... packageClasses);
+
+    /**
+     * Add packages for the given classes to the synthetic bean archive.
+     *
+     * @param scanRecursively if true, will recursively check the child packages of each
of these classes' packages
+     * @param packageClasses
+     * @return this
+     */
+    public abstract SeContainerInitializer addPackages(boolean scanRecursively, Class<?>...
packageClasses);
+
+    /**
+     * Adds the given packages to the synthetic bean archive.
+     *
+     * @param packages
+     * @return this
+     */
+    public abstract SeContainerInitializer addPackages(Package... packages);
+
+    /**
+     * Adds the given packages to the synthetic bean archive.
+     *
+     * @param scanRecursively if true, will recursively check the child packages of each
of these classes' packages
+     * @param packages
+     * @return this
+     */
+    public abstract SeContainerInitializer addPackages(boolean scanRecursively, Package...
packages);
+
+    /**
+     * Adds the given Extension instances to the synthetic bean archive
+     *
+     * @param extensions
+     * @return this
+     */
+    public abstract SeContainerInitializer addExtensions(Extension... extensions);
+
+    /**
+     * Adds the given Extension classes to the synthetic bean archive
+     *
+     * @param extensions
+     * @return this
+     */
+    public abstract SeContainerInitializer addExtensions(Class<? extends Extension>...
extensions);
+
+    /**
+     * Enables the given interceptors in the synthetic bean archive
+     *
+     * @param interceptorClasses
+     * @return this
+     */
+    public abstract SeContainerInitializer enableInterceptors(Class<?>... interceptorClasses);
+
+    /**
+     * Enables the given decorators in the synthetic bean archive
+     * @param decoratorClasses
+     * @return this
+     */
+    public abstract SeContainerInitializer enableDecorators(Class<?>... decoratorClasses);
+
+    /**
+     * Adds the given alternatives to the list of available alternatives in the bean archive
+     *
+     * @param alternativeClasses
+     * @return this
+     */
+    public abstract SeContainerInitializer selectAlternatives(Class<?>... alternativeClasses);
+
+    /**
+     * Adds the given alternative stereotypes to the list of available alternative stereotypes
in the bean archive
+     *
+     * @param alternativeStereotypeClasses
+     * @return
+     */
+    public abstract SeContainerInitializer selectAlternativeStereotypes(Class<? extends
Annotation>... alternativeStereotypeClasses);
+
+    /**
+     * Adds a configuration property to the container
+     *
+     * @param key
+     * @param value
+     * @return this
+     */
+    public abstract SeContainerInitializer addProperty(String key, Object value);
+
+    /**
+     * Overwrites all existing properties with the contents of the new given map
+     *
+     * @param properties
+     * @return this
+     */
+    public abstract SeContainerInitializer setProperties(Map<String, Object> properties);
+
+    /**
+     * Disables bean discovery of the classpath and instead relies solely on the classes
defined in the archive
+     *
+     * @return this
+     */
+    public abstract SeContainerInitializer disableDiscovery();
+
+    /**
+     * Sets the default ClassLoader for this synthetic bean archive
+     *
+     * @param classLoader
+     * @return this
+     */
+    public abstract SeContainerInitializer setClassLoader(ClassLoader classLoader);
+
+    /**
+     * Bootstraps the container that has been built from this SeContainerInitializer
+     *
+     * @return a new SeContainer representing this synthetic bean archive
+     */
+    public abstract SeContainer initialize();
+
+}
\ No newline at end of file

Propchange: geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/se/SeContainerInitializer.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message