Skip to content

Commit 8db770d

Browse files
committed
Migrate from Slf4J to JCL.
Closes #2359
1 parent 6cab3d7 commit 8db770d

10 files changed

+45
-45
lines changed

Diff for: src/main/java/org/springframework/data/jpa/repository/cdi/JpaRepositoryExtension.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
import javax.enterprise.inject.spi.ProcessBean;
3333
import javax.persistence.EntityManager;
3434

35-
import org.slf4j.Logger;
36-
import org.slf4j.LoggerFactory;
35+
import org.apache.commons.logging.Log;
36+
import org.apache.commons.logging.LogFactory;
3737
import org.springframework.data.repository.cdi.CdiRepositoryBean;
3838
import org.springframework.data.repository.cdi.CdiRepositoryExtensionSupport;
3939

@@ -47,7 +47,7 @@
4747
*/
4848
public class JpaRepositoryExtension extends CdiRepositoryExtensionSupport {
4949

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

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

@@ -70,7 +70,7 @@ <X> void processBean(@Observes ProcessBean<X> processBean) {
7070
if (type instanceof Class<?> && EntityManager.class.isAssignableFrom((Class<?>) type)) {
7171
Set<Annotation> qualifiers = new HashSet<Annotation>(bean.getQualifiers());
7272
if (bean.isAlternative() || !entityManagers.containsKey(qualifiers)) {
73-
LOGGER.debug("Discovered '{}' with qualifiers {}.", EntityManager.class.getName(), qualifiers);
73+
LOGGER.debug(String.format("Discovered '%s' with qualifiers %s.", EntityManager.class.getName(), qualifiers));
7474
entityManagers.put(qualifiers, (Bean<EntityManager>) bean);
7575
}
7676
}
@@ -94,7 +94,7 @@ void afterBeanDiscovery(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanMan
9494

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

9999
// Register the bean to the extension and the container.
100100
registerBean(repositoryBean);

Diff for: src/main/java/org/springframework/data/jpa/repository/config/JpaMetamodelMappingContextFactoryBean.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import javax.persistence.EntityManagerFactory;
2222
import javax.persistence.metamodel.Metamodel;
2323

24-
import org.slf4j.Logger;
25-
import org.slf4j.LoggerFactory;
24+
import org.apache.commons.logging.Log;
25+
import org.apache.commons.logging.LogFactory;
2626
import org.springframework.beans.BeansException;
2727
import org.springframework.beans.factory.BeanFactoryUtils;
2828
import org.springframework.beans.factory.FactoryBean;
@@ -44,7 +44,7 @@
4444
public class JpaMetamodelMappingContextFactoryBean extends AbstractFactoryBean<JpaMetamodelMappingContext>
4545
implements ApplicationContextAware {
4646

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

4949
private @Nullable ListableBeanFactory beanFactory;
5050

Diff for: src/main/java/org/springframework/data/jpa/repository/query/JpaQueryLookupStrategy.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
import javax.persistence.EntityManager;
2121

22-
import org.slf4j.Logger;
23-
import org.slf4j.LoggerFactory;
22+
import org.apache.commons.logging.Log;
23+
import org.apache.commons.logging.LogFactory;
2424

2525
import org.springframework.data.jpa.repository.Query;
2626
import org.springframework.data.projection.ProjectionFactory;
@@ -44,7 +44,7 @@
4444
*/
4545
public final class JpaQueryLookupStrategy {
4646

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

4949
/**
5050
* Private constructor to prevent instantiation.

Diff for: src/main/java/org/springframework/data/jpa/repository/query/NamedQuery.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
import javax.persistence.Tuple;
2121
import javax.persistence.TypedQuery;
2222

23-
import org.slf4j.Logger;
24-
import org.slf4j.LoggerFactory;
25-
23+
import org.apache.commons.logging.Log;
24+
import org.apache.commons.logging.LogFactory;
2625
import org.springframework.data.jpa.provider.QueryExtractor;
2726
import org.springframework.data.repository.query.Parameters;
2827
import org.springframework.data.repository.query.QueryCreationException;
@@ -45,7 +44,7 @@ final class NamedQuery extends AbstractJpaQuery {
4544
+ "have a JpaDialect configured at your EntityManagerFactoryBean as this affects "
4645
+ "discovering the concrete persistence provider.";
4746

48-
private static final Logger LOG = LoggerFactory.getLogger(NamedQuery.class);
47+
private static final Log LOG = LogFactory.getLog(NamedQuery.class);
4948

5049
private final String queryName;
5150
private final String countQueryName;
@@ -89,8 +88,9 @@ private NamedQuery(JpaQueryMethod method, EntityManager em) {
8988
}
9089

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

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

135135
final String queryName = method.getNamedQueryName();
136136

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

139139
if (!hasNamedQuery(em, queryName)) {
140140
return null;
141141
}
142142

143143
try {
144144
RepositoryQuery query = new NamedQuery(method, em);
145-
LOG.debug("Found named query {}!", queryName);
145+
LOG.debug(String.format("Found named query %s!", queryName));
146146
return query;
147147
} catch (IllegalArgumentException e) {
148148
return null;

Diff for: src/main/java/org/springframework/data/jpa/repository/query/QueryParameterSetter.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import javax.persistence.TemporalType;
3131
import javax.persistence.criteria.ParameterExpression;
3232

33-
import org.slf4j.Logger;
34-
import org.slf4j.LoggerFactory;
33+
import org.apache.commons.logging.Log;
34+
import org.apache.commons.logging.LogFactory;
3535

3636
import org.springframework.lang.Nullable;
3737
import org.springframework.util.Assert;
@@ -155,7 +155,7 @@ public void execute(Runnable block) {
155155
}
156156
};
157157

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

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

281281
} catch (RuntimeException e) {
282282

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

285285
return queryType;
286286
}

Diff for: src/main/java/org/springframework/data/jpa/repository/support/JpaRepositoryFactory.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
import javax.persistence.EntityManager;
2626
import javax.persistence.Tuple;
2727

28-
import org.slf4j.Logger;
28+
import org.apache.commons.logging.Log;
29+
import org.apache.commons.logging.LogFactory;
2930
import org.springframework.beans.factory.BeanFactory;
3031
import org.springframework.dao.InvalidDataAccessApiUsageException;
3132
import org.springframework.data.jpa.projection.CollectionAwareProjectionFactory;
@@ -304,8 +305,7 @@ private static class EclipseLinkProjectionQueryCreationListener implements Query
304305

305306
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:";
306307

307-
private static final Logger log = org.slf4j.LoggerFactory
308-
.getLogger(EclipseLinkProjectionQueryCreationListener.class);
308+
private static final Log log = LogFactory.getLog(EclipseLinkProjectionQueryCreationListener.class);
309309

310310
private final JpaMetamodel metamodel;
311311

@@ -340,7 +340,7 @@ public void onCreation(AbstractJpaQuery query) {
340340
this.warningLogged = true;
341341
}
342342

343-
log.info(" - {}", queryMethod);
343+
log.info(String.format(" - %s", queryMethod));
344344
}
345345
}
346346
}

Diff for: src/main/java/org/springframework/data/jpa/support/ClasspathScanningPersistenceUnitPostProcessor.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import javax.persistence.Entity;
2525
import javax.persistence.MappedSuperclass;
2626

27-
import org.slf4j.Logger;
28-
import org.slf4j.LoggerFactory;
27+
import org.apache.commons.logging.Log;
28+
import org.apache.commons.logging.LogFactory;
2929
import org.springframework.beans.factory.config.BeanDefinition;
3030
import org.springframework.context.EnvironmentAware;
3131
import org.springframework.context.ResourceLoaderAware;
@@ -58,7 +58,7 @@
5858
public class ClasspathScanningPersistenceUnitPostProcessor
5959
implements PersistenceUnitPostProcessor, ResourceLoaderAware, EnvironmentAware {
6060

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

6363
private final String basePackage;
6464

@@ -133,7 +133,7 @@ public void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo pui) {
133133

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

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

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

143143
for (String location : scanForMappingFileLocations()) {
144144

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

147147
pui.addMappingFileName(location);
148148
}

Diff for: src/main/java/org/springframework/data/jpa/support/MergingPersistenceUnitManager.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
import javax.persistence.spi.PersistenceUnitInfo;
2222

23-
import org.slf4j.Logger;
24-
import org.slf4j.LoggerFactory;
23+
import org.apache.commons.logging.Log;
24+
import org.apache.commons.logging.LogFactory;
2525
import org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager;
2626
import org.springframework.orm.jpa.persistenceunit.MutablePersistenceUnitInfo;
2727

@@ -34,7 +34,7 @@
3434
*/
3535
public class MergingPersistenceUnitManager extends DefaultPersistenceUnitManager {
3636

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

3939
/*
4040
* (non-Javadoc)
@@ -68,21 +68,21 @@ void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo pui, PersistenceU
6868

6969
for (URL url : oldPui.getJarFileUrls()) {
7070
if (!pui.getJarFileUrls().contains(url)) {
71-
LOG.debug("Adding JAR file URL {} to persistence unit {}.", url, persistenceUnitName);
71+
LOG.debug(String.format("Adding JAR file URL %s to persistence unit %s.", url, persistenceUnitName));
7272
pui.addJarFileUrl(url);
7373
}
7474
}
7575

7676
for (String className : oldPui.getManagedClassNames()) {
7777
if (!pui.getManagedClassNames().contains(className)) {
78-
LOG.debug("Adding class {} to PersistenceUnit {}", className, persistenceUnitName);
78+
LOG.debug(String.format("Adding class %s to PersistenceUnit %s", className, persistenceUnitName));
7979
pui.addManagedClassName(className);
8080
}
8181
}
8282

8383
for (String mappingFileName : oldPui.getMappingFileNames()) {
8484
if (!pui.getMappingFileNames().contains(mappingFileName)) {
85-
LOG.debug("Adding mapping file to persistence unit {}.", mappingFileName, persistenceUnitName);
85+
LOG.debug(String.format("Adding mapping file to persistence unit %s.", mappingFileName, persistenceUnitName));
8686
pui.addMappingFileName(mappingFileName);
8787
}
8888
}

Diff for: src/test/java/org/springframework/data/jpa/repository/cdi/CdiExtensionIntegrationTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
import org.junit.jupiter.api.BeforeAll;
2828
import org.junit.jupiter.api.Test;
29-
import org.slf4j.Logger;
30-
import org.slf4j.LoggerFactory;
29+
import org.apache.commons.logging.Log;
30+
import org.apache.commons.logging.LogFactory;
3131

3232
/**
3333
* Integration tests for Spring Data JPA CDI extension.
@@ -40,7 +40,7 @@
4040
class CdiExtensionIntegrationTests {
4141

4242
private static SeContainer container;
43-
private static Logger LOGGER = LoggerFactory.getLogger(CdiExtensionIntegrationTests.class);
43+
private static Log LOGGER = LogFactory.getLog(CdiExtensionIntegrationTests.class);
4444

4545
@BeforeAll
4646
static void setUp() {

Diff for: src/test/java/org/springframework/data/jpa/repository/sample/UserRepositoryImpl.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
package org.springframework.data.jpa.repository.sample;
1717

18-
import org.slf4j.Logger;
19-
import org.slf4j.LoggerFactory;
18+
import org.apache.commons.logging.Log;
19+
import org.apache.commons.logging.LogFactory;
2020
import org.springframework.beans.factory.annotation.Autowired;
2121
import org.springframework.data.jpa.domain.sample.User;
2222
import org.springframework.data.jpa.repository.JpaContext;
@@ -29,7 +29,7 @@
2929
*/
3030
public class UserRepositoryImpl implements UserRepositoryCustom {
3131

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

3434
@Autowired
3535
public UserRepositoryImpl(JpaContext context) {

0 commit comments

Comments
 (0)