All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.weld.bootstrap.api.Bootstrap Maven / Gradle / Ivy

There is a newer version: 3.0.0.Alpha1
Show newest version
/*
 * JBoss, Home of Professional Open Source
 * Copyright 2010, Red Hat, Inc., and individual contributors
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * 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.jboss.weld.bootstrap.api;

import java.net.URL;

import javax.enterprise.inject.spi.AfterBeanDiscovery;
import javax.enterprise.inject.spi.AfterDeploymentValidation;
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.BeforeShutdown;
import javax.enterprise.inject.spi.Extension;

import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.bootstrap.spi.BeansXml;
import org.jboss.weld.bootstrap.spi.Deployment;
import org.jboss.weld.bootstrap.spi.Metadata;
import org.jboss.weld.manager.api.WeldManager;

/**
 * Application container initialization API for Weld.
 *
 * To initialize the container you must call, in this order:
 *
 * 
    *
  1. {@link #startContainer(Environment, Deployment)}
  2. *
  3. {@link #startInitialization()}
  4. *
  5. {@link #deployBeans()}
  6. *
  7. {@link #validateBeans()}
  8. *
  9. {@link #endInitialization()}
  10. *
* * To stop the container and clean up, you must call {@link #shutdown()} * * @author Pete Muir * */ public interface Bootstrap { /** * Creates the application container: *
    *
  • Checks that the services required by the environment have been provided
  • *
  • Adds container provided services
  • *
  • Creates and initializes the built in contexts
  • *
  • Creates the manager
  • *
* * context * * @param environment the environment in use, by default {@link Environments#EE} * @param deployment the Deployment to be booted * @throws IllegalStateException if not all the services required for the given environment are available * * @return self */ Bootstrap startContainer(Environment environment, Deployment deployment); /** * Starts the application container initialization process: * *
    *
  • Reads metadata from beans.xml and the {@link Deployment} service
  • *
  • Starts the application context
  • *
  • Starts the request context which lasts until {@link #endInitialization()} is called
  • *
  • Discovers and creates {@link Extension} service providers
  • *
* * Finally, the {@link BeforeBeanDiscovery} event is fired. * * @return self */ Bootstrap startInitialization(); /** * Creates and deploys the application's beans: * *
    *
  • Creates and deploys the discovered beans
  • *
  • Creates and deploys the built-in beans defined by the CDI specification
  • *
* * Finally the {@link AfterBeanDiscovery} is event is fired * * @return self */ Bootstrap deployBeans(); /** * Validates the deployment. * * After validation, the {@link AfterDeploymentValidation} event is fired * * @return self */ Bootstrap validateBeans(); /** * Cleans up after the initialization * * @return self */ Bootstrap endInitialization(); /** * Causes the container to clean up and shutdown * * Before the contain is shutdown the {@link BeforeShutdown} event is fired */ void shutdown(); /** * Get the manager used for the given beanDeploymentArchive. * * If {@link #startContainer(Environment, Deployment)} has not been called, this method will return null. * * If the beanDeploymentArchive is not known to Weld (for example, it was not passed to the Weld as part of the * {@link Deployment}, or has not yet been requested by {@link Deployment#loadBeanDeploymentArchive(Class)}), null will be * returned. * * @param beanDeploymentArchive the given beanDeploymentArchive * @return the manager or null if not yet available or not found. */ WeldManager getManager(BeanDeploymentArchive beanDeploymentArchive); /** * Parse the specified URL as a beans.xml file. * * @param url the url to parse * @return the BeansXml data structure which represents the URL * @throws IllegalArgumentException if the URL cannot be opened * */ BeansXml parse(URL url); /** * Parse the specified URLs as a series of beans.xml file and merge the result. * * Duplicate entries are not removed. * * @param urls the urls to parse * @return the BeansXml data structure which represents the URL * @throws IllegalArgumentException if the URL cannot be opened */ BeansXml parse(Iterable urls); /** * Parse the specified URLs as a series of beans.xml file and merge the result. * * @param urls the urls to parse * @param removeDuplicates whether duplicate entries (alternatives, interceptors, etc) are removed * @return the BeansXml data structure which represents the URL * @throws IllegalArgumentException if the URL cannot be opened */ BeansXml parse(Iterable urls, boolean removeDuplicates); /** * Load CDI extensions using the provided ClassLoader * * @param classLoader the ClassLoader to use to load the extensions * @throws IllegalArgumentException if classLoader is null * @return loaded extensions */ Iterable> loadExtensions(ClassLoader classLoader); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy