Skip to content

Commit

Permalink
optimizate Runner
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardShan committed Nov 27, 2018
1 parent b541892 commit 9d2d054
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assembly/src/main/assembly/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


<assembly>
<id>dist</id>
<id>dist-beta.4</id>
<formats>
<format>zip</format>
</formats>
Expand Down
2 changes: 1 addition & 1 deletion assembly/src/main/assembly/release.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


<assembly>
<id>release</id>
<id>release-beta.4</id>
<formats>
<format>zip</format>
</formats>
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/edp/davinci/dto/userDto/SendMail.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@NotNull(message = "email address cannot be null")
public class SendMail {

@NotBlank(message = "email address cannote be empty")
@NotBlank(message = "email address cannot be empty")
@Pattern(regexp = Constants.REG_EMAIL_FORMAT, message = "invalid email format")
private String email;
}
81 changes: 81 additions & 0 deletions server/src/main/java/edp/davinci/runner/CheckConfigRunner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* <<
* Davinci
* ==
* Copyright (C) 2016 - 2018 EDP
* ==
* 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 edp.davinci.runner;

import com.alibaba.druid.util.StringUtils;
import edp.core.utils.CustomDataSourceUtils;
import edp.davinci.service.CronJobService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;


@Order(0)
@Component
@Slf4j
public class CheckConfigRunner implements ApplicationRunner {

@Value("${spring.mail.host:}")
private String mailHost;

@Value("${spring.mail.port}")
private String mailPort;

@Value("${spring.mail.username}")
private String mailUserName;


@Value("${spring.mail.nickname}")
private String nickName;


@Autowired
private ApplicationContext applicationContext;


@Override
public void run(ApplicationArguments args) {
if (StringUtils.isEmpty(mailHost)) {
log.error("************** Configuration error: mail host connot be empty! **************");
SpringApplication.exit(applicationContext);
}

if (StringUtils.isEmpty(mailPort)) {
log.error("************** Configuration error: mail port connot be empty! **************");
SpringApplication.exit(applicationContext);
}

if (StringUtils.isEmpty(mailUserName)) {
log.error("************** Configuration error: mail username connot be empty! **************");
SpringApplication.exit(applicationContext);
}

if (StringUtils.isEmpty(mailUserName)) {
log.error("************** Configuration error: mail nickname connot be empty! **************");
SpringApplication.exit(applicationContext);
}
}
}
2 changes: 2 additions & 0 deletions server/src/main/java/edp/davinci/runner/CronJobRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Order(2)
@Component
@Slf4j
public class CronJobRunner implements ApplicationRunner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Order(1)
@Component
@Slf4j
public class CustomDataSourceRunner implements ApplicationRunner {
Expand Down

0 comments on commit 9d2d054

Please sign in to comment.