public ActorBaseTest() { ServiceLocatorFactory factory = ServiceLocatorFactory.getInstance(); serviceLocator = factory.create(UUID.randomUUID().toString()); ServiceLocatorUtilities.addOneConstant(serviceLocator, fakeSync); }
/** * Creates a new {@link ServiceLocator} instance from static {@link ServiceLocatorFactory} and adds the provided parent * locator if the instance is not null. * * @param parentLocator parent locator, can be {@code null}. * @return new instance of injection manager. */ private static ServiceLocator createLocator(ServiceLocator parentLocator) { ServiceLocator result = factory.create(null, parentLocator, null, ServiceLocatorFactory.CreatePolicy.DESTROY); result.setNeutralContextClassLoader(false); ServiceLocatorUtilities.enablePerThreadScope(result); return result; }
/** * Creates a new {@link ServiceLocator} instance from static {@link ServiceLocatorFactory} and adds the provided parent * locator if the instance is not null. * * @param parentLocator parent locator, can be {@code null}. * @return new instance of injection manager. */ private static ServiceLocator createLocator(ServiceLocator parentLocator) { ServiceLocator result = factory.create(null, parentLocator, null, ServiceLocatorFactory.CreatePolicy.DESTROY); result.setNeutralContextClassLoader(false); ServiceLocatorUtilities.enablePerThreadScope(result); return result; }
/** * Ensures that even the non-standard format of metadata from the hk2-config subsystem can * be read from the service in addClasses. addClasses will now read both forms, if the * documented form fails, it'll try the hk2-config form */ @Test public void testAddClassOfInjector() { ServiceLocator locator = ServiceLocatorFactory.getInstance().create(null); List<ActiveDescriptor<?>> added = ServiceLocatorUtilities.addClasses(locator, EjbContainerAvailabilityInjector.class); ActiveDescriptor<?> descriptor = added.get(0); Assert.assertEquals("org.jvnet.hk2.config.test.EjbContainerAvailability", ServiceLocatorUtilities.getOneMetadataField(descriptor, "target")); }
@Before public void before() { String testName = TEST_NAME + RANDOM.nextInt(); habitat = ServiceLocatorFactory.getInstance().create(testName); DynamicConfigurationService dcs = habitat.getService(DynamicConfigurationService.class); DynamicConfiguration config = dcs.createDynamicConfiguration(); new ConfigModule(habitat).configure(config); config.commit(); parseDomainXml(); }
@Test public void testEnableConfigUtilities() { ServiceLocator locator = ServiceLocatorFactory.getInstance().create(null); Assert.assertNull(locator.getService(ConfigSupport.class)); Assert.assertNull(locator.getService(ConfigurationPopulator.class)); Assert.assertNull(locator.getService(Transactions.class)); Assert.assertNull(locator.getService(ConfigInstanceListener.class)); HK2DomConfigUtilities.enableHK2DomConfiguration(locator); // Twice to check idempotence HK2DomConfigUtilities.enableHK2DomConfiguration(locator); Assert.assertEquals(1, locator.getAllServices(ConfigSupport.class).size()); Assert.assertEquals(1, locator.getAllServices(ConfigurationPopulator.class).size()); Assert.assertEquals(1, locator.getAllServices(Transactions.class).size()); Assert.assertEquals(1, locator.getAllServices(ConfigInstanceListener.class).size()); }
/** * This can be used to configure the name of the service locator * to use * * @param name The name to be used. If null an anonymous service * locator will be used */ public synchronized void setServiceLocatorName(String name) { locator = ServiceLocatorFactory.getInstance().create(name); }
public ActorBaseTest() { ServiceLocatorFactory factory = ServiceLocatorFactory.getInstance(); serviceLocator = factory.create(UUID.randomUUID().toString()); ServiceLocatorUtilities.addOneConstant(serviceLocator, fakeSync); }
/** * Create a new ServiceLocator optionally providing a parent Services */ @Override public ServiceLocator newServiceLocator(ServiceLocator parent) throws MultiException { // We intentionally create an unnamed service locator, because the caller is going to // manage its lifecycle. ServiceLocator serviceLocator = ServiceLocatorFactory.getInstance().create(null, parent); initializeServiceLocator(serviceLocator); return serviceLocator; }
/** * Create a new ServiceLocator optionally providing a parent Services */ @Override public ServiceLocator newServiceLocator(ServiceLocator parent) throws MultiException { // We intentionally create an unnamed service locator, because the caller is going to // manage its lifecycle. ServiceLocator serviceLocator = ServiceLocatorFactory.getInstance().create(null, parent); initializeServiceLocator(serviceLocator); return serviceLocator; }
/** * Creates a new {@link ServiceLocator} instance from static {@link ServiceLocatorFactory} and adds the provided parent * locator if the instance is not null. * * @param parentLocator parent locator, can be {@code null}. * @return new instance of injection manager. */ private static ServiceLocator createLocator(ServiceLocator parentLocator) { ServiceLocator result = factory.create(null, parentLocator, null, ServiceLocatorFactory.CreatePolicy.DESTROY); result.setNeutralContextClassLoader(false); ServiceLocatorUtilities.enablePerThreadScope(result); return result; }
private static ServiceLocator _createLocator(final String name, final ServiceLocator parent, final Binder... binders) { // Passing null as service locator generator would force HK2 to find appropriate one. final ServiceLocator result = factory.create(name, parent, null, ServiceLocatorFactory.CreatePolicy.DESTROY); result.setNeutralContextClassLoader(false); ServiceLocatorUtilities.enablePerThreadScope(result); // HK2 Immediate Scope is commented out due to JERSEY-2979 and other issues // ServiceLocatorUtilities.enableImmediateScope(result); for (final Binder binder : binders) { bind(result, binder); } return result; }
private static ServiceLocator _createLocator(final String name, final ServiceLocator parent, final Binder... binders) { // Passing null as service locator generator would force HK2 to find appropriate one. final ServiceLocator result = factory.create(name, parent, null, ServiceLocatorFactory.CreatePolicy.DESTROY); result.setNeutralContextClassLoader(false); ServiceLocatorUtilities.enablePerThreadScope(result); // HK2 Immediate Scope is commented out due to JERSEY-2979 and other issues // ServiceLocatorUtilities.enableImmediateScope(result); for (final Binder binder : binders) { bind(result, binder); } return result; }
private static ServiceLocator _createLocator(final String name, final ServiceLocator parent, final Binder... binders) { // Passing null as service locator generator would force HK2 to find appropriate one. final ServiceLocator result = factory.create(name, parent, null, ServiceLocatorFactory.CreatePolicy.DESTROY); result.setNeutralContextClassLoader(false); ServiceLocatorUtilities.enablePerThreadScope(result); // HK2 Immediate Scope is commented out due to JERSEY-2979 and other issues // ServiceLocatorUtilities.enableImmediateScope(result); for (final Binder binder : binders) { bind(result, binder); } return result; }
@Override public ServiceLocator create(TestContext testContext) { TestConfigurer testConfigurer = testContext.getTestConfigurer(); ServiceLocatorFactory locatorFactory = ServiceLocatorFactory.getInstance(); ServiceLocator serviceLocator = locatorFactory.create(testContext.getName()); return testConfigurer.configure(testContext, serviceLocator); }
@Before public void setUp() throws Exception { when(options.getPackages()).thenReturn(packages); locator = ServiceLocatorFactory.getInstance().create(null); }
private void createServiceLocator() { String locatorName = APP_SERVICE_LOCATOR_PREFIX + name; ServiceLocatorFactory slf = ServiceLocatorFactory.getInstance(); if (slf.find(locatorName) != null) { slf.destroy(locatorName); } appServiceLocator = slf.create(locatorName); deploymentFailedListener = new DeploymentFailedListener(source); events.register(deploymentFailedListener); }
/** * Ensures that even the non-standard format of metadata from the hk2-config subsystem can * be read from the service in addClasses. addClasses will now read both forms, if the * documented form fails, it'll try the hk2-config form */ @Test public void testAddClassOfInjector() { ServiceLocator locator = ServiceLocatorFactory.getInstance().create(null); List<ActiveDescriptor<?>> added = ServiceLocatorUtilities.addClasses(locator, EjbContainerAvailabilityInjector.class); ActiveDescriptor<?> descriptor = added.get(0); Assert.assertEquals("org.jvnet.hk2.config.test.EjbContainerAvailability", ServiceLocatorUtilities.getOneMetadataField(descriptor, "target")); }
@Before public void before() { String testName = TEST_NAME + RANDOM.nextInt(); habitat = ServiceLocatorFactory.getInstance().create(testName); DynamicConfigurationService dcs = habitat.getService(DynamicConfigurationService.class); DynamicConfiguration config = dcs.createDynamicConfiguration(); new ConfigModule(habitat).configure(config); config.commit(); parseDomainXml(); }
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); } }