I have a MyTask class which implements Runnable and there can be many such objects instantiated at any given moment. There are certain properties t
first, beans declared with @Component and picked up by spring component scan will become a spring-managed singleton by default.
I have no idea how you use MyTask, but it is overkilled to use AspectJ in your situation, and it does not make much sense to declare MyTask as a spring-managed bean. another way of doing this will be:
define MyTask as a plain java class and add a constructor to initialize the dependency blah
autowire blah in where you use MyTask, and instantiate a MyTask object every time you want to execute a task as follow:
//autowire the dependency of MyTask in another spring bean with default singleton scope
@Autowired private SomeSpecialSpringConfiguredConnectionClass blah
//create task and wire the blah yourself
executor.submit(new MyTask(blah))