Examples of ServiceRegistration


Examples of org.osgi.framework.ServiceRegistration

        Object service = item.service;
        Debug.printDebugInfo(10,
            "Unregistering Jini Service in OSGi Framework " +
            item.serviceID.toString());

        ServiceRegistration reg = (ServiceRegistration) services.remove(service);

        if (reg != null) {
            reg.unregister();
        } else {
            Debug.printDebugInfo(10,
                "Service Already Unregistered out OSGi Framework");
        }
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

    System.out.println(bc.getBundle().getHeaders().get
                       (Constants.BUNDLE_NAME) + " starting...");
    Activator.bc = bc;

    DateService         service       = new DateServiceImpl();
    ServiceRegistration registration =
      bc.registerService(DateService.class.getName(),
                         service,
                         new Hashtable());
    System.out.println("Service registered: DateService");
  }
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

    desktop = new Desktop();
    desktop.start();

    DefaultSwingBundleDisplayer disp;

    ServiceRegistration reg;

    String[] dispClassNames = new String[] {
      LargeIconsDisplayer.class.getName(),
      GraphDisplayer.class.getName(),
      TableDisplayer.class.getName(),
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

      }

      for(Iterator it = displayers.keySet().iterator(); it.hasNext();) {
        DefaultSwingBundleDisplayer disp
          = (DefaultSwingBundleDisplayer)it.next();
        ServiceRegistration reg = (ServiceRegistration)displayers.get(disp);

        disp.unregister();
      }
      displayers.clear();
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

        /* create the hashtable to put properties in */
        Hashtable props = new Hashtable();
        /* put service.pid property in hashtable */
        props.put("service.pid", testSuiteAllTests.getName());
        /* register service with the suite for all tests */
        ServiceRegistration serviceRegistration = context.registerService(
                TestSuite.class.getName(), testSuiteAllTests, props);

    }
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

    public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
    }

    public void removedBundle(Bundle bundle, BundleEvent event, Object object) {
        if (object instanceof ServiceRegistration) {
            ServiceRegistration service = (ServiceRegistration) object;
            service.unregister();
        }
    }
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

        installedApis.remove(api.getId());
    }


    public void deleted(String pid) {
        ServiceRegistration oldRegistration = registrations.remove(pid);
        if (oldRegistration != null) {
            oldRegistration.unregister();
        }
    }
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

    public String getName() {
        return "Chef Service Factory";
    }

    public void updated(String pid, Dictionary properties) throws ConfigurationException {
        ServiceRegistration newRegistration = null;
        try {
            if (properties != null) {
                Properties props = new Properties();
                for (Enumeration e = properties.keys(); e.hasMoreElements(); ) {
                    Object key = e.nextElement();
                    Object val = properties.get(key);
                    props.put(key, val);
                }

                String api = (String) properties.get(ChefConstants.API);

                ProviderMetadata providerMetadata = null;
                ApiMetadata apiMetadata = null;
                if (!Strings.isNullOrEmpty(api) && installedApis.containsKey(api)) {
                    apiMetadata = installedApis.get(api);
                    validate(apiMetadata, properties);
                } else {

                    if (!Strings.isNullOrEmpty(api)) {
                        apiPids.put(api, pid);
                    }
                    pendingPids.put(pid, properties);
                    LOGGER.warn("Api {} is not currently installed. Service will resume once the the api is installed.", api);
                    return;
                }

                String id = (String) properties.get(ChefConstants.NAME);
                String clientName = (String) properties.get(ChefConstants.CLIENT_NAME);
                String clientKeyFile = (String) properties.get(ChefConstants.CLIENT_KEY_FILE);
                String clientCredential = (String) properties.get(ChefConstants.CLIENT_CREDENTIAL);
                String validatorName = (String) properties.get(ChefConstants.VALIDATOR_NAME);
                String validatorKeyFile = (String) properties.get(ChefConstants.VALIDATOR_KEY_FILE);
                String validatorCredential = (String) properties.get(ChefConstants.VALIDATOR_CREDENTIAL);
                String endpoint = (String) properties.get(ChefConstants.ENDPOINT);

                ChefService service = ChefHelper.createChefService(apiMetadata, id, clientName, clientCredential, clientKeyFile, validatorName, validatorCredential, validatorKeyFile, endpoint);
                newRegistration = bundleContext.registerService(
                        ChefService.class.getName(), service, properties);

                //If all goes well remove the pending pid.
                if (pendingPids.containsKey(pid)) {
                    activePids.put(pid, pendingPids.remove(pid));
                }
            }
        } catch (InvalidConfigurationException ex) {
            LOGGER.warn("Invalid configuration: {}", ex.getMessage());
        } catch (Exception ex) {
            LOGGER.error("Error creating compute service.", ex);
        } finally {
            ServiceRegistration oldRegistration = (newRegistration == null)
                    ? registrations.remove(pid)
                    : registrations.put(pid, newRegistration);
            if (oldRegistration != null) {
                oldRegistration.unregister();
            }
        }
    }
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

                chefServiceFactory, properties);
    }

    private void registerRecipeProviderForService(BundleContext context, String serviceId, ChefService chefService) {
        ChefRecipeProvider chefRecipeProvider = new ChefRecipeProvider(chefService);
        ServiceRegistration registration = context.registerService(RecipeProvider.class.getName(), chefRecipeProvider, null);
        registrationMap.put(serviceId, registration);
    }
View Full Code Here

Examples of org.osgi.framework.ServiceRegistration

        registrationMap.put(serviceId, registration);
    }

    private void unregisterRecipeProviderForService(BundleContext context, String serviceId, ChefService chefService) {
        if (registrationMap.containsKey(serviceId)) {
            ServiceRegistration registration = registrationMap.remove(serviceId);
            try {
                registration.unregister();
            } catch (Exception ex) {
                //ignore
            }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.