org.jboss.weld.environment.se
Class Weld

java.lang.Object
  extended by org.jboss.weld.environment.se.Weld

public class Weld
extends Object

The preferred method of booting Weld SE.

Typical usage of this API looks like this:

 WeldContainer weld = new Weld().initialize();
 weld.instance().select(Foo.class).get();
 weld.event().select(Bar.class).fire(new Bar());
 weld.shutdown();
 

Author:
Peter Royle, Pete Muir, Ales Justin

Constructor Summary
Weld()
           
 
Method Summary
 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.Bootstrap bootstrap)
           Extensions to Weld SE can subclass and override this method to customise 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Weld

public Weld()
Method Detail

addExtension

public void addExtension(javax.enterprise.inject.spi.Extension extension)
Add extension explicitly.

Parameters:
extension - an extension

initialize

public WeldContainer initialize()
Boots Weld and creates and returns a WeldContainer instance, through which beans and events can be accessed.

Returns:
weld container

createDeployment

protected org.jboss.weld.bootstrap.spi.Deployment createDeployment(org.jboss.weld.resources.spi.ResourceLoader resourceLoader,
                                                                   org.jboss.weld.bootstrap.api.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();
 


getInstanceByType

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). Should only called once Weld has finished booting.

Parameters:
manager - the BeanManager to use to access the managed instance
type - the type of the Bean
bindings - the bean's qualifiers
Returns:
a managed instance of the bean
Throws:
IllegalArgumentException - if the given type represents a type variable
IllegalArgumentException - if two instances of the same qualifier type are given
IllegalArgumentException - if an instance of an annotation that is not a qualifier type is given
javax.enterprise.inject.UnsatisfiedResolutionException - if no beans can be resolved * @throws AmbiguousResolutionException if the ambiguous dependency resolution rules fail
IllegalArgumentException - if the given type is not a bean type of the given bean

shutdown

public void shutdown()
Shuts down Weld.



Copyright © 2013 Seam Framework. All Rights Reserved.