Package org.osgi.framework

Examples of org.osgi.framework.BundleContext


    private synchronized void reloadExtensionCommands() throws InvalidSyntaxException {
        if(crankstartContext.getOsgiFramework() == null) {
            return;
        }
        extensionCommands.clear();
        final BundleContext bc = crankstartContext.getOsgiFramework().getBundleContext();
        final ServiceReference [] refs = bc.getServiceReferences(CrankstartCommand.class.getName(), null);
        if(refs != null) {
            for(ServiceReference ref : refs) {
                extensionCommands.add((CrankstartCommand)bc.getService(ref));
            }
        }
        log.info("Reloaded extension commands: {}", getDescriptions(extensionCommands));
    }
View Full Code Here


       
        Dictionary<String, Object> properties = commandLine.getProperties();
        if(felixFormat) {
            properties = parseFelixConfig(properties);
        }
        final BundleContext bundleContext = crankstartContext.getOsgiFramework().getBundleContext();
       
        // TODO: wait for configadmin service?
        final String CONFIG_ADMIN_CLASS = "org.osgi.service.cm.ConfigurationAdmin";
        final ServiceReference configAdminRef = bundleContext.getServiceReference(CONFIG_ADMIN_CLASS);
        if(configAdminRef == null) {
            throw new IllegalStateException("Required service is missing:" + CONFIG_ADMIN_CLASS);
        }
       
        @SuppressWarnings("unchecked")
        final Object configAdminService = bundleContext.getService(configAdminRef);
       
        // Use reflection to minimize coupling with the OSGi framework that we are talking to
        Object config = null;
        if(commandLine.getVerb().endsWith(FACTORY_SUFFIX)) {
            config = getExistingConfig(configAdminService, pid, properties);
View Full Code Here

        } else {
            final String prefix = commandLine.getQualifier();
            if(prefix == null || prefix.length() == 0) {
                throw new CrankstartException("Missing command qualifier, required to specify installer resources prefix");
            }
            final BundleContext ctx = crankstartContext.getOsgiFramework().getBundleContext();
            final String serviceClass = OsgiInstaller.class.getName();
            final ServiceReference ref = ctx.getServiceReference(serviceClass);
            if(ref == null) {
                throw new CrankstartException("Installer service not available, cannot register resource (" + serviceClass + ")");
            }
            final OsgiInstaller installer = (OsgiInstaller)ctx.getService(ref);
            try {
                installer.registerResources(prefix, toRegister.toArray(new InstallableResource[] {}));
                log.info("Registered {} resources with installer, using prefix '{}'", toRegister.size(), prefix);
                resources.clear();
            } finally {
                ctx.ungetService(ref);
            }
        }
       
    }
View Full Code Here

        filter = new TestFilterImpl();
        requestPath = "/NO_PATH_YET";
    }
   
    private void setProvider(final TestProvider provider) throws Exception {
        final BundleContext bundleContext = mockery.mock(BundleContext.class);
        final ComponentContext componentContext = mockery.mock(ComponentContext.class);
       
        final Action storeStatus = new Action() {
            public void describeTo(Description d) {
                d.appendText("Store HTTP response values");
View Full Code Here

    @Test
    public void testGetOrCreateNamedQueue() throws Exception {
        JobManager jobManager = mock(JobManager.class);

        BundleContext context = mock(BundleContext.class);
        JobHandlingReplicationQueueProvider jobHandlingReplicationQueueProvider = new JobHandlingReplicationQueueProvider(
                jobManager, context);
        ReplicationQueue queue = jobHandlingReplicationQueueProvider.getInternalQueue("dummy-agent", "default");
        assertNotNull(queue);
    }
View Full Code Here

    public void testEnableQueueProcessing() throws Exception {
        JobManager jobManager = mock(JobManager.class);
        ConfigurationAdmin configAdmin = mock(ConfigurationAdmin.class);
        Configuration config = mock(Configuration.class);
        when(configAdmin.createFactoryConfiguration(QueueConfiguration.class.getName(), null)).thenReturn(config);
        BundleContext context = mock(BundleContext.class);
        JobHandlingReplicationQueueProvider jobHandlingReplicationQueueProvider = new JobHandlingReplicationQueueProvider(
                jobManager, context);
        String agentName = "dummy-agent";
        ReplicationQueueProcessor queueProcessor = mock(ReplicationQueueProcessor.class);
        jobHandlingReplicationQueueProvider.enableQueueProcessing(agentName, queueProcessor);
View Full Code Here

    public void testDisableQueueProcessing() throws Exception {
        JobManager jobManager = mock(JobManager.class);
        ConfigurationAdmin configAdmin = mock(ConfigurationAdmin.class);
        Configuration config = mock(Configuration.class);
        when(configAdmin.createFactoryConfiguration(QueueConfiguration.class.getName(), null)).thenReturn(config);
        BundleContext context = mock(BundleContext.class);
        JobHandlingReplicationQueueProvider jobHandlingReplicationQueueProvider = new JobHandlingReplicationQueueProvider(
                jobManager,  context);
        String agentName = "dummy-agent";
        jobHandlingReplicationQueueProvider.disableQueueProcessing(agentName);
    }
View Full Code Here

public class CoordinatingReplicationAgentFactoryTest {

    @Test
    public void testActivationWithoutConfig() throws Exception {
        CoordinatingReplicationAgentFactory coordinatingReplicationAgentFactory = new CoordinatingReplicationAgentFactory();
        BundleContext context = mock(BundleContext.class);
        Map<String, Object> config = new HashMap<String, Object>();
        try {
            coordinatingReplicationAgentFactory.activate(context, config);
            fail("cannot activate a coordinate agents without exporters/importers");
        } catch (IllegalArgumentException e) {
View Full Code Here

    }

    @Test
    public void testActivationWithEmptyImportersAndExporters() throws Exception {
        CoordinatingReplicationAgentFactory coordinatingReplicationAgentFactory = new CoordinatingReplicationAgentFactory();
        BundleContext context = mock(BundleContext.class);
        Map<String, Object> config = new HashMap<String, Object>();
        config.put(CoordinatingReplicationAgentFactory.PACKAGE_IMPORTER, new String[]{});
        config.put(CoordinatingReplicationAgentFactory.PACKAGE_EXPORTER, new String[]{});
        try {
            coordinatingReplicationAgentFactory.activate(context, config);
View Full Code Here

    @Test
    public void testActivationWithImportersAndExporters() throws Exception {


        BundleContext context = mock(BundleContext.class);
        Map<String, Object> config = new HashMap<String, Object>();
        config.put(CoordinatingReplicationAgentFactory.PACKAGE_IMPORTER, new String[]{"packageBuilder/type=vlt",
                "endpoints[0]=http://host:101/libs/sling/replication/services/exporters/reverse-101",
                "endpoints[1]=http://host:102/libs/sling/replication/services/exporters/reverse-102",
                "endpoints[2]=http://host:103/libs/sling/replication/services/exporters/reverse-103",
View Full Code Here

TOP

Related Classes of org.osgi.framework.BundleContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.