@Override public Set<Object> getInstances() { return componentBag.getInstances(); }
@Override public Set<Object> getInstances() { return componentBag.getInstances(); }
@Override public boolean isRegistered(final Object component) { return componentBag.getInstances().contains(component); }
@Override public boolean isRegistered(final Object component) { return componentBag.getInstances().contains(component); }
private Collection<Binder> getBinder(Set<Binder> configured) { return componentBag.getInstances(ComponentBag.BINDERS_ONLY) .stream() .map(CAST_TO_BINDER) .filter(binder -> !configured.contains(binder)) .collect(Collectors.toList()); }
private Collection<Binder> getBinder(Set<Binder> configured) { return componentBag.getInstances(ComponentBag.BINDERS_ONLY) .stream() .map(CAST_TO_BINDER) .filter(binder -> !configured.contains(binder)) .collect(Collectors.toList()); }
private void configureExternalObjects(InjectionManager injectionManager) { componentBag.getInstances(model -> ComponentBag.EXTERNAL_ONLY.test(model, injectionManager)) .forEach(injectionManager::register); componentBag.getClasses(model -> ComponentBag.EXTERNAL_ONLY.test(model, injectionManager)) .forEach(injectionManager::register); }
private void configureExternalObjects(InjectionManager injectionManager) { componentBag.getInstances(model -> ComponentBag.EXTERNAL_ONLY.test(model, injectionManager)) .forEach(injectionManager::register); componentBag.getClasses(model -> ComponentBag.EXTERNAL_ONLY.test(model, injectionManager)) .forEach(injectionManager::register); }
componentBag.getClasses(ComponentBag.EXECUTOR_SERVICE_PROVIDER_ONLY).stream() .map(injectionManager::createAndInitialize), componentBag.getInstances(ComponentBag.EXECUTOR_SERVICE_PROVIDER_ONLY).stream()) .map(CAST_TO_EXECUTOR_PROVIDER) .collect(Collectors.toList()); componentBag.getClasses(ComponentBag.SCHEDULED_EXECUTOR_SERVICE_PROVIDER_ONLY).stream() .map(injectionManager::createAndInitialize), componentBag.getInstances(ComponentBag.SCHEDULED_EXECUTOR_SERVICE_PROVIDER_ONLY).stream()) .map(CAST_TO_SCHEDULED_EXECUTOR_PROVIDER) .collect(Collectors.toList());
componentBag.getClasses(ComponentBag.EXECUTOR_SERVICE_PROVIDER_ONLY).stream() .map(injectionManager::createAndInitialize), componentBag.getInstances(ComponentBag.EXECUTOR_SERVICE_PROVIDER_ONLY).stream()) .map(CAST_TO_EXECUTOR_PROVIDER) .collect(Collectors.toList()); componentBag.getClasses(ComponentBag.SCHEDULED_EXECUTOR_SERVICE_PROVIDER_ONLY).stream() .map(injectionManager::createAndInitialize), componentBag.getInstances(ComponentBag.SCHEDULED_EXECUTOR_SERVICE_PROVIDER_ONLY).stream()) .map(CAST_TO_SCHEDULED_EXECUTOR_PROVIDER) .collect(Collectors.toList());
return componentBag.getInstances(ComponentBag.BINDERS_ONLY).stream() .map(CAST_TO_BINDER) .flatMap(binder -> Bindings.getBindings(injectionManager, binder).stream())
return componentBag.getInstances(ComponentBag.BINDERS_ONLY).stream() .map(CAST_TO_BINDER) .flatMap(binder -> Bindings.getBindings(injectionManager, binder).stream())
@Override public void init(InjectionManager injectionManager, BootstrapBag bootstrapBag) { ServerBootstrapBag serverBag = (ServerBootstrapBag) bootstrapBag; ResourceConfig runtimeConfig = serverBag.getRuntimeConfig(); ComponentBag componentBag = runtimeConfig.getComponentBag(); OptionsMethodProcessor optionsMethodProcessor = new OptionsMethodProcessor(); injectionManager.register(Bindings.service(optionsMethodProcessor).to(ModelProcessor.class)); // Get all model processors, registered as an instance or class List<ModelProcessor> modelProcessors = Stream.concat( componentBag.getClasses(CONTRACT_PROVIDER_MODEL_PROCESSOR_ONLY).stream() .map(injectionManager::createAndInitialize), componentBag.getInstances(CONTRACT_PROVIDER_MODEL_PROCESSOR_ONLY).stream()) .map(CAST_TO_MODEL_PROCESSOR) .collect(Collectors.toList()); modelProcessors.add(optionsMethodProcessor); // model processors registered using binders List<ModelProcessor> modelProcessorsFromBinders = ComponentBag .getFromBinders(injectionManager, componentBag, CAST_TO_MODEL_PROCESSOR, BINDING_MODEL_PROCESSOR_ONLY); modelProcessors.addAll(modelProcessorsFromBinders); serverBag.setModelProcessors(modelProcessors); } }
@Override public void init(InjectionManager injectionManager, BootstrapBag bootstrapBag) { ServerBootstrapBag serverBag = (ServerBootstrapBag) bootstrapBag; ResourceConfig runtimeConfig = serverBag.getRuntimeConfig(); ComponentBag componentBag = runtimeConfig.getComponentBag(); OptionsMethodProcessor optionsMethodProcessor = new OptionsMethodProcessor(); injectionManager.register(Bindings.service(optionsMethodProcessor).to(ModelProcessor.class)); // Get all model processors, registered as an instance or class List<ModelProcessor> modelProcessors = Stream.concat( componentBag.getClasses(CONTRACT_PROVIDER_MODEL_PROCESSOR_ONLY).stream() .map(injectionManager::createAndInitialize), componentBag.getInstances(CONTRACT_PROVIDER_MODEL_PROCESSOR_ONLY).stream()) .map(CAST_TO_MODEL_PROCESSOR) .collect(Collectors.toList()); modelProcessors.add(optionsMethodProcessor); // model processors registered using binders List<ModelProcessor> modelProcessorsFromBinders = ComponentBag .getFromBinders(injectionManager, componentBag, CAST_TO_MODEL_PROCESSOR, BINDING_MODEL_PROCESSOR_ONLY); modelProcessors.addAll(modelProcessorsFromBinders); serverBag.setModelProcessors(modelProcessors); } }
Set<Object> instances = componentBag.getInstances(filter); if (constrainedTo != null) { instances = instances.stream()
Set<Object> instances = componentBag.getInstances(filter); if (constrainedTo != null) { instances = instances.stream()
componentBag.getInstances(ComponentBag.excludeMetaProviders(injectionManager)).stream() .filter(instance -> correctlyConfigured.test(instance.getClass())) .collect(Collectors.toSet());
componentBag.getInstances(ComponentBag.excludeMetaProviders(injectionManager)).stream() .filter(instance -> correctlyConfigured.test(instance.getClass())) .collect(Collectors.toSet());
componentBag.getInstances(ComponentBag.excludeMetaProviders(injectionManager)));
componentBag.getInstances(ComponentBag.excludeMetaProviders(injectionManager)));