@Override public void completeRegistration() throws IllegalStateException { Hk2Helper.bind(this, bindings); ServiceLocatorUtilities.bind(getServiceLocator(), providers.toArray(new org.glassfish.hk2.utilities.Binder[]{})); completed = true; } }
@Override public void completeRegistration() throws IllegalStateException { Hk2Helper.bind(this, bindings); ServiceLocatorUtilities.bind(getServiceLocator(), providers.toArray(new org.glassfish.hk2.utilities.Binder[]{})); completed = true; } }
@Override public void register(Object provider) { if (isRegistrable(provider.getClass())) { ServiceLocatorUtilities.bind(getServiceLocator(), (org.glassfish.hk2.utilities.Binder) provider); } else { throw new IllegalArgumentException(LocalizationMessages.HK_2_PROVIDER_NOT_REGISTRABLE(provider.getClass())); } } }
@Override public void register(Object provider) { if (isRegistrable(provider.getClass())) { ServiceLocatorUtilities.bind(getServiceLocator(), (org.glassfish.hk2.utilities.Binder) provider); } else { throw new IllegalArgumentException(LocalizationMessages.HK_2_PROVIDER_NOT_REGISTRABLE(provider.getClass())); } } }
/** * Private constructor. * * @param parent parent of type {@link org.glassfish.jersey.internal.inject.InjectionManager} or {@link ServiceLocator}. */ AbstractHk2InjectionManager(Object parent) { ServiceLocator parentLocator = resolveServiceLocatorParent(parent); this.locator = createLocator(parentLocator); // Register all components needed for proper HK2 locator bootstrap ServiceLocatorUtilities.bind(locator, new Hk2BootstrapBinder(locator)); this.locator.setDefaultClassAnalyzerName(JerseyClassAnalyzer.NAME); // clear HK2 caches ServiceLocatorRuntimeBean serviceLocatorRuntimeBean = locator.getService(ServiceLocatorRuntimeBean.class); if (serviceLocatorRuntimeBean != null) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(LocalizationMessages.HK_2_CLEARING_CACHE(serviceLocatorRuntimeBean.getServiceCacheSize(), serviceLocatorRuntimeBean.getReflectionCacheSize())); } serviceLocatorRuntimeBean.clearReflectionCache(); serviceLocatorRuntimeBean.clearServiceCache(); } }
/** * Private constructor. * * @param parent parent of type {@link org.glassfish.jersey.internal.inject.InjectionManager} or {@link ServiceLocator}. */ AbstractHk2InjectionManager(Object parent) { ServiceLocator parentLocator = resolveServiceLocatorParent(parent); this.locator = createLocator(parentLocator); // Register all components needed for proper HK2 locator bootstrap ServiceLocatorUtilities.bind(locator, new Hk2BootstrapBinder(locator)); this.locator.setDefaultClassAnalyzerName(JerseyClassAnalyzer.NAME); // clear HK2 caches ServiceLocatorRuntimeBean serviceLocatorRuntimeBean = locator.getService(ServiceLocatorRuntimeBean.class); if (serviceLocatorRuntimeBean != null) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(LocalizationMessages.HK_2_CLEARING_CACHE(serviceLocatorRuntimeBean.getServiceCacheSize(), serviceLocatorRuntimeBean.getReflectionCacheSize())); } serviceLocatorRuntimeBean.clearReflectionCache(); serviceLocatorRuntimeBean.clearServiceCache(); } }
}; ServiceLocatorUtilities.bind(locator, createBinder(bindConsumer));
}; ServiceLocatorUtilities.bind(locator, createBinder(bindConsumer));
ServiceLocatorUtilities.bind(locator, createBinder(bindConsumer));
ServiceLocatorUtilities.bind(locator, createBinder(bindConsumer));
/** * This method will create or find a ServiceLocator with the name "default" and * bind all of the binders given together in a single config transaction. * * @param binders The non-null list of binders to be added to the locator * @return The service locator that was either found or created * @throws MultiException if any error was encountered while binding services */ public static ServiceLocator bind(Binder... binders) { return bind(DEFAULT_LOCATOR_NAME, binders); }
/** * This method will create or find a ServiceLocator with the name "default" and * bind all of the binders given together in a single config transaction. * * @param binders The non-null list of binders to be added to the locator * @return The service locator that was either found or created * @throws MultiException if any error was encountered while binding services */ public static ServiceLocator bind(Binder... binders) { return bind(DEFAULT_LOCATOR_NAME, binders); }
private ServiceLocator createDIContainer(List<Binder> binders) { String uniqueName = "HermesFrontendLocator" + UUID.randomUUID(); return ServiceLocatorUtilities.bind(uniqueName, binders.toArray(new Binder[binders.size()])); }
@Override public void completeRegistration() throws IllegalStateException { Hk2Helper.bind(this, bindings); ServiceLocatorUtilities.bind(getServiceLocator(), providers.toArray(new org.glassfish.hk2.utilities.Binder[]{})); completed = true; } }
@Override public void register(Object provider) { if (isRegistrable(provider.getClass())) { ServiceLocatorUtilities.bind(getServiceLocator(), (org.glassfish.hk2.utilities.Binder) provider); } else { throw new IllegalArgumentException(LocalizationMessages.HK_2_PROVIDER_NOT_REGISTRABLE(provider.getClass())); } } }
@Override public void completeRegistration() throws IllegalStateException { Hk2Helper.bind(this, bindings); ServiceLocatorUtilities.bind(getServiceLocator(), providers.toArray(new org.glassfish.hk2.utilities.Binder[]{})); completed = true; } }
@Override public void register(Object provider) { if (isRegistrable(provider.getClass())) { ServiceLocatorUtilities.bind(getServiceLocator(), (org.glassfish.hk2.utilities.Binder) provider); } else { throw new IllegalArgumentException(LocalizationMessages.HK_2_PROVIDER_NOT_REGISTRABLE(provider.getClass())); } } }
public HK2Locator(Vertx vertx, Binder... binders) { locator = ServiceLocatorFactory.getInstance().create(null); ServiceLocatorUtilities.bind(locator, new HK2WhenBinder(), new HK2WhenCassandraBinder(), new HK2VertxBinder(vertx)); if (binders != null) { ServiceLocatorUtilities.bind(locator, binders); } }
@Override public void init(Vertx vertx) { locator = ServiceLocatorUtilities.bind( new HK2VertxBinder(vertx), new WhenHK2JerseyBinder(), new HK2WhenBinder()); }
@Test public void shouldGetAllServicesWithoutAnyExceptions() { ServiceLocator serviceLocator = ServiceLocatorUtilities.bind("serviceLocatorTestName1", new CommonBinder(), new ConsumersBinder(), new TestBinder(configFactory), new TrackersBinder() ); serviceLocator.getAllServices(d -> true); }