mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Document public API of module "registration"
This commit is contained in:
parent
8ee25abc58
commit
f9c2e257c7
|
@ -1,8 +1,12 @@
|
||||||
/**
|
/**
|
||||||
* Poodinis Dependency Injection Framework
|
* This module contains objects for defining and scoping dependency registrations.
|
||||||
* Copyright 2014-2015 Mike Bierlee
|
*
|
||||||
* This software is licensed under the terms of the MIT license.
|
* Authors:
|
||||||
* The full terms of the license can be found in the LICENSE file.
|
* Mike Bierlee, m.bierlee@lostmoment.com
|
||||||
|
* Copyright: 2014-2015 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module poodinis.registration;
|
module poodinis.registration;
|
||||||
|
@ -75,6 +79,11 @@ class SingleInstanceScope : CreationScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scopes registrations to return the same instance every time a given registration is resolved.
|
||||||
|
*
|
||||||
|
* Effectively makes the given registration a singleton.
|
||||||
|
*/
|
||||||
public Registration singleInstance(Registration registration) {
|
public Registration singleInstance(Registration registration) {
|
||||||
registration.registationScope = new SingleInstanceScope(registration.instantiatableType);
|
registration.registationScope = new SingleInstanceScope(registration.instantiatableType);
|
||||||
return registration;
|
return registration;
|
||||||
|
@ -95,6 +104,9 @@ class NewInstanceScope : CreationScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scopes registrations to return a new instance every time the given registration is resolved.
|
||||||
|
*/
|
||||||
public Registration newInstance(Registration registration) {
|
public Registration newInstance(Registration registration) {
|
||||||
registration.registationScope = new NewInstanceScope(registration.instantiatableType);
|
registration.registationScope = new NewInstanceScope(registration.instantiatableType);
|
||||||
return registration;
|
return registration;
|
||||||
|
@ -115,6 +127,9 @@ class ExistingInstanceScope : CreationScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scopes registrations to return the given instance every time the given registration is resolved.
|
||||||
|
*/
|
||||||
public Registration existingInstance(Registration registration, Object instance) {
|
public Registration existingInstance(Registration registration, Object instance) {
|
||||||
registration.registationScope = new ExistingInstanceScope(instance);
|
registration.registationScope = new ExistingInstanceScope(instance);
|
||||||
return registration;
|
return registration;
|
||||||
|
|
Loading…
Reference in a new issue