/// <summary>
 /// Ensure that the MessageQueueObject name is set and creates a 
 /// <see cref="DefaultMessageQueueFactory"/> if no <see cref="IMessageQueueFactory"/>
 /// is specified.
 /// </summary>
 /// <remarks>Will attempt to create an instance of the DefaultMessageQueue to detect early
 /// any configuraiton errors.</remarks>
 /// <exception cref="System.Exception">
 /// In the event of misconfiguration (such as the failure to set a
 /// required property) or if initialization fails.
 /// </exception>
 public virtual void AfterPropertiesSet()
 {
     if (MessageQueueObjectName == null)
     {
         throw new ArgumentException("The DefaultMessageQueueObjectName property has not been set.");
     }
     if (messageQueueFactory == null)
     {
         DefaultMessageQueueFactory mqf = new DefaultMessageQueueFactory();
         mqf.ApplicationContext = applicationContext;
         messageQueueFactory = mqf;
     }
     //Create an instance so we can 'fail-fast' if there isn't an DefaultMessageQueue unde 
     MessageQueue mq = MessageQueueFactory.CreateMessageQueue(messageQueueObjectName);
 }
Esempio n. 2
0
        /// <summary>
        /// Invoked by an <see cref="Spring.Objects.Factory.IObjectFactory"/>
        /// after it has injected all of an object's dependencies.
        /// </summary>
        /// <remarks>
        /// Ensure that the DefaultMessageQueueObjectName property is set, creates 
        /// a default implementation of the <see cref="IMessageQueueFactory"/> interface
        /// (<see cref="DefaultMessageQueueFactory"/>) that retrieves instances on a per-thread
        /// basis, and registers in the Spring container a default implementation of 
        /// <see cref="IMessageConverter"/> (<see cref="XmlMessageConverter"/>) with a
        /// simple System.String as its TargetType.  <see cref="QueueUtils.RegisterDefaultMessageConverter"/>
        /// </remarks>
        public void AfterPropertiesSet()
        {
            if (MessageQueueFactory == null)
            {
                AssertUtils.ArgumentNotNull(applicationContext, "MessageQueueTemplate requires the ApplicationContext property to be set if the MessageQueueFactory property is not set for automatic create of the DefaultMessageQueueFactory");

                DefaultMessageQueueFactory mqf = new DefaultMessageQueueFactory();
                mqf.ApplicationContext = applicationContext;
                messageQueueFactory = mqf;
            }
            if (messageConverterObjectName == null)
            {
                messageConverterObjectName = QueueUtils.RegisterDefaultMessageConverter(applicationContext);
            }
            //If it has not been set by the user explicitly, then initialize.
            CreateDefaultMetadataCache();
        }
 /// <summary>
 /// Validates that the <see cref="messageQueueObjectName"/> is not null.  If <see cref="MessageQueueFactory"/>
 /// is null, a <see cref="DefaultMessageQueueFactory"/> is created.  Can be be overridden in subclasses.
 /// </summary>
 protected override void ValidateConfiguration()
 {
     if (MessageQueueObjectName == null)
     {
         throw new ArgumentException("Property 'MessageQueueObjectName' is required");
     }
     if (MessageQueueFactory == null)
     {
         DefaultMessageQueueFactory qf = new DefaultMessageQueueFactory();
         qf.ApplicationContext = applicationContext;
         MessageQueueFactory = qf;
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Invoked by an <see cref="Spring.Objects.Factory.IObjectFactory"/>
 /// after it has injected all of an object's dependencies.
 /// </summary>
 /// <remarks>
 /// 	<p>
 /// This method allows the object instance to perform the kind of
 /// initialization only possible when all of it's dependencies have
 /// been injected (set), and to throw an appropriate exception in the
 /// event of misconfiguration.
 /// </p>
 /// 	<p>
 /// Please do consult the class level documentation for the
 /// <see cref="Spring.Objects.Factory.IObjectFactory"/> interface for a
 /// description of exactly <i>when</i> this method is invoked. In
 /// particular, it is worth noting that the
 /// <see cref="Spring.Objects.Factory.IObjectFactoryAware"/>
 /// and <see cref="Spring.Context.IApplicationContextAware"/>
 /// callbacks will have been invoked <i>prior</i> to this method being
 /// called.
 /// </p>
 /// </remarks>
 /// <exception cref="System.Exception">
 /// In the event of misconfiguration (such as the failure to set a
 /// required property) or if initialization fails.
 /// </exception>
 public void AfterPropertiesSet()
 {
     if (messageQueueFactory == null)
     {
         DefaultMessageQueueFactory mqf = new DefaultMessageQueueFactory();
         mqf.ApplicationContext = applicationContext;
         messageQueueFactory = mqf;
     }
     if (messageConverterObjectName == null)
     {
         messageConverterObjectName = QueueUtils.RegisterDefaultMessageConverter(applicationContext);
     }
     if (messageQueueTemplate == null)
     {
         messageQueueTemplate = new MessageQueueTemplate();
         messageQueueTemplate.ApplicationContext = ApplicationContext;
         messageQueueTemplate.AfterPropertiesSet();
     }
 }