DATACMNS-248 - Moved to Slf4j API for logging.
This commit is contained in:
@@ -13,10 +13,13 @@
|
||||
<name>Spring Data Commons Core</name>
|
||||
|
||||
<properties>
|
||||
<querydsl.version>2.8.0</querydsl.version>
|
||||
<cdi.version>1.0</cdi.version>
|
||||
<webbeans.version>1.1.3</webbeans.version>
|
||||
<jackson.version>1.9.7</jackson.version>
|
||||
<logback.version>1.0.6</logback.version>
|
||||
<mockito.version>1.8.5</mockito.version>
|
||||
<querydsl.version>2.8.0</querydsl.version>
|
||||
<slf4j.version>1.7.1</slf4j.version>
|
||||
<webbeans.version>1.1.3</webbeans.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -26,6 +29,12 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
@@ -85,7 +94,7 @@
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>1.8.5</version>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -169,6 +178,28 @@
|
||||
<version>1.8.6</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Logging -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
*/
|
||||
package org.springframework.data.crossstore;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.transaction.support.TransactionSynchronization;
|
||||
|
||||
public class ChangeSetBackedTransactionSynchronization implements TransactionSynchronization {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private final ChangeSetPersister<Object> changeSetPersister;
|
||||
private final ChangeSetBacked entity;
|
||||
|
||||
@@ -29,8 +29,8 @@ import javax.enterprise.inject.spi.Bean;
|
||||
import javax.enterprise.inject.spi.BeanManager;
|
||||
import javax.enterprise.inject.spi.InjectionPoint;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -41,7 +41,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public abstract class CdiRepositoryBean<T> implements Bean<T> {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(CdiRepositoryBean.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CdiRepositoryBean.class);
|
||||
|
||||
private final Set<Annotation> qualifiers;
|
||||
private final Class<T> repositoryType;
|
||||
@@ -76,8 +76,8 @@ public abstract class CdiRepositoryBean<T> implements Bean<T> {
|
||||
interfaces.add(repositoryType);
|
||||
interfaces.addAll(Arrays.asList(repositoryType.getInterfaces()));
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(String.format("Declaring types '%s' for repository '%s'.", interfaces.toString(),
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(String.format("Declaring types '%s' for repository '%s'.", interfaces.toString(),
|
||||
repositoryType.getName()));
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ public abstract class CdiRepositoryBean<T> implements Bean<T> {
|
||||
*/
|
||||
public final T create(CreationalContext<T> creationalContext) {
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(String.format("Creating bean instance for repository type '%s'.", repositoryType.getName()));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(String.format("Creating bean instance for repository type '%s'.", repositoryType.getName()));
|
||||
}
|
||||
return create(creationalContext, repositoryType);
|
||||
}
|
||||
@@ -115,8 +115,8 @@ public abstract class CdiRepositoryBean<T> implements Bean<T> {
|
||||
*/
|
||||
public void destroy(T instance, CreationalContext<T> creationalContext) {
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(String.format("Destroying bean instance %s for repository type '%s'.", instance.toString(),
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(String.format("Destroying bean instance %s for repository type '%s'.", instance.toString(),
|
||||
repositoryType.getName()));
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ import javax.enterprise.inject.spi.ProcessAnnotatedType;
|
||||
import javax.enterprise.util.AnnotationLiteral;
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.repository.NoRepositoryBean;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.RepositoryDefinition;
|
||||
@@ -45,7 +45,7 @@ import org.springframework.data.repository.RepositoryDefinition;
|
||||
*/
|
||||
public abstract class CdiRepositoryExtensionSupport implements Extension {
|
||||
|
||||
private static final Log LOGGER = LogFactory.getLog(CdiRepositoryExtensionSupport.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CdiRepositoryExtensionSupport.class);
|
||||
|
||||
private final Map<Class<?>, Set<Annotation>> repositoryTypes = new HashMap<Class<?>, Set<Annotation>>();
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
@@ -40,7 +40,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class RepositoryBeanDefinitionBuilder {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(RepositoryBeanDefinitionBuilder.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RepositoryBeanDefinitionBuilder.class);
|
||||
|
||||
private final RepositoryConfiguration<?> configuration;
|
||||
private final RepositoryConfigurationExtension extension;
|
||||
@@ -118,8 +118,8 @@ public class RepositoryBeanDefinitionBuilder {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Registering custom repository implementation: " + configuration.getImplementationBeanName() + " "
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Registering custom repository implementation: " + configuration.getImplementationBeanName() + " "
|
||||
+ beanDefinition.getBeanClassName());
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ package org.springframework.data.repository.config;
|
||||
|
||||
import static org.springframework.beans.factory.support.BeanDefinitionReaderUtils.*;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
||||
import org.springframework.beans.factory.parsing.ReaderContext;
|
||||
@@ -39,7 +39,7 @@ import org.w3c.dom.Element;
|
||||
*/
|
||||
public class RepositoryBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(RepositoryBeanDefinitionParser.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RepositoryBeanDefinitionParser.class);
|
||||
|
||||
private final RepositoryConfigurationExtension extension;
|
||||
|
||||
@@ -109,8 +109,8 @@ public class RepositoryBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
String beanName = generator.generateBeanName(beanDefinition, parser.getRegistry());
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Registering repository: " + beanName + " - Interface: " + configuration.getRepositoryInterface()
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Registering repository: " + beanName + " - Interface: " + configuration.getRepositoryInterface()
|
||||
+ " - Factory: " + extension.getRepositoryFactoryClassName());
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.data.repository.core.support;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.PropertyValue;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
@@ -40,7 +40,7 @@ import org.springframework.util.ClassUtils;
|
||||
class RepositoryInterfaceAwareBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter implements
|
||||
BeanFactoryAware {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(RepositoryInterfaceAwareBeanPostProcessor.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RepositoryInterfaceAwareBeanPostProcessor.class);
|
||||
private static final Class<?> REPOSITORY_TYPE = RepositoryFactoryBeanSupport.class;
|
||||
|
||||
private final Map<String, Class<?>> cache = new ConcurrentHashMap<String, Class<?>>();
|
||||
@@ -109,7 +109,7 @@ class RepositoryInterfaceAwareBeanPostProcessor extends InstantiationAwareBeanPo
|
||||
try {
|
||||
return ClassUtils.resolveClassName(className, context.getBeanClassLoader());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
LOG.warn(String.format("Couldn't load class %s referenced as repository interface in bean %s!", className,
|
||||
LOGGER.warn(String.format("Couldn't load class %s referenced as repository interface in bean %s!", className,
|
||||
beanName));
|
||||
return Void.class;
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.core.BridgeMethodResolver;
|
||||
@@ -34,6 +34,7 @@ import org.springframework.dao.support.PersistenceExceptionTranslationIntercepto
|
||||
import org.springframework.transaction.annotation.Ejb3TransactionAnnotationParser;
|
||||
import org.springframework.transaction.annotation.SpringTransactionAnnotationParser;
|
||||
import org.springframework.transaction.annotation.TransactionAnnotationParser;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.DefaultTransactionAttribute;
|
||||
import org.springframework.transaction.interceptor.TransactionAttribute;
|
||||
import org.springframework.transaction.interceptor.TransactionAttributeSource;
|
||||
@@ -98,7 +99,6 @@ class TransactionalRepositoryProxyPostProcessor implements RepositoryProxyPostPr
|
||||
/**
|
||||
* Implementation of the {@link org.springframework.transaction.interceptor.TransactionAttributeSource} interface for
|
||||
* working with transaction metadata in JDK 1.5+ annotation format.
|
||||
*
|
||||
* <p>
|
||||
* This class reads Spring's JDK 1.5+ {@link Transactional} annotation and exposes corresponding transaction
|
||||
* attributes to Spring's transaction infrastructure. Also supports EJB3's {@link javax.ejb.TransactionAttribute}
|
||||
@@ -216,13 +216,11 @@ class TransactionalRepositoryProxyPostProcessor implements RepositoryProxyPostPr
|
||||
/**
|
||||
* Abstract implementation of {@link TransactionAttributeSource} that caches attributes for methods and implements a
|
||||
* fallback policy: 1. specific target method; 2. target class; 3. declaring method; 4. declaring class/interface.
|
||||
*
|
||||
* <p>
|
||||
* Defaults to using the target class's transaction attribute if none is associated with the target method. Any
|
||||
* transaction attribute associated with the target method completely overrides a class transaction attribute. If none
|
||||
* found on the target class, the interface that the invoked method has been called through (in case of a JDK proxy)
|
||||
* will be checked.
|
||||
*
|
||||
* <p>
|
||||
* This implementation caches attributes by method after they are first used. If it is ever desirable to allow dynamic
|
||||
* changing of transaction attributes (which is very unlikely), caching could be made configurable. Caching is
|
||||
@@ -246,7 +244,7 @@ class TransactionalRepositoryProxyPostProcessor implements RepositoryProxyPostPr
|
||||
* As this base class is not marked Serializable, the logger will be recreated after serialization - provided that
|
||||
* the concrete subclass is Serializable.
|
||||
*/
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
/**
|
||||
* Cache of TransactionAttributes, keyed by DefaultCacheKey (Method + target Class).
|
||||
@@ -409,8 +407,8 @@ class TransactionalRepositoryProxyPostProcessor implements RepositoryProxyPostPr
|
||||
return false;
|
||||
}
|
||||
DefaultCacheKey otherKey = (DefaultCacheKey) other;
|
||||
return (this.method.equals(otherKey.method) && ObjectUtils.nullSafeEquals(this.targetClass,
|
||||
otherKey.targetClass));
|
||||
return this.method.equals(otherKey.method)
|
||||
&& ObjectUtils.nullSafeEquals(this.targetClass, otherKey.targetClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,8 +20,8 @@ import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -39,7 +39,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ResourceReaderRepositoryPopulator implements RepositoryPopulator, ApplicationEventPublisherAware {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(ResourceReaderRepositoryPopulator.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceReaderRepositoryPopulator.class);
|
||||
|
||||
private final ResourcePatternResolver resolver;
|
||||
private final ResourceReader reader;
|
||||
@@ -110,7 +110,7 @@ public class ResourceReaderRepositoryPopulator implements RepositoryPopulator, A
|
||||
|
||||
for (Resource resource : resources) {
|
||||
|
||||
LOG.info(String.format("Reading resource: %s", resource));
|
||||
LOGGER.info(String.format("Reading resource: %s", resource));
|
||||
|
||||
Object result = readObjectFrom(resource);
|
||||
|
||||
@@ -119,7 +119,7 @@ public class ResourceReaderRepositoryPopulator implements RepositoryPopulator, A
|
||||
if (element != null) {
|
||||
persist(element, repositories);
|
||||
} else {
|
||||
LOG.info("Skipping null element found in unmarshal result!");
|
||||
LOGGER.info("Skipping null element found in unmarshal result!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -155,7 +155,7 @@ public class ResourceReaderRepositoryPopulator implements RepositoryPopulator, A
|
||||
private void persist(Object object, Repositories repositories) {
|
||||
|
||||
CrudRepository<Object, Serializable> repository = repositories.getRepositoryFor(object.getClass());
|
||||
LOG.debug(String.format("Persisting %s using repository %s", object, repository));
|
||||
LOGGER.debug(String.format("Persisting %s using repository %s", object, repository));
|
||||
repository.save(object);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
|
||||
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d %-5p %c{1} - %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<category name="org.springframework.data.mapping">
|
||||
<level value="DEBUG"/>
|
||||
</category>
|
||||
<category name="org.springframework">
|
||||
<level value="WARN"/>
|
||||
</category>
|
||||
|
||||
<root>
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
</log4j:configuration>
|
||||
16
spring-data-commons-core/src/test/resources/logback.xml
Normal file
16
spring-data-commons-core/src/test/resources/logback.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d %5p %40.40c:%4L - %m%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="org.springframework.data.mapping" level="debug" />
|
||||
|
||||
<root level="warn">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
</beans>
|
||||
@@ -12,8 +12,6 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<junit.version>4.10</junit.version>
|
||||
<log4j.version>1.2.16</log4j.version>
|
||||
<org.mockito.version>1.8.5</org.mockito.version>
|
||||
<org.springframework.version.30>3.0.7.RELEASE</org.springframework.version.30>
|
||||
<org.springframework.version>3.1.2.RELEASE</org.springframework.version>
|
||||
<org.springframework.hateoas.version>0.3.0.RELEASE</org.springframework.hateoas.version>
|
||||
@@ -90,13 +88,6 @@
|
||||
</licenses>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
|
||||
Reference in New Issue
Block a user