Skip to content

Creating beans

Rishabh Joshi edited this page Oct 25, 2018 · 3 revisions

Are you using Spring in your project? You can have the following configuration to make things simple. Even if you are using Riko in a non-Spring project, refer the code below to get the drift. ^_^

@Configuration
public class ApplicationConfiguration {

    @Autowired
    private UpstoxAuthService upstoxAuthService;

    @Bean
    public LoginService loginService() {
        return new LoginService(upstoxAuthService);
    }

    @Bean
    public FeedService feedService() {
        return new FeedService(upstoxAuthService);
    }

    @Bean
    public HistoricalService historicalService() {
        return new HistoricalService(upstoxAuthService);
    }

    @Bean
    public UserService userService() {
        return new UserService(upstoxAuthService);
    }

    @Bean
    public WebSocketService webSocketService() {
        return new WebSocketService(upstoxAuthService);
    }

    @Bean
    public OrderService orderService() {
        return new OrderService(upstoxAuthService);
    }
}

Don't forget to declare your UpstoxAuthService's implementation with @Service("upstoxAuthService") or @Component("upstoxAuthService").

Clone this wiki locally