From e90306ef5771cd9415bf22baf634703e70103571 Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Mon, 13 Feb 2017 20:20:35 +0100 Subject: [PATCH] Update copyrights --- LICENSE.txt | 2 +- README.md | 2 +- dub.json | 2 +- example/annotations/app.d | 144 ++++++++++----------- example/applicationcontext/app.d | 136 +++++++++---------- example/arraycompletion/app.d | 108 ++++++++-------- example/constructorinjection/app.d | 128 +++++++++--------- example/postconstructorpredestructor/app.d | 106 +++++++-------- example/qualifiers/app.d | 2 +- example/quickstart/app.d | 2 +- example/registeronresolve/app.d | 90 ++++++------- example/valueinjection/app.d | 128 +++++++++--------- source/poodinis/autowire.d | 2 +- source/poodinis/container.d | 2 +- source/poodinis/context.d | 2 +- source/poodinis/factory.d | 2 +- source/poodinis/package.d | 2 +- source/poodinis/polyfill.d | 2 +- source/poodinis/registration.d | 2 +- source/poodinis/valueinjection.d | 2 +- test/poodinis/autowiretest.d | 2 +- test/poodinis/containertest.d | 2 +- test/poodinis/contexttest.d | 2 +- test/poodinis/factorytest.d | 2 +- test/poodinis/foreigndependencies.d | 2 +- test/poodinis/registrationtest.d | 2 +- test/poodinis/testclasses.d | 2 +- test/poodinis/testmain.d | 2 +- test/poodinis/valueinjectiontest.d | 2 +- 29 files changed, 442 insertions(+), 442 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 277c5a6..a55b4c3 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2014-2016 Mike Bierlee +Copyright (c) 2014-2017 Mike Bierlee Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index aba16bf..720b0a8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Poodinis Dependency Injection Framework ======================================= Version 8.0.0 -Copyright 2014-2016 Mike Bierlee +Copyright 2014-2017 Mike Bierlee Licensed under the terms of the MIT license - See [LICENSE.txt](LICENSE.txt) Master: [![Build Status](https://api.travis-ci.org/mbierlee/poodinis.png?branch=master)](https://travis-ci.org/mbierlee/poodinis) - Dev: [![Build Status](https://api.travis-ci.org/mbierlee/poodinis.png?branch=develop)](https://travis-ci.org/mbierlee/poodinis) diff --git a/dub.json b/dub.json index 7cc781e..377823f 100644 --- a/dub.json +++ b/dub.json @@ -3,7 +3,7 @@ "description" : "A dependency injection framework with support for autowiring.", "homepage": "http://lostmoment.com/open-source/poodinis", "authors": ["Mike Bierlee"], - "copyright": "Copyright 2014-2016 Mike Bierlee", + "copyright": "Copyright 2014-2017 Mike Bierlee", "license": "MIT", "configurations": [ { diff --git a/example/annotations/app.d b/example/annotations/app.d index 8733c25..ae9e70f 100644 --- a/example/annotations/app.d +++ b/example/annotations/app.d @@ -1,72 +1,72 @@ -/** - * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee - * This software is licensed under the terms of the MIT license. - * The full terms of the license can be found in the LICENSE file. - */ - -import poodinis; - -import std.random; -import std.digest.md; -import std.stdio; -import std.conv; - -class SecurityAuditor { - public void submitAudit() { - writeln("Hmmmyes I have received your audit. It is.... adequate."); - } -} - -class SuperSecurityDevice { - private int seed; - - public this() { - auto randomGenerator = Random(unpredictableSeed); - seed = uniform(0, 999, randomGenerator); - } - - public string getPassword() { - return to!string(seed) ~ "t1m3sp13!!:"; - } -} - -class SecurityManager { - @Autowire - private SuperSecurityDevice levelOneSecurity; - - @Autowire - @AssignNewInstance - private SuperSecurityDevice levelTwoSecurity; - - @Autowire - @OptionalDependency - private SecurityAuditor auditor; - - public void doAudit() { - if (auditor !is null) { - auditor.submitAudit(); - } else { - writeln("I uh, will skip the audit for now..."); - } - } -} - -void main() { - auto dependencies = new shared DependencyContainer(); - dependencies.register!SuperSecurityDevice; // Registered with the default "Single instance" scope - dependencies.register!SecurityManager; - - auto manager = dependencies.resolve!SecurityManager; - - writeln("Password for user one: " ~ manager.levelOneSecurity.getPassword()); - writeln("Password for user two: " ~ manager.levelTwoSecurity.getPassword()); - - if (manager.levelOneSecurity is manager.levelTwoSecurity) { - writeln("SECURITY BREACH!!!!!"); // Should not be printed since levelTwoSecurity is a new instance. - } else { - writeln("Security okay!"); - } - - manager.doAudit(); // Will not cause the SecurityAuditor to print, since we didn't register a SecurityAuditor. -} +/** + * Poodinis Dependency Injection Framework + * Copyright 2014-2017 Mike Bierlee + * This software is licensed under the terms of the MIT license. + * The full terms of the license can be found in the LICENSE file. + */ + +import poodinis; + +import std.random; +import std.digest.md; +import std.stdio; +import std.conv; + +class SecurityAuditor { + public void submitAudit() { + writeln("Hmmmyes I have received your audit. It is.... adequate."); + } +} + +class SuperSecurityDevice { + private int seed; + + public this() { + auto randomGenerator = Random(unpredictableSeed); + seed = uniform(0, 999, randomGenerator); + } + + public string getPassword() { + return to!string(seed) ~ "t1m3sp13!!:"; + } +} + +class SecurityManager { + @Autowire + private SuperSecurityDevice levelOneSecurity; + + @Autowire + @AssignNewInstance + private SuperSecurityDevice levelTwoSecurity; + + @Autowire + @OptionalDependency + private SecurityAuditor auditor; + + public void doAudit() { + if (auditor !is null) { + auditor.submitAudit(); + } else { + writeln("I uh, will skip the audit for now..."); + } + } +} + +void main() { + auto dependencies = new shared DependencyContainer(); + dependencies.register!SuperSecurityDevice; // Registered with the default "Single instance" scope + dependencies.register!SecurityManager; + + auto manager = dependencies.resolve!SecurityManager; + + writeln("Password for user one: " ~ manager.levelOneSecurity.getPassword()); + writeln("Password for user two: " ~ manager.levelTwoSecurity.getPassword()); + + if (manager.levelOneSecurity is manager.levelTwoSecurity) { + writeln("SECURITY BREACH!!!!!"); // Should not be printed since levelTwoSecurity is a new instance. + } else { + writeln("Security okay!"); + } + + manager.doAudit(); // Will not cause the SecurityAuditor to print, since we didn't register a SecurityAuditor. +} diff --git a/example/applicationcontext/app.d b/example/applicationcontext/app.d index 5773d8a..0fff63d 100644 --- a/example/applicationcontext/app.d +++ b/example/applicationcontext/app.d @@ -1,68 +1,68 @@ -/** - * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee - * This software is licensed under the terms of the MIT license. - * The full terms of the license can be found in the LICENSE file. - */ - -import poodinis; - -import std.stdio; - -class TownSquare { - - @Autowire - private MarketStall marketStall; - - public void makeSound() { - marketStall.announceGoodsForSale(); - } - -} - -interface Goods { - public string getGoodsName(); -} - -class Fish : Goods { - public override string getGoodsName() { - return "Fish"; - } -} - -class MarketStall { - private Goods goods; - - this(Goods goods) { - this.goods = goods; - } - - public void announceGoodsForSale() { - writeln(goods.getGoodsName() ~ " for sale!"); - } -} - -class ExampleApplicationContext : ApplicationContext { - - @Autowire - private Goods goods; - - public override void registerDependencies(shared(DependencyContainer) container) { - container.register!(Goods, Fish); - container.register!TownSquare; - } - - @Component - public MarketStall marketStall() { - return new MarketStall(goods); - } - -} - -void main() { - auto container = new shared DependencyContainer(); - container.registerContext!ExampleApplicationContext; - - auto townSquare = container.resolve!TownSquare; - townSquare.makeSound(); -} +/** + * Poodinis Dependency Injection Framework + * Copyright 2014-2017 Mike Bierlee + * This software is licensed under the terms of the MIT license. + * The full terms of the license can be found in the LICENSE file. + */ + +import poodinis; + +import std.stdio; + +class TownSquare { + + @Autowire + private MarketStall marketStall; + + public void makeSound() { + marketStall.announceGoodsForSale(); + } + +} + +interface Goods { + public string getGoodsName(); +} + +class Fish : Goods { + public override string getGoodsName() { + return "Fish"; + } +} + +class MarketStall { + private Goods goods; + + this(Goods goods) { + this.goods = goods; + } + + public void announceGoodsForSale() { + writeln(goods.getGoodsName() ~ " for sale!"); + } +} + +class ExampleApplicationContext : ApplicationContext { + + @Autowire + private Goods goods; + + public override void registerDependencies(shared(DependencyContainer) container) { + container.register!(Goods, Fish); + container.register!TownSquare; + } + + @Component + public MarketStall marketStall() { + return new MarketStall(goods); + } + +} + +void main() { + auto container = new shared DependencyContainer(); + container.registerContext!ExampleApplicationContext; + + auto townSquare = container.resolve!TownSquare; + townSquare.makeSound(); +} diff --git a/example/arraycompletion/app.d b/example/arraycompletion/app.d index 01faf5a..47608a0 100644 --- a/example/arraycompletion/app.d +++ b/example/arraycompletion/app.d @@ -1,54 +1,54 @@ -/** - * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee - * This software is licensed under the terms of the MIT license. - * The full terms of the license can be found in the LICENSE file. - */ - -import poodinis; - -import std.stdio; - -interface Pie { - public void eat(); -} - -class BlueBerryPie : Pie { - public override void eat() { - writeln("Nom nom nom. I like this one!"); - } -} - -class ApplePie : Pie { - public override void eat() { - writeln("Nom nom nom. These aren't real apples..."); - } -} - -class CardboardBoxPie : Pie { - public override void eat() { - writeln("Nom nom nom. This... is not a pie."); - } -} - -class PieEater { - @Autowire - private Pie[] pies; - - public void eatThemAll() { - foreach(pie ; pies) { - pie.eat(); - } - } -} - -void main() { - auto dependencies = new shared DependencyContainer(); - dependencies.register!(Pie, BlueBerryPie); - dependencies.register!(Pie, ApplePie); - dependencies.register!(Pie, CardboardBoxPie); - dependencies.register!(PieEater); - - auto eater = dependencies.resolve!PieEater; - eater.eatThemAll(); -} +/** + * Poodinis Dependency Injection Framework + * Copyright 2014-2017 Mike Bierlee + * This software is licensed under the terms of the MIT license. + * The full terms of the license can be found in the LICENSE file. + */ + +import poodinis; + +import std.stdio; + +interface Pie { + public void eat(); +} + +class BlueBerryPie : Pie { + public override void eat() { + writeln("Nom nom nom. I like this one!"); + } +} + +class ApplePie : Pie { + public override void eat() { + writeln("Nom nom nom. These aren't real apples..."); + } +} + +class CardboardBoxPie : Pie { + public override void eat() { + writeln("Nom nom nom. This... is not a pie."); + } +} + +class PieEater { + @Autowire + private Pie[] pies; + + public void eatThemAll() { + foreach(pie ; pies) { + pie.eat(); + } + } +} + +void main() { + auto dependencies = new shared DependencyContainer(); + dependencies.register!(Pie, BlueBerryPie); + dependencies.register!(Pie, ApplePie); + dependencies.register!(Pie, CardboardBoxPie); + dependencies.register!(PieEater); + + auto eater = dependencies.resolve!PieEater; + eater.eatThemAll(); +} diff --git a/example/constructorinjection/app.d b/example/constructorinjection/app.d index d97f839..7327422 100644 --- a/example/constructorinjection/app.d +++ b/example/constructorinjection/app.d @@ -1,64 +1,64 @@ -/** - * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee - * This software is licensed under the terms of the MIT license. - * The full terms of the license can be found in the LICENSE file. - */ - -class Scheduler { - private Calendar calendar; - - // All parameters will autmatically be assigned when Scheduler is created. - this(Calendar calendar) { - this.calendar = calendar; - } - - public void scheduleJob() { - calendar.findOpenDate(); - } - -} - -class Calendar { - private HardwareClock hardwareClock; - - // This constructor contains built-in type "int" and thus will not be used. - this(int initialDateTimeStamp, HardwareClock hardwareClock) { - } - - // This constructor is chosen instead as candidate for injection when Calendar is created. - this(HardwareClock hardwareClock) { - this.hardwareClock = hardwareClock; - } - - public void findOpenDate() { - hardwareClock.doThings(); - } -} - -class HardwareClock { - // Parameterless constructors will halt any further selection of constructors. - this() {} - - // As a result, this constructor will not be used when HardwareClock is created. - this(Calendar calendar) { - throw new Exception("This constructor should not be used by Poodinis"); - } - - public void doThings() { - import std.stdio; - writeln("Things are being done!"); - } -} - -void main() { - import poodinis; // Locally imported to emphasize that classes do not depend on Poodinis. - - auto dependencies = new shared DependencyContainer(); - dependencies.register!Scheduler; - dependencies.register!Calendar; - dependencies.register!HardwareClock; - - auto scheduler = dependencies.resolve!Scheduler; - scheduler.scheduleJob(); -} +/** + * Poodinis Dependency Injection Framework + * Copyright 2014-2017 Mike Bierlee + * This software is licensed under the terms of the MIT license. + * The full terms of the license can be found in the LICENSE file. + */ + +class Scheduler { + private Calendar calendar; + + // All parameters will autmatically be assigned when Scheduler is created. + this(Calendar calendar) { + this.calendar = calendar; + } + + public void scheduleJob() { + calendar.findOpenDate(); + } + +} + +class Calendar { + private HardwareClock hardwareClock; + + // This constructor contains built-in type "int" and thus will not be used. + this(int initialDateTimeStamp, HardwareClock hardwareClock) { + } + + // This constructor is chosen instead as candidate for injection when Calendar is created. + this(HardwareClock hardwareClock) { + this.hardwareClock = hardwareClock; + } + + public void findOpenDate() { + hardwareClock.doThings(); + } +} + +class HardwareClock { + // Parameterless constructors will halt any further selection of constructors. + this() {} + + // As a result, this constructor will not be used when HardwareClock is created. + this(Calendar calendar) { + throw new Exception("This constructor should not be used by Poodinis"); + } + + public void doThings() { + import std.stdio; + writeln("Things are being done!"); + } +} + +void main() { + import poodinis; // Locally imported to emphasize that classes do not depend on Poodinis. + + auto dependencies = new shared DependencyContainer(); + dependencies.register!Scheduler; + dependencies.register!Calendar; + dependencies.register!HardwareClock; + + auto scheduler = dependencies.resolve!Scheduler; + scheduler.scheduleJob(); +} diff --git a/example/postconstructorpredestructor/app.d b/example/postconstructorpredestructor/app.d index 32cc8b1..4ca7bbe 100644 --- a/example/postconstructorpredestructor/app.d +++ b/example/postconstructorpredestructor/app.d @@ -1,53 +1,53 @@ -/** - * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee - * This software is licensed under the terms of the MIT license. - * The full terms of the license can be found in the LICENSE file. - */ - -import poodinis; - -import std.stdio; - -class ADependency { - @PostConstruct - public void postConstructor() { - writeln("The dependency is created."); - } - - public void callMe() { - writeln("The dependency was called."); - } -} - -class AClass { - @Autowire - public ADependency dependency; // Dependencies are autowired before the post-constructor is called. - - @PostConstruct - public void postConstructor() { - writeln("The class is created."); - if (dependency !is null) { - writeln("The dependency is autowired."); - } else { - writeln("The dependency was NOT autowired."); - } - } - - @PreDestroy - public void preDestructor() { - writeln("The class is no longer registered with the container."); - } -} - -public void main() { - auto container = new shared DependencyContainer(); - container.register!ADependency; - container.register!AClass; - auto instance = container.resolve!AClass; // Will cause the post constructor to be called. - container.removeRegistration!AClass; // Will cause the pre destructor to be called. - - // The instance won't be destroyed by the container and as long as there are references to it, - // it will not be collected by the garbage collector either. - instance.dependency.callMe(); -} +/** + * Poodinis Dependency Injection Framework + * Copyright 2014-2017 Mike Bierlee + * This software is licensed under the terms of the MIT license. + * The full terms of the license can be found in the LICENSE file. + */ + +import poodinis; + +import std.stdio; + +class ADependency { + @PostConstruct + public void postConstructor() { + writeln("The dependency is created."); + } + + public void callMe() { + writeln("The dependency was called."); + } +} + +class AClass { + @Autowire + public ADependency dependency; // Dependencies are autowired before the post-constructor is called. + + @PostConstruct + public void postConstructor() { + writeln("The class is created."); + if (dependency !is null) { + writeln("The dependency is autowired."); + } else { + writeln("The dependency was NOT autowired."); + } + } + + @PreDestroy + public void preDestructor() { + writeln("The class is no longer registered with the container."); + } +} + +public void main() { + auto container = new shared DependencyContainer(); + container.register!ADependency; + container.register!AClass; + auto instance = container.resolve!AClass; // Will cause the post constructor to be called. + container.removeRegistration!AClass; // Will cause the pre destructor to be called. + + // The instance won't be destroyed by the container and as long as there are references to it, + // it will not be collected by the garbage collector either. + instance.dependency.callMe(); +} diff --git a/example/qualifiers/app.d b/example/qualifiers/app.d index 32a8949..3d19543 100644 --- a/example/qualifiers/app.d +++ b/example/qualifiers/app.d @@ -1,6 +1,6 @@ /** * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee + * Copyright 2014-2017 Mike Bierlee * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. */ diff --git a/example/quickstart/app.d b/example/quickstart/app.d index 15c3117..c5a20e3 100644 --- a/example/quickstart/app.d +++ b/example/quickstart/app.d @@ -1,6 +1,6 @@ /** * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee + * Copyright 2014-2017 Mike Bierlee * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. */ diff --git a/example/registeronresolve/app.d b/example/registeronresolve/app.d index f27f776..f095381 100644 --- a/example/registeronresolve/app.d +++ b/example/registeronresolve/app.d @@ -1,45 +1,45 @@ -/** - * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee - * This software is licensed under the terms of the MIT license. - * The full terms of the license can be found in the LICENSE file. - */ - -import poodinis; - -class Violin { -} - -interface InstrumentPlayer { -} - -class ViolinPlayer : InstrumentPlayer { - // Autowired concrete types can be registered on resolve - @Autowire - private Violin violin; -} - -class Orchestra { - // Autowired non-concrete types can be registered on resolved, given they have a qualifier. - @Autowire!ViolinPlayer - private InstrumentPlayer violinPlayer; -} - -void main() { - auto dependencies = new shared DependencyContainer(); - - /* - * By using the resolve option "registerBeforeResolving" you can register the resolved class - * immediately. Note that any autowired member will not automatically be registered as well. - */ - auto violinPlayer = dependencies.resolve!Violin(ResolveOption.registerBeforeResolving); - - /* - * You can make the resolve option persistent by setting it on the container with setPersistentResolveOptions(). - * This will register all resolved types and their autowired members (recursively). - * Note that you will still get ResolveExceptions when a non-concrete type is autowired (without qualifier). - * In those cases you will still have to register those particular dependencies beforehand. - */ - dependencies.setPersistentResolveOptions(ResolveOption.registerBeforeResolving); - auto orchestra = dependencies.resolve!Orchestra; -} +/** + * Poodinis Dependency Injection Framework + * Copyright 2014-2017 Mike Bierlee + * This software is licensed under the terms of the MIT license. + * The full terms of the license can be found in the LICENSE file. + */ + +import poodinis; + +class Violin { +} + +interface InstrumentPlayer { +} + +class ViolinPlayer : InstrumentPlayer { + // Autowired concrete types can be registered on resolve + @Autowire + private Violin violin; +} + +class Orchestra { + // Autowired non-concrete types can be registered on resolved, given they have a qualifier. + @Autowire!ViolinPlayer + private InstrumentPlayer violinPlayer; +} + +void main() { + auto dependencies = new shared DependencyContainer(); + + /* + * By using the resolve option "registerBeforeResolving" you can register the resolved class + * immediately. Note that any autowired member will not automatically be registered as well. + */ + auto violinPlayer = dependencies.resolve!Violin(ResolveOption.registerBeforeResolving); + + /* + * You can make the resolve option persistent by setting it on the container with setPersistentResolveOptions(). + * This will register all resolved types and their autowired members (recursively). + * Note that you will still get ResolveExceptions when a non-concrete type is autowired (without qualifier). + * In those cases you will still have to register those particular dependencies beforehand. + */ + dependencies.setPersistentResolveOptions(ResolveOption.registerBeforeResolving); + auto orchestra = dependencies.resolve!Orchestra; +} diff --git a/example/valueinjection/app.d b/example/valueinjection/app.d index c960563..f45ab24 100644 --- a/example/valueinjection/app.d +++ b/example/valueinjection/app.d @@ -1,64 +1,64 @@ -/** - * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee - * This software is licensed under the terms of the MIT license. - * The full terms of the license can be found in the LICENSE file. - */ - -import poodinis; - -import std.stdio; -import std.string; - -class IntValueInjector : ValueInjector!int { - int get(string key) { - switch(key) { - case "http.port": - return 8080; - case "http.keep_alive": - return 60; - default: - throw new ValueNotAvailableException(key); - } - } -} - -class StringValueInjector : ValueInjector!string { - string get(string key) { - switch(key) { - case "http.hostname": - return "acme.org"; - default: - throw new ValueNotAvailableException(key); - } - } -} - -class HttpServer { - - @Value("http.port") - private int port = 80; - - @Value("http.hostname") - private string hostName = "localhost"; - - @Value("http.max_connections") - private int maxConnections = 1000; // Default assignment is kept because max_connections is not available within the injector - - @MandatoryValue("http.keep_alive") - private int keepAliveTime; // A ResolveException is thrown when the value is not available, default assignments are not used. - - public void serve() { - writeln(format("Serving pages for %s:%s with max connection count of %s", hostName, port, maxConnections)); - } -} - -void main() { - auto dependencies = new shared DependencyContainer(); - dependencies.register!(ValueInjector!int, IntValueInjector); - dependencies.register!(ValueInjector!string, StringValueInjector); - dependencies.register!HttpServer; - - auto server = dependencies.resolve!HttpServer; - server.serve(); // Prints "Serving pages for acme.org:8080 with max connection count of 1000" -} +/** + * Poodinis Dependency Injection Framework + * Copyright 2014-2017 Mike Bierlee + * This software is licensed under the terms of the MIT license. + * The full terms of the license can be found in the LICENSE file. + */ + +import poodinis; + +import std.stdio; +import std.string; + +class IntValueInjector : ValueInjector!int { + int get(string key) { + switch(key) { + case "http.port": + return 8080; + case "http.keep_alive": + return 60; + default: + throw new ValueNotAvailableException(key); + } + } +} + +class StringValueInjector : ValueInjector!string { + string get(string key) { + switch(key) { + case "http.hostname": + return "acme.org"; + default: + throw new ValueNotAvailableException(key); + } + } +} + +class HttpServer { + + @Value("http.port") + private int port = 80; + + @Value("http.hostname") + private string hostName = "localhost"; + + @Value("http.max_connections") + private int maxConnections = 1000; // Default assignment is kept because max_connections is not available within the injector + + @MandatoryValue("http.keep_alive") + private int keepAliveTime; // A ResolveException is thrown when the value is not available, default assignments are not used. + + public void serve() { + writeln(format("Serving pages for %s:%s with max connection count of %s", hostName, port, maxConnections)); + } +} + +void main() { + auto dependencies = new shared DependencyContainer(); + dependencies.register!(ValueInjector!int, IntValueInjector); + dependencies.register!(ValueInjector!string, StringValueInjector); + dependencies.register!HttpServer; + + auto server = dependencies.resolve!HttpServer; + server.serve(); // Prints "Serving pages for acme.org:8080 with max connection count of 1000" +} diff --git a/source/poodinis/autowire.d b/source/poodinis/autowire.d index b33b935..4c0e673 100644 --- a/source/poodinis/autowire.d +++ b/source/poodinis/autowire.d @@ -9,7 +9,7 @@ * * Authors: * Mike Bierlee, m.bierlee@lostmoment.com - * Copyright: 2014-2016 Mike Bierlee + * Copyright: 2014-2017 Mike Bierlee * License: * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. diff --git a/source/poodinis/container.d b/source/poodinis/container.d index 01771f2..6c58f4b 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -5,7 +5,7 @@ * * Authors: * Mike Bierlee, m.bierlee@lostmoment.com - * Copyright: 2014-2016 Mike Bierlee + * Copyright: 2014-2017 Mike Bierlee * License: * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. diff --git a/source/poodinis/context.d b/source/poodinis/context.d index 6ab848c..3d3e865 100644 --- a/source/poodinis/context.d +++ b/source/poodinis/context.d @@ -5,7 +5,7 @@ * * Authors: * Mike Bierlee, m.bierlee@lostmoment.com - * Copyright: 2014-2016 Mike Bierlee + * Copyright: 2014-2017 Mike Bierlee * License: * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. diff --git a/source/poodinis/factory.d b/source/poodinis/factory.d index a3dd8c0..048a27b 100644 --- a/source/poodinis/factory.d +++ b/source/poodinis/factory.d @@ -3,7 +3,7 @@ * * Authors: * Mike Bierlee, m.bierlee@lostmoment.com - * Copyright: 2014-2016 Mike Bierlee + * Copyright: 2014-2017 Mike Bierlee * License: * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. diff --git a/source/poodinis/package.d b/source/poodinis/package.d index 0ef133b..ef511ba 100644 --- a/source/poodinis/package.d +++ b/source/poodinis/package.d @@ -3,7 +3,7 @@ * * Authors: * Mike Bierlee, m.bierlee@lostmoment.com - * Copyright: 2014-2016 Mike Bierlee + * Copyright: 2014-2017 Mike Bierlee * License: * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. diff --git a/source/poodinis/polyfill.d b/source/poodinis/polyfill.d index 5d875b2..5bd5fd7 100644 --- a/source/poodinis/polyfill.d +++ b/source/poodinis/polyfill.d @@ -19,7 +19,7 @@ * Kenji Hara, * Shoichi Kato, * Mike Bierlee (m.bierlee@lostmoment.com) - * Copyright: Copyright Digital Mars 2005 - 2009., Copyright Andrei Alexandrescu 2008-, Jonathan M Davis 2011-., 2014-2016 Mike Bierlee + * Copyright: Copyright Digital Mars 2005 - 2009., Copyright Andrei Alexandrescu 2008-, Jonathan M Davis 2011-., 2014-2017 Mike Bierlee * License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0) */ diff --git a/source/poodinis/registration.d b/source/poodinis/registration.d index f7fed37..d530d89 100644 --- a/source/poodinis/registration.d +++ b/source/poodinis/registration.d @@ -5,7 +5,7 @@ * * Authors: * Mike Bierlee, m.bierlee@lostmoment.com - * Copyright: 2014-2016 Mike Bierlee + * Copyright: 2014-2017 Mike Bierlee * License: * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. diff --git a/source/poodinis/valueinjection.d b/source/poodinis/valueinjection.d index 6c6f4e5..c75a3a3 100644 --- a/source/poodinis/valueinjection.d +++ b/source/poodinis/valueinjection.d @@ -4,7 +4,7 @@ * * Authors: * Mike Bierlee, m.bierlee@lostmoment.com - * Copyright: 2014-2016 Mike Bierlee + * Copyright: 2014-2017 Mike Bierlee * License: * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. diff --git a/test/poodinis/autowiretest.d b/test/poodinis/autowiretest.d index b9dfc2f..5008b82 100644 --- a/test/poodinis/autowiretest.d +++ b/test/poodinis/autowiretest.d @@ -1,6 +1,6 @@ /** * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee + * Copyright 2014-2017 Mike Bierlee * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. */ diff --git a/test/poodinis/containertest.d b/test/poodinis/containertest.d index 1d3cd3a..79e3f5e 100644 --- a/test/poodinis/containertest.d +++ b/test/poodinis/containertest.d @@ -1,6 +1,6 @@ /** * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee + * Copyright 2014-2017 Mike Bierlee * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. */ diff --git a/test/poodinis/contexttest.d b/test/poodinis/contexttest.d index 7f5bbec..5e4fe5e 100644 --- a/test/poodinis/contexttest.d +++ b/test/poodinis/contexttest.d @@ -1,6 +1,6 @@ /** * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee + * Copyright 2014-2017 Mike Bierlee * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. */ diff --git a/test/poodinis/factorytest.d b/test/poodinis/factorytest.d index 9526165..e19537f 100644 --- a/test/poodinis/factorytest.d +++ b/test/poodinis/factorytest.d @@ -1,6 +1,6 @@ /** * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee + * Copyright 2014-2017 Mike Bierlee * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. */ diff --git a/test/poodinis/foreigndependencies.d b/test/poodinis/foreigndependencies.d index d378b69..25590f8 100644 --- a/test/poodinis/foreigndependencies.d +++ b/test/poodinis/foreigndependencies.d @@ -1,6 +1,6 @@ /** * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee + * Copyright 2014-2017 Mike Bierlee * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. */ diff --git a/test/poodinis/registrationtest.d b/test/poodinis/registrationtest.d index ba0d249..d5be162 100644 --- a/test/poodinis/registrationtest.d +++ b/test/poodinis/registrationtest.d @@ -1,6 +1,6 @@ /** * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee + * Copyright 2014-2017 Mike Bierlee * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. */ diff --git a/test/poodinis/testclasses.d b/test/poodinis/testclasses.d index 8afeab8..9dcf864 100644 --- a/test/poodinis/testclasses.d +++ b/test/poodinis/testclasses.d @@ -1,6 +1,6 @@ /** * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee + * Copyright 2014-2017 Mike Bierlee * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. */ diff --git a/test/poodinis/testmain.d b/test/poodinis/testmain.d index 89846b0..71c6cd5 100644 --- a/test/poodinis/testmain.d +++ b/test/poodinis/testmain.d @@ -1,6 +1,6 @@ /** * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee + * Copyright 2014-2017 Mike Bierlee * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. */ diff --git a/test/poodinis/valueinjectiontest.d b/test/poodinis/valueinjectiontest.d index 45b7219..a85a12e 100644 --- a/test/poodinis/valueinjectiontest.d +++ b/test/poodinis/valueinjectiontest.d @@ -1,6 +1,6 @@ /** * Poodinis Dependency Injection Framework - * Copyright 2014-2016 Mike Bierlee + * Copyright 2014-2017 Mike Bierlee * This software is licensed under the terms of the MIT license. * The full terms of the license can be found in the LICENSE file. */