Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

of

Itb2018   wire box basics Slide 1 Itb2018   wire box basics Slide 2 Itb2018   wire box basics Slide 3 Itb2018   wire box basics Slide 4 Itb2018   wire box basics Slide 5 Itb2018   wire box basics Slide 6 Itb2018   wire box basics Slide 7 Itb2018   wire box basics Slide 8 Itb2018   wire box basics Slide 9 Itb2018   wire box basics Slide 10 Itb2018   wire box basics Slide 11 Itb2018   wire box basics Slide 12 Itb2018   wire box basics Slide 13
Upcoming SlideShare
What to Upload to SlideShare
Next
Download to read offline and view in fullscreen.

0 Likes

Share

Download to read offline

Itb2018 wire box basics

Download to read offline

Brad Wood

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Itb2018 wire box basics

  1. 1. WireBox Basics Dead Simple DI Brad Wood @bdw429s
  2. 2. WireBox, friend of CFCs ● Part of ColdBox ● Also standalone! ● Helps you create, persist, and manage the CFCs in your app
  3. 3. OO Overview ● Encapsulation ● Re-use ● Separation of data of behavior ● Inherited behavior between objects
  4. 4. Types of objects ● Transient ○ var order = new Order(); ● Singleton ○ application.myService = new myService(); ● Session-scoped ○ session.user = new User(); ● Cache-scoped ○ myCache.set( new featuredContent() );
  5. 5. Objects are needy ● They need other objects ● They need app settings like datasources, etc ● A large app can have hundreds of interdependent objects ● This creates boilerplate and complicates your code
  6. 6. WireBox is here to simplify your life ● Creates objects ● Managed persistence ● Manages Dependencies ● Easily configurable with simple conventions and annotations ● No XML, no huge config files!
  7. 7. Install WireBox ● ColdBox: Nothing to do here ○ Drop your CFCs in /models ○ Configure it with /config/WireBox.cfc ● Standalone: “install wirebox” ○ new wirebox.system.Injector(); ○ application.wirebox.getInstance( ‘foobar’ );
  8. 8. Map directory ● Ask WireBox to recursively scan a folder ● Any CFCs found are registered with their name ● You can ask for these CFCs by name now mapDirectory( ‘/models’ );
  9. 9. Object Factory ● When we want a CFC instance, we ask WireBox ● WireBox handles creation for us myService = getInstance( ‘myService’ ); myService.doSomething();
  10. 10. ● Only need one instance of a CFC ● No overhead of creation every time ● Make sure your code is thread safe component singleton { } Singleton Persistence
  11. 11. ● One CFC instance per session ● You don’t have to actually touch the session scope component scope=”session” { } Session Persistence
  12. 12. ● When one CFC needs another ● Use cfproperty to declare the dependency component { property name=”myFoo” inject=”FooService”; } Dependencies
  13. 13. ● Generic ad-hoc way to get CFC instances ● In ColdBox, getInstance() exists everywhere ● Outside of ColdBox, wirebox.getInstance() application.wirebox.getInstance( ‘FooBar’ ); getInstance()

Brad Wood

Views

Total views

199

On Slideshare

0

From embeds

0

Number of embeds

1

Actions

Downloads

2

Shares

0

Comments

0

Likes

0

×