Package org.osgi.service.cm

Examples of org.osgi.service.cm.ManagedService


        this.jettyService = jettyService;
    }

    public Object getService(Bundle bundle, ServiceRegistration registration)
    {
        return new ManagedService()
        {
            public void updated(Dictionary properties)
            {
                jettyService.updated(properties);
            }
View Full Code Here


    private void updateService( ServiceReference<ManagedService> service, final TargetedPID configPid,
        Dictionary<String, ?> properties, long revision, ConfigurationMap<?> configs)
    {
        // Get the ManagedService and terminate here if already
        // unregistered from the framework concurrently
        final ManagedService srv = this.getRealService( service );
        if (srv == null) {
            return;
        }

        // Get the Configuration-to-PID map from the parameter or from
View Full Code Here

    private Object tryToCreateManagedService()
    {
        try
        {
            return new ManagedService()
            {
                @Override
                public void updated( Dictionary<String, ?> properties ) throws ConfigurationException
                {
                    updateFromConfigAdmin(properties);
View Full Code Here

        this.configReceiver = super.context.registerService(ManagedService.class.getName(), new ServiceFactory()
        {
            public Object getService(Bundle bundle, ServiceRegistration registration)
            {
                return new ManagedService()
                {
                    public void updated(@SuppressWarnings("rawtypes") Dictionary properties) throws ConfigurationException
                    {
                        configureFilters(properties);
                    }
View Full Code Here

        BundleContext context = mongoStoreBundle.getBundleContext();

        ServiceReference serviceRef = context.getServiceReference(ManagedService.class.getName());
        assertNotNull(serviceRef);

        ManagedService service = (ManagedService) context.getService(serviceRef);
        try
        {
            service.updated(null);

            Mongo mongo = new Mongo();
            DB db = mongo.getDB("ua_repo");
            DBCollection collection = db.getCollection("useradmin");
            // we always get a collection back, regardless if there is an actual MongoDB listening, hence we should do
View Full Code Here

        }
    }

    @Override
    public void start(final BundleContext context) throws Exception {
        ManagedService managedService = new DataSourceConfig(context);
        Dictionary<String, String> properties = new Hashtable<String, String>();
        properties.put(Constants.SERVICE_PID, "mysqldatasource");
        context.registerService(ManagedService.class, managedService, properties);
    }
View Full Code Here

    // Configuration of baz
    Properties conf = new Properties();
    conf.put("baz", "zab");
    conf.put("bar", new Integer(2));
    conf.put("foo", "foo");
    ManagedService ms = (ManagedService) getContext().getService(msRef);
    try {
      ms.updated(conf);
    } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }

    // Re-check props
    fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
    fooP = (String) fooRef.getProperty("foo");
View Full Code Here

        // Configuration of baz
        Properties conf = new Properties();
        conf.put("baz", "zab");
        conf.put("bar", new Integer(2));
        conf.put("foo", "foo");
        ManagedService ms = (ManagedService) getContext().getService(msRef);
        try {
            ms.updated(conf);
        } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }

        // Recheck props
        fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
        fooP = (String) fooRef.getProperty("foo");
        barP = (Integer) fooRef.getProperty("bar");
        bazP = (String) fooRef.getProperty("baz");
        assertEquals("Check foo equality -2", fooP, "foo");
        assertEquals("Check bar equality -2", barP, new Integer(2));
        assertEquals("Check baz equality -2", bazP, "zab");

        // Get Service
        FooService fs = (FooService) context.getService(fooRef);
        Integer updated = (Integer) fs.fooProps().get("updated");

        assertEquals("Check updated", 1, updated.intValue());

        conf.put("baz", "zab2");
        conf.put("foo", "oof2");
        conf.put("bar", new Integer(0));
        ms = (ManagedService) getContext().getService(msRef);
        try {
            ms.updated(conf);
        } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }

        updated = (Integer) fs.fooProps().get("updated");

        assertEquals("Check updated -2", 2, updated.intValue());
View Full Code Here

      // Configuration of baz
      Properties conf = new Properties();
      conf.put("baz", "zab");
      conf.put("foo", "oof");
      conf.put("bar", new Integer(0));
      ManagedService ms = (ManagedService) getContext().getService(msRef);
      try {
        ms.updated(conf);
      } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }

      // Re-check props
      fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
      fooP = (String) fooRef.getProperty("foo");
      barP = (Integer) fooRef.getProperty("bar");
      bazP = (String) fooRef.getProperty("baz");

      assertEquals("Check foo equality", fooP, "oof");
      assertEquals("Check bar equality", barP, new Integer(0));
      assertEquals("Check baz equality", bazP, "zab");

      // Check field value
      FooService fs = (FooService) getContext().getService(fooRef);
      Properties p = fs.fooProps();
      fooP = (String) p.get("foo");
      barP = (Integer) p.get("bar");

      assertEquals("Check foo field equality", fooP, "oof");
      assertEquals("Check bar field equality", barP, new Integer(0));

        Integer updated = (Integer) fs.fooProps().get("updated");

        assertEquals("Check updated -1", 1, updated.intValue());

        conf.put("baz", "zab2");
        conf.put("foo", "oof2");
        conf.put("bar", new Integer(0));
        ms = (ManagedService) getContext().getService(msRef);
        try {
            ms.updated(conf);
        } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }

        updated = (Integer) fs.fooProps().get("updated");

        assertEquals("Check updated -2", 2, updated.intValue());
View Full Code Here

        // Configuration of baz
        Properties conf = new Properties();
        conf.put("baz", "zab");
        conf.put("foo", "oof");
        conf.put("bar", new Integer(0));
        ManagedService ms = (ManagedService) getContext().getService(msRef);
        try {
            ms.updated(conf);
        } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }

        // Recheck props
        fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
        fooP = (String) fooRef.getProperty("foo");
        barP = (Integer) fooRef.getProperty("bar");
        bazP = (String) fooRef.getProperty("baz");

        assertEquals("Check foo equality", fooP, "oof");
        assertEquals("Check bar equality", barP, new Integer(0));
        assertEquals("Check baz equality", bazP, "zab");

        // Check field value
        FooService fs = (FooService) getContext().getService(fooRef);
        Properties p = fs.fooProps();
        fooP = (String) p.get("foo");
        barP = (Integer) p.get("bar");

        assertEquals("Check foo field equality", fooP, "oof");
        assertEquals("Check bar field equality", barP, new Integer(0));

        Integer updated = (Integer) fs.fooProps().get("updated");

        assertEquals("Check updated", 1, updated.intValue());

        conf.put("baz", "zab2");
        conf.put("foo", "oof2");
        conf.put("bar", new Integer(0));
        ms = (ManagedService) getContext().getService(msRef);
        try {
            ms.updated(conf);
        } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }

        updated = (Integer) fs.fooProps().get("updated");

        assertEquals("Check updated -2", 2, updated.intValue());
View Full Code Here

TOP

Related Classes of org.osgi.service.cm.ManagedService

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.