Beispiel #1
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (_objectFactory != null)
            {
                _objectFactory.Dispose();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Instantiates and populates the underlying
        /// <see cref="Spring.Objects.Factory.IObjectFactory"/> with the object
        /// definitions yielded up by the <see cref="ConfigurationLocations"/>
        /// method.
        /// </summary>
        /// <exception cref="Spring.Objects.ObjectsException">
        /// In the case of errors encountered while refreshing the object factory.
        /// </exception>
        /// <exception cref="ApplicationContextException">
        /// In the case of errors encountered reading any of the resources
        /// yielded by the <see cref="ConfigurationLocations"/> method.
        /// </exception>
        /// <seealso cref="Spring.Context.Support.AbstractApplicationContext.RefreshObjectFactory()"/>
        protected override void RefreshObjectFactory()
        {
            // Shut down previous object factory, if any.
            DefaultListableObjectFactory oldObjectFactory = _objectFactory;

            _objectFactory = null;

            if (oldObjectFactory != null)
            {
                oldObjectFactory.Dispose();
            }

            try
            {
                DefaultListableObjectFactory objectFactory = CreateObjectFactory();
                CustomizeObjectFactory(objectFactory);
                LoadObjectDefinitions(objectFactory);

                _objectFactory = objectFactory;

                #region Instrumentation

                if (log.IsDebugEnabled)
                {
                    log.Debug(
                        string.Format(
                            "Refreshed ObjectFactory for application context '{0}'.",
                            Name));
                }

                #endregion
            }
            catch (IOException ex)
            {
                throw new ApplicationContextException(
                          string.Format(
                              "I/O error parsing XML resource for application context '{0}'.",
                              Name), ex);
            }
            catch (UriFormatException ex)
            {
                throw new ApplicationContextException(
                          string.Format(
                              "Error parsing resource locations [{0}] for application context '{1}'.",
                              StringUtils.ArrayToCommaDelimitedString(ConfigurationLocations),
                              Name), ex);
            }
        }