public ActorBaseTest() { ServiceLocatorFactory factory = ServiceLocatorFactory.getInstance(); serviceLocator = factory.create(UUID.randomUUID().toString()); ServiceLocatorUtilities.addOneConstant(serviceLocator, fakeSync); }
protected void injectMultiBindings(ServiceLocator locator, Injector injector, Key<? extends Set<?>> key, Type type) { Set<?> set = injector.getInstance(key); if (set != null && !set.isEmpty()) { for (Object obj : set) { ServiceLocatorUtilities.addOneConstant(locator, obj, null, type); } } }
protected void injectMultiBindings(ServiceLocator locator, Injector injector, Key<? extends Set<?>> key, Type type) { Set<?> set = injector.getInstance(key); if (set != null && !set.isEmpty()) { for (Object obj : set) { ServiceLocatorUtilities.addOneConstant(locator, obj, null, type); } } }
protected void injectMultiBindings(ServiceLocator locator, Injector injector, Key<? extends Set<?>> key, Type type) { Set<?> set = injector.getInstance(key); if (set != null && !set.isEmpty()) { for (Object obj : set) { ServiceLocatorUtilities.addOneConstant(locator, obj, null, type); } } }
@Override public void bridgeGuiceInjector(Injector injector) { GuiceToHk2JITResolver resolver = new GuiceToHk2JITResolver(locator, injector); ServiceLocatorUtilities.addOneConstant(locator, resolver); }
@Override public void bridgeSpringBeanFactory(BeanFactory beanFactory) { SpringToHK2JITResolver resolver = new SpringToHK2JITResolver(serviceLocator, beanFactory); ServiceLocatorUtilities.addOneConstant(serviceLocator, resolver); }
public ActorBaseTest() { ServiceLocatorFactory factory = ServiceLocatorFactory.getInstance(); serviceLocator = factory.create(UUID.randomUUID().toString()); ServiceLocatorUtilities.addOneConstant(serviceLocator, fakeSync); }
public ServiceLocator getServiceLocator() { if (serviceLocator == null) { Metrix.event("Init hk2 - start"); ModulesRegistry registry = new StaticModulesRegistry(this.classLoader); serviceLocator = registry.createServiceLocator("default"); if (programOptions != null) { ServiceLocatorUtilities.addOneConstant(serviceLocator, programOptions); } if (environment != null) { ServiceLocatorUtilities.addOneConstant(serviceLocator, environment); } ServiceLocatorUtilities.addOneConstant(serviceLocator, this); Metrix.event("Init hk2 - done"); } return serviceLocator; }
private void prepareHabitat() { ModulesRegistry registry = new StaticModulesRegistry(getClass().getClassLoader()); ServiceLocator serviceLocator = registry.createServiceLocator("default"); habitat = serviceLocator.getService(ServiceLocator.class); StartupContext startupContext = new StartupContext(); ServiceLocatorUtilities.addOneConstant(habitat, startupContext); ServiceLocatorUtilities.addOneConstant(habitat, new ProcessEnvironment(ProcessEnvironment.ProcessType.Other)); }
@SuppressWarnings("unchecked") private <T> T processClass(Class<?> classType) throws InstantiationException, IllegalAccessException { if(!discoveredClasses.contains(classType)) { discoveredClasses.add(classType); if (classType.isAnnotationPresent(Singleton.class) || classType.isAnnotationPresent(Service.class)) { // Singletons are a special case as we allow interception // Do we have an intercept? Object o = config.getAsInstance(classType.getName(), Object.class); if (o == null) { o = classType.newInstance(); } discoveredServices.add(o); ServiceLocatorUtilities.addOneConstant(getServiceLocator(), o); return (T) o; } final Class<?>[] childClasses = classType.getClasses(); for(Class childClass : childClasses) { processClass(childClass); } } return null; }
protected void decorate() { Server server = habitat.getService(Server.class, env.getInstanceName()); if (server == null) { LogRecord lr = new LogRecord(Level.SEVERE, badEnv); lr.setLoggerName(getClass().getName()); EarlyLogHandler.earlyMessages.add(lr); return; } ServiceLocatorUtilities.addOneConstant(habitat, server, ServerEnvironment.DEFAULT_INSTANCE_NAME, Server.class); server.getConfig().addIndex(habitat, ServerEnvironment.DEFAULT_INSTANCE_NAME); Cluster c = server.getCluster(); if (c != null) { ServiceLocatorUtilities.addOneConstant(habitat, c, ServerEnvironment.DEFAULT_INSTANCE_NAME, Cluster.class); } }
public static ServiceLocator getServiceLocator(final InputStream inputStream, String name) { try { final ServiceLocator habitat = getNewServiceLocator(name); final ConfigParser parser = new ConfigParser(habitat); XMLInputFactory xif = XMLInputFactory.class.getClassLoader() == null ? XMLInputFactory.newFactory() : XMLInputFactory.newFactory(XMLInputFactory.class.getName(), XMLInputFactory.class.getClassLoader()); final DomDocument document = parser.parse(xif.createXMLStreamReader(inputStream)); ServiceLocatorUtilities.addOneConstant(habitat, document); return habitat; } catch (Exception e) { e.printStackTrace(); throw new GrizzlyConfigException(e.getMessage(), e); } }
private static synchronized ServiceLocator getNewHabitat(final ConfigApiTest test) { final ServiceLocator sl = getNewHabitat(); final String fileName = test.getFileName(); ConfigParser configParser = new ConfigParser(sl); long now = System.currentTimeMillis(); URL url = Utils.class.getClassLoader().getResource(fileName + ".xml"); if (url != null) { try { DomDocument testDocument = test.getDocument(sl); DomDocument document = configParser.parse(url, testDocument); ServiceLocatorUtilities.addOneConstant(sl, document); test.decorate(sl); } catch (Exception e) { e.printStackTrace(); } Logger.getAnonymousLogger().fine( "time to parse domain.xml : " + String.valueOf(System.currentTimeMillis() - now)); } return sl; }
public static ServiceLocator getServiceLocator(final InputStream inputStream, String name) { try { final ServiceLocator habitat = getNewServiceLocator(name); final ConfigParser parser = new ConfigParser(habitat); XMLInputFactory xif = XMLInputFactory.class.getClassLoader() == null ? XMLInputFactory.newFactory() : XMLInputFactory.newFactory(XMLInputFactory.class.getName(), XMLInputFactory.class.getClassLoader()); final DomDocument document = parser.parse(xif.createXMLStreamReader(inputStream)); ServiceLocatorUtilities.addOneConstant(habitat, document); return habitat; } catch (Exception e) { e.printStackTrace(); throw new GrizzlyConfigException(e.getMessage(), e); } }
return null; ServiceLocatorUtilities.addOneConstant(habitat, result, cluster.getName(), GMSAdapter.class);
return null; ServiceLocatorUtilities.addOneConstant(habitat, result, cluster.getName(), GMSAdapter.class);
logger.log(Level.FINE, AddingDefaultInstanceIndexFor, nvb.getProxyType().getName()); ServiceLocatorUtilities.addOneConstant(habitat, nvbp, ServerEnvironment.DEFAULT_INSTANCE_NAME, nvb.getProxyType());
public Task start() { logger.info("Starting Orbit Container"); try { // Read configuration config = YAMLConfigReader.readConfig(); // Create the DI container ServiceLocatorFactory factory = ServiceLocatorFactory.getInstance(); serviceLocator = factory.create(containerName); ServiceLocatorUtilities.addOneConstant(getServiceLocator(), this); // Discover addons discoverAddons(); // Crawl the packages and make the container aware of them crawlPackages(); } catch(Exception e) { logger.log(Level.SEVERE, e.toString()); } // Initialize singletons/services initServices(); logger.info("Container successfully started"); return Task.done(); }
ServiceLocatorUtilities.addOneConstant(habitat, this); fileSystem = habitat.getServiceHandle( ServiceLocatorUtilities.<EmbeddedFileSystem>addOneConstant(habitat, fs, null, EmbeddedFileSystem.class));
@Override public Object run(Domain writeableDomain) throws PropertyVetoException, TransactionFailure { ConfigBeanProxy child = writeableDomain.createChild(type); Dom domDomain = Dom.unwrap(writeableDomain); final String elementName; try { elementName = GenericCrudCommand.elementName(domDomain.document, Domain.class, type); } catch (ClassNotFoundException e) { throw new TransactionFailure(e.toString()); } if (elementName==null) { String msg = localStrings.getLocalString(TypeResolver.class, "TypeResolver.no_element_of_that_type", "The Domain configuration does not have a sub-element of the type {0}", type.getSimpleName()); throw new TransactionFailure(msg); } domDomain.setNodeElements(elementName, Dom.unwrap(child)); // add to the habitat ServiceLocatorUtilities.addOneConstant(habitat, child, null, type); return child; } }, domain));