ApplicationFactory<BeanT extends Object> class

Create an instance when first used and reuses it for all subsequent requests during the application's execution.

This scope defines its behavior on the getWith or getAsyncWith methods.

First, it will verify if the instance is ready and return it. If not, it will do:

  • Create the instance.
  • Run the Interceptor for create process.
  • Apply all Decorators to the instance.
  • Refresh the qualifier for the Module.
  • Make the instance ready.
  • Run the PostConstruct for the instance.
  • Run the Interceptor for get process.

Note: PreDispose and PreDestroy mixins will only be called if the instance is in use. Use Interceptor if you want to call them regardless.

Inheritance

Constructors

ApplicationFactory({required CustomBuilder<FutureOr<BeanT>> builder, bool canDestroy = true, ListDecorator<BeanT> decorators = const [], Set<Object> interceptors = const {}, Set<Object> children = const {}, FutureOr<bool> selector(Object)?})

Properties

children Set<Object>
Gets the set of child modules for this parent module.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
isFuture bool
Verify if this factory is a Future.
no setteroverride
isReady bool
Verify if this factory is ready (Created).
no setteroverride
isRegistered bool
Indicates whether this factory is currently registered in the DDI container. Returns true if the factory is registered, false otherwise.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selector FutureOr<bool> Function(Object)?
Gets the selector function for conditional bean selection.
no setterinherited
state BeanStateEnum
The current state of this factory in its lifecycle.
no setteroverride
type Type
Returns the current Bean type.
no setterinherited

Methods

addChildrenModules(Set<Object> child) → void
Adds multiple child modules to this parent module.
override
addDecorator(ListDecorator<BeanT> newDecorators) → void
Allows to dynamically add a Decorators.
override
addInterceptor(Set<Object> newInterceptors) → void
Dynamically adds interceptors to this Bean.
override
createInstance<BeanT extends Object, ParameterT extends Object>({required CustomBuilder<FutureOr<BeanT>> builder, ParameterT? parameter}) → BeanT
Creates an instance of BeanT using the provided CustomBuilder and optional parameter.
inherited
createInstanceAsync<BeanT extends Object, ParameterT extends Object>({required CustomBuilder<FutureOr<BeanT>> builder, ParameterT? parameter}) FutureOr<BeanT>
inherited
destroy(void apply()) FutureOr<void>
Removes this instance of the registered class in DDI.
override
dispose() Future<void>
Disposes of the instance of the registered class in DDI.
override
getAsyncWith<ParameterT extends Object>({required Object qualifier, ParameterT? parameter}) Future<BeanT>
Gets or create this instance as Future.
override
getWith<ParameterT extends Object>({required Object qualifier, ParameterT? parameter}) → BeanT
Gets or creates this instance.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
register({required Object qualifier}) Future<void>
Register the instance in DDI. When the instance is ready, must call apply function.
override
setType<NewType extends Object>() → void
Sets the type for this factory to a new type.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited