Annotation Type InjectConnector


  • @Autowired
    @Qualifier
    @Documented
    @Retention(RUNTIME)
    @Target({FIELD,PARAMETER,ANNOTATION_TYPE})
    public @interface InjectConnector
    Provides support for NetworkConnectors autowiring.

    This annotation can be placed on any autowire-capable elements (fields, properties, parameters, etc) of application beans in order to inject NetworkConnector by its protocol name.

    Below is the example of how this annotation can be used.

    1) Define a bean that will use InjectConnector annotation to inject NetworkConnector into its field.

    
    @Component
    public class MyBean {
        @InjectConnector("my-connector")
        private NetworkConnector<Object> connector;
    
        // ... other fields and methods...
    }
    
    2) Define a Spring Boot application that will provide connector configuration.
    
    @EnableHekate
    @SpringBootApplication
    public class MyApp {
        @Bean
        public NetworkConnectorConfig<Object> networkConnectorConfig() {
            return new NetworkConnectorConfig<>()
                .withProtocol("my-connector")
                .withServerHandler((msg, from) ->
                    System.out.println("Got message " + msg + " from " + from)
                );
        }
    
        // ... other beans and methods...
    }
    

    See Also:
    HekateNetworkServiceConfigurer