Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C202A200C84 for ; Mon, 29 May 2017 17:08:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C0C96160BCE; Mon, 29 May 2017 15:08:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E063E160BC2 for ; Mon, 29 May 2017 17:08:05 +0200 (CEST) Received: (qmail 30631 invoked by uid 500); 29 May 2017 15:08:03 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 30622 invoked by uid 99); 29 May 2017 15:08:03 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 May 2017 15:08:03 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 495353A047C for ; Mon, 29 May 2017 15:08:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: scm@geronimo.apache.org From: struberg@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170529150803.495353A047C@svn01-us-west.apache.org> archived-at: Mon, 29 May 2017 15:08:06 -0000 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,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 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... 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... 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 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