Код: Выделить всё
@Target({ElementType.METHOD, ElementType.TYPE, ElementType.FIELD})
@Retention(RUNTIME)
public @interface MyCustomAnnotation {
}
Код: Выделить всё
@MyCustomAnnotation
@Component
public class CoreBusinessLogicHandler implements GenericHandler {
// some business logic
}
Код: Выделить всё
@Configuration
public class BusinessConfig {
@Autowired
private CoreIntegrationComponent coreIntegrationComponent;
@MyCustomAnnotation
@Bean(name = INCOMING_PROCESS_CHANNEL)
public MessageChannel incomingProcessChannel() {
return coreIntegrationComponent.amqpChannel(INCOMING_PROCESS_CHANNEL);
}
//some other configurations
}
Код: Выделить всё
import org.springframework.context.ApplicationContext;
@Configuration
public class ChannelConfig {
@Autowired
private ApplicationContext applicationContext;
public List getRecipientChannel(CoreIntegrationComponent coreIntegrationComponent) {
String[] beanNamesForAnnotation = applicationContext.getBeanNamesForAnnotation(MyCustomAnnotation.class);
//Here in output I am getting bean name for CoreBusinessLogicHandler Only.
}
}
Подробнее здесь: https://stackoverflow.com/questions/459 ... ring-beans
Мобильная версия