fixed SPRNET-1208
This commit is contained in:
@@ -212,10 +212,17 @@ namespace Spring.Context.Support
|
||||
}
|
||||
}
|
||||
|
||||
private bool objectFactorySet = false;
|
||||
public IObjectFactory ObjectFactory
|
||||
{
|
||||
set
|
||||
{
|
||||
// ignore multiple calls (due to OF also set during AbstractObjectFactory.AddObjectPostProcessor())
|
||||
if (objectFactorySet)
|
||||
{
|
||||
return;
|
||||
}
|
||||
objectFactorySet = true;
|
||||
Assert.AreEqual(ObjectProcessingState.SetObjectFactory, this.CurrentState);
|
||||
this.CurrentState++;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright 2002-2004 the original author or authors.
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -173,6 +173,15 @@ namespace Spring.Objects.Factory
|
||||
Assert.IsFalse(lb.Destroyed, "Was destroyed");
|
||||
}
|
||||
|
||||
[Test(Description = "SPRNET-1208")]
|
||||
public void AddObjectFactoryOnObjectFactoryAwareObjectPostProcessors()
|
||||
{
|
||||
AbstractObjectFactory aof = ObjectFactory;
|
||||
LifecycleObject.PostProcessor lb = new LifecycleObject.PostProcessor();
|
||||
aof.AddObjectPostProcessor(lb);
|
||||
Assert.AreSame( aof, lb.ObjectFactory );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindsValidInstance()
|
||||
{
|
||||
@@ -287,11 +296,7 @@ namespace Spring.Objects.Factory
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void RegisterNullCustomTypeConverter()
|
||||
{
|
||||
AbstractObjectFactory fac = ObjectFactory as AbstractObjectFactory;
|
||||
if(fac != null)
|
||||
{
|
||||
fac.RegisterCustomConverter(null, null);
|
||||
}
|
||||
ObjectFactory.RegisterCustomConverter(null, null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -431,11 +436,11 @@ namespace Spring.Objects.Factory
|
||||
}
|
||||
|
||||
// Create alias
|
||||
((AbstractObjectFactory) ObjectFactory).RegisterAlias("rod", alias);
|
||||
ObjectFactory.RegisterAlias("rod", alias);
|
||||
object rod = ObjectFactory.GetObject("rod");
|
||||
object aliasRod = ObjectFactory.GetObject(alias);
|
||||
Assert.IsTrue(rod == aliasRod);
|
||||
((AbstractObjectFactory) ObjectFactory).RegisterAlias("father", alias);
|
||||
ObjectFactory.RegisterAlias("father", alias);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace Spring.Objects.Factory {
|
||||
#endregion
|
||||
|
||||
#region Inner Class : PostProcessor
|
||||
public class PostProcessor : IObjectPostProcessor
|
||||
public class PostProcessor : IObjectPostProcessor, IObjectFactoryAware
|
||||
{
|
||||
|
||||
public object PostProcessBeforeInitialization (object obj, string name)
|
||||
@@ -181,6 +181,14 @@ namespace Spring.Objects.Factory {
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
private IObjectFactory objectFactory;
|
||||
|
||||
public IObjectFactory ObjectFactory
|
||||
{
|
||||
set { objectFactory=value; }
|
||||
get { return objectFactory; }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user