public ActorBaseTest() { ServiceLocatorFactory factory = ServiceLocatorFactory.getInstance(); serviceLocator = factory.create(UUID.randomUUID().toString()); ServiceLocatorUtilities.addOneConstant(serviceLocator, fakeSync); }
@After public void after() { ServiceLocatorFactory.getInstance().destroy(habitat); habitat = null; }
/** * 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); }
/** * Close the factory. The implementation must release all resources. */ @Override public void close() { if (locator != null) { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; } }
public ActorBaseTest() { ServiceLocatorFactory factory = ServiceLocatorFactory.getInstance(); serviceLocator = factory.create(UUID.randomUUID().toString()); ServiceLocatorUtilities.addOneConstant(serviceLocator, fakeSync); }
public void shutdownServiceLocator( final ConfigApiTest test) { String fileName = test.getFileName(); if (habitats.containsKey(fileName)) { ServiceLocator locator = habitats.remove(fileName); ServiceLocatorFactory.getInstance().destroy(locator); } } }
/** * 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; }
private void disposeServiceLocator() { if (deploymentFailedListener != null) { events.unregister(deploymentFailedListener); deploymentFailedListener = null; } if (appServiceLocator != null) { ServiceLocatorFactory.getInstance().destroy(appServiceLocator); appServiceLocator = null; } }
@Override public void initialize(NotDuplicateTargetName constraintAnnotation) { ServiceLocator locator = ServiceLocatorFactory.getInstance().find("default"); if (locator == null) return; ConfigBeansUtilities cbu = locator.getService(ConfigBeansUtilities.class); if (cbu == null) return; domain = cbu.getDomain(); }
@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); }
@After public void after() { ServiceLocatorFactory.getInstance().destroy(habitat); habitat = 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); } }