You can create a rule for the service interface, that specifies, which classes may implement the interface.
@Service(permits = { MongoUserService.class,MySQLUserService.class })interfaceUserService {}@ServiceclassMongoUserServiceimplementsUserService {}@ServiceclassMySQLUserServiceimplementsUserService {}@ServiceclassPostgresUserServiceimplementsUserService {}voidinitUserService() {Container.implement(UserService.class,MongoUserService.class);Container.implement(UserService.class,MySQLUSerService.class);// both should work fineContainer.implement(UserService.class,PostgresUserService.class); // will throw an `InvalidServiceAccessException`}