public class Assembler<T> extends Object
Assembler
assembles a component instance according to the descriptor.Constructor and Description |
---|
Assembler(Container container,
Descriptor<T> descriptor)
Constructs a new
Assembler instance with the specified container
and descriptor. |
Assembler(Container container,
Descriptor<T> descriptor,
T instance)
Constructs a new
Assembler instance with the specified container,
descriptor and component instance. |
public Assembler(Container container, Descriptor<T> descriptor)
Assembler
instance with the specified container
and descriptor.container
- The Container
dependent components are required.descriptor
- The component descriptor.public Assembler(Container container, Descriptor<T> descriptor, T instance)
Assembler
instance with the specified container,
descriptor and component instance.container
- The Container
dependent components are required.descriptor
- The component descriptor.instance
- The component instance to be assembled.public T assemble()
Assembler
assembles a component instance by the following
instructions:
Descriptor#type()
returns with the dependent
components getting from the Container
with the constructor's
parameter type and binding annotations. Otherwise, assembler constructs
the instance by invoking Class#newInstance()
method on the class
Descriptor#type()
returns.
When a joinpoint method is declared on the component class, assembler
generates the subclass dynamically with cglib
before the instantiation and instantiates it attaching Dispatcher
as the method invocation handler to intercept the method invocations.
After the instance construction, assembler fires the Constructed
event on the instance. If any exception has occurred, assembler returns
null
immediately.Container
corresponding to the Key
constructed from the
injectable field and populates it to the assembling instance. If any
exception has occurred, assembler skips the failed population.
Validator#valid(Annotation, Object)
. If the method returns
false
, assembler throws ViolationException
. If all
constrained fields are validated, the assembled instance is returned.Copyright © 2011-2014 Eiichiro Uchiumi. All Rights Reserved.