You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by md...@apache.org on 2015/08/27 13:12:47 UTC

[20/33] syncope git commit: Cleanly handling Quartz scheduler shutdown

Cleanly handling Quartz scheduler shutdown


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/56fe1eec
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/56fe1eec
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/56fe1eec

Branch: refs/heads/SYNCOPE-156
Commit: 56fe1eeca69eb222544da59ee07fafdb15a2016b
Parents: ec6bcf2
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Fri Aug 21 16:04:02 2015 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Fri Aug 21 16:04:02 2015 +0200

----------------------------------------------------------------------
 .../java/job/SchedulerShutdown.java             | 49 ++++++++++++++++++++
 .../src/main/resources/provisioningContext.xml  |  1 +
 2 files changed, 50 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/56fe1eec/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/SchedulerShutdown.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/SchedulerShutdown.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/SchedulerShutdown.java
new file mode 100644
index 0000000..8129928
--- /dev/null
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/SchedulerShutdown.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.syncope.core.provisioning.java.job;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.scheduling.quartz.SchedulerFactoryBean;
+
+/**
+ * Clean shutdown for Quartz scheduler.
+ */
+public class SchedulerShutdown implements ApplicationContextAware, DisposableBean {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SchedulerShutdown.class);
+
+    private ApplicationContext ctx;
+
+    @Override
+    public void setApplicationContext(final ApplicationContext ctx) throws BeansException {
+        this.ctx = ctx;
+    }
+
+    @Override
+    public void destroy() throws Exception {
+        SchedulerFactoryBean scheduler = ctx.getBean(SchedulerFactoryBean.class);
+        scheduler.getScheduler().shutdown();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/56fe1eec/core/provisioning-java/src/main/resources/provisioningContext.xml
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/resources/provisioningContext.xml b/core/provisioning-java/src/main/resources/provisioningContext.xml
index 2f0f617..4d635d2 100644
--- a/core/provisioning-java/src/main/resources/provisioningContext.xml
+++ b/core/provisioning-java/src/main/resources/provisioningContext.xml
@@ -81,6 +81,7 @@ under the License.
       </props>
     </property>
   </bean>
+  <bean class="org.apache.syncope.core.provisioning.java.job.SchedulerShutdown"/>
   
   <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
     <property name="defaultEncoding" value="${smtpEncoding}"/>