use of org.apache.karaf.features.internal.service.FeatureConfigInstaller in project karaf by apache.
the class AppendTest method before.
@Before
public void before() throws Exception {
System.setProperty("karaf.data", "data");
System.setProperty("karaf.etc", "target");
RepositoryImpl r = new RepositoryImpl(getClass().getResource("internal/service/f08.xml").toURI());
Feature[] features = r.getFeatures();
feature = features[0];
checkFeature(feature);
c = EasyMock.createControl();
admin = c.createMock(ConfigurationAdmin.class);
installer = new FeatureConfigInstaller(admin);
}
use of org.apache.karaf.features.internal.service.FeatureConfigInstaller in project karaf by apache.
the class AppendTest method testLoad.
public void testLoad() throws Exception {
System.setProperty("karaf.data", "data");
System.setProperty("karaf.etc", "etc");
RepositoryImpl r = new RepositoryImpl(getClass().getResource("internal/service/f08.xml").toURI());
// Check repo
Feature[] features = r.getFeatures();
assertNotNull(features);
assertEquals(1, features.length);
Feature feature = features[0];
ConfigInfo configInfo = feature.getConfigurations().get(0);
assertNotNull(configInfo);
assertTrue(configInfo.isAppend());
Properties properties = configInfo.getProperties();
assertNotNull(properties);
String property = properties.getProperty("javax.servlet.context.tempdir");
assertNotNull(property);
assertFalse(property.contains("${"));
assertEquals(property, "data/pax-web-jsp");
ConfigurationAdmin admin = EasyMock.createMock(ConfigurationAdmin.class);
Configuration config = EasyMock.createMock(Configuration.class);
EasyMock.expect(admin.listConfigurations(EasyMock.eq("(service.pid=org.ops4j.pax.web)"))).andReturn(new Configuration[] { config });
Hashtable<String, Object> original = new Hashtable<>();
original.put("javax.servlet.context.tempdir", "data/pax-web-jsp");
EasyMock.expect(config.getProperties()).andReturn(original);
Hashtable<String, Object> expected = new Hashtable<>();
expected.put("org.ops4j.pax.web", "data/pax-web-jsp");
expected.put("org.apache.karaf.features.configKey", "org.ops4j.pax.web");
expected.put("foo", "bar");
EasyMock.expectLastCall();
EasyMock.replay(admin, config);
FeatureConfigInstaller installer = new FeatureConfigInstaller(admin);
installer.installFeatureConfigs(feature);
EasyMock.verify(admin, config);
EasyMock.reset(admin, config);
EasyMock.expect(admin.listConfigurations(EasyMock.eq("(service.pid=org.ops4j.pax.web)"))).andReturn(new Configuration[] { config });
original = new Hashtable<>();
original.put("org.apache.karaf.features.configKey", "org.ops4j.pax.web");
original.put("javax.servlet.context.tempdir", "value");
original.put("foo", "bar");
EasyMock.expect(config.getProperties()).andReturn(original);
EasyMock.replay(admin, config);
installer.installFeatureConfigs(feature);
EasyMock.verify(admin, config);
}
use of org.apache.karaf.features.internal.service.FeatureConfigInstaller in project karaf by apache.
the class Activator method doStart.
protected void doStart() throws Exception {
BundleContext systemBundleContext = bundleContext.getBundle(0).getBundleContext();
ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class);
int resolverThreads = getInt("resolverThreads", Runtime.getRuntime().availableProcessors());
executorService = new ThreadPoolExecutor(0, resolverThreads, 1L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), ThreadUtils.namedThreadFactory("resolver"));
Resolver resolver = new ResolverImpl(new Slf4jResolverLog(LoggerFactory.getLogger(ResolverImpl.class)), executorService);
URLStreamHandlerService mvnUrlHandler = getTrackedService(URLStreamHandlerService.class);
if (configurationAdmin == null || mvnUrlHandler == null) {
return;
}
StandardRegionDigraph dg = DigraphHelper.loadDigraph(bundleContext);
DigraphHelper.verifyUnmanagedBundles(bundleContext, dg);
registerRegionDiGraph(dg);
boolean configCfgStore = getBoolean("configCfgStore", FeaturesService.DEFAULT_CONFIG_CFG_STORE);
FeatureConfigInstaller configInstaller = new FeatureConfigInstaller(configurationAdmin, configCfgStore);
installSupport = new BundleInstallSupportImpl(bundleContext.getBundle(), bundleContext, systemBundleContext, getTrackedServiceRef(ConfigurationAdmin.class).getBundle(), configInstaller, dg);
register(RegionDigraphPersistence.class, () -> installSupport.saveDigraph());
FeatureRepoFinder featureFinder = new FeatureRepoFinder();
register(ManagedService.class, featureFinder, FeatureRepoFinder.getServiceProperties());
Repository globalRepository = getGlobalRepository();
FeaturesServiceConfig cfg = getConfig();
StateStorage stateStorage = createStateStorage();
featuresService = new FeaturesServiceImpl(stateStorage, featureFinder, configurationAdmin, resolver, installSupport, globalRepository, cfg);
try {
EventAdminListener eventAdminListener = new EventAdminListener(bundleContext);
featuresService.registerListener(eventAdminListener);
} catch (Throwable t) {
// No EventAdmin support in this case
}
register(FeaturesService.class, featuresService);
featuresListenerTracker = createFeatureListenerTracker();
featuresListenerTracker.open();
FeaturesServiceMBeanImpl featuresServiceMBean = new FeaturesServiceMBeanImpl();
featuresServiceMBean.setBundleContext(bundleContext);
featuresServiceMBean.setFeaturesService(featuresService);
registerMBean(featuresServiceMBean, "type=feature");
String[] featuresRepositories = getStringArray("featuresRepositories", "");
String featuresBoot = getString("featuresBoot", "");
boolean featuresBootAsynchronous = getBoolean("featuresBootAsynchronous", false);
BootFeaturesInstaller bootFeaturesInstaller = new BootFeaturesInstaller(bundleContext, featuresService, featuresRepositories, featuresBoot, featuresBootAsynchronous);
bootFeaturesInstaller.start();
}
Aggregations