Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) OSGi Alliance (2000, 2012). All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.osgi.framework;
 
A registered service.

The Framework returns a ServiceRegistration object when a BundleContext.registerService method invocation is successful. The ServiceRegistration object is for the private use of the registering bundle and should not be shared with other bundles.

The ServiceRegistration object may be used to update the properties of the service or to unregister the service.

Parameters:
<S> Type of Service.
Version:
$Id: a84248da0db0538708d2394a9478153e06b8afb9 $
See also:
BundleContext.registerService(java.lang.String[],java.lang.Object,java.util.Dictionary)
ThreadSafe:
Noimplement:
 
 
 public interface ServiceRegistration<S> {
Returns a ServiceReference object for a service being registered.

The ServiceReference object may be shared with other bundles.

Returns:
ServiceReference object.
Throws:
java.lang.IllegalStateException If this ServiceRegistration object has already been unregistered.
 
 	public ServiceReference<S> getReference();

Updates the properties associated with a service.

The Constants.OBJECTCLASS and Constants.SERVICE_ID keys cannot be modified by this method. These values are set by the Framework when the service is registered in the OSGi environment.

The following steps are required to modify service properties:

  1. The service's properties are replaced with the provided properties.
  2. A service event of type ServiceEvent.MODIFIED is fired.

Parameters:
properties The properties for this service. See Constants for a list of standard service property keys. Changes should not be made to this object after calling this method. To update the service's properties this method should be called again.
Throws:
java.lang.IllegalStateException If this ServiceRegistration object has already been unregistered.
java.lang.IllegalArgumentException If properties contains case variants of the same key name.
 
 	public void setProperties(Dictionary<String, ?> properties);

Unregisters a service. Remove a ServiceRegistration object from the Framework service registry. All ServiceReference objects associated with this ServiceRegistration object can no longer be used to interact with the service once unregistration is complete.

The following steps are required to unregister a service:

  1. The service is removed from the Framework service registry so that it can no longer be obtained.
  2. A service event of type ServiceEvent.UNREGISTERING is fired so that bundles using this service can release their use of the service. Once delivery of the service event is complete, the ServiceReference objects for the service may no longer be used to get a service object for the service.
  3. For each bundle whose use count for this service is greater than zero:
    The bundle's use count for this service is set to zero.
    If the service was registered with a ServiceFactory object, the ServiceFactory.ungetService method is called to release the service object for the bundle.

	public void unregister();
New to GrepCode? Check out our FAQ X