I'm enjoying my eperiments with spring, and have a question about how to incoporate an existing factory idiom I use in in some current apps.
I have factories that load many flavors of an object (for example to represent a plugin for a particular media type). I load them up from a configuration file and put the objects on a hashtable.
Each media type has additional info that is associated with it, besides the plugin. This is currently loaded into a bunch of helper objects accessible through another factory. All of it encoded in an XML file:
Curently, I'm loading both factories into the IApplicationContext in order to inject their dependencies and to take advantage of the quasi singleton pattern you offer.
<ArrayOfAnyType xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
However, in doing so the objects created by my factories aren't managed by Spring and so can't take advantage of features like the loosely bound event publishing mechanism. I could of course eliminate my factory and load each flavor of plugin and its helper object into the IApplicationContext and retrieve from there. But it seems that this is less elegant than my first approach since I'll have to have an entry for every single plugin and helper object in the spring configuration
Say I have 8 media types, it seems much less elegant to have 16 entries that follow the above pattern, then to have my factory instantiate the objects using reflection and inject all the necessary dependencies:
<object name="PowerPointPlugin" type="MostMedia.Cwrapper.Plugins.PowerPointPlugin,CorePlugins.dll">
<object name="PowerPointPlugin" type="MostMedia.Cwrapper.Core.LibraryItemHelper,CwrapperCore.dll">
<property name="Description">Powerpoint Presentation</property>
string  pluginInfo =Utilities.splitString(",",myHelper.PluginClass);
if (pluginInfo.Length != 2) throw new ConfigurationException(item.ItemType +
" PluginClass property requires a class and assembly name seperated by a comma");
ObjectHandle hdl = System.Activator.CreateInstanceFrom(pluginInfo.Trim(),pluginInfo.Trim());
ICwrapperPlugin aPlugin = (ICwrapperPlugin)hdl.Unwrap();
aPlugin.Ppt = myPptFacade;
return (ICwrapperPlugin) myContents[item.ItemType];
This IApplicationContext approach seems to have a number of other disadvantages. The info about a media type is now in two places in the spring config file instead of one place in mine. I'll need to provide a facade that can tanslate my media type id to the correct spring id (since I can't assign the same id to both the media object helper and the media object pluging e.g, "ppt"). Finally seems to me that I lose information on how my app hangs together, about dependencies that really matter.
I'm guessing that if my objects aren't managed by the spring framework, I won't be able to take advantage of things link AOP. Do I need to implement my own IFactoryObject. If I do will this play nicely with the objects in the IApplicationContext . For example can they use the messaging feature and AOP features?