public class Weld extends Object
The preferred method of booting Weld SE.
Typical usage of this API looks like this:
Weld weld = new Weld(); WeldContainer container = weld.initialize(); container.instance().select(Foo.class).get(); container.event().select(Bar.class).fire(new Bar()); weld.shutdown();
| Modifier and Type | Field and Description |
|---|---|
static String |
ARCHIVE_ISOLATION_SYSTEM_PROPERTY |
| Constructor and Description |
|---|
Weld() |
Weld(String containerId)
Assign a unique ID to this Weld instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addExtension(javax.enterprise.inject.spi.Extension extension)
Add extension explicitly.
|
protected org.jboss.weld.bootstrap.spi.Deployment |
createDeployment(org.jboss.weld.resources.spi.ResourceLoader resourceLoader,
org.jboss.weld.bootstrap.api.CDI11Bootstrap bootstrap)
Extensions to Weld SE can subclass and override this method to customize the deployment before weld boots up.
|
protected <T> T |
getInstanceByType(javax.enterprise.inject.spi.BeanManager manager,
Class<T> type,
Annotation... bindings)
Utility method allowing managed instances of beans to provide entry points for non-managed beans (such as
WeldContainer). |
WeldContainer |
initialize()
Boots Weld and creates and returns a WeldContainer instance, through which
beans and events can be accessed.
|
void |
shutdown()
Shuts down Weld.
|
public static final String ARCHIVE_ISOLATION_SYSTEM_PROPERTY
public Weld()
public Weld(String containerId)
containerId - the unique ID for this containerpublic void addExtension(javax.enterprise.inject.spi.Extension extension)
extension - an extensionpublic WeldContainer initialize()
protected org.jboss.weld.bootstrap.spi.Deployment createDeployment(org.jboss.weld.resources.spi.ResourceLoader resourceLoader,
org.jboss.weld.bootstrap.api.CDI11Bootstrap bootstrap)
Extensions to Weld SE can subclass and override this method to customize the deployment before weld boots up. For example, to add a custom ResourceLoader, you would subclass Weld like so:
public class MyWeld extends Weld {
protected Deployment createDeployment(ResourceLoader resourceLoader, CDI11Bootstrap bootstrap) {
return super.createDeployment(new MyResourceLoader(), bootstrap);
}
}
This could then be used as normal:
WeldContainer container = new MyWeld().initialize();
resourceLoader - bootstrap - protected <T> T getInstanceByType(javax.enterprise.inject.spi.BeanManager manager,
Class<T> type,
Annotation... bindings)
WeldContainer). Should only called once
Weld has finished booting.manager - the BeanManager to use to access the managed instancetype - the type of the Beanbindings - the bean's qualifiersIllegalArgumentException - if the given type represents a type variableIllegalArgumentException - if two instances of the same qualifier type are givenIllegalArgumentException - if an instance of an annotation that is not a qualifier type is givenjavax.enterprise.inject.UnsatisfiedResolutionException - if no beans can be resolved * @throws AmbiguousResolutionException if the ambiguous dependency resolution rules
failIllegalArgumentException - if the given type is not a bean type of the given beanpublic void shutdown()
Copyright © 2016. All rights reserved.