fun ServiceManager(services: Iterable<Service?>?) { var copy: ImmutableList<Service?> = ImmutableList.copyOf(services) if (copy.isEmpty()) { logger.log( Level.WARNING, "ServiceManager configured with no services. Is your application configured properly?", EmptyServiceManagerWarning() ) copy = ImmutableList.< Service > of < Service ? > NoOpService() } this.state = ServiceManagerState(copy) services = copy val stateReference: WeakReference<ServiceManagerState> = WeakReference<ServiceManagerState>(state) for (service in copy) { service.addListener( ServiceListener(service, stateReference), MoreExecutors.directExecutor() ) checkArgument(service.state() === NEW, "Can only manage NEW services, %s", service) } this.state.markReady() }
Constructs a new instance for managing the given services .