For the complete documentation index, see llms.txt. This page is also available as Markdown.

Common Methods

The following chart shows you the most common methods when dealing with the WireBox Injector. This doesn't mean there are no other methods on the Injector that are of value, so please check out the API Docs for more in-depth knowledge.

API Docs
// Send an object to WireBox for autowiring by convention or mapping lookups
autowire( target, [mapping], [targetID], [annotationCheck] )

// Clears all singleton instances from the singleton scope (handy in development)
clearSingletons()

// Checks if this injector can build the named instance
containsInstance( name )

// Get the configuration binder for this injector
getBinder()

// The primary method to request an object instance by name, DSL string, or child injector
getInstance( [name], [initArguments], [dsl], [targetObject], [injector] )

// Return the WireBox ObjectPopulator utility (populate objects from JSON, XML, structs, etc.)
getObjectPopulator()

// Get a reference to the parent injector (if any)
getParent()

// Get a reference to a registered persistence scope by name
getScope( name )

// Set or replace the parent injector
setParent( injector )

// Gracefully shut down the injector and all child injectors
shutdown()

// Return the injector's unique name (e.g. 'root')
getName()

// -----------------------------------------------
// Child Injector Methods
// -----------------------------------------------

// Check whether a named child injector has been registered
hasChildInjector( name )

// Register a child injector, setting this injector as its parent
registerChildInjector( name, child )

// Remove and shut down a child injector by name
removeChildInjector( name )

// Get a registered child injector by name
getChildInjector( name )

// Return an array of all registered child injector names
getChildInjectorNames()

getInstance() – injector Argument

The injector argument lets you route a creation request directly to a registered child injector:

Instance Location & Construction

These methods are the lower-level building blocks that getInstance() uses internally. You normally won't need them, but they are handy when you need finer control over how an object gets located or built (e.g. custom factories, tooling, or dynamic mapping registration).

Injector State & Hierarchy Checks

Other Notable Methods

A handful of remaining public methods are mostly used internally (bootstrap, DSL plumbing, provider bookkeeping) but are worth knowing about:

Method
Description

getScopeRegistration()

Returns the struct describing this injector's scope registration (enabled, key, scope). Bubbles up to the parent injector if this injector doesn't have scope registration enabled.

locateScopedSelf()

Returns this injector's own scoped-registration reference (mostly used internally by providers/scope-widening objects). Throws if scope registration isn't enabled.

registerListener( listener )

Programmatically registers a single WireBox/ColdBox listener struct ({ class, name, properties }) at runtime, the same way listeners declared in your binder's listeners array are registered on startup.

registerDSL( namespace, path )

Registers a custom injection DSL namespace directly on a live injector. See Registering a Custom DSL for the full walkthrough and example.

configure(), getTransientCache(), registerInjectorReference(), getInjectorReference(), and getInjectorReferenceNames() are internal bootstrap/bookkeeping methods (binder loading, per-request transient DI caching, and named-injector lookup for providers). They're public for framework/internal reasons, but application code should not need to call them directly.

Child Injectors

Child injectors allow you to create isolated DI scopes nested within a parent injector. A child inherits parent lookups but its own mappings are isolated.

Last updated

Was this helpful?