Consider abstract classes with @Lookup methods as candidate components
Issue: SPR-14550
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,6 +24,7 @@ import javax.annotation.PostConstruct;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Lookup;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@@ -42,7 +43,7 @@ import org.springframework.util.Assert;
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
@Service @Lazy @DependsOn("myNamedComponent")
|
||||
public class FooServiceImpl implements FooService {
|
||||
public abstract class FooServiceImpl implements FooService {
|
||||
|
||||
// Just to test ASM5's bytecode parsing of INVOKESPECIAL/STATIC on interfaces
|
||||
private static final Comparator<MessageBean> COMPARATOR_BY_MESSAGE = Comparator.comparing(MessageBean::getMessage);
|
||||
@@ -84,11 +85,15 @@ public class FooServiceImpl implements FooService {
|
||||
return this.fooDao.findFoo(id);
|
||||
}
|
||||
|
||||
public String lookupFoo(int id) {
|
||||
return fooDao().findFoo(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<String> asyncFoo(int id) {
|
||||
System.out.println(Thread.currentThread().getName());
|
||||
Assert.state(ServiceInvocationCounter.getThreadLocalCount() != null, "Thread-local counter not exposed");
|
||||
return new AsyncResult<>(this.fooDao.findFoo(id));
|
||||
return new AsyncResult<>(fooDao().findFoo(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,4 +101,8 @@ public class FooServiceImpl implements FooService {
|
||||
return this.initCalled;
|
||||
}
|
||||
|
||||
|
||||
@Lookup
|
||||
protected abstract FooDao fooDao();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user