Fix class tangle

pull/313/head
Phillip Webb 11 years ago
parent 042e512d3d
commit 32f3e353b4

@ -411,6 +411,10 @@ public class SpringApplication {
}
}
/**
* Setup any active profiles on the environment.
* @param environment the environment to configure
*/
protected void setupProfiles(ConfigurableEnvironment environment) {
for (String profile : this.profiles) {
environment.addActiveProfile(profile);

@ -19,7 +19,8 @@ import org.springframework.util.ClassUtils;
public class LiquibaseServiceLocatorApplicationListener implements
ApplicationListener<ApplicationStartedEvent> {
static final Log logger = LogFactory.getLog(LiquibaseServiceLocatorApplicationListener.class);
static final Log logger = LogFactory
.getLog(LiquibaseServiceLocatorApplicationListener.class);
@Override
public void onApplicationEvent(ApplicationStartedEvent event) {
@ -35,7 +36,7 @@ public class LiquibaseServiceLocatorApplicationListener implements
public void replaceServiceLocator() {
ServiceLocator.setInstance(new CustomResolverServiceLocator(
new SpringPackageScanClassResolver()));
new SpringPackageScanClassResolver(logger)));
}
}

@ -23,6 +23,7 @@ import liquibase.servicelocator.DefaultPackageScanClassResolver;
import liquibase.servicelocator.PackageScanClassResolver;
import liquibase.servicelocator.PackageScanFilter;
import org.apache.commons.logging.Log;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
@ -40,6 +41,12 @@ import org.springframework.util.ClassUtils;
*/
public class SpringPackageScanClassResolver extends DefaultPackageScanClassResolver {
private final Log logger;
public SpringPackageScanClassResolver(Log logger) {
this.logger = logger;
}
@Override
protected void find(PackageScanFilter test, String packageName, ClassLoader loader,
Set<Class<?>> classes) {
@ -74,9 +81,8 @@ public class SpringPackageScanClassResolver extends DefaultPackageScanClassResol
return ClassUtils.forName(reader.getClassMetadata().getClassName(), loader);
}
catch (Exception ex) {
if (LiquibaseServiceLocatorApplicationListener.logger.isWarnEnabled()) {
LiquibaseServiceLocatorApplicationListener.logger.warn(
"Ignoring cadidate class resource " + resource, ex);
if (this.logger.isWarnEnabled()) {
this.logger.warn("Ignoring cadidate class resource " + resource, ex);
}
return null;
}

@ -20,6 +20,7 @@ import java.util.Set;
import liquibase.logging.Logger;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
import static org.hamcrest.Matchers.greaterThan;
@ -34,7 +35,8 @@ public class SpringPackageScanClassResolverTests {
@Test
public void testScan() {
SpringPackageScanClassResolver resolver = new SpringPackageScanClassResolver();
SpringPackageScanClassResolver resolver = new SpringPackageScanClassResolver(
LogFactory.getLog(getClass()));
resolver.addClassLoader(getClass().getClassLoader());
Set<Class<?>> implementations = resolver.findImplementations(Logger.class,
"liquibase.logging.core");

Loading…
Cancel
Save