2 * ============LICENSE_START========================================================================
\r
3 * ONAP : tr-069-adapter
\r
4 * =================================================================================================
\r
5 * Copyright (C) 2020 CommScope Inc Intellectual Property.
\r
6 * =================================================================================================
\r
7 * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,
\r
8 * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
\r
9 * may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
\r
14 * either express or implied. See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
16 * ===============LICENSE_END=======================================================================
\r
19 package org.commscope.tr069adapter.common.scheduler.impl;
\r
21 import java.io.BufferedInputStream;
\r
22 import java.io.FileInputStream;
\r
23 import java.io.IOException;
\r
24 import java.io.InputStream;
\r
25 import java.util.Properties;
\r
27 import org.apache.commons.logging.Log;
\r
28 import org.apache.commons.logging.LogFactory;
\r
29 import org.quartz.Scheduler;
\r
30 import org.quartz.SchedulerException;
\r
31 import org.quartz.impl.StdSchedulerFactory;
\r
32 import org.springframework.stereotype.Component;
\r
35 public class QuartzSchedulerProducer {
\r
37 private static final Log logger = LogFactory.getLog(QuartzSchedulerProducer.class);
\r
39 public Scheduler getStdScheduler() {
\r
40 StdSchedulerFactory schedulerFactory = new StdSchedulerFactory();
\r
42 schedulerFactory.initialize("config/quartz.properties");
\r
43 Properties props = new Properties();
\r
44 props.setProperty("org.quartz.scheduler.instanceName",
\r
45 props.getProperty("org.quartz.scheduler.instanceName") + "_standby");
\r
46 return schedulerFactory.getScheduler();
\r
47 } catch (SchedulerException e) {
\r
48 logger.error("SchedulerException : {}" + e.getMessage());
\r
54 public Properties initialize(String filename) throws SchedulerException {
\r
56 InputStream is = null;
\r
57 Properties props = new Properties();
\r
59 is = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
\r
63 is = new BufferedInputStream(is);
\r
65 is = new BufferedInputStream(new FileInputStream(filename));
\r
68 } catch (IOException ioe) {
\r
69 throw new SchedulerException("Properties file: '" + filename + "' could not be read.", ioe);
\r
74 } catch (IOException ignore) {
\r
75 logger.error("while initialize : {}" + ignore.getMessage());
\r