QQ苹果一直处于开机状态登陆状态

SchedulerFactoryBean
org.springframework.scheduling.quartz
Class SchedulerFactoryBean
org.springframework.scheduling.quartz.SchedulerFactoryBean
All Implemented Interfaces: , , &org.quartz.Scheduler&, , , , , ,
public class SchedulerFactoryBeanextends implements &org.quartz.Scheduler&, , , , ,
that creates and configures a Quartz Scheduler,
manages its lifecycle as part of the Spring application context, and exposes the
Scheduler as bean reference for dependency injection.
Allows registration of JobDetails, Calendars and Triggers, automatically
starting the scheduler on initialization and shutting it down on destruction.
In scenarios that just require static registration of jobs at startup, there
is no need to access the Scheduler instance itself in application code.
For dynamic registration of jobs at runtime, use a bean reference to
this SchedulerFactoryBean to get direct access to the Quartz Scheduler
(org.quartz.Scheduler). This allows you to create new jobs
and triggers, and also to control and monitor the entire Scheduler.
Note that Quartz instantiates a new Job for each execution, in
contrast to Timer which uses a TimerTask instance that is shared
between repeated executions. Just JobDetail descriptors are shared.
When using persistent jobs, it is strongly recommended to perform all
operations on the Scheduler within Spring-managed (or plain JTA) transactions.
Else, database locking will not properly work and might even break.
javadoc for details.)
The preferred way to achieve transactional execution is to demarcate
declarative transactions at the business facade level, which will
automatically apply to Scheduler operations performed within those scopes.
Alternatively, you may add transactional advice for the Scheduler itself.
Note: This version of Spring's SchedulerFactoryBean supports Quartz 1.x,
more specifically Quartz 1.5 or higher. The "jobSchedulingDataLocation" feature
requires Quartz 1.6.1 or higher (as of Spring 2.5.5).
18.02.2004
Juergen Hoeller
See Also:,
Scheduler,
SchedulerFactory,
StdSchedulerFactory,
static&int
&&&&&&&&&&&
&&&&&&&&&&&
&&&&&&&&&&&
&&&&&&&&&&Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
protected &org.quartz.Scheduler
(org.quartz.SchedulerFactory&schedulerFactory,
&schedulerName)
&&&&&&&&&&Create the Scheduler instance for the given factory and scheduler name.
&&&&&&&&&&Shut down the Quartz scheduler on bean factory shutdown,
stopping all scheduled jobs.
&&&&&&&&&&Return the DataSource for the currently configured Quartz Scheduler,
to be used by LocalDataSourceJobStore.
&&&&&&&&&&Return the non-transactional DataSource for the currently configured
Quartz Scheduler, to be used by LocalDataSourceJobStore.
&&&&&&&&&&Return the ResourceLoader for the currently configured Quartz Scheduler,
to be used by ResourceLoaderClassLoadHelper.
&&&&&&&&&&Return the TaskExecutor for the currently configured Quartz Scheduler,
to be used by LocalTaskExecutorThreadPool.
&org.quartz.Scheduler
&&&&&&&&&&Return an instance (possibly shared or independent) of the object
managed by this factory.
&&? extends org.quartz.Scheduler&
&&&&&&&&&&Return the type of object that this FactoryBean creates,
or null if not known in advance.
&&&&&&&&&&Return the phase in which this scheduler will be started and stopped.
&org.quartz.Scheduler
&&&&&&&&&&Template method that determines the Scheduler to operate on.
&&&&&&&&&&Return whether this scheduler is configured for auto-startup.
&&&&&&&&&&Check whether this component is currently running.
&&&&&&&&&&Is the object managed by this factory a singleton? That is,
always return the same object
(a reference that can be cached)?
(&applicationContext)
&&&&&&&&&&Set the ApplicationContext that this object runs in.
(&applicationContextSchedulerContextKey)
&&&&&&&&&&Set the key of an ApplicationContext reference to expose in the
SchedulerContext, for example "applicationContext".
(boolean&autoStartup)
&&&&&&&&&&Set whether to automatically start the scheduler after initialization.
&&&&&&&&&&Set the name of the bean in the bean factory that created this bean.
(&configLocation)
&&&&&&&&&&Set the location of the Quartz properties config file, for example
as classpath resource "classpath:quartz.properties".
(&dataSource)
&&&&&&&&&&Set the default DataSource to be used by the Scheduler.
(boolean&exposeSchedulerInRepository)
&&&&&&&&&&Set whether to expose the Spring-managed Scheduler instance in the
Quartz SchedulerRepository.
(org.quartz.spi.JobFactory&jobFactory)
&&&&&&&&&&Set the Quartz JobFactory to use for this Scheduler.
(&nonTransactionalDataSource)
&&&&&&&&&&Set the DataSource to be used by the Scheduler for non-transactional access.
(int&phase)
&&&&&&&&&&Specify the phase in which this scheduler should be started and
(&quartzProperties)
&&&&&&&&&&Set Quartz properties, like "org.quartz.threadPool.class".
(&schedulerContextAsMap)
&&&&&&&&&&Register objects in the Scheduler context via a given Map.
(&schedulerFactoryClass)
&&&&&&&&&&Set the Quartz SchedulerFactory implementation to use.
(&schedulerName)
&&&&&&&&&&Set the name of the Scheduler to create via the SchedulerFactory.
(int&startupDelay)
&&&&&&&&&&Set the number of seconds to wait after initialization before
starting the scheduler asynchronously.
(&taskExecutor)
&&&&&&&&&&Set the Spring TaskExecutor to use as Quartz backend.
(boolean&waitForJobsToCompleteOnShutdown)
&&&&&&&&&&Set whether to wait for running jobs to complete on shutdown.
&&&&&&&&&&Start this component.
protected &void
(org.quartz.Scheduler&scheduler,
int&startupDelay)
&&&&&&&&&&Start the Quartz Scheduler, respecting the "startupDelay" setting.
&&&&&&&&&&Stop this component.
(&callback)
&&&&&&&&&&Indicates that a Lifecycle component must stop if it is currently running.
, , , , , , , , , , , , , ,
, , , , , , , , , ,
PROP_THREAD_COUNT
public static final
PROP_THREAD_COUNT
DEFAULT_THREAD_COUNT
public static final int DEFAULT_THREAD_COUNT
SchedulerFactoryBean
public SchedulerFactoryBean()
getConfigTimeResourceLoader
public static
getConfigTimeResourceLoader()
Return the ResourceLoader for the currently configured Quartz Scheduler,
to be used by ResourceLoaderClassLoadHelper.
This instance will be set before initialization of the corresponding
Scheduler, and reset immediately afterwards. It is thus only available
during configuration.
See Also:,
getConfigTimeTaskExecutor
public static
getConfigTimeTaskExecutor()
Return the TaskExecutor for the currently configured Quartz Scheduler,
to be used by LocalTaskExecutorThreadPool.
This instance will be set before initialization of the corresponding
Scheduler, and reset immediately afterwards. It is thus only available
during configuration.
See Also:,
getConfigTimeDataSource
public static
getConfigTimeDataSource()
Return the DataSource for the currently configured Quartz Scheduler,
to be used by LocalDataSourceJobStore.
This instance will be set before initialization of the corresponding
Scheduler, and reset immediately afterwards. It is thus only available
during configuration.
See Also:,
getConfigTimeNonTransactionalDataSource
public static
getConfigTimeNonTransactionalDataSource()
Return the non-transactional DataSource for the currently configured
Quartz Scheduler, to be used by LocalDataSourceJobStore.
This instance will be set before initialization of the corresponding
Scheduler, and reset immediately afterwards. It is thus only available
during configuration.
See Also:,
setSchedulerFactoryClass
public void setSchedulerFactoryClass(&schedulerFactoryClass)
Set the Quartz SchedulerFactory implementation to use.
Default is StdSchedulerFactory, reading in the standard
quartz.properties from quartz.jar.
To use custom Quartz properties, specify the "configLocation"
or "quartzProperties" bean property on this FactoryBean.
See Also:StdSchedulerFactory,
setSchedulerName
public void setSchedulerName(&schedulerName)
Set the name of the Scheduler to create via the SchedulerFactory.
If not specified, the bean name will be used as default scheduler name.
See Also:,
SchedulerFactory.getScheduler(),
SchedulerFactory.getScheduler(String)
setConfigLocation
public void setConfigLocation(&configLocation)
Set the location of the Quartz properties config file, for example
as classpath resource "classpath:quartz.properties".
Note: Can be omitted when all necessary properties are specified
locally via this bean, or when relying on Quartz' default configuration.
setQuartzProperties
public void setQuartzProperties(&quartzProperties)
Set Quartz properties, like "org.quartz.threadPool.class".
Can be used to override values in a Quartz properties config file,
or to specify all necessary properties locally.
setTaskExecutor
public void setTaskExecutor(&taskExecutor)
Set the Spring TaskExecutor to use as Quartz backend.
Exposed as thread pool through the Quartz SPI.
Can be used to assign a JDK 1.5 ThreadPoolExecutor or a CommonJ
WorkManager as Quartz backend, to avoid Quartz's manual thread creation.
By default, a Quartz SimpleThreadPool will be used, configured through
the corresponding Quartz properties.
See Also:,
setDataSource
public void setDataSource(&dataSource)
Set the default DataSource to be used by the Scheduler. If set,
this will override corresponding settings in Quartz properties.
Note: If this is set, the Quartz settings should not define
a job store "dataSource" to avoid meaningless double configuration.
A Spring-specific subclass of Quartz' JobStoreCMT will be used.
It is therefore strongly recommended to perform all operations on
the Scheduler within Spring-managed (or plain JTA) transactions.
Else, database locking will not properly work and might even break
(e.g. if trying to obtain a lock on Oracle without a transaction).
Supports both transactional and non-transactional DataSource access.
With a non-XA DataSource and local Spring transactions, a single DataSource
argument is sufficient. In case of an XA DataSource and global JTA transactions,
SchedulerFactoryBean's "nonTransactionalDataSource" property should be set,
passing in a non-XA DataSource that will not participate in global transactions.
See Also:,
setNonTransactionalDataSource
public void setNonTransactionalDataSource(&nonTransactionalDataSource)
Set the DataSource to be used by the Scheduler for non-transactional access.
This is only necessary if the default DataSource is an XA DataSource that will
always participate in transactions: A non-XA version of that DataSource should
be specified as "nonTransactionalDataSource" in such a scenario.
This is not relevant with a local DataSource instance and Spring transactions.
Specifying a single default DataSource as "dataSource" is sufficient there.
See Also:,
setSchedulerContextAsMap
public void setSchedulerContextAsMap(&schedulerContextAsMap)
Register objects in the Scheduler context via a given Map.
These objects will be available to any Job that runs in this Scheduler.
Note: When using persistent Jobs whose JobDetail will be kept in the
database, do not put Spring-managed beans or an ApplicationContext
reference into the JobDataMap but rather into the SchedulerContext.
Parameters:schedulerContextAsMap - Map with String keys and any objects as
values (for example Spring-managed beans)See Also:
setApplicationContextSchedulerContextKey
public void setApplicationContextSchedulerContextKey(&applicationContextSchedulerContextKey)
Set the key of an ApplicationContext reference to expose in the
SchedulerContext, for example "applicationContext". Default is none.
Only applicable when running in a Spring ApplicationContext.
Note: When using persistent Jobs whose JobDetail will be kept in the
database, do not put an ApplicationContext reference into the JobDataMap
but rather into the SchedulerContext.
In case of a QuartzJobBean, the reference will be applied to the Job
instance as bean property. An "applicationContext" attribute will
correspond to a "setApplicationContext" method in that scenario.
Note that BeanFactory callback interfaces like ApplicationContextAware
are not automatically applied to Quartz Job instances, because Quartz
itself is reponsible for the lifecycle of its Jobs.
See Also:,
setJobFactory
public void setJobFactory(org.quartz.spi.JobFactory&jobFactory)
Set the Quartz JobFactory to use for this Scheduler.
Default is Spring's , which supports
objects as well as standard Quartz
Job instances. Note that this default only applies
to a local Scheduler, not to a RemoteScheduler (where setting
a custom JobFactory is not supported by Quartz).
Specify an instance of Spring's
(typically as an inner bean definition) to automatically populate a job's
bean properties from the specified job data map and scheduler context.
See Also:,
setAutoStartup
public void setAutoStartup(boolean&autoStartup)
Set whether to automatically start the scheduler after initialization.
Default is "true"; set this to "false" to allow for manual startup.
isAutoStartup
public boolean isAutoStartup()
Return whether this scheduler is configured for auto-startup. If "true",
the scheduler will start after the context is refreshed and after the
start delay, if any.
Specified by: in interface
public void setPhase(int&phase)
Specify the phase in which this scheduler should be started and
stopped. The startup order proceeds from lowest to highest, and
the shutdown order is the reverse of that. By default this value
is Integer.MAX_VALUE meaning that this scheduler starts as late
as possible and stops as soon as possible.
public int getPhase()
Return the phase in which this scheduler will be started and stopped.
Specified by: in interface
setStartupDelay
public void setStartupDelay(int&startupDelay)
Set the number of seconds to wait after initialization before
starting the scheduler asynchronously. Default is 0, meaning
immediate synchronous startup on initialization of this bean.
Setting this to 10 or 20 seconds makes sense if no jobs
should be run before the entire application has started up.
setExposeSchedulerInRepository
public void setExposeSchedulerInRepository(boolean&exposeSchedulerInRepository)
Set whether to expose the Spring-managed Scheduler instance in the
Quartz SchedulerRepository. Default is "false", since the Spring-managed
Scheduler is usually exclusively intended for access within the Spring context.
Switch this flag to "true" in order to expose the Scheduler globally.
This is not recommended unless you have an existing Spring application that
relies on this behavior. Note that such global exposure was the accidental
default in earlier S this has been fixed as of Spring 2.5.6.
setWaitForJobsToCompleteOnShutdown
public void setWaitForJobsToCompleteOnShutdown(boolean&waitForJobsToCompleteOnShutdown)
Set whether to wait for running jobs to complete on shutdown.
Default is "false". Switch this to "true" if you prefer
fully completed jobs at the expense of a longer shutdown phase.
See Also:Scheduler.shutdown(boolean)
setBeanName
public void setBeanName(&name)
Description copied from interface:
Set the name of the bean in the bean factory that created this bean.
Invoked after population of normal bean properties but before an
init callback such as
or a custom init-method.
Specified by: in interface
Parameters:name - the name of the bean in the factory.
Note that this name is the actual bean name used in the factory, which may
differ from the originally specified name: in particular for inner bean
names, the actual bean name might have been made unique through appending
"#..." suffixes. Use the
method to extract the original bean name (without suffix), if desired.
setApplicationContext
public void setApplicationContext(&applicationContext)
Description copied from interface:
Set the ApplicationContext that this object runs in.
Normally this call will be used to initialize the object.
Invoked after population of normal bean properties but before an init callback such
or a custom init-method. Invoked after ,
, if applicable.
Specified by: in interface
Parameters:applicationContext - the ApplicationContext object to be used by this objectSee Also:
afterPropertiesSet
public void afterPropertiesSet()
Description copied from interface:
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
This method allows the bean instance to perform initialization only
possible when all bean properties have been set and to throw an
exception in the event of misconfiguration.
Specified by: in interface
- in the event of misconfiguration (such
as failure to set an essential property) or if initialization fails.
createScheduler
protected org.quartz.Scheduler createScheduler(org.quartz.SchedulerFactory&schedulerFactory,
&schedulerName)
throws org.quartz.SchedulerException
Create the Scheduler instance for the given factory and scheduler name.
Called by .
The default implementation invokes SchedulerFactory's getScheduler
method. Can be overridden for custom Scheduler creation.
Parameters:schedulerFactory - the factory to create the Scheduler withschedulerName - the name of the scheduler to create
Returns:the Scheduler instance
org.quartz.SchedulerException - if thrown by Quartz methodsSee Also:,
SchedulerFactory.getScheduler()
startScheduler
protected void startScheduler(org.quartz.Scheduler&scheduler,
int&startupDelay)
throws org.quartz.SchedulerException
Start the Quartz Scheduler, respecting the "startupDelay" setting.
Parameters:scheduler - the Scheduler to startstartupDelay - the number of seconds to wait before starting
the Scheduler asynchronously
org.quartz.SchedulerException
getScheduler
public org.quartz.Scheduler getScheduler()
Description copied from class:
Template method that determines the Scheduler to operate on.
To be implemented by subclasses.
Specified by: in class
public org.quartz.Scheduler getObject()
Description copied from interface:
Return an instance (possibly shared or independent) of the object
managed by this factory.
As with a , this allows support for both the
Singleton and Prototype design pattern.
If this FactoryBean is not fully initialized yet at the time of
the call (for example because it is involved in a circular reference),
throw a corresponding .
As of Spring 2.0, FactoryBeans are allowed to return null
objects. The factory will consider this as nor it
will not throw a FactoryBeanNotInitializedException in this case anymore.
FactoryBean implementations are encouraged to throw
FactoryBeanNotInitializedException themselves now, as appropriate.
Specified by: in interface &org.quartz.Scheduler&
Returns:an instance of the bean (can be null)See Also:
getObjectType
public &? extends org.quartz.Scheduler& getObjectType()
Description copied from interface:
Return the type of object that this FactoryBean creates,
or null if not known in advance.
This allows one to check for specific types of beans without
instantiating objects, for example on autowiring.
In the case of implementations that are creating a singleton object,
this method should try to avoid singleton creatio
it should rather estimate the type in advance.
For prototypes, returning a meaningful type here is advisable too.
This method can be called before this FactoryBean has
been fully initialized. It must not rely on state created during
of course, it can still use such state if available.
NOTE: Autowiring will simply ignore FactoryBeans that return
null here. Therefore it is highly recommended to implement
this method properly, using the current state of the FactoryBean.
Specified by: in interface &org.quartz.Scheduler&
Returns:the type of object that this FactoryBean creates,
or null if not known at the time of the callSee Also:
isSingleton
public boolean isSingleton()
Description copied from interface:
Is the object managed by this factory a singleton? That is,
always return the same object
(a reference that can be cached)?
NOTE: If a FactoryBean indicates to hold a singleton object,
the object returned from getObject() might get cached
by the owning BeanFactory. Hence, do not return true
unless the FactoryBean always exposes the same reference.
The singleton status of the FactoryBean itself will generally
be provided by the owning BeanF usually, it has to be
defined as singleton there.
NOTE: This method returning false does not
necessarily indicate that returned objects are independent instances.
An implementation of the extended
may explicitly indicate independent instances through its
method. Plain
implementations which do not implement this extended interface are
simply assumed to always return independent instances if the
isSingleton() implementation returns false.
Specified by: in interface &org.quartz.Scheduler&
Returns:whether the exposed object is a singletonSee Also:,
public void start()
Description copied from interface:
Start this component.
Should not throw an exception if the component is already running.
In the case of a container, this will propagate the start signal
to all components that apply.
Specified by: in interface
public void stop()
Description copied from interface:
Stop this component.
Should not throw an exception if the component isn't started yet.
In the case of a container, this will propagate the stop signal
to all components that apply.
Specified by: in interface
public void stop(&callback)
Description copied from interface:
Indicates that a Lifecycle component must stop if it is currently running.
The provided callback is used by the LifecycleProcessor to support an
ordered, and potentially concurrent, shutdown of all components having a
common shutdown order value. The callback must be executed after
the SmartLifecycle component does indeed stop.
Specified by: in interface
public boolean isRunning()
Description copied from interface:
Check whether this component is currently running.
In the case of a container, this will return true
only if all components that apply are currently running.
Specified by: in interface
Returns:whether the component is currently running
public void destroy()
throws org.quartz.SchedulerException
Shut down the Quartz scheduler on bean factory shutdown,
stopping all scheduled jobs.
Specified by: in interface
org.quartz.SchedulerException

我要回帖

更多关于 cpu一直处于睿频状态 的文章

 

随机推荐