View Javadoc

1   /*
2    * $Id: AbstractJobConfig.java 20321 2010-11-24 15:21:24Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  package org.mule.transport.quartz.config;
11  
12  import org.mule.api.MuleContext;
13  import org.mule.api.context.MuleContextAware;
14  import org.mule.transport.quartz.QuartzConnector;
15  
16  import org.quartz.Job;
17  import org.quartz.StatefulJob;
18  
19  /**
20   * Base implementation of {@link JobConfig}.
21   */
22  public abstract class AbstractJobConfig implements JobConfig, MuleContextAware
23  {
24      private boolean stateful = false;
25  
26      private String groupName = QuartzConnector.DEFAULT_GROUP_NAME;
27  
28      private String jobGroupName = QuartzConnector.DEFAULT_GROUP_NAME;
29  
30      private transient MuleContext muleContext;
31  
32      public void setMuleContext(MuleContext context)
33      {
34          this.muleContext = context;
35      }
36  
37      public MuleContext getMuleContext()
38      {
39          return muleContext;
40      }
41  
42      public String getGroupName()
43      {
44          return groupName;
45      }
46  
47      public void setGroupName(String groupName)
48      {
49          this.groupName = groupName;
50      }
51  
52      public String getJobGroupName()
53      {
54          return jobGroupName;
55      }
56  
57      public void setJobGroupName(String jobGroupName)
58      {
59          this.jobGroupName = jobGroupName;
60      }
61  
62      public boolean isStateful()
63      {
64          return stateful;
65      }
66  
67      public void setStateful(boolean stateful)
68      {
69          this.stateful = stateful;
70      }
71  
72      public final Class<? extends Job> getJobClass()
73      {
74          return (isStateful() ? getStatefulJobClass() : getStatelessJobClass());
75      }
76  
77      protected abstract Class<? extends StatefulJob> getStatefulJobClass();
78      
79      protected abstract Class<? extends Job> getStatelessJobClass();
80  }