QuartzSchedulerResources.cs :  » Business-Application » Quartz-Enterprise-Scheduler » Quartz » Core » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Business Application » Quartz Enterprise Scheduler 
Quartz Enterprise Scheduler » Quartz » Core » QuartzSchedulerResources.cs
/* 
* Copyright 2004-2009 James House 
* 
* Licensed under the Apache License, Version 2.0 (the "License"); you may not 
* use this file except in compliance with the License. You may obtain a copy 
* of the License at 
* 
*   http://www.apache.org/licenses/LICENSE-2.0 
*   
* Unless required by applicable law or agreed to in writing, software 
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
* License for the specific language governing permissions and limitations 
* under the License.
* 
*/

/*
* Previously Copyright (c) 2001-2004 James House
*/
using System;
using System.Collections;
using System.Globalization;

using Quartz.Spi;

namespace Quartz.Core{
  /// <summary>
  /// Contains all of the resources (<see cref="IJobStore" />,<see cref="IThreadPool" />,
  /// etc.) necessary to create a <see cref="QuartzScheduler" /> instance.
  /// </summary>
  /// <seealso cref="QuartzScheduler" />
  /// <author>James House</author>
  /// <author>Marko Lahma (.NET)</author>
  public class QuartzSchedulerResources
  {
        private string name;
        private string instanceId;
        private string threadName;
        private IThreadPool threadPool;
        private IJobStore jobStore;
        private IJobRunShellFactory jobRunShellFactory;
        private readonly ArrayList schedulerPlugins = new ArrayList(10);
        private bool makeSchedulerThreadDaemon = false;
      private ISchedulerExporter exporter;

    /// <summary>
    /// Get or set the name for the <see cref="QuartzScheduler" />.
    /// </summary>
    /// <exception cref="ArgumentException">
    /// if name is null or empty.
    /// </exception>
    public virtual string Name
    {
      get { return name; }

      set
      {
        if (value == null || value.Trim().Length == 0)
        {
          throw new ArgumentException("Scheduler name cannot be empty.");
        }

        name = value;

        if (threadName == null)
        {
          // thread name not already set, use default thread name
          ThreadName = string.Format(CultureInfo.InvariantCulture, "{0}_QuartzSchedulerThread", value);
        }
      }
    }

    /// <summary>
    /// Get or set the instance Id for the <see cref="QuartzScheduler" />.
    /// </summary>
    /// <exception cref="ArgumentException"> 
    /// if name is null or empty.
    /// </exception>
    public virtual string InstanceId
    {
      get { return instanceId; }

      set
      {
        if (value == null || value.Trim().Length == 0)
        {
          throw new ArgumentException("Scheduler instanceId cannot be empty.");
        }

        instanceId = value;
      }
    }


    /// <summary>
    /// Get or set the name for the <see cref="QuartzSchedulerThread" />.
    /// </summary>
    /// <exception cref="ArgumentException"> 
    /// if name is null or empty.
    /// </exception>
    public virtual string ThreadName
    {
      get { return threadName; }

      set
      {
        if (value == null || value.Trim().Length == 0)
        {
          throw new ArgumentException("Scheduler thread name cannot be empty.");
        }

        threadName = value;
      }
    }

    /// <summary>
    /// Get or set the <see cref="ThreadPool" /> for the <see cref="QuartzScheduler" />
    /// to use.
    /// </summary>
    /// <exception cref="ArgumentException"> 
    /// if threadPool is null.
    /// </exception>
    public virtual IThreadPool ThreadPool
    {
      get { return threadPool; }

      set
      {
        if (value == null)
        {
          throw new ArgumentException("ThreadPool cannot be null.");
        }

        threadPool = value;
      }
    }

    /// <summary>
    /// Get or set the <see cref="IJobStore" /> for the <see cref="QuartzScheduler" />
    /// to use.
    /// </summary>
    /// <exception cref="ArgumentException"> 
    /// if jobStore is null.
    /// </exception>
    public virtual IJobStore JobStore
    {
      get { return jobStore; }

      set
      {
        if (value == null)
        {
          throw new ArgumentException("JobStore cannot be null.");
        }

        jobStore = value;
      }
    }

    /// <summary> 
    /// Get or set the <see cref="JobRunShellFactory" /> for the <see cref="QuartzScheduler" />
    /// to use.
    /// </summary>
    /// <exception cref="ArgumentException"> 
    /// if jobRunShellFactory is null.
    /// </exception>
    public virtual IJobRunShellFactory JobRunShellFactory
    {
      get { return jobRunShellFactory; }

      set
      {
        if (value == null)
        {
          throw new ArgumentException("JobRunShellFactory cannot be null.");
        }

        jobRunShellFactory = value;
      }
    }

    /// <summary>
    /// Gets the unique identifier.
    /// </summary>
    /// <param name="schedName">Name of the scheduler.</param>
    /// <param name="schedInstId">The scheduler instance id.</param>
    /// <returns></returns>
    public static string GetUniqueIdentifier(string schedName, string schedInstId)
    {
      return string.Format(CultureInfo.InvariantCulture, "{0}_$_{1}", schedName, schedInstId);
    }

    /// <summary>
    /// Gets the unique identifier.
    /// </summary>
    /// <returns></returns>
    public virtual string GetUniqueIdentifier()
    {
      return GetUniqueIdentifier(name, instanceId);
    }

        /// <summary>
        /// Add the given <see cref="ISchedulerPlugin" /> for the 
        /// <see cref="QuartzScheduler" /> to use. This method expects the plugin's
         /// "initialize" method to be invoked externally (either before or after
        /// this method is called).
        /// </summary>
        /// <param name="plugin"></param>
        public void AddSchedulerPlugin(ISchedulerPlugin plugin)
        {
            schedulerPlugins.Add(plugin);
        }

      /// <summary>
        /// Get the <see cref="IList" /> of all 
        /// <see cref="ISchedulerPlugin" />s for the 
        /// <see cref="QuartzScheduler" /> to use.
      /// </summary>
      /// <returns></returns>
      public IList SchedulerPlugins
      {
          get { return schedulerPlugins; }
      }


        /// <summary>
        /// Gets or sets a value indicating whether to make scheduler thread daemon.
        /// </summary>
        /// <value>
        ///   <c>true</c> if scheduler should be thread daemon; otherwise, <c>false</c>.
        /// </value>
      public bool MakeSchedulerThreadDaemon
      {
          get { return makeSchedulerThreadDaemon; }
          set { makeSchedulerThreadDaemon = value; }
      }


        /// <summary>
        /// Gets or sets the scheduler exporter.
        /// </summary>
        /// <value>The scheduler exporter.</value>
      public ISchedulerExporter SchedulerExporter
      {
          get { return exporter; }
          set { exporter = value; }
      }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.