/// <summary>
        /// Creates a new job resolved from the IoC container.
        /// </summary>
        /// <param name="bundle">Trigger fired bundle instance.</param>
        /// <param name="scheduler">Scheduler instance.</param>
        /// <returns>Returns a new job resolved from the IoC container.</returns>
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            if (bundle == null)
                throw new ArgumentNullException("bundle");

            return (IJob)this._container.Resolve(bundle.JobDetail.JobType);
        }
        /// <summary>
        /// Called by the scheduler at the time of the trigger firing, in order to
        ///                         produce a <see cref="T:Quartz.IJob"/> instance on which to call Execute.
        /// 
        /// </summary>
        /// 
        /// <remarks>
        /// It should be extremely rare for this method to throw an exception -
        ///                         basically only the the case where there is no way at all to instantiate
        ///                         and prepare the Job for execution.  When the exception is thrown, the
        ///                         Scheduler will move all triggers associated with the Job into the
        ///                         <see cref="F:Quartz.TriggerState.Error"/> state, which will require human
        ///                         intervention (e.g. an application restart after fixing whatever
        ///                         configuration problem led to the issue wih instantiating the Job.
        /// 
        /// </remarks>
        /// <param name="bundle">The TriggerFiredBundle from which the <see cref="T:Quartz.IJobDetail"/>
        ///                           and other info relating to the trigger firing can be obtained.
        ///                         </param><param name="scheduler">a handle to the scheduler that is about to execute the job</param><throws>SchedulerException if there is a problem instantiating the Job. </throws>
        /// <returns>
        /// the newly instantiated Job
        /// 
        /// </returns>
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            var jobType = bundle.JobDetail.JobType.FullName;
            TenantId tenantId = null;
            if (bundle.JobDetail.JobDataMap.ContainsKey(JobKeys.TenantId))
            {
                tenantId = new TenantId(
                    bundle.JobDetail.JobDataMap.GetString(JobKeys.TenantId)
                    );
                Logger.DebugFormat("new job {0} on tenant {1}", jobType, tenantId );
            }
            else
            {
                if (typeof (ITenantJob).IsAssignableFrom(bundle.JobDetail.JobType))
                {
                    string message = String.Format("Job {0}: missing tenantId", jobType);
                    Logger.Error(message);
                    throw new Exception(message);
                }

                Logger.DebugFormat("new job {0} without tenant", jobType);
            }

            var kernel = SelectKernel(tenantId);
            var job = this.ResolveByJobName ? 
                (IJob)kernel.Resolve(bundle.JobDetail.Key.ToString(), typeof(IJob)) :
                (IJob)kernel.Resolve(bundle.JobDetail.JobType);

            if (job is ITenantJob)
            {
                (job as ITenantJob).TenantId = new TenantId(tenantId);
            }

            return job;
        }
 /// <summary> 
 /// Create the job instance, populating it with property values taken
 /// from the scheduler context, job data map and trigger data map.
 /// </summary>
 protected override object CreateJobInstance(TriggerFiredBundle bundle)
 {
     ObjectWrapper ow = new ObjectWrapper(bundle.JobDetail.JobType);
     if (IsEligibleForPropertyPopulation(ow.WrappedInstance))
     {
         MutablePropertyValues pvs = new MutablePropertyValues();
         if (schedulerContext != null)
         {
             pvs.AddAll(schedulerContext);
         }
         pvs.AddAll(bundle.JobDetail.JobDataMap);
         pvs.AddAll(bundle.Trigger.JobDataMap);
         if (ignoredUnknownProperties != null)
         {
             for (int i = 0; i < ignoredUnknownProperties.Length; i++)
             {
                 string propName = ignoredUnknownProperties[i];
                 if (pvs.Contains(propName))
                 {
                     pvs.Remove(propName);
                 }
             }
             ow.SetPropertyValues(pvs);
         }
         else
         {
             ow.SetPropertyValues(pvs, true);
         }
     }
     return ow.WrappedInstance;
 }
 public IJob NewJob(TriggerFiredBundle bundle)
 {
     Type jobType = bundle.JobDetail.JobType;
     var job = ObjectFactory.GetInstance(jobType) as IJob;
     ObjectFactory.BuildUp(job);
     return job;
 }
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            var jobDetail = bundle.JobDetail;
            var jobType = jobDetail.JobType;

            try
            {
                if (Log.IsDebugEnabled)
                {
                    Log.Debug(string.Format("Producing instance of Job '{0}', class={1}",
                        new object[] { jobDetail.Key, jobType.FullName }));
                }

                var disallowConcurent =
                    jobType.GetCustomAttributes(typeof(DisallowConcurrentExecutionAttribute), true).Length == 1;

                return typeof(IInterruptableJob).IsAssignableFrom(jobType)
                    ? disallowConcurent
                        ? new InterruptableDisallowConcurrentExecutionJobWrapper(bundle, _container)
                        : new InterruptableJobWrapper(bundle, _container)
                    : disallowConcurent
                        ? new DisallowConcurrentExecutionJobWrapper(bundle, _container)
                        : new JobWrapper(bundle, _container);
            }
            catch (Exception ex)
            {
                throw new SchedulerException(
                    string.Format("Problem instantiating class '{0}'", new object[] { jobDetail.JobType.FullName }), ex);
            }
        }
 /// <summary>
 /// Called by the scheduler at the time of the trigger firing, in order to produce
 /// a Quartz.IJob instance on which to call Execute
 /// </summary>
 /// <param name="bundle">The TriggerFiredBundle from which the Quartz.IJobDetail and other info relating to the trigger firing can be obtained.</param>
 /// <param name="scheduler">A handle to the scheduler that is about to execute the job</param>
 /// <returns>The new intance of IJob</returns>
 public IJob NewJob(
     TriggerFiredBundle bundle,
     IScheduler scheduler)
 {
     return (IJob)_container
         .GetInstance(bundle.JobDetail.JobType);
 }
		/// <summary>
		/// Initializes the job execution context with given scheduler and bundle.
		/// </summary>
		/// <param name="sched">The scheduler.</param>
		/// <param name="firedBundle">The bundle offired triggers.</param>
		public virtual void Initialize(QuartzScheduler sched, TriggerFiredBundle firedBundle)
		{
			qs = sched;

			IJob job;
			JobDetail jobDetail = firedBundle.JobDetail;

			try
			{
				job = sched.JobFactory.NewJob(firedBundle);
			}
			catch (SchedulerException se)
			{
				sched.NotifySchedulerListenersError(string.Format(CultureInfo.InvariantCulture, "An error occured instantiating job to be executed. job= '{0}'", jobDetail.FullName), se);
				throw;
			}
			catch (Exception e)
			{
				SchedulerException se = new SchedulerException(string.Format(CultureInfo.InvariantCulture, "Problem instantiating type '{0}'", jobDetail.JobType.FullName), e);
				sched.NotifySchedulerListenersError(string.Format(CultureInfo.InvariantCulture, "An error occured instantiating job to be executed. job= '{0}'", jobDetail.FullName), se);
				throw se;
			}

			jec = new JobExecutionContext(scheduler, firedBundle, job);
		}
Example #8
0
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            var jobDetail = bundle.JobDetail;
            var jobType = jobDetail.JobType;

            try
            {
                if (Log.IsDebugEnabled)
                {
                    Log.Debug(string.Format(
                        CultureInfo.InvariantCulture,
                        "Producing instance of Job '{0}', class={1}", new object[] { jobDetail.Key, jobType.FullName }));
                }

                return typeof(IInterruptableJob).IsAssignableFrom(jobType)
                    ? new InterruptableJobWrapper(bundle, container)
                    : new JobWrapper(bundle, container);
            }
            catch (Exception ex)
            {
                throw new SchedulerException(string.Format(
                    CultureInfo.InvariantCulture,
                    "Problem instantiating class '{0}'", new object[] { jobDetail.JobType.FullName }), ex);
            }
        }
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            if (bundle == null) throw new ArgumentNullException("bundle");
            if (scheduler == null) throw new ArgumentNullException("scheduler");

            var job = (IJob)IocManager.Instance.Resolve(bundle.JobDetail.JobType);
            return job;
        }
Example #10
0
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            var jobType = typeof(AutofacOwnedJob<>).MakeGenericType(new[] { bundle.JobDetail.JobType });

            var job = this.container.Resolve(jobType);

            return (IJob)job;
        }
Example #11
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            var jobAdapter = (IJob)_components.Resolve(
                bundle.JobDetail.JobType,
                new TypedParameter(typeof(IJobDetail), bundle.JobDetail));

            return jobAdapter;
        }
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            var type = bundle.JobDetail.JobType;

            _logger.Info("Job {0} was created", type.FullName);

            return _kernel.Get(type) as IJob;
        }
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            IJobDetail jobDetail = bundle.JobDetail;
            if (jobDetail == null)
                throw new SchedulerException("JobDetail was null");

            Type type = jobDetail.JobType;

            return _typeFactories[type].NewJob(bundle, scheduler);
        }
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            var jobDetail = bundle.JobDetail;
            if (jobDetail == null)
                throw new SchedulerException("JobDetail was null");

            var type = jobDetail.JobType;

            return _typeFactories.GetOrAdd(type, CreateJobFactory)
                .NewJob(bundle, scheduler);
        }
 public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
 {
     try
     {
         return (IJob)_lifetimeScope.Resolve(bundle.JobDetail.JobType);
     }
     catch (Exception e)
     {
         throw new SchedulerException("Problem instantiating class: " + e.Message, e);
     }
 }
 public override IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
 {
     try
     {
         return (IJob) this._kernel.Get(bundle.JobDetail.JobType); // will inject dependencies that the job requires
     }
     catch (Exception e)
     {
         throw new SchedulerException(string.Format("Problem while instantiating job '{0}' from the NinjectJobFactory.", bundle.JobDetail.Key), e);
     }
 }
Example #17
0
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            // Configure your IoC container to return a job instance based on jobType

            var jobDetail = bundle.JobDetail;

            Type jobType = jobDetail.JobType;

            Log.TraceFormat("Getting instance of job type {0}", jobType);

            throw new NotImplementedException();
        }
Example #18
0
        public Quartz.IJob NewJob(TriggerFiredBundle bundle, Quartz.IScheduler scheduler)
        {
            try
            {
                return (IJob)this.Container.Resolve(bundle.JobDetail.JobType);
            }
            catch (Exception ex)
            {

                throw;
            }
        }
 public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
 {
     try
     {
         var job = Container.Resolve(bundle.JobDetail.JobType) as IJob;
         return job;
     }
     catch (Exception exception)
     {
         throw new SchedulerException("Error on creation of new job", exception);
     }
 }
Example #20
0
 public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
 {
     try
     {
         return (IJob)InversionControl.Current.Resolve(bundle.JobDetail.JobType);
     }
     catch (Exception e)
     {
         var se = new SchedulerException("falha ao agendar", e);
         throw;
     }
 }
Example #21
0
 /// <summary>
 /// Called by the scheduler at the time of the trigger firing, in order to
 /// produce a <see cref="IJob"/> instance on which to call Execute.
 /// </summary>
 /// <remarks>
 /// It should be extremely rare for this method to throw an exception -
 /// basically only the the case where there is no way at all to instantiate
 /// and prepare the Job for execution.  When the exception is thrown, the
 /// Scheduler will move all triggers associated with the Job into the
 /// <see cref="TriggerState.Error"/> state, which will require human
 /// intervention (e.g. an application restart after fixing whatever
 /// configuration problem led to the issue wih instantiating the Job.
 /// </remarks>
 /// <param name="bundle">The TriggerFiredBundle from which the <see cref="IJobDetail"/>
 /// and other info relating to the trigger firing can be obtained.</param>
 /// <param name="scheduler">The scheduler instance.</param>
 /// <returns>the newly instantiated Job</returns>
 /// <throws>SchedulerException if there is a problem instantiating the Job.</throws>        
 public virtual IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
 {
     try
     {
         object jobObject = CreateJobInstance(bundle);
         return AdaptJob(jobObject);
     }
     catch (Exception ex)
     {
         throw new SchedulerException("Job instantiation failed", ex);
     }
 }
Example #22
0
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            try
            {
                return (IJob) Activator.CreateInstance(bundle.JobDetail.JobType);
            }
            catch
            {
            }

            throw new InvalidOperationException("Cannot construct job of type " + bundle.JobDetail.GetType().FullName);
        }
Example #23
0
 public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
 {
     try
     {                
         var job = this.serviceLocator.GetInstance(bundle.JobDetail.JobType) as IJob;
         Contract.Assert(job != null);
         return job;
     }
     catch (Exception exception)
     {
         throw new SchedulerException("Error on creation of new job", exception);
     }
 }
 /// <summary>
 /// News the job.
 /// </summary>
 /// <param name="bundle">The bundle.</param>
 /// <param name="scheduler">The scheduler.</param>
 /// <returns>IJob object.</returns>
 public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
 {
     var jobDetail = bundle.JobDetail;
     var jobType = jobDetail.JobType;
     try
     {
         return (IJob)this.container.GetInstance(bundle.JobDetail.JobType);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            try {
                IJobDetail jobDetail = bundle.JobDetail;
                Type jobType = jobDetail.JobType;

                return (IJob)_locator.Resolve(jobType);
            }
            catch (Exception e) {
                var se = new SchedulerException("Problem instantiating class of type", e);
                throw se;
            }
        }
 public IJob NewJob(TriggerFiredBundle bundle)
 {
     JobDetail jobDetail = bundle.JobDetail;
     try
     {
         return (IJob)NServiceBus.Configure.Instance.Builder.Build(jobDetail.JobType);
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message, ex);
         throw;
     }
 }
 public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
 {
     try
     {
         IJobDetail jobDetail = bundle.JobDetail;
         Type jobType = jobDetail.JobType;
         return (IJob)locator.GetInstance(jobType);
     }
     catch (Exception e)
     {
         throw new SchedulerException("Problem instantiating class", e);
     }
 }
		public IJob NewJob(TriggerFiredBundle bundle, Quartz.IScheduler scheduler)
		{
			try 
			{
				var x = this.Kernel.Get(bundle.JobDetail.JobType);
				return (IJob)x;
			}
			catch(Exception err)
			{
				this.EventReporter.ExceptionForObject(err, bundle.JobDetail);
				throw;
			}
		}
 public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
 {
     try
     {
         var jobDetail = bundle.JobDetail;
         var jobType = jobDetail.JobType;
         return (IJob) TinyIoCContainer.Current.Resolve(jobType);
     }
     catch (Exception ex)
     {
         throw new SchedulerException("Problem Instantiating job class", ex);
     }
 }
 public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
 {
     IJob newJob;
     try
     {
         newJob = (IJob)container.Resolve(bundle.JobDetail.JobType);
     }
     catch (Exception ex)
     {
          Console.WriteLine(ex.Message);   
         throw;
     }
     return newJob;
 }
 ///<summary>
 /// Constructor.
 ///</summary>
 ///<param name="triggerFiredBundle"></param>
 public TriggerFiredResult(TriggerFiredBundle triggerFiredBundle)
 {
     this.triggerFiredBundle = triggerFiredBundle;
 }