Search in sources :

Example 1 with ConfigurationScanner

use of org.eclipse.gemini.blueprint.extender.support.scanning.ConfigurationScanner in project motech by motech.

the class PlatformActivator method registerStatusManager.

private void registerStatusManager() {
    List<Bundle> bundles = new ArrayList<>();
    if (bundlesByType.containsKey(BundleType.MOTECH_MODULE)) {
        bundles.addAll(bundlesByType.get(BundleType.MOTECH_MODULE));
    }
    if (bundlesByType.containsKey(BundleType.MDS_BUNDLE)) {
        bundles.addAll(bundlesByType.get(BundleType.MDS_BUNDLE));
    }
    if (bundlesByType.containsKey(BundleType.PLATFORM_BUNDLE_PRE_MDS)) {
        bundles.addAll(bundlesByType.get(BundleType.PLATFORM_BUNDLE_PRE_MDS));
    }
    if (bundlesByType.containsKey(BundleType.PLATFORM_BUNDLE_PRE_WS)) {
        bundles.addAll(bundlesByType.get(BundleType.PLATFORM_BUNDLE_PRE_WS));
    }
    if (bundlesByType.containsKey(BundleType.WS_BUNDLE)) {
        bundles.addAll(bundlesByType.get(BundleType.WS_BUNDLE));
    }
    if (bundlesByType.containsKey(BundleType.PLATFORM_BUNDLE_POST_WS)) {
        bundles.addAll(bundlesByType.get(BundleType.PLATFORM_BUNDLE_POST_WS));
    }
    List<Bundle> osgiBundles = new ArrayList<>();
    List<Bundle> blueprintBundles = new ArrayList<>();
    ConfigurationScanner configurationScanner = new DefaultConfigurationScanner();
    for (Bundle bundle : bundles) {
        String[] config = configurationScanner.getConfigurations(bundle);
        if (config.length > 0) {
            blueprintBundles.add(bundle);
        } else {
            osgiBundles.add(bundle);
        }
    }
    platformStatusManager = new PlatformStatusManagerImpl(osgiBundles, blueprintBundles);
    bundleContext.addBundleListener(platformStatusManager);
    bundleContext.registerService(OsgiBundleApplicationContextListener.class, platformStatusManager, null);
    bundleContext.registerService(PlatformStatusManager.class, platformStatusManager, null);
}
Also used : DefaultConfigurationScanner(org.eclipse.gemini.blueprint.extender.support.scanning.DefaultConfigurationScanner) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) DefaultConfigurationScanner(org.eclipse.gemini.blueprint.extender.support.scanning.DefaultConfigurationScanner) ConfigurationScanner(org.eclipse.gemini.blueprint.extender.support.scanning.ConfigurationScanner) PlatformStatusManagerImpl(org.motechproject.server.osgi.status.PlatformStatusManagerImpl)

Example 2 with ConfigurationScanner

use of org.eclipse.gemini.blueprint.extender.support.scanning.ConfigurationScanner in project motech by motech.

the class MotechOsgiApplicationContextCreatorTest method shouldReturnApplicationOfTypeWebApplicationContext.

@Test
public void shouldReturnApplicationOfTypeWebApplicationContext() throws Exception {
    MockBundle bundle = new MockBundle();
    MockBundleContext bundleContext = new MockBundleContext(bundle);
    ConfigurationScanner configurationScanner = mock(ConfigurationScanner.class);
    when(configurationScanner.getConfigurations(bundle)).thenReturn(new String[] { "resource.xml" });
    MotechOsgiApplicationContextCreator contextCreator = new MotechOsgiApplicationContextCreator();
    contextCreator.setConfigurationScanner(configurationScanner);
    MotechOsgiConfigurableApplicationContext applicationContext = (MotechOsgiConfigurableApplicationContext) contextCreator.createApplicationContext(bundleContext);
    assertThat(applicationContext, notNullValue());
}
Also used : MockBundleContext(org.eclipse.gemini.blueprint.mock.MockBundleContext) MockBundle(org.eclipse.gemini.blueprint.mock.MockBundle) ConfigurationScanner(org.eclipse.gemini.blueprint.extender.support.scanning.ConfigurationScanner) Test(org.junit.Test)

Aggregations

ConfigurationScanner (org.eclipse.gemini.blueprint.extender.support.scanning.ConfigurationScanner)2 ArrayList (java.util.ArrayList)1 DefaultConfigurationScanner (org.eclipse.gemini.blueprint.extender.support.scanning.DefaultConfigurationScanner)1 MockBundle (org.eclipse.gemini.blueprint.mock.MockBundle)1 MockBundleContext (org.eclipse.gemini.blueprint.mock.MockBundleContext)1 Test (org.junit.Test)1 PlatformStatusManagerImpl (org.motechproject.server.osgi.status.PlatformStatusManagerImpl)1 Bundle (org.osgi.framework.Bundle)1