Skip to content

Migrate from Slf4J to JCL. #2360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.7.0-SNAPSHOT</version>
<version>2.7.0-2359-spring-jcl-SNAPSHOT</version>

<name>Spring Data JPA</name>
<description>Spring Data module for JPA repositories.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import javax.enterprise.inject.spi.ProcessBean;
import javax.persistence.EntityManager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.data.repository.cdi.CdiRepositoryBean;
import org.springframework.data.repository.cdi.CdiRepositoryExtensionSupport;

Expand All @@ -47,9 +47,9 @@
*/
public class JpaRepositoryExtension extends CdiRepositoryExtensionSupport {

private static final Logger LOGGER = LoggerFactory.getLogger(JpaRepositoryExtension.class);
private static final Log LOGGER = LogFactory.getLog(JpaRepositoryExtension.class);

private final Map<Set<Annotation>, Bean<EntityManager>> entityManagers = new HashMap<Set<Annotation>, Bean<EntityManager>>();
private final Map<Set<Annotation>, Bean<EntityManager>> entityManagers = new HashMap<>();

public JpaRepositoryExtension() {
LOGGER.info("Activating CDI extension for Spring Data JPA repositories.");
Expand All @@ -64,13 +64,14 @@ public JpaRepositoryExtension() {
*/
@SuppressWarnings("unchecked")
<X> void processBean(@Observes ProcessBean<X> processBean) {

Bean<X> bean = processBean.getBean();
for (Type type : bean.getTypes()) {
// Check if the bean is an EntityManager.
if (type instanceof Class<?> && EntityManager.class.isAssignableFrom((Class<?>) type)) {
Set<Annotation> qualifiers = new HashSet<Annotation>(bean.getQualifiers());
Set<Annotation> qualifiers = new HashSet<>(bean.getQualifiers());
if (bean.isAlternative() || !entityManagers.containsKey(qualifiers)) {
LOGGER.debug("Discovered '{}' with qualifiers {}.", EntityManager.class.getName(), qualifiers);
LOGGER.debug(String.format("Discovered '%s' with qualifiers %s.", EntityManager.class.getName(), qualifiers));
entityManagers.put(qualifiers, (Bean<EntityManager>) bean);
}
}
Expand All @@ -94,7 +95,7 @@ void afterBeanDiscovery(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanMan

// Create the bean representing the repository.
CdiRepositoryBean<?> repositoryBean = createRepositoryBean(repositoryType, qualifiers, beanManager);
LOGGER.info("Registering bean for '{}' with qualifiers {}.", repositoryType.getName(), qualifiers);
LOGGER.info(String.format("Registering bean for '%s' with qualifiers %s.", repositoryType.getName(), qualifiers));

// Register the bean to the extension and the container.
registerBean(repositoryBean);
Expand Down Expand Up @@ -122,7 +123,7 @@ private <T> CdiRepositoryBean<T> createRepositoryBean(Class<T> repositoryType, S
}

// Construct and return the repository bean.
return new JpaRepositoryBean<T>(beanManager, entityManagerBean, qualifiers, repositoryType,
return new JpaRepositoryBean<>(beanManager, entityManagerBean, qualifiers, repositoryType,
Optional.of(getCustomImplementationDetector()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import javax.persistence.EntityManagerFactory;
import javax.persistence.metamodel.Metamodel;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.FactoryBean;
Expand All @@ -44,7 +44,7 @@
public class JpaMetamodelMappingContextFactoryBean extends AbstractFactoryBean<JpaMetamodelMappingContext>
implements ApplicationContextAware {

private static final Logger LOG = LoggerFactory.getLogger(JpaMetamodelMappingContextFactoryBean.class);
private static final Log LOG = LogFactory.getLog(JpaMetamodelMappingContextFactoryBean.class);

private @Nullable ListableBeanFactory beanFactory;

Expand All @@ -71,7 +71,7 @@ public Class<?> getObjectType() {
* @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance()
*/
@Override
protected JpaMetamodelMappingContext createInstance() throws Exception {
protected JpaMetamodelMappingContext createInstance() {

if (LOG.isDebugEnabled()) {
LOG.debug("Initializing JpaMetamodelMappingContext…");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import javax.persistence.EntityManager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.projection.ProjectionFactory;
Expand All @@ -44,7 +44,7 @@
*/
public final class JpaQueryLookupStrategy {

private static final Logger LOG = LoggerFactory.getLogger(JpaQueryLookupStrategy.class);
private static final Log LOG = LogFactory.getLog(JpaQueryLookupStrategy.class);

/**
* Private constructor to prevent instantiation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
import javax.persistence.Tuple;
import javax.persistence.TypedQuery;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.data.jpa.provider.QueryExtractor;
import org.springframework.data.repository.query.Parameters;
import org.springframework.data.repository.query.QueryCreationException;
Expand All @@ -45,7 +44,7 @@ final class NamedQuery extends AbstractJpaQuery {
+ "have a JpaDialect configured at your EntityManagerFactoryBean as this affects "
+ "discovering the concrete persistence provider.";

private static final Logger LOG = LoggerFactory.getLogger(NamedQuery.class);
private static final Log LOG = LogFactory.getLog(NamedQuery.class);

private final String queryName;
private final String countQueryName;
Expand Down Expand Up @@ -89,8 +88,9 @@ private NamedQuery(JpaQueryMethod method, EntityManager em) {
}

if (parameters.hasPageableParameter()) {
LOG.warn("Finder method {} is backed by a NamedQuery" + " but contains a Pageable parameter! Sorting delivered "
+ "via this Pageable will not be applied!", method);
LOG.warn(String.format(
"Finder method %s is backed by a NamedQuery but contains a Pageable parameter! Sorting delivered via this Pageable will not be applied!",
method));
}

this.metadataCache = new QueryParameterSetter.QueryMetadataCache();
Expand All @@ -115,7 +115,7 @@ static boolean hasNamedQuery(EntityManager em, String queryName) {
lookupEm.createNamedQuery(queryName);
return true;
} catch (IllegalArgumentException e) {
LOG.debug("Did not find named query {}", queryName);
LOG.debug(String.format("Did not find named query %s", queryName));
return false;
} finally {
lookupEm.close();
Expand All @@ -134,15 +134,15 @@ public static RepositoryQuery lookupFrom(JpaQueryMethod method, EntityManager em

final String queryName = method.getNamedQueryName();

LOG.debug("Looking up named query {}", queryName);
LOG.debug(String.format("Looking up named query %s", queryName));

if (!hasNamedQuery(em, queryName)) {
return null;
}

try {
RepositoryQuery query = new NamedQuery(method, em);
LOG.debug("Found named query {}!", queryName);
LOG.debug(String.format("Found named query %s!", queryName));
return query;
} catch (IllegalArgumentException e) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import javax.persistence.TemporalType;
import javax.persistence.criteria.ParameterExpression;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
Expand Down Expand Up @@ -155,7 +155,7 @@ public void execute(Runnable block) {
}
};

private static final Logger LOG = LoggerFactory.getLogger(ErrorHandling.class);
private static final Log LOG = LogFactory.getLog(ErrorHandling.class);

abstract void execute(Runnable block);
}
Expand Down Expand Up @@ -280,7 +280,7 @@ private static Class<?> unwrapClass(Query query) {

} catch (RuntimeException e) {

LoggerFactory.getLogger(QueryMetadata.class).warn("Failed to unwrap actual class for Query proxy.", e);
LogFactory.getLog(QueryMetadata.class).warn("Failed to unwrap actual class for Query proxy.", e);

return queryType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
import javax.persistence.EntityManager;
import javax.persistence.Tuple;

import org.slf4j.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.jpa.projection.CollectionAwareProjectionFactory;
Expand Down Expand Up @@ -304,8 +305,7 @@ private static class EclipseLinkProjectionQueryCreationListener implements Query

private static final String ECLIPSELINK_PROJECTIONS = "Usage of Spring Data projections detected on persistence provider EclipseLink. Make sure the following query methods declare result columns in exactly the order the accessors are declared in the projecting interface or the order of parameters for DTOs:";

private static final Logger log = org.slf4j.LoggerFactory
.getLogger(EclipseLinkProjectionQueryCreationListener.class);
private static final Log log = LogFactory.getLog(EclipseLinkProjectionQueryCreationListener.class);

private final JpaMetamodel metamodel;

Expand Down Expand Up @@ -340,7 +340,7 @@ public void onCreation(AbstractJpaQuery query) {
this.warningLogged = true;
}

log.info(" - {}", queryMethod);
log.info(String.format(" - %s", queryMethod));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import javax.persistence.Entity;
import javax.persistence.MappedSuperclass;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.ResourceLoaderAware;
Expand Down Expand Up @@ -58,7 +58,7 @@
public class ClasspathScanningPersistenceUnitPostProcessor
implements PersistenceUnitPostProcessor, ResourceLoaderAware, EnvironmentAware {

private static final Logger LOG = LoggerFactory.getLogger(ClasspathScanningPersistenceUnitPostProcessor.class);
private static final Log LOG = LogFactory.getLog(ClasspathScanningPersistenceUnitPostProcessor.class);

private final String basePackage;

Expand Down Expand Up @@ -133,7 +133,7 @@ public void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo pui) {

for (BeanDefinition definition : provider.findCandidateComponents(basePackage)) {

LOG.debug("Registering classpath-scanned entity {} in persistence unit info!", definition.getBeanClassName());
LOG.debug(String.format("Registering classpath-scanned entity %s in persistence unit info!", definition.getBeanClassName()));

if (definition.getBeanClassName() != null) {
pui.addManagedClassName(definition.getBeanClassName());
Expand All @@ -142,7 +142,7 @@ public void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo pui) {

for (String location : scanForMappingFileLocations()) {

LOG.debug("Registering classpath-scanned entity mapping file {} in persistence unit info!", location);
LOG.debug(String.format("Registering classpath-scanned entity mapping file %s in persistence unit info!", location));

pui.addMappingFileName(location);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import javax.persistence.spi.PersistenceUnitInfo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager;
import org.springframework.orm.jpa.persistenceunit.MutablePersistenceUnitInfo;

Expand All @@ -34,7 +34,7 @@
*/
public class MergingPersistenceUnitManager extends DefaultPersistenceUnitManager {

private static final Logger LOG = LoggerFactory.getLogger(MergingPersistenceUnitManager.class);
private static final Log LOG = LogFactory.getLog(MergingPersistenceUnitManager.class);

/*
* (non-Javadoc)
Expand Down Expand Up @@ -68,21 +68,21 @@ void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo pui, PersistenceU

for (URL url : oldPui.getJarFileUrls()) {
if (!pui.getJarFileUrls().contains(url)) {
LOG.debug("Adding JAR file URL {} to persistence unit {}.", url, persistenceUnitName);
LOG.debug(String.format("Adding JAR file URL %s to persistence unit %s.", url, persistenceUnitName));
pui.addJarFileUrl(url);
}
}

for (String className : oldPui.getManagedClassNames()) {
if (!pui.getManagedClassNames().contains(className)) {
LOG.debug("Adding class {} to PersistenceUnit {}", className, persistenceUnitName);
LOG.debug(String.format("Adding class %s to PersistenceUnit %s", className, persistenceUnitName));
pui.addManagedClassName(className);
}
}

for (String mappingFileName : oldPui.getMappingFileNames()) {
if (!pui.getMappingFileNames().contains(mappingFileName)) {
LOG.debug("Adding mapping file to persistence unit {}.", mappingFileName, persistenceUnitName);
LOG.debug(String.format("Adding mapping file to persistence unit %s.", mappingFileName, persistenceUnitName));
pui.addMappingFileName(mappingFileName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
* Integration tests for Spring Data JPA CDI extension.
Expand All @@ -40,7 +40,7 @@
class CdiExtensionIntegrationTests {

private static SeContainer container;
private static Logger LOGGER = LoggerFactory.getLogger(CdiExtensionIntegrationTests.class);
private static Log LOGGER = LogFactory.getLog(CdiExtensionIntegrationTests.class);

@BeforeAll
static void setUp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package org.springframework.data.jpa.repository.sample;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.sample.User;
import org.springframework.data.jpa.repository.JpaContext;
Expand All @@ -29,7 +29,7 @@
*/
public class UserRepositoryImpl implements UserRepositoryCustom {

private static final Logger LOG = LoggerFactory.getLogger(UserRepositoryImpl.class);
private static final Log LOG = LogFactory.getLog(UserRepositoryImpl.class);

@Autowired
public UserRepositoryImpl(JpaContext context) {
Expand Down