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();
Constructor and Description |
---|
Weld() |
Modifier and Type | Method and Description |
---|---|
void |
addExtension(Extension extension)
Add extension explicitly.
|
protected Deployment |
createDeployment(ResourceLoader resourceLoader,
Bootstrap bootstrap)
Extensions to Weld SE can subclass and override this method to customise
the deployment before weld boots up.
|
protected <T> T |
getInstanceByType(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 void addExtension(Extension extension)
extension
- an extensionpublic WeldContainer initialize()
protected Deployment createDeployment(ResourceLoader resourceLoader, Bootstrap bootstrap)
Extensions to Weld SE can subclass and override this method to customise 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() { Deployment deployment = super.createDeployment(); deployment.getServices().add(ResourceLoader.class, new MyResourceLoader()); return deployment; } }
This could then be used as normal:
WeldContainer container = new MyWeld().initialize();
protected <T> T getInstanceByType(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 givenUnsatisfiedResolutionException
- 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 © 2013 Seam Framework. All Rights Reserved.