This is an automated email from the ASF dual-hosted git repository. guangning pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pulsar-manager.git
The following commit(s) were added to refs/heads/master by this push: new d15a0f1 Passing LoggerFactory to @Slf4j lombok notation (#356) d15a0f1 is described below commit d15a0f1e45a3fe9821df51361584dce87e104948 Author: Matteo Minardi <minardi.mat...@hotmail.it> AuthorDate: Sat Dec 5 02:49:35 2020 +0100 Passing LoggerFactory to @Slf4j lombok notation (#356) ### Motivation Remove boilerplate code for the logger setup. ### Modifications Passed the remaining explicit declarations of LoggerFactory to @Slf4j annotation --- .../org/apache/pulsar/manager/PulsarApplicationListener.java | 6 ++---- .../apache/pulsar/manager/controller/EnvironmentsController.java | 6 ++---- .../org/apache/pulsar/manager/interceptor/WebAppConfigurer.java | 7 +++---- .../pulsar/manager/service/impl/BrokerStatsServiceImpl.java | 6 ++---- .../apache/pulsar/manager/service/impl/BrokersServiceImpl.java | 6 ++---- .../apache/pulsar/manager/service/impl/ClustersServiceImpl.java | 6 ++---- .../pulsar/manager/service/impl/NamespacesServiceImpl.java | 6 ++---- .../pulsar/manager/service/impl/PulsarAdminServiceImpl.java | 6 ++---- .../apache/pulsar/manager/service/impl/TenantsServiceImpl.java | 6 ++---- .../apache/pulsar/manager/service/impl/TopicsServiceImpl.java | 6 ++---- src/main/java/org/apache/pulsar/manager/utils/HttpUtil.java | 6 ++---- .../java/org/apache/pulsar/manager/zuul/EnvironmentForward.java | 6 ++---- .../org/apache/pulsar/manager/profiles/HerdDBTestProfile.java | 9 ++++----- .../org/apache/pulsar/manager/profiles/SqliteDBTestProfile.java | 9 ++++----- 14 files changed, 33 insertions(+), 58 deletions(-) diff --git a/src/main/java/org/apache/pulsar/manager/PulsarApplicationListener.java b/src/main/java/org/apache/pulsar/manager/PulsarApplicationListener.java index 4cc1c40..82ee60e 100644 --- a/src/main/java/org/apache/pulsar/manager/PulsarApplicationListener.java +++ b/src/main/java/org/apache/pulsar/manager/PulsarApplicationListener.java @@ -14,12 +14,11 @@ package org.apache.pulsar.manager; import com.github.pagehelper.Page; +import lombok.extern.slf4j.Slf4j; import org.apache.pulsar.client.admin.PulsarAdminException; import org.apache.pulsar.manager.entity.EnvironmentEntity; import org.apache.pulsar.manager.entity.EnvironmentsRepository; import org.apache.pulsar.manager.service.PulsarAdminService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationListener; @@ -32,10 +31,9 @@ import java.util.Optional; * PulsarApplicationListener do something after the spring framework initialization is complete. */ @Component +@Slf4j public class PulsarApplicationListener implements ApplicationListener<ContextRefreshedEvent> { - private static final Logger log = LoggerFactory.getLogger(PulsarApplicationListener.class); - private final EnvironmentsRepository environmentsRepository; private final PulsarAdminService pulsarAdminService; diff --git a/src/main/java/org/apache/pulsar/manager/controller/EnvironmentsController.java b/src/main/java/org/apache/pulsar/manager/controller/EnvironmentsController.java index 0b050a0..f49e915 100644 --- a/src/main/java/org/apache/pulsar/manager/controller/EnvironmentsController.java +++ b/src/main/java/org/apache/pulsar/manager/controller/EnvironmentsController.java @@ -15,6 +15,7 @@ package org.apache.pulsar.manager.controller; import com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; import org.apache.pulsar.client.admin.PulsarAdminException; import org.apache.pulsar.manager.entity.EnvironmentEntity; import org.apache.pulsar.manager.entity.EnvironmentsRepository; @@ -36,8 +37,6 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import org.apache.pulsar.manager.utils.ResourceType; import org.hibernate.validator.constraints.Range; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; @@ -61,10 +60,9 @@ import java.util.Optional; @Api(description = "Support change environments") @Validated @RestController +@Slf4j public class EnvironmentsController { - private static final Logger log = LoggerFactory.getLogger(EnvironmentsController.class); - private final EnvironmentsRepository environmentsRepository; private final EnvironmentCacheService environmentCacheService; diff --git a/src/main/java/org/apache/pulsar/manager/interceptor/WebAppConfigurer.java b/src/main/java/org/apache/pulsar/manager/interceptor/WebAppConfigurer.java index a70a2a5..9637f43 100644 --- a/src/main/java/org/apache/pulsar/manager/interceptor/WebAppConfigurer.java +++ b/src/main/java/org/apache/pulsar/manager/interceptor/WebAppConfigurer.java @@ -14,8 +14,8 @@ package org.apache.pulsar.manager.interceptor; import java.io.File; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + +import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; @@ -23,10 +23,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import javax.annotation.Resource; @Configuration +@Slf4j public class WebAppConfigurer implements WebMvcConfigurer { - private static final Logger log = LoggerFactory.getLogger(WebAppConfigurer.class); - @Resource private AdminHandlerInterceptor adminHandlerInterceptor; diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/BrokerStatsServiceImpl.java b/src/main/java/org/apache/pulsar/manager/service/impl/BrokerStatsServiceImpl.java index cc8c1a9..9c7e647 100644 --- a/src/main/java/org/apache/pulsar/manager/service/impl/BrokerStatsServiceImpl.java +++ b/src/main/java/org/apache/pulsar/manager/service/impl/BrokerStatsServiceImpl.java @@ -20,6 +20,7 @@ import com.google.gson.reflect.TypeToken; import java.text.DecimalFormat; +import lombok.extern.slf4j.Slf4j; import org.apache.pulsar.client.admin.Brokers; import org.apache.pulsar.client.admin.PulsarAdminException; import org.apache.pulsar.manager.controller.exception.PulsarAdminOperationException; @@ -45,8 +46,6 @@ import java.util.List; import java.util.Map; import org.apache.commons.lang3.tuple.Pair; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; @@ -59,10 +58,9 @@ import org.springframework.stereotype.Service; @Configuration @Component @EnableScheduling +@Slf4j public class BrokerStatsServiceImpl implements BrokerStatsService { - private static final Logger log = LoggerFactory.getLogger(BrokerStatsServiceImpl.class); - @Value("${backend.directRequestHost}") private String directRequestHost; diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/BrokersServiceImpl.java b/src/main/java/org/apache/pulsar/manager/service/impl/BrokersServiceImpl.java index e139695..e632e85 100644 --- a/src/main/java/org/apache/pulsar/manager/service/impl/BrokersServiceImpl.java +++ b/src/main/java/org/apache/pulsar/manager/service/impl/BrokersServiceImpl.java @@ -14,13 +14,12 @@ package org.apache.pulsar.manager.service.impl; import com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; import org.apache.pulsar.client.admin.PulsarAdminException; import org.apache.pulsar.common.policies.data.FailureDomain; import org.apache.pulsar.manager.controller.exception.PulsarAdminOperationException; import org.apache.pulsar.manager.service.BrokersService; import org.apache.pulsar.manager.service.PulsarAdminService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -30,10 +29,9 @@ import java.util.List; import java.util.Map; @Service +@Slf4j public class BrokersServiceImpl implements BrokersService { - private static final Logger log = LoggerFactory.getLogger(BrokersServiceImpl.class); - @Value("${backend.directRequestBroker}") private boolean directRequestBroker; diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/ClustersServiceImpl.java b/src/main/java/org/apache/pulsar/manager/service/impl/ClustersServiceImpl.java index 636cc77..d4589fb 100644 --- a/src/main/java/org/apache/pulsar/manager/service/impl/ClustersServiceImpl.java +++ b/src/main/java/org/apache/pulsar/manager/service/impl/ClustersServiceImpl.java @@ -15,6 +15,7 @@ package org.apache.pulsar.manager.service.impl; import com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; import org.apache.pulsar.client.admin.PulsarAdminException; import org.apache.pulsar.manager.controller.exception.PulsarAdminOperationException; import org.apache.pulsar.manager.service.BrokersService; @@ -23,8 +24,6 @@ import org.apache.pulsar.manager.service.PulsarAdminService; import java.util.function.Function; import org.apache.pulsar.common.policies.data.ClusterData; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -34,10 +33,9 @@ import java.util.List; import java.util.Map; @Service +@Slf4j public class ClustersServiceImpl implements ClustersService { - private static final Logger log = LoggerFactory.getLogger(ClustersServiceImpl.class); - @Value("${backend.directRequestBroker}") private boolean directRequestBroker; diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/NamespacesServiceImpl.java b/src/main/java/org/apache/pulsar/manager/service/impl/NamespacesServiceImpl.java index f9d6e8c..54dbfb2 100644 --- a/src/main/java/org/apache/pulsar/manager/service/impl/NamespacesServiceImpl.java +++ b/src/main/java/org/apache/pulsar/manager/service/impl/NamespacesServiceImpl.java @@ -16,6 +16,7 @@ package org.apache.pulsar.manager.service.impl; import com.github.pagehelper.Page; import com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; import org.apache.pulsar.client.admin.PulsarAdminException; import org.apache.pulsar.manager.controller.exception.PulsarAdminOperationException; import org.apache.pulsar.manager.entity.TopicStatsEntity; @@ -24,8 +25,6 @@ import org.apache.pulsar.manager.service.BrokerStatsService; import org.apache.pulsar.manager.service.NamespacesService; import org.apache.pulsar.manager.service.PulsarAdminService; import org.apache.pulsar.manager.service.TopicsService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -34,13 +33,12 @@ import javax.servlet.http.HttpServletRequest; import java.util.*; @Service +@Slf4j public class NamespacesServiceImpl implements NamespacesService { @Value("${backend.directRequestBroker}") private boolean directRequestBroker; - private static final Logger log = LoggerFactory.getLogger(NamespacesServiceImpl.class); - private final TopicsStatsRepository topicsStatsRepository; private final TopicsService topicsService; private final HttpServletRequest request; diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/PulsarAdminServiceImpl.java b/src/main/java/org/apache/pulsar/manager/service/impl/PulsarAdminServiceImpl.java index 1b79c1f..3d89d75 100644 --- a/src/main/java/org/apache/pulsar/manager/service/impl/PulsarAdminServiceImpl.java +++ b/src/main/java/org/apache/pulsar/manager/service/impl/PulsarAdminServiceImpl.java @@ -20,6 +20,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.pulsar.client.admin.BrokerStats; import org.apache.pulsar.client.admin.Brokers; @@ -35,16 +36,13 @@ import org.apache.pulsar.client.api.AuthenticationFactory; import org.apache.pulsar.client.api.PulsarClientException; import org.apache.pulsar.manager.controller.exception.PulsarAdminOperationException; import org.apache.pulsar.manager.service.PulsarAdminService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @Service +@Slf4j public class PulsarAdminServiceImpl implements PulsarAdminService { - private static final Logger log = LoggerFactory.getLogger(PulsarAdminServiceImpl.class); - @Value("${backend.broker.pulsarAdmin.authPlugin:}") private String authPlugin; diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/TenantsServiceImpl.java b/src/main/java/org/apache/pulsar/manager/service/impl/TenantsServiceImpl.java index ee2bdd6..66cdcf5 100644 --- a/src/main/java/org/apache/pulsar/manager/service/impl/TenantsServiceImpl.java +++ b/src/main/java/org/apache/pulsar/manager/service/impl/TenantsServiceImpl.java @@ -17,6 +17,7 @@ import com.github.pagehelper.Page; import com.google.common.collect.Maps; import com.google.common.collect.Sets; +import lombok.extern.slf4j.Slf4j; import org.apache.pulsar.client.admin.PulsarAdminException; import org.apache.pulsar.manager.controller.exception.PulsarAdminOperationException; import org.apache.pulsar.manager.entity.TopicStatsEntity; @@ -25,8 +26,6 @@ import org.apache.pulsar.manager.service.BrokerStatsService; import org.apache.pulsar.manager.service.PulsarAdminService; import org.apache.pulsar.manager.service.TenantsService; import org.apache.pulsar.common.policies.data.TenantInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -38,10 +37,9 @@ import java.util.Map; import java.util.Optional; @Service +@Slf4j public class TenantsServiceImpl implements TenantsService { - private static final Logger log = LoggerFactory.getLogger(TenantsServiceImpl.class); - @Value("${backend.directRequestBroker}") private boolean directRequestBroker; diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/TopicsServiceImpl.java b/src/main/java/org/apache/pulsar/manager/service/impl/TopicsServiceImpl.java index 6013b21..472657a 100644 --- a/src/main/java/org/apache/pulsar/manager/service/impl/TopicsServiceImpl.java +++ b/src/main/java/org/apache/pulsar/manager/service/impl/TopicsServiceImpl.java @@ -16,6 +16,7 @@ package org.apache.pulsar.manager.service.impl; import com.github.pagehelper.Page; import com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; import org.apache.pulsar.client.admin.PulsarAdmin; import org.apache.pulsar.client.admin.PulsarAdminBuilder; import org.apache.pulsar.client.admin.PulsarAdminException; @@ -33,8 +34,6 @@ import org.apache.pulsar.manager.entity.TopicStatsEntity.TopicStatsSummary; import org.apache.pulsar.manager.entity.TopicsStatsRepository; import org.apache.pulsar.manager.service.PulsarAdminService; import org.apache.pulsar.manager.service.TopicsService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -42,10 +41,9 @@ import org.springframework.stereotype.Service; import java.util.*; @Service +@Slf4j public class TopicsServiceImpl implements TopicsService { - private static final Logger log = LoggerFactory.getLogger(TopicsServiceImpl.class); - public static final String PARTITIONED_TOPIC_SUFFIX = "-partition-"; @Value("${backend.directRequestBroker}") diff --git a/src/main/java/org/apache/pulsar/manager/utils/HttpUtil.java b/src/main/java/org/apache/pulsar/manager/utils/HttpUtil.java index 1350ae8..c45662c 100644 --- a/src/main/java/org/apache/pulsar/manager/utils/HttpUtil.java +++ b/src/main/java/org/apache/pulsar/manager/utils/HttpUtil.java @@ -13,6 +13,7 @@ */ package org.apache.pulsar.manager.utils; +import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpStatus; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; @@ -31,8 +32,6 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; @@ -49,6 +48,7 @@ import java.util.Map; * http client class, to get info from pulsar broker */ @Component +@Slf4j public class HttpUtil { private static boolean tlsEnabled; @@ -59,8 +59,6 @@ public class HttpUtil { private static boolean tlsHostnameVerifier; - private static final Logger log = LoggerFactory.getLogger(HttpUtil.class); - private static CloseableHttpClient httpClient; private static int CONNECTION_TIMEOUT = 28 * 1000; diff --git a/src/main/java/org/apache/pulsar/manager/zuul/EnvironmentForward.java b/src/main/java/org/apache/pulsar/manager/zuul/EnvironmentForward.java index da0d8cc..79e67e6 100644 --- a/src/main/java/org/apache/pulsar/manager/zuul/EnvironmentForward.java +++ b/src/main/java/org/apache/pulsar/manager/zuul/EnvironmentForward.java @@ -21,13 +21,12 @@ import java.net.URL; import java.util.Map; import javax.servlet.http.HttpServletRequest; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.pulsar.manager.service.EnvironmentCacheService; import org.apache.pulsar.manager.service.PulsarAdminService; import org.apache.pulsar.manager.service.PulsarEvent; import org.apache.pulsar.manager.service.RolesService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants; import org.springframework.stereotype.Component; @@ -39,10 +38,9 @@ import static org.springframework.cloud.netflix.zuul.filters.support.FilterConst * Handle http redirect and forward. */ @Component +@Slf4j public class EnvironmentForward extends ZuulFilter { - private static final Logger log = LoggerFactory.getLogger(EnvironmentForward.class); - private final EnvironmentCacheService environmentCacheService; private final PulsarEvent pulsarEvent; diff --git a/src/test/java/org/apache/pulsar/manager/profiles/HerdDBTestProfile.java b/src/test/java/org/apache/pulsar/manager/profiles/HerdDBTestProfile.java index cb90ddc..1ab170f 100644 --- a/src/test/java/org/apache/pulsar/manager/profiles/HerdDBTestProfile.java +++ b/src/test/java/org/apache/pulsar/manager/profiles/HerdDBTestProfile.java @@ -15,8 +15,8 @@ package org.apache.pulsar.manager.profiles; import java.io.IOException; import javax.sql.DataSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + +import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; @@ -25,16 +25,15 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration @EnableTransactionManagement +@Slf4j public class HerdDBTestProfile { - private static final Logger logger = LoggerFactory.getLogger(HerdDBTestProfile.class); - @Bean @Profile("test") public DataSource dataSource() throws IOException { // in memory String jdbcUrl = "jdbc:herddb:local"; - logger.info("Created a temp HerdDB db for testing : {}", jdbcUrl); + log.info("Created a temp HerdDB db for testing : {}", jdbcUrl); DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(herddb.jdbc.Driver.class.getName()); diff --git a/src/test/java/org/apache/pulsar/manager/profiles/SqliteDBTestProfile.java b/src/test/java/org/apache/pulsar/manager/profiles/SqliteDBTestProfile.java index 56676bc..b1327d3 100644 --- a/src/test/java/org/apache/pulsar/manager/profiles/SqliteDBTestProfile.java +++ b/src/test/java/org/apache/pulsar/manager/profiles/SqliteDBTestProfile.java @@ -17,8 +17,8 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import javax.sql.DataSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + +import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; @@ -27,17 +27,16 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration @EnableTransactionManagement +@Slf4j public class SqliteDBTestProfile { - private static final Logger logger = LoggerFactory.getLogger(SqliteDBTestProfile.class); - @Bean @Profile("test") public DataSource dataSource() throws IOException { Path tempFile = Files.createTempFile("test-pulsar-manager-db", "sqlite"); tempFile.toFile().deleteOnExit(); String sqliteDb = "jdbc:sqlite:" + tempFile.toFile().getAbsolutePath(); - logger.info("Created a temp sqlite db for testing : {}", sqliteDb); + log.info("Created a temp sqlite db for testing : {}", sqliteDb); DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName("org.sqlite.JDBC");