Permalink
Browse files

Remove the option of ObjectDefinitions with parent definitions as it …

…is not needed anywhere
  • Loading branch information...
1 parent 89ee1c9 commit f15b836255aef2503c4b426ea3cdc37ac3fd5f0b Jens Halm committed Jan 1, 2012
@@ -32,8 +32,6 @@ import org.spicefactory.parsley.core.registry.ObjectDefinitionRegistry;
import org.spicefactory.parsley.core.registry.ObjectInstantiator;
import org.spicefactory.parsley.core.registry.SingletonObjectDefinition;
-
-
/**
* Represents the context for a single object definition build process.
*
@@ -130,9 +128,18 @@ public class ObjectDefinitionContext {
*/
public function processDefinition (target:ObjectDefinition, additionalDecorators:Array,
builder:ObjectDefinitionBuilder) : ObjectDefinition {
+
+ if (processed) {
+ throw new IllegalStateError("A definition has already been built from this configuration");
+ }
+ processed = true;
+
processDecorators(target, additionalDecorators, builder);
+
applyBuilderParts(target);
+
target.instantiator = instantiator;
+
return applyDefinitionReplacer(target);
}
@@ -156,7 +163,6 @@ public class ObjectDefinitionContext {
return newDef;
}
-
/**
* Processes the decorators for this builder. This implementation processes all decorators obtained
* through the decorator assemblers registered for the core <code>Configuration</code> instance
@@ -167,21 +173,16 @@ public class ObjectDefinitionContext {
* @param definition the definition to process
* @param additionalDecorators the decorators to process in addition to the ones added through the assemblers
* @param builder the builder for the definition
- * @return the resulting definition (possibly the same instance that was passed to this method)
*/
protected function processDecorators (definition:ObjectDefinition, additionalDecorators:Array,
builder:ObjectDefinitionBuilder) : void {
+
var decorators:Array = new Array();
- if (!processed) {
- processed = true;
- for each (var assembler:DecoratorAssembler in assemblers) {
- decorators = decorators.concat(assembler.assemble(definition.type));
- }
- decorators = decorators.concat(additionalDecorators);
- }
- else {
- decorators = additionalDecorators;
+ for each (var assembler:DecoratorAssembler in assemblers) {
+ decorators = decorators.concat(assembler.assemble(definition.type));
}
+ decorators = decorators.concat(additionalDecorators);
+
var errors:Array = new Array();
for each (var decorator:ObjectDefinitionDecorator in decorators) {
try {
@@ -196,5 +197,7 @@ public class ObjectDefinitionContext {
throw new ObjectDefinitionError(definition, errors);
}
}
+
+
}
}
@@ -39,7 +39,6 @@ public class AbstractObjectDefinition implements ObjectDefinition {
private var attributes:Dictionary = new Dictionary();
private var _registry:ObjectDefinitionRegistry;
- private var _parent:ObjectDefinition;
private var _instantiator:ObjectInstantiator;
private var _processors:Array = new Array();
@@ -56,11 +55,10 @@ public class AbstractObjectDefinition implements ObjectDefinition {
* @param parent the parent definition containing shared configuration for this definition
*/
function AbstractObjectDefinition (type:ClassInfo, id:String,
- registry:ObjectDefinitionRegistry, parent:ObjectDefinition = null) {
+ registry:ObjectDefinitionRegistry) {
_type = type;
_id = id;
_registry = registry;
- _parent = parent;
}
@@ -103,7 +101,7 @@ public class AbstractObjectDefinition implements ObjectDefinition {
* @inheritDoc
*/
public function get instantiator () : ObjectInstantiator {
- return (_instantiator) ? _instantiator : ((_parent) ? _parent.instantiator : null);
+ return _instantiator;
}
/**
@@ -117,7 +115,7 @@ public class AbstractObjectDefinition implements ObjectDefinition {
* @inheritDoc
*/
public function get processors () : Array {
- return (_parent) ? _parent.processors.concat(_processors) : _processors.concat();
+ return _processors.concat();
}
/**
@@ -15,9 +15,9 @@
*/
package org.spicefactory.parsley.core.registry.impl {
+
import org.spicefactory.lib.reflect.ClassInfo;
import org.spicefactory.parsley.core.registry.DynamicObjectDefinition;
-import org.spicefactory.parsley.core.registry.ObjectDefinition;
import org.spicefactory.parsley.core.registry.ObjectDefinitionRegistry;
import org.spicefactory.parsley.instantiator.ObjectWrapperInstantiator;
@@ -36,9 +36,8 @@ public class DefaultDynamicObjectDefinition extends AbstractObjectDefinition imp
* @param registry the registry this definition belongs to
* @param parent the parent definition containing shared configuration for this definition
*/
- function DefaultDynamicObjectDefinition (type:ClassInfo, id:String,
- registry:ObjectDefinitionRegistry, parent:ObjectDefinition = null) {
- super(type, id, registry, parent);
+ function DefaultDynamicObjectDefinition (type:ClassInfo, id:String, registry:ObjectDefinitionRegistry) {
+ super(type, id, registry);
}
@@ -18,7 +18,6 @@ package org.spicefactory.parsley.core.registry.impl {
import org.spicefactory.lib.reflect.ClassInfo;
import org.spicefactory.parsley.core.registry.AsyncInitConfig;
-import org.spicefactory.parsley.core.registry.ObjectDefinition;
import org.spicefactory.parsley.core.registry.ObjectDefinitionRegistry;
import org.spicefactory.parsley.core.registry.SingletonObjectDefinition;
@@ -33,7 +32,7 @@ public class DefaultSingletonObjectDefinition extends AbstractObjectDefinition i
private var _lazy:Boolean;
private var _order:int;
private var _asyncInitConfig:AsyncInitConfig;
- private var _parent:SingletonObjectDefinition;
+
/**
* Creates a new instance.
@@ -46,13 +45,10 @@ public class DefaultSingletonObjectDefinition extends AbstractObjectDefinition i
* @param parent the parent definition containing shared configuration for this definition
*/
function DefaultSingletonObjectDefinition (type:ClassInfo, id:String, registry:ObjectDefinitionRegistry,
- lazy:Boolean = false, order:int = int.MAX_VALUE, parent:ObjectDefinition = null) {
- super(type, id, registry, parent);
+ lazy:Boolean = false, order:int = int.MAX_VALUE) {
+ super(type, id, registry);
_lazy = lazy;
_order = order;
- if (parent is SingletonObjectDefinition) {
- _parent = SingletonObjectDefinition(parent);
- }
}
@@ -74,7 +70,7 @@ public class DefaultSingletonObjectDefinition extends AbstractObjectDefinition i
* @inheritDoc
*/
public function get asyncInitConfig () : AsyncInitConfig {
- return (_asyncInitConfig) ? _asyncInitConfig : ((_parent) ? _parent.asyncInitConfig : null);
+ return _asyncInitConfig;
}
/**

0 comments on commit f15b836

Please sign in to comment.