diff --git a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/web/SessionListenerAdapter.java b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/web/HttpSessionListenerAdapter.java similarity index 93% rename from maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/web/SessionListenerAdapter.java rename to maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/web/HttpSessionListenerAdapter.java index 577c1157..cc84d539 100644 --- a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/web/SessionListenerAdapter.java +++ b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/web/HttpSessionListenerAdapter.java @@ -30,10 +30,10 @@ import org.slf4j.LoggerFactory; import org.springframework.security.core.Authentication; @WebListener -public class SessionListenerAdapter implements HttpSessionListener { - private static final Logger _logger = LoggerFactory.getLogger(SessionListenerAdapter.class); +public class HttpSessionListenerAdapter implements HttpSessionListener { + private static final Logger _logger = LoggerFactory.getLogger(HttpSessionListenerAdapter.class); - public SessionListenerAdapter() { + public HttpSessionListenerAdapter() { super(); _logger.debug("SessionListenerAdapter inited . "); } diff --git a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/autoconfigure/AuthenticationAutoConfiguration.java b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/autoconfigure/AuthenticationAutoConfiguration.java index eabf414c..7685e275 100644 --- a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/autoconfigure/AuthenticationAutoConfiguration.java +++ b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/autoconfigure/AuthenticationAutoConfiguration.java @@ -30,7 +30,7 @@ import org.maxkey.authn.provider.TrustedAuthenticationProvider; import org.maxkey.authn.realm.AbstractAuthenticationRealm; import org.maxkey.authn.session.SessionManager; import org.maxkey.authn.session.SessionManagerFactory; -import org.maxkey.authn.web.SessionListenerAdapter; +import org.maxkey.authn.web.HttpSessionListenerAdapter; import org.maxkey.configuration.ApplicationConfig; import org.maxkey.configuration.AuthJwkConfig; import org.maxkey.constants.ConstsPersistence; @@ -195,9 +195,9 @@ public class AuthenticationAutoConfiguration implements InitializingBean { return sessionManager; } - @Bean(name = "sessionListenerAdapter") - public SessionListenerAdapter sessionListenerAdapter() { - return new SessionListenerAdapter(); + @Bean(name = "httpSessionListenerAdapter") + public HttpSessionListenerAdapter httpSessionListenerAdapter() { + return new HttpSessionListenerAdapter(); } @Override diff --git a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/MaxKeyMgtApplication.java b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/MaxKeyMgtApplication.java index 9d65e8ef..f0da7408 100644 --- a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/MaxKeyMgtApplication.java +++ b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/MaxKeyMgtApplication.java @@ -62,9 +62,8 @@ public class MaxKeyMgtApplication extends SpringBootServletInitializer { _logger.info("Start MaxKeyMgtApplication ..."); ConfigurableApplicationContext applicationContext = - SpringApplication.run(MaxKeyMgtApplication.class, args); - InitializeContext initWebContext = - new InitializeContext(applicationContext); + SpringApplication.run(MaxKeyMgtApplication.class, args); + InitializeContext initWebContext = new InitializeContext(applicationContext); try { initWebContext.init(null); diff --git a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/MaxKeyMgtJobs.java b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/MaxKeyMgtJobs.java deleted file mode 100644 index 9533cdeb..00000000 --- a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/MaxKeyMgtJobs.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright [2022] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed 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.maxkey; - -import org.maxkey.authn.session.SessionManager; -import org.maxkey.jobs.AccountsStrategyJob; -import org.maxkey.jobs.DynamicGroupsJob; -import org.maxkey.jobs.SessionListenerAdapter; -import org.maxkey.persistence.service.AccountsService; -import org.maxkey.persistence.service.GroupsService; -import org.quartz.CronScheduleBuilder; -import org.quartz.CronTrigger; -import org.quartz.Job; -import org.quartz.JobBuilder; -import org.quartz.JobDataMap; -import org.quartz.JobDetail; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.quartz.TriggerBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.quartz.SchedulerFactoryBean; - -@Configuration -public class MaxKeyMgtJobs implements InitializingBean { - private static final Logger _logger = LoggerFactory.getLogger(MaxKeyMgtJobs.class); - - @Bean(name = "schedulerSessionListenerAdapter") - public String sessionListenerAdapter( - SchedulerFactoryBean schedulerFactoryBean, - SessionManager sessionManager) throws SchedulerException { - - JobDataMap jobDataMap = new JobDataMap(); - jobDataMap.put("service", sessionManager); - addJobScheduler( - SessionListenerAdapter.class, - schedulerFactoryBean, - jobDataMap, - "0 0/10 * * * ?",//10 minutes - "SessionListenerAdapter" - ); - - return "schedulerSessionListenerAdapter"; - } - - @Bean(name = "schedulerDynamicGroupsJobs") - public String dynamicGroupsJobs( - SchedulerFactoryBean schedulerFactoryBean, - GroupsService groupsService, - @Value("${maxkey.job.cron.schedule}") String cronSchedule - ) throws SchedulerException { - JobDataMap jobDataMap = new JobDataMap(); - jobDataMap.put("service", groupsService); - - addJobScheduler( - DynamicGroupsJob.class, - schedulerFactoryBean, - jobDataMap, - cronSchedule, - "DynamicGroups" - ); - - return "schedulerDynamicGroupsJobs"; - } - - @Bean(name = "schedulerAccountsStrategyJobs") - public String accountsStrategyJobs( - SchedulerFactoryBean schedulerFactoryBean, - AccountsService accountsService, - @Value("${maxkey.job.cron.schedule}") String cronSchedule - ) throws SchedulerException { - JobDataMap jobDataMap = new JobDataMap(); - jobDataMap.put("service", accountsService); - addJobScheduler( - AccountsStrategyJob.class, - schedulerFactoryBean, - jobDataMap, - cronSchedule, - "AccountsStrategy" - ); - - return "schedulerAccountsStrategyJobs"; - } - - private void addJobScheduler( Class jobClass, - SchedulerFactoryBean schedulerFactoryBean , - JobDataMap jobDataMap, - String cronSchedule, - String identity - ) throws SchedulerException { - _logger.debug("Cron {} , Job schedule {} ", cronSchedule , identity ); - Scheduler scheduler = schedulerFactoryBean.getScheduler(); - - JobDetail jobDetail = - JobBuilder.newJob(jobClass) - .withIdentity(identity + "Job", identity + "Group") - .build(); - - - CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cronSchedule); - - CronTrigger cronTrigger = - TriggerBuilder.newTrigger() - .withIdentity("trigger" + identity, identity + "TriggerGroup") - .usingJobData(jobDataMap) - .withSchedule(scheduleBuilder) - .build(); - - scheduler.scheduleJob(jobDetail,cronTrigger); - } - - @Override - public void afterPropertiesSet() throws Exception { - - } - -} diff --git a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/MaxKeyMgtListenerConfig.java b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/MaxKeyMgtListenerConfig.java new file mode 100644 index 00000000..9333969c --- /dev/null +++ b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/MaxKeyMgtListenerConfig.java @@ -0,0 +1,96 @@ +/* + * Copyright [2022] [MaxKey of copyright http://www.maxkey.top] + * + * Licensed 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.maxkey; + +import org.maxkey.authn.session.SessionManager; +import org.maxkey.listener.AccountsStrategyListenerAdapter; +import org.maxkey.listener.DynamicGroupsListenerAdapter; +import org.maxkey.listener.ListenerAdapter; +import org.maxkey.listener.ListenerParameter; +import org.maxkey.listener.SessionListenerAdapter; +import org.maxkey.persistence.service.AccountsService; +import org.maxkey.persistence.service.GroupsService; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class MaxKeyMgtListenerConfig implements InitializingBean { + private static final Logger _logger = LoggerFactory.getLogger(MaxKeyMgtListenerConfig.class); + + @Bean + public String sessionListenerAdapter( + Scheduler scheduler, + SessionManager sessionManager) throws SchedulerException { + ListenerAdapter.addListener( + SessionListenerAdapter.class, + scheduler, + new ListenerParameter().add("sessionManager",sessionManager).build(), + "0 0/10 * * * ?",//10 minutes + SessionListenerAdapter.class.getSimpleName() + ); + _logger.debug("Session ListenerAdapter inited ."); + return "sessionListenerAdapter"; + } + + @Bean + public String dynamicGroupsListenerAdapter( + Scheduler scheduler, + GroupsService groupsService, + @Value("${maxkey.job.cron.schedule}") String cronSchedule + ) throws SchedulerException { + + ListenerAdapter.addListener( + DynamicGroupsListenerAdapter.class, + scheduler, + new ListenerParameter().add("groupsService",groupsService).build(), + cronSchedule, + DynamicGroupsListenerAdapter.class.getSimpleName() + ); + _logger.debug("DynamicGroups ListenerAdapter inited ."); + return "dynamicGroupsListenerAdapter"; + } + + @Bean + public String accountsStrategyListenerAdapter( + Scheduler scheduler, + AccountsService accountsService, + @Value("${maxkey.job.cron.schedule}") String cronSchedule + ) throws SchedulerException { + ListenerAdapter.addListener( + AccountsStrategyListenerAdapter.class, + scheduler, + new ListenerParameter().add("accountsService",accountsService).build(), + cronSchedule, + AccountsStrategyListenerAdapter.class.getSimpleName() + ); + _logger.debug("AccountsStrategy ListenerAdapter inited ."); + return "accountsStrategyListenerAdapter"; + } + + @Override + public void afterPropertiesSet() throws Exception { + + } + +} diff --git a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/AbstractScheduleJob.java b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/AbstractScheduleJob.java deleted file mode 100644 index 52fb4733..00000000 --- a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/AbstractScheduleJob.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.maxkey.jobs; - -import org.quartz.JobExecutionContext; - -public class AbstractScheduleJob { - - public final static class JOBSTATUS{ - public static int STOP = 0; - public static int RUNNING = 1; - public static int ERROR = 2; - public static int FINISHED = 3; - } - - protected int jobStatus = JOBSTATUS.STOP; - - - void init(JobExecutionContext context){}; - -} diff --git a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/AccountsStrategyJob.java b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/AccountsStrategyListenerAdapter.java similarity index 82% rename from maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/AccountsStrategyJob.java rename to maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/AccountsStrategyListenerAdapter.java index f76dbd83..34d016ad 100644 --- a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/AccountsStrategyJob.java +++ b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/AccountsStrategyListenerAdapter.java @@ -15,23 +15,24 @@ */ -package org.maxkey.jobs; +package org.maxkey.listener; import java.io.Serializable; + import org.maxkey.persistence.service.AccountsService; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class AccountsStrategyJob extends AbstractScheduleJob implements Job , Serializable { +public class AccountsStrategyListenerAdapter extends ListenerAdapter implements Job , Serializable { /** * */ private static final long serialVersionUID = 167999890940939820L; - final static Logger _logger = LoggerFactory.getLogger(AccountsStrategyJob.class); + final static Logger _logger = LoggerFactory.getLogger(AccountsStrategyListenerAdapter.class); private static AccountsService accountsService = null; @@ -41,14 +42,14 @@ public class AccountsStrategyJob extends AbstractScheduleJob implements Job , S init(context); - _logger.debug("Accounts Strategy Job running ... " ); + _logger.debug("running ... " ); jobStatus = JOBSTATUS.RUNNING; try { if(accountsService != null) { accountsService.refreshAllByStrategy(); Thread.sleep(10 * 1000);//10 minutes } - _logger.debug("Accounts Strategy Job finished " ); + _logger.debug("finished " ); jobStatus = JOBSTATUS.FINISHED; }catch(Exception e) { jobStatus = JOBSTATUS.ERROR; @@ -58,9 +59,9 @@ public class AccountsStrategyJob extends AbstractScheduleJob implements Job , S @Override void init(JobExecutionContext context){ + super.init(context); if(accountsService == null) { - accountsService = - (AccountsService) context.getMergedJobDataMap().get("service"); + accountsService = getParameter("accountsService",AccountsService.class); } } diff --git a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/DynamicGroupsJob.java b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/DynamicGroupsListenerAdapter.java similarity index 75% rename from maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/DynamicGroupsJob.java rename to maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/DynamicGroupsListenerAdapter.java index c2e7579b..c022fa81 100644 --- a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/DynamicGroupsJob.java +++ b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/DynamicGroupsListenerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] + * Copyright [2022] [MaxKey of copyright http://www.maxkey.top] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,23 +15,21 @@ */ -package org.maxkey.jobs; +package org.maxkey.listener; import java.io.Serializable; + import org.maxkey.persistence.service.GroupsService; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class DynamicGroupsJob extends AbstractScheduleJob implements Job , Serializable { - /** - * - */ +public class DynamicGroupsListenerAdapter extends ListenerAdapter implements Job , Serializable { + final static Logger _logger = LoggerFactory.getLogger(DynamicGroupsListenerAdapter.class); + private static final long serialVersionUID = 8831626240807856084L; - final static Logger _logger = LoggerFactory.getLogger(DynamicGroupsJob.class); - private static GroupsService groupsService = null; @Override @@ -40,14 +38,14 @@ public class DynamicGroupsJob extends AbstractScheduleJob implements Job , Seri init(context); - _logger.debug("DynamicGroups Job running ... " ); + _logger.debug("running ... " ); jobStatus = JOBSTATUS.RUNNING; try { if(groupsService != null) { groupsService.refreshAllDynamicGroups(); Thread.sleep(10 * 1000);//10 minutes } - _logger.debug("DynamicGroups Job finished " ); + _logger.debug("finished " ); jobStatus = JOBSTATUS.FINISHED; }catch(Exception e) { jobStatus = JOBSTATUS.ERROR; @@ -57,9 +55,9 @@ public class DynamicGroupsJob extends AbstractScheduleJob implements Job , Seri @Override void init(JobExecutionContext context){ + super.init(context); if(groupsService == null) { - groupsService = - (GroupsService) context.getMergedJobDataMap().get("service"); + groupsService = getParameter("groupsService",GroupsService.class); } } diff --git a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/DynamicRolesJob.java b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/DynamicRolesListenerAdapter.java similarity index 86% rename from maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/DynamicRolesJob.java rename to maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/DynamicRolesListenerAdapter.java index f9a7a0e3..742214b9 100644 --- a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/DynamicRolesJob.java +++ b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/DynamicRolesListenerAdapter.java @@ -15,8 +15,8 @@ */ -package org.maxkey.jobs; +package org.maxkey.listener; -public class DynamicRolesJob extends AbstractScheduleJob { +public class DynamicRolesListenerAdapter extends ListenerAdapter { } diff --git a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/ListenerAdapter.java b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/ListenerAdapter.java new file mode 100644 index 00000000..b0abe990 --- /dev/null +++ b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/ListenerAdapter.java @@ -0,0 +1,80 @@ +/* + * Copyright [2022] [MaxKey of copyright http://www.maxkey.top] + * + * Licensed 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.maxkey.listener; + +import org.quartz.CronScheduleBuilder; +import org.quartz.CronTrigger; +import org.quartz.Job; +import org.quartz.JobBuilder; +import org.quartz.JobDataMap; +import org.quartz.JobDetail; +import org.quartz.JobExecutionContext; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.TriggerBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ListenerAdapter { + private static final Logger _logger = LoggerFactory.getLogger(ListenerAdapter.class); + + JobExecutionContext context; + + public final static class JOBSTATUS{ + public static int STOP = 0; + public static int RUNNING = 1; + public static int ERROR = 2; + public static int FINISHED = 3; + } + + protected int jobStatus = JOBSTATUS.STOP; + + + void init(JobExecutionContext context){ + this.context = context; + }; + + @SuppressWarnings("unchecked") + public T getParameter(String name, Class requiredType) { + return (T) context.getMergedJobDataMap().get(name); + }; + + public static void addListener( + Class jobClass, + Scheduler scheduler , + JobDataMap jobDataMap, + String cronSchedule, + String identity + ) throws SchedulerException { + _logger.debug("Cron {} , Job schedule {} ", cronSchedule , identity ); + + JobDetail jobDetail = + JobBuilder.newJob(jobClass) + .withIdentity(identity, identity + "Group") + .build(); + + CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cronSchedule); + + CronTrigger cronTrigger = + TriggerBuilder.newTrigger() + .withIdentity("trigger" + identity, identity + "TriggerGroup") + .usingJobData(jobDataMap) + .withSchedule(scheduleBuilder) + .build(); + + scheduler.scheduleJob(jobDetail,cronTrigger); + } +} diff --git a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/ListenerParameter.java b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/ListenerParameter.java new file mode 100644 index 00000000..397230ac --- /dev/null +++ b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/ListenerParameter.java @@ -0,0 +1,20 @@ +package org.maxkey.listener; + +import org.quartz.JobDataMap; + +public class ListenerParameter { + JobDataMap parameters ; + + public ListenerParameter() { + parameters = new JobDataMap(); + } + + public ListenerParameter add(String key , Object value) { + parameters.put(key, value); + return this; + } + + public JobDataMap build() { + return this.parameters; + } +} diff --git a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/SessionListenerAdapter.java b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/SessionListenerAdapter.java similarity index 85% rename from maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/SessionListenerAdapter.java rename to maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/SessionListenerAdapter.java index ba6e5849..ee3d0d06 100644 --- a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/SessionListenerAdapter.java +++ b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/listener/SessionListenerAdapter.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.maxkey.jobs; +package org.maxkey.listener; import java.io.Serializable; @@ -25,7 +25,7 @@ import org.quartz.JobExecutionException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SessionListenerAdapter extends AbstractScheduleJob implements Job , Serializable { +public class SessionListenerAdapter extends ListenerAdapter implements Job , Serializable { final static Logger _logger = LoggerFactory.getLogger(SessionListenerAdapter.class); private static final long serialVersionUID = 4782358765969474833L; @@ -37,7 +37,7 @@ public class SessionListenerAdapter extends AbstractScheduleJob implements Job if(jobStatus == JOBSTATUS.RUNNING) {return;} init(context); - _logger.debug("SessionListener Job is running ... " ); + _logger.debug("running ... " ); jobStatus = JOBSTATUS.RUNNING; try { if(sessionManager != null) { @@ -50,7 +50,7 @@ public class SessionListenerAdapter extends AbstractScheduleJob implements Job } } } - _logger.debug("SessionListener Job finished " ); + _logger.debug("finished " ); jobStatus = JOBSTATUS.FINISHED; }catch(Exception e) { jobStatus = JOBSTATUS.ERROR; @@ -61,9 +61,9 @@ public class SessionListenerAdapter extends AbstractScheduleJob implements Job @Override void init(JobExecutionContext context){ + super.init(context); if(sessionManager == null) { - sessionManager = - (SessionManager) context.getMergedJobDataMap().get("service"); + sessionManager = getParameter("sessionManager",SessionManager.class); } } } diff --git a/maxkey-webs/maxkey-web-mgt/src/main/resources/META-INF/spring.factories b/maxkey-webs/maxkey-web-mgt/src/main/resources/META-INF/spring.factories index c83eb142..dc8fdd99 100644 --- a/maxkey-webs/maxkey-web-mgt/src/main/resources/META-INF/spring.factories +++ b/maxkey-webs/maxkey-web-mgt/src/main/resources/META-INF/spring.factories @@ -10,5 +10,5 @@ org.maxkey.synchronizer.autoconfigure.SynchronizerAutoConfiguration,\ org.maxkey.autoconfigure.SwaggerConfig,\ org.maxkey.Oauth20ClientAutoConfiguration,\ org.maxkey.MaxKeyMgtConfig,\ -org.maxkey.MaxKeyMgtJobs,\ -org.maxkey.MaxKeyMgtMvcConfig +org.maxkey.MaxKeyMgtMvcConfig,\ +org.maxkey.MaxKeyMgtListenerConfig