ApplicationFactory<BeanT extends Object> class

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

This Scopes defines is behavior on the getWith or getAsyncWith methods.

First 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.new({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>
This function returns a set of child modules for a 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.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selector FutureOr<bool> Function(Object)?
no setterinherited
state BeanStateEnum
getter/setter pairinherited
type Type
Returns the current Bean type.
no setterinherited

Methods

addChildrenModules(Set<Object> child) → void
This function adds multiple child modules to a parent module. It takes a list of 'child' objects and an optional 'qualifier' for the parent module.
override
addDecorator(ListDecorator<BeanT> newDecorators) FutureOr<void>
Allows to dynamically add a Decorators.
override
addInterceptor(Set<Object> newInterceptors) → void
Allows to dynamically add a Interceptor.
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
disposeChildrenAsync() Future<void>
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, required void apply(DDIBaseFactory<BeanT>)}) Future<void>
Register the instance in DDI. When the instance is ready, must call apply function.
override
setType<NewType extends Object>() → void
inherited
toString() String
A string representation of this object.
inherited

Operators

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