1 /***
2 Copyright (C) 2005 The Java Community
3
4 This program is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free Software
6 Foundation; either version 2 of the License, or (at your option) any later
7 version.
8
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 Place, Suite 330, Boston, MA 02111-1307 USA.
16 */
17 package org.bejug.javacareers.feeder;
18
19 import org.apache.commons.logging.Log;
20 import org.apache.commons.logging.LogFactory;
21 import org.bejug.javacareers.common.search.SearchCriteriaFactory;
22 import org.bejug.javacareers.common.search.SearchCriteriaService;
23 import org.bejug.javacareers.jobs.service.AdminService;
24 import org.bejug.javacareers.jobs.service.JobService;
25 import org.bejug.javacareers.jobs.service.RssFeedService;
26 import org.bejug.javacareers.project.properties.JavaCareersConfig;
27 import org.gnu.stealthp.rsslib.RSSChannel;
28 import org.gnu.stealthp.rsslib.RSSImage;
29
30 /***
31 * Base class for scheduled tasks
32 *
33 * @author Bavo Bruylandt (Last modified by $Author: bavo_jcs $)
34 * @version $Revision: 1.3 $ - $Date: 2005/09/30 14:38:08 $
35 */
36 public abstract class FeederTask {
37
38 /***
39 * The class logger.
40 */
41 private static final Log LOG = LogFactory.getLog(FeederTask.class);
42
43 private FeederDaemonConfig feederDaemonConfig;
44 private RssFeedService rssFeedService;
45 private JobService jobService;
46 private AdminService adminService;
47 private SearchCriteriaFactory searchCriteriaFactory;
48
49 /***
50 * search service to use.
51 */
52 private SearchCriteriaService searchCriteriaService;
53
54 /***
55 * the javacareersconfig-file containing the javacareers props.
56 */
57 private JavaCareersConfig javaCareersConfig;
58
59 /***
60 * Is thread running.
61 */
62 private boolean running;
63
64 /***
65 * the filepath.
66 */
67 protected String filepath;
68
69 /***
70 * the rsschannel.
71 */
72 protected RSSChannel channel;
73
74 /***
75 * Starts running the task
76 *
77 * @param run boolean
78 */
79 public void setRunning(boolean run) {
80 this.running = run;
81 }
82
83
84 /***
85 * Is the task running
86 *
87 * @return boolean task is running
88 */
89 public boolean isRunning() {
90 return running;
91 }
92
93 /***
94 * FeederDaemon feederDaemonConfig file is set through Springs IoC.
95 *
96 * @param config Sets the feederDaemonConfig object (Spring)
97 */
98 public void setFeederDaemonConfig(FeederDaemonConfig config) {
99 LOG.info("Debug: >>>>>>>>>>>>>>>>> Setting config");
100 this.feederDaemonConfig = config;
101 }
102
103 /***
104 * @return Config object containg settings
105 */
106 public FeederDaemonConfig getFeederDaemonConfig() {
107 return feederDaemonConfig;
108 }
109
110
111 /***
112 * @return Returns the rssFeedService.
113 */
114 public RssFeedService getRssFeedService() {
115 return rssFeedService;
116 }
117
118 /***
119 * Spring-injection method for RSSFeedDAO
120 *
121 * @param rssFeedService The rssFeedService to set.
122 */
123 public void setRssFeedService(RssFeedService rssFeedService) {
124 LOG.info("Debug: Setting config");
125 this.rssFeedService = rssFeedService;
126 }
127
128
129 /***
130 * Gets JobService to manage persistent jobs
131 *
132 * @return the JobService to manage persistent jobs
133 */
134
135 public JobService getJobService() {
136 return jobService;
137 }
138
139 /***
140 * Gets Admin service to manage users
141 *
142 * @return service to manage persistent users
143 */
144 public AdminService getAdminService() {
145 return adminService;
146 }
147
148 /***
149 * Sets service to manage persistent jobs
150 *
151 * @param jobService to manage persistent jobs
152 */
153 public void setJobService(JobService jobService) {
154 this.jobService = jobService;
155 }
156
157 /***
158 * @param adminService AdminService
159 */
160 public void setAdminService(AdminService adminService) {
161 this.adminService = adminService;
162 }
163
164 /***
165 * @return JavaCareersConfig
166 */
167 public JavaCareersConfig getJavaCareersConfig() {
168 return javaCareersConfig;
169 }
170
171 /***
172 * @param javaCareersConfig JavaCareersConfig
173 */
174 public void setJavaCareersConfig(JavaCareersConfig javaCareersConfig) {
175 this.javaCareersConfig = javaCareersConfig;
176 }
177
178 /***
179 * @return the searchCriteriaFactory.
180 */
181 public SearchCriteriaFactory getSearchCriteriaFactory() {
182 return searchCriteriaFactory;
183 }
184
185 /***
186 * @param searchCriteriaFactory the searchCriteriaFactort through IoC
187 */
188 public void setSearchCriteriaFactory(SearchCriteriaFactory searchCriteriaFactory) {
189 this.searchCriteriaFactory = searchCriteriaFactory;
190 }
191
192 /***
193 * @return the searchCriteriaService.
194 */
195 public SearchCriteriaService getSearchCriteriaService() {
196 return searchCriteriaService;
197 }
198
199 /***
200 * @param searchCriteriaService the searchCriteriaService.
201 */
202 public void setSearchCriteriaService(SearchCriteriaService searchCriteriaService) {
203 this.searchCriteriaService = searchCriteriaService;
204 }
205
206 /***
207 * @param config FeederDaemonConfig
208 */
209 protected void constructFeeder(FeederDaemonConfig config) {
210 LOG.info("Debug: filepath: " + filepath);
211 channel = new RSSChannel();
212 channel.setDescription(config.getChannelDescription());
213 LOG.info("Debug: description: " + config.getChannelDescription());
214 channel.setLink(config.getChannelLink());
215 channel.setTitle(config.getChannelTitle());
216 channel.setCopyright(config.getChannelCopyright());
217 channel.setManagingEditor(config.getChannelEditor());
218 channel.setWebMaster(config.getChannelWebmaster());
219 RSSImage image = new RSSImage();
220 image.setTitle(config.getChannelTitle());
221 image.setLink(config.getChannelLink());
222 image.setUrl(config.getChannelImage());
223 channel.setRSSImage(image);
224 LOG.info("Debug: Constructed");
225 }
226
227 }
228
229 /***
230 * $Log: FeederTask.java,v $
231 * Revision 1.3 2005/09/30 14:38:08 bavo_jcs
232 * Fixed URL
233 *
234 * Revision 1.2 2005/09/01 09:38:55 bavo_jcs
235 * Added logo
236 *
237 * Revision 1.1 2005/08/26 07:58:29 ge0ffrey
238 * split up the sources in service, serviceimpl and webclient
239 *
240 * Revision 1.8 2005/08/09 12:59:54 bavo_jcs
241 * Optimized imports
242 *
243 * Revision 1.7 2005/08/05 08:27:55 bme_jcs
244 * resolved checkstyle errors
245 *
246 * Revision 1.6 2005/07/20 15:07:38 bavo_jcs
247 * Feeder smart delete
248 *
249 * Revision 1.5 2005/06/17 12:01:17 schauwvliege
250 * CheckStyle/ PMD
251 *
252 * Revision 1.4 2005/06/17 11:42:46 schauwvliege
253 * CheckStyle/ PMD
254 *
255 * Revision 1.3 2005/06/14 12:05:52 schauwvliege
256 * CheckStyle and fixing tests
257 *
258 * Revision 1.2 2005/06/09 08:18:43 bejug_cc
259 * Fix initial import
260 *
261 * Revision 1.6 2005/06/07 09:46:13 bbr
262 * job source, webpath, indexing
263 *
264 * Revision 1.5 2005/06/01 15:07:11 bbr
265 * RssFeed page
266 *
267 * Revision 1.4 2005/05/30 14:14:56 bbr
268 * servletcontext enabled
269 *
270 * Revision 1.3 2005/05/26 12:26:03 bbr
271 * no message
272 *
273 * Revision 1.2 2005/05/24 15:33:26 bbr
274 * Using spring sheduling
275 *
276 * Revision 1.1 2005/05/24 11:52:39 bbr
277 * Using spring sheduling
278 *
279 * Revision 1.1 2005/05/23 17:04:57 sja
280 * Moved to org.bejug.javacareers.feeder package.
281 *
282 * Revision 1.1 2005/05/23 08:46:33 PSONG09
283 * added feeder source files to project
284 *
285 * Revision 1.4 2005/05/23 07:15:15 stephan_janssen
286 * Code cleanup.
287 *
288 * Revision 1.3 2005/05/11 14:25:23 bavo_jcs
289 * - renamed main files
290 *
291 * Revision 1.2 2005/05/11 13:16:02 bavo_jcs
292 * - debugged thread
293 *
294 * Revision 1.1 2005/05/11 11:53:25 bavo_jcs
295 * refactored
296 * - conform to conventions
297 * - some javadoc
298 * - Added FeederTask design
299 *
300 */