@Test public void testGenEnvironmentServiceFilledWithPackages() { Environment environment = factory.getEnvironment(null, "com.tacitknowledge.flip.fixtures"); assertNotNull(environment); Assert.assertTrue(environment.getProperties().isEmpty()); assertTrue(isListHasItemOfType(environment.getPropertyReaders(), TestPropertyReader.class)); assertTrue(isListHasItemOfType(environment.getContextProviders(), TestContextProvider.class)); assertTrue(isListHasItemOfType(environment.getContextProviders(), Test1ContextProvider.class)); }
protected Environment getEnvironment(final Properties properties, String... packagesToSearch) { final Environment environment = new Environment(); if (properties != null) { environment.setProperties(properties); } packagesToSearch = ArrayUtils.add(packagesToSearch, getClass().getPackage().getName()); final ServiceProvider serviceProvider = new ServiceProvider(packagesToSearch); final List<PropertyReader> propertyReaders = Lists.newArrayList(serviceProvider.find(FlipProperty.class, PropertyReader.class)); Collections.sort(propertyReaders, new FlipPropertiesPriorityComparator()); environment.setPropertyReaders(propertyReaders); final List<Object> contextProviders = Lists.newArrayList(serviceProvider.find(FlipContext.class)); Collections.sort(contextProviders, new FlipContextsPriorityComparator()); environment.setContextProviders(contextProviders); return environment; }
FeatureServiceReflectionFactory extends AbstractFeatureServiceFactory { protected Environment getEnvironment(final Properties properties, String... packagesToSearch) { final Environment environment = new Environment(); if (properties != null) { environment.setProperties(properties); } packagesToSearch = ArrayUtils.add(packagesToSearch, getClass().getPackage().getName()); final ServiceProvider serviceProvider = new ServiceProvider(packagesToSearch); final List<PropertyReader> propertyReaders = Lists.newArrayList(serviceProvider.find(FlipProperty.class, PropertyReader.class)); Collections.sort(propertyReaders, new FlipPropertiesPriorityComparator()); environment.setPropertyReaders(propertyReaders); final List<Object> contextProviders = Lists.newArrayList(serviceProvider.find(FlipContext.class)); Collections.sort(contextProviders, new FlipContextsPriorityComparator()); environment.setContextProviders(contextProviders); return environment; } }
FeatureServiceReflectionFactory extends AbstractFeatureServiceFactory { protected Environment getEnvironment(final Properties properties, String... packagesToSearch) { final Environment environment = new Environment(); if (properties != null) { environment.setProperties(properties); } packagesToSearch = ArrayUtils.add(packagesToSearch, getClass().getPackage().getName()); final ServiceProvider serviceProvider = new ServiceProvider(packagesToSearch); final List<PropertyReader> propertyReaders = Lists.newArrayList(serviceProvider.find(FlipProperty.class, PropertyReader.class)); Collections.sort(propertyReaders, new FlipPropertiesPriorityComparator()); environment.setPropertyReaders(propertyReaders); final List<Object> contextProviders = Lists.newArrayList(serviceProvider.find(FlipContext.class)); Collections.sort(contextProviders, new FlipContextsPriorityComparator()); environment.setContextProviders(contextProviders); return environment; }  }
FeatureServiceReflectionFactory extends AbstractFeatureServiceFactory { protected Environment getEnvironment(final Properties properties, String... packagesToSearch) { final Environment environment = new Environment(); if (properties != null) { environment.setProperties(properties); } packagesToSearch = ArrayUtils.add(packagesToSearch, getClass().getPackage().getName()); final ServiceProvider serviceProvider = new ServiceProvider(packagesToSearch); final List<PropertyReader> propertyReaders = Lists.newArrayList(serviceProvider.find(FlipProperty.class, PropertyReader.class)); Collections.sort(propertyReaders, new FlipPropertiesPriorityComparator()); environment.setPropertyReaders(propertyReaders); final List<Object> contextProviders = Lists.newArrayList(serviceProvider.find(FlipContext.class)); Collections.sort(contextProviders, new FlipContextsPriorityComparator()); environment.setContextProviders(contextProviders); return environment; }  static FeatureServiceReflectionFactory getInstance(); FeatureService createFeatureService(); FeatureService createFeatureService(final Properties properties); FeatureService createFeatureService(final String... packagesToSearch); FeatureService createFeatureService(final Properties properties, final String... packagesToSearch); }
FeatureServiceReflectionFactory extends AbstractFeatureServiceFactory { protected Environment getEnvironment(final Properties properties, String... packagesToSearch) { final Environment environment = new Environment(); if (properties != null) { environment.setProperties(properties); } packagesToSearch = ArrayUtils.add(packagesToSearch, getClass().getPackage().getName()); final ServiceProvider serviceProvider = new ServiceProvider(packagesToSearch); final List<PropertyReader> propertyReaders = Lists.newArrayList(serviceProvider.find(FlipProperty.class, PropertyReader.class)); Collections.sort(propertyReaders, new FlipPropertiesPriorityComparator()); environment.setPropertyReaders(propertyReaders); final List<Object> contextProviders = Lists.newArrayList(serviceProvider.find(FlipContext.class)); Collections.sort(contextProviders, new FlipContextsPriorityComparator()); environment.setContextProviders(contextProviders); return environment; }  static FeatureServiceReflectionFactory getInstance(); FeatureService createFeatureService(); FeatureService createFeatureService(final Properties properties); FeatureService createFeatureService(final String... packagesToSearch); FeatureService createFeatureService(final Properties properties, final String... packagesToSearch);  }