1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

format code with maven plugins

This commit is contained in:
fangjian0423
2019-09-26 17:15:41 +08:00
parent ed6942d9df
commit 2435167e1e
529 changed files with 6304 additions and 5164 deletions

View File

@@ -1,11 +1,11 @@
/*
* Copyright (C) 2018 the original author or authors.
* Copyright 2013-2018 the original author or authors.
*
* 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
* https://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,
@@ -21,6 +21,7 @@ import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
import com.alibaba.cloud.sidecar.SidecarAutoConfiguration;
import com.alibaba.cloud.sidecar.SidecarDiscoveryClient;
import com.alibaba.cloud.sidecar.SidecarProperties;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -31,18 +32,23 @@ import org.springframework.context.annotation.Configuration;
* @author www.itmuch.com
*/
@Configuration
@AutoConfigureBefore({NacosDiscoveryClientAutoConfiguration.class, SidecarAutoConfiguration.class})
@AutoConfigureBefore({ NacosDiscoveryClientAutoConfiguration.class,
SidecarAutoConfiguration.class })
@ConditionalOnClass(NacosDiscoveryProperties.class)
public class SidecarNacosAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public SidecarNacosDiscoveryProperties sidecarNacosDiscoveryProperties(SidecarProperties sidecarProperties) {
return new SidecarNacosDiscoveryProperties(sidecarProperties);
}
@Bean
@ConditionalOnMissingBean
public SidecarDiscoveryClient sidecarDiscoveryClient(SidecarNacosDiscoveryProperties sidecarNacosDiscoveryProperties) {
return new SidecarNacosDiscoveryClient(sidecarNacosDiscoveryProperties);
}
@Bean
@ConditionalOnMissingBean
public SidecarNacosDiscoveryProperties sidecarNacosDiscoveryProperties(
SidecarProperties sidecarProperties) {
return new SidecarNacosDiscoveryProperties(sidecarProperties);
}
@Bean
@ConditionalOnMissingBean
public SidecarDiscoveryClient sidecarDiscoveryClient(
SidecarNacosDiscoveryProperties sidecarNacosDiscoveryProperties) {
return new SidecarNacosDiscoveryClient(sidecarNacosDiscoveryProperties);
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright (C) 2018 the original author or authors.
* Copyright 2013-2018 the original author or authors.
*
* 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
* https://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,
@@ -18,35 +18,44 @@ package com.alibaba.cloud.sidecar.nacos;
import com.alibaba.cloud.sidecar.SidecarDiscoveryClient;
import com.alibaba.nacos.api.exception.NacosException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author www.itmuch.com
*/
@Slf4j
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SidecarNacosDiscoveryClient implements SidecarDiscoveryClient {
private final SidecarNacosDiscoveryProperties sidecarNacosDiscoveryProperties;
@Override
public void registerInstance(String applicationName, String ip, Integer port) {
try {
this.sidecarNacosDiscoveryProperties.namingServiceInstance()
.registerInstance(applicationName, ip, port);
} catch (NacosException e) {
log.warn("nacos exception happens", e);
}
}
private static final Logger log = LoggerFactory
.getLogger(SidecarNacosDiscoveryClient.class);
private final SidecarNacosDiscoveryProperties sidecarNacosDiscoveryProperties;
public SidecarNacosDiscoveryClient(
SidecarNacosDiscoveryProperties sidecarNacosDiscoveryProperties) {
this.sidecarNacosDiscoveryProperties = sidecarNacosDiscoveryProperties;
}
@Override
public void registerInstance(String applicationName, String ip, Integer port) {
try {
this.sidecarNacosDiscoveryProperties.namingServiceInstance()
.registerInstance(applicationName, ip, port);
}
catch (NacosException e) {
log.warn("nacos exception happens", e);
}
}
@Override
public void deregisterInstance(String applicationName, String ip, Integer port) {
try {
this.sidecarNacosDiscoveryProperties.namingServiceInstance()
.deregisterInstance(applicationName, ip, port);
}
catch (NacosException e) {
log.warn("nacos exception happens", e);
}
}
@Override
public void deregisterInstance(String applicationName, String ip, Integer port) {
try {
this.sidecarNacosDiscoveryProperties.namingServiceInstance()
.deregisterInstance(applicationName, ip, port);
} catch (NacosException e) {
log.warn("nacos exception happens", e);
}
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright (C) 2018 the original author or authors.
* Copyright 2013-2018 the original author or authors.
*
* 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
* https://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,
@@ -16,31 +16,34 @@
package com.alibaba.cloud.sidecar.nacos;
import java.net.SocketException;
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
import com.alibaba.cloud.sidecar.SidecarProperties;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import java.net.SocketException;
/**
* @author itmuch.com
*/
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SidecarNacosDiscoveryProperties extends NacosDiscoveryProperties {
private final SidecarProperties sidecarProperties;
@Override
public void init() throws SocketException {
super.init();
private final SidecarProperties sidecarProperties;
String ip = sidecarProperties.getIp();
if (StringUtils.isNotBlank(ip)) {
this.setIp(ip);
}
public SidecarNacosDiscoveryProperties(SidecarProperties sidecarProperties) {
this.sidecarProperties = sidecarProperties;
}
@Override
public void init() throws SocketException {
super.init();
String ip = sidecarProperties.getIp();
if (StringUtils.isNotBlank(ip)) {
this.setIp(ip);
}
Integer port = sidecarProperties.getPort();
this.setPort(port);
}
Integer port = sidecarProperties.getPort();
this.setPort(port);
}
}