const mixinafIoc::Registry

afIoc::Registry

The registry of IoC services.

autobuild

Source

abstract Obj autobuild(Type type, Obj?[] ctorArgs := Obj#.emptyList())

Autobuilds an instance of the given type, resolving all dependencies:

  • create instance via ctor marked with @Inject or the ctor with the most parameters
  • inject dependencies into fields (of all visibilities) marked with @Inject
  • call any methods annotated with @PostInjection

The other parameters (if provided) may be passed to the autobuild ctor. Handy when you wish the ctor to take a mixture of objects and services. e.g. for a fwt::Command:

registry.autobuild(MySaveCommand#, [entityToSave]).invoke(null)
..
class MySaveCommand {
  @Inject
  private EntityDao entityDao
  
  private Entity entity

  new make(Entity entity, OtherService service, |This| injectInto) {
    injectInto(this)       // ioc to inject all fields
    service.doSomething    // this service is only used here, so doesn't need to be a field 
    entityDao.save(entity) // use the field service and passed in entity 
  }
}

Note: the passed in parameters must be first in the ctor parameter list.

Impl note: A list is used rather than splats so nulls can be passed in.

dependencyByType

Source

abstract Obj dependencyByType(Type dependencyType)

Locates a dependency of the given type. The search takes into account inheritance of the service mixin, not the service implementation.

injectIntoFields

Source

abstract Obj injectIntoFields(Obj service)

Injects services and dependencies into fields (of all visibilities) marked with @Inject.

Returns the object passed in for method chaining.

Note usage of this method is discouraged, it is far better practice for the creator to call autobuild instead.

serviceById

Source

abstract Obj serviceById(Str serviceId)

Obtains a service via its unique service id.

shutdown

Source

abstract This shutdown()

Shuts down the Registry. Notifies all listeners that the registry has shutdown. Further method invocations on the Registry are no longer allowed, and the Registry instance should be discarded.

See RegistryShutdownHub

startup

Source

abstract This startup()

Invoke to execute all contributions to the RegistryStartup service.