BoxLang 🚀 A New JVM Dynamic Language Learn More...
Copyright Since 2005 ColdBox Platform by Luis Majano
and Ortus Solutions, Corp
www.coldbox.org | www.ortussolutions.com
Because of God's grace, this project exists. If you don't like this, then don't read it, its not for you.
"Therefore being justified by faith, we have peace with God through our Lord Jesus Christ: By whom also we have access by faith into this grace wherein we stand, and rejoice in hope of the glory of God. And not only so, but we glory in tribulations also: knowing that tribulation worketh patience; And patience, experience; and experience, hope: And hope maketh not ashamed; because the love of God is shed abroad in our hearts by the Holy Ghost which is given unto us. ." Romans 5:5
Enterprise Dependency Injection Container for Modern Applications
WireBox is a powerful, flexible dependency injection and AOP (Aspect-Oriented Programming) framework designed for two modern programming languages:
✨ Use WireBox Standalone - While part of the ColdBox Platform, WireBox can be installed and used independently in ANY BoxLang or CFML application without requiring the full ColdBox framework.
19+ Years of Excellence - Since 2006, WireBox has been battle-tested in enterprise environments worldwide, evolving with modern development practices and industry standards.
Professional Open Source - Backed by Ortus Solutions, WireBox provides the reliability and support that businesses demand. With dedicated full-time development, comprehensive documentation, and professional services, enterprises can confidently build mission-critical applications on WireBox.
Enterprise Ready - Trusted by Fortune 500 companies and organizations globally, WireBox delivers the stability, performance, and long-term support that enterprise applications require. Learn more at www.coldbox.org.
# Install WireBox independently
box install wirebox
# Or with ColdBox Platform
box install coldbox
// Create WireBox injector
injector = new wirebox.system.ioc.Injector()
// Configure with mappings
injector.mapDirectory( "models" )
injector.map( "UserService" ).to( "models.UserService" ).asSingleton()
// Get instances with automatic dependency injection
userService = injector.getInstance( "UserService" )
user = injector.getInstance( "User" )
// Property injection example
class {
@inject( "UserService" )
property userService;
@inject( "logbox:logger: {this}" )
property logger;
}
// Configure and get logger
logBox.configure( config )
logger = logBox.getLogger( "MyApp" )
// Inject dependencies in any ColdBox Enabled Class
@inject( "UserService" )
property userService
@inject( "logbox:logger: {this}" )
property logger
function index( event, rc, prc ) {
// Dependencies are automatically injected
user = userService.getUser( getUserId() )
logger.info( "User retrieved", user )
}
# Standalone WireBox
box install wirebox
# With ColdBox Platform
box install coldbox
# Bleeding Edge
box install wirebox@be
Visit ForgeBox for additional installation options.
Enhance your WireBox development experience with our official VS Code extensions:
Download from VS Code Marketplace | Open VSX Registry
Features:
Download from VS Code Marketplace | Open VSX Registry
Complete development suite including:
WireBox provides a comprehensive dependency injection architecture:
Use Independently - WireBox is designed as a standalone library that can be used in ANY BoxLang or CFML application without requiring the full ColdBox framework. This modular architecture allows you to:
BoxLang (Recommended)
CFML Support
Comprehensive documentation is available at: https://wirebox.ortusbooks.com
WireBox is a professional open source project. Support us by:
// Model with dependency injection
class {
@inject( "UserService" )
property userService;
@inject( "logbox:logger: {this}" )
property logger;
function getUser( id ) {
logger.info( "Getting user: #arguments.id#" );
return userService.findById( arguments.id );
}
}
// Constructor injection
class {
@inject( "dsl:myDSN" )
property datasource;
function init( required userService inject="UserService" ) {
variables.userService = arguments.userService;
return this;
}
}
// Configure WireBox mappings
map( "UserService" )
.to( "models.security.UserService" )
.asSingleton()
.initWith( datasource="myDSN" )
// Factory method pattern
map( "PaymentGateway" )
.toFactoryMethod( "PaymentFactory", "createGateway" )
.initArg( name="type", value="stripe" )
// Virtual inheritance mapping
map( "BaseService" )
.to( "models.BaseService" )
.asTransient()
map( "UserService" )
.to( "models.UserService" )
.parent( "BaseService" )
// Method interceptor
class extends="wirebox.system.aop.MethodInterceptor" {
function invokeMethod( required invocation ) {
var start = getTickCount()
try {
var result = arguments.invocation.proceed()
var duration = getTickCount() - start
writeLog( "Method #invocation.getMethod()# took #duration#ms" )
return result;
} catch( any e ) {
writeLog( "Error in #invocation.getMethod()#: #e.message#" )
rethrow
}
}
}
// Map the Aspect so it can be used
mapAspect( "PerformanceInterceptor" )
.to( "aspects.PerformanceInterceptor" )
// Aspect Binding now applies interceptor to mappings
bindAspect(
classes : match().mappings( "UserService" ),
methods : match().all(),
aspects : "PerformanceInterceptor"
)
// Lazy loading with providers
class {
@inject( "provider:UserService" )
property userServiceProvider;
function getUser( id ) {
// Service is created only when needed
var userService = userServiceProvider.get()
return userService.findById( arguments.id )
}
}
Apache License, Version 2.0 - See LICENSE file for details.
The ColdBox websites, logos and content have separate licensing and are separate entities.
"I am the way, and the truth, and the life; no one comes to the Father, but by me (JESUS)" Jn 14:1-12
$
box install wirebox