PDA

View Full Version : Does StaticApplicationContext Work?



sbellware
02-02-2006, 12:36 AM
Been trying to:

StaticApplicationContext context = new StaticApplicationContext();
context.ConfigureObject(someObject, someName);

The following exception is thrown:
Spring.Objects.Factory.NoSuchObjectDefinitionExcep tion

Any ideas?

Aleks Seovic
02-02-2006, 01:32 PM
It works, but not the way you are using it and I'm not quite sure why would you want to use it.

StaticApplicationContext only allows you to register existing singleton instances with it. It doesn't support object definitions, which means that it doesn't support ConfigureObject method either.

I'm not sure what your use case is, but if you want to configure existing objects based on templates specified in the Spring config file you should use either XmlApplicationContext or WebApplicationContext instead and mark definitions as abstract so they are not instantiated.

Regards,

Aleks

sbellware
02-02-2006, 02:14 PM
Hi Aleks,

Thanks for the response.

The use case in question involves injecting an instance of a dynamic mock object (NMock) via Spring.

I wasn't aware of the ability to mark object definitions as abstract. I'm already using XmlApplicationContext, so I'll give that a try.

Thanks,
Scott