Top Description Inners Fields Constructors Methods
org.osgi.service.remoteserviceadmin

public Class EndpointDescription

extends Object
Class Inheritance
Static Imports
org.osgi.service.remoteserviceadmin.RemoteConstants.*

A description of an endpoint that provides sufficient information for a compatible distribution provider to create a connection to this endpoint An Endpoint Description is easy to transfer between different systems because it is property based where the property keys are strings and the values are simple types. This allows it to be used as a communications device to convey available endpoint information to nodes in a network. An Endpoint Description reflects the perspective of an importer. That is, the property keys have been chosen to match filters that are created by client bundles that need a service. Therefore the map must not contain any service.exported.* property and must contain the corresponding service.imported.* ones. The service.intents property must contain the intents provided by the service itself combined with the intents added by the exporting distribution provider. Qualified intents appear fully expanded on this property.
Author
$Id: a5371a48ad089d08cafc0792f93b8dfe8be33e43 $

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
EndpointDescription.UnmodifiableDictionary<K, V>

Unmodifiable Dictionary wrapper for a Map.

Field Summary

Modifier and TypeField and Description
private final String
private final String
private final List<String>
private final Map<String, Object>
private static final String
private static final int
private final long

Constructor Summary

AccessConstructor and Description
public
EndpointDescription(Map<String, ?>
The map from which to create the Endpoint Description. The keys in the map must be type String and, since the keys are case insensitive, there must be no duplicates with case variation.
properties
)

Create an Endpoint Description from a Map.

public
EndpointDescription(final ServiceReference<?>
A service reference that can be exported.
reference
,
final Map<String, ?>
Map of properties. This argument can be null. The keys in the map must be type String and, since the keys are case insensitive, there must be no duplicates with case variation.
properties
)

Create an Endpoint Description based on a Service Reference and a Map of properties.

Method Summary

Modifier and TypeMethod and Description
private static void
append(StringBuffer
Receiving StringBuffer.
sb
,
Object[]
Object array to append to the specified StringBuffer.
value
)

Append the specified Object array to the specified StringBuffer.

private void
conditionProperties(Map<String, Object>
Property map to condition.
props
)

Condition the properties.

private static <T> List<T>
public boolean

Returns:

true if object is a EndpointDescription and is equal to this object; false otherwise.
equals
(Object
The EndpointDescription object to be compared.
other
)

Overrides java.lang.Object.equals.

Compares this EndpointDescription object to another object.

public List<String>

Returns:

An unmodifiable list of the configuration types used for the associated endpoint and optionally synonyms.
getConfigurationTypes
()

Returns the configuration types.

public String

Returns:

Remote Framework UUID, or null if this endpoint is not associated with an OSGi framework having a framework UUID.
getFrameworkUUID
()

Return the framework UUID for the remote service, if present.

public String

Returns:

The id of the endpoint, never null. The returned value has leading and trailing whitespace removed.
getId
()

Returns the endpoint's id. The id is an opaque id for an endpoint.

public List<String>

Returns:

An unmodifiable list of expanded intents that are provided by this endpoint.
getIntents
()

Return the list of intents implemented by this endpoint.

public List<String>

Returns:

An unmodifiable list of Java interface names implemented by this endpoint.
getInterfaces
()

Provide the list of interfaces implemented by the exported service.

public Version

Returns:

The version of the specified package or Version.emptyVersion if the package has no version in this Endpoint Description.
getPackageVersion
(String
The name of the package for which a version is requested.
packageName
)

Provide the version of the given package name.

public Map<String, Object>

Returns:

An unmodifiable map referring to the properties of this Endpoint Description.
getProperties
()

Returns all endpoint properties.

public long

Returns:

Service id of a service or 0 if this Endpoint Description does not relate to an OSGi service.
getServiceId
()

Returns the service id for the service exported through this endpoint.

private List<String>

Returns:

An unmodifiable list
getStringPlusProperty
(String
The property
key
)

Reads a 'String+' property from the properties map, which may be of type String, String[] or Collection<String> and returns it as an unmodifiable List.

public int

Returns:

An integer which is a hash code value for this object.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.

public boolean

Returns:

True if this endpoint description points to the same service as the other
isSameService
(EndpointDescription
The Endpoint Description to look at
other
)

Answers if this Endpoint Description refers to the same service instance as the given Endpoint Description.

public boolean

Returns:

true If the properties of this EndpointDescription match the filter, false otherwise.
matches
(String
The filter to test.
filter
)

Tests the properties of this EndpointDescription against the given filter using a case insensitive match.

public String

Returns:

String form of this EndpointDescription.
toString
()

Overrides java.lang.Object.toString.

Returns the string representation of this EndpointDescription.

private long

Returns:

The value of the property or 0 if the property is not set.
verifyLongProperty
(String
The name of the property
propName
)

Verify and obtain a required long property.

private List<String>

Returns:

A list with the interface names.
verifyObjectClassProperty
()

Verify and obtain the interface list from the properties.

private String

Returns:

The value of the property or null if the property is not set.
verifyStringProperty
(String
The name of the property
propName
)

Verify and obtain a required String property.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

frameworkUUIDback to summary
private final String frameworkUUID
idback to summary
private final String id
interfacesback to summary
private final List<String> interfaces
propertiesback to summary
private final Map<String, Object> properties
SERVICE_EXPORTED_back to summary
private static final String SERVICE_EXPORTED_
SERVICE_EXPORTED_lengthback to summary
private static final int SERVICE_EXPORTED_length
serviceIdback to summary
private final long serviceId

Constructor Detail

EndpointDescriptionback to summary
public EndpointDescription(Map<String, ?> properties)

Create an Endpoint Description from a Map.

The endpoint.id, service.imported.configs and objectClass properties must be set.

Parameters
properties:Map<String, ?>

The map from which to create the Endpoint Description. The keys in the map must be type String and, since the keys are case insensitive, there must be no duplicates with case variation.

Exceptions
IllegalArgumentException:
When the properties are not proper for an Endpoint Description.
EndpointDescriptionback to summary
public EndpointDescription(final ServiceReference<?> reference, final Map<String, ?> properties)

Create an Endpoint Description based on a Service Reference and a Map of properties. The properties in the map take precedence over the properties in the Service Reference.

This method will automatically set the endpoint.framework.uuid and endpoint.service.id properties based on the specified Service Reference as well as the service.imported property if they are not specified as properties.

The endpoint.id, service.imported.configs and objectClass properties must be set.

Parameters
reference:ServiceReference<?>

A service reference that can be exported.

properties:Map<String, ?>

Map of properties. This argument can be null. The keys in the map must be type String and, since the keys are case insensitive, there must be no duplicates with case variation.

Exceptions
IllegalArgumentException:
When the properties are not proper for an Endpoint Description

Method Detail

appendback to summary
private static void append(StringBuffer sb, Object[] value)

Append the specified Object array to the specified StringBuffer.

Parameters
sb:StringBuffer

Receiving StringBuffer.

value:Object[]

Object array to append to the specified StringBuffer.

conditionPropertiesback to summary
private void conditionProperties(Map<String, Object> props)

Condition the properties.

Parameters
props:Map<String, Object>

Property map to condition.

emptyListback to summary
private static <T> List<T> emptyList()
Annotations
@SuppressWarnings:unchecked
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Compares this EndpointDescription object to another object.

An Endpoint Description is considered to be equal to another Endpoint Description if their ids are equal.

Parameters
other:Object

The EndpointDescription object to be compared.

Returns:boolean

true if object is a EndpointDescription and is equal to this object; false otherwise.

Annotations
@Override
getConfigurationTypesback to summary
public List<String> getConfigurationTypes()

Returns the configuration types. A distribution provider exports a service with an endpoint. This endpoint uses some kind of communications protocol with a set of configuration parameters. There are many different types but each endpoint is configured by only one configuration type. However, a distribution provider can be aware of different configuration types and provide synonyms to increase the change a receiving distribution provider can create a connection to this endpoint. This value of the configuration types is stored in the RemoteConstants#SERVICE_IMPORTED_CONFIGS service property.

Returns:List<String>

An unmodifiable list of the configuration types used for the associated endpoint and optionally synonyms.

getFrameworkUUIDback to summary
public String getFrameworkUUID()

Return the framework UUID for the remote service, if present. The value of the remote framework UUID is stored in the RemoteConstants#ENDPOINT_FRAMEWORK_UUID endpoint property.

Returns:String

Remote Framework UUID, or null if this endpoint is not associated with an OSGi framework having a framework UUID.

getIdback to summary
public String getId()

Returns the endpoint's id. The id is an opaque id for an endpoint. No two different endpoints must have the same id. Two Endpoint Descriptions with the same id must represent the same endpoint. The value of the id is stored in the RemoteConstants#ENDPOINT_ID property.

Returns:String

The id of the endpoint, never null. The returned value has leading and trailing whitespace removed.

getIntentsback to summary
public List<String> getIntents()

Return the list of intents implemented by this endpoint. The intents are based on the service.intents on an imported service, except for any intents that are additionally provided by the importing distribution provider. All qualified intents must have been expanded. This value of the intents is stored in the RemoteConstants#SERVICE_INTENTS service property.

Returns:List<String>

An unmodifiable list of expanded intents that are provided by this endpoint.

getInterfacesback to summary
public List<String> getInterfaces()

Provide the list of interfaces implemented by the exported service. The value of the interfaces is derived from the objectClass property.

Returns:List<String>

An unmodifiable list of Java interface names implemented by this endpoint.

getPackageVersionback to summary
public Version getPackageVersion(String packageName)

Provide the version of the given package name. The version is encoded by prefixing the given package name with endpoint.package.version., and then using this as an endpoint property key. For example:

endpoint.package.version.com.acme
The value of this property is in String format and will be converted to a Version object by this method.
Parameters
packageName:String

The name of the package for which a version is requested.

Returns:Version

The version of the specified package or Version.emptyVersion if the package has no version in this Endpoint Description.

Exceptions
IllegalArgumentException:
If the version property value is not String.
getPropertiesback to summary
public Map<String, Object> getProperties()

Returns all endpoint properties.

Returns:Map<String, Object>

An unmodifiable map referring to the properties of this Endpoint Description.

getServiceIdback to summary
public long getServiceId()

Returns the service id for the service exported through this endpoint. This is the service id under which the framework has registered the service. This field together with the Framework UUID is a globally unique id for a service. The value of the remote service id is stored in the RemoteConstants#ENDPOINT_SERVICE_ID endpoint property.

Returns:long

Service id of a service or 0 if this Endpoint Description does not relate to an OSGi service.

getStringPlusPropertyback to summary
private List<String> getStringPlusProperty(String key)

Reads a 'String+' property from the properties map, which may be of type String, String[] or Collection<String> and returns it as an unmodifiable List.

Parameters
key:String

The property

Returns:List<String>

An unmodifiable list

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.

Returns:int

An integer which is a hash code value for this object.

Annotations
@Override
isSameServiceback to summary
public boolean isSameService(EndpointDescription other)

Answers if this Endpoint Description refers to the same service instance as the given Endpoint Description. Two Endpoint Descriptions point to the same service if they have the same id or their framework UUIDs and remote service ids are equal.

Parameters
other:EndpointDescription

The Endpoint Description to look at

Returns:boolean

True if this endpoint description points to the same service as the other

matchesback to summary
public boolean matches(String filter)

Tests the properties of this EndpointDescription against the given filter using a case insensitive match.

Parameters
filter:String

The filter to test.

Returns:boolean

true If the properties of this EndpointDescription match the filter, false otherwise.

Exceptions
IllegalArgumentException:
If filter contains an invalid filter string that cannot be parsed.
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the string representation of this EndpointDescription.

Returns:String

String form of this EndpointDescription.

Annotations
@Override
verifyLongPropertyback to summary
private long verifyLongProperty(String propName)

Verify and obtain a required long property.

Parameters
propName:String

The name of the property

Returns:long

The value of the property or 0 if the property is not set.

Exceptions
IllegalArgumentException:
when the property doesn't have the correct data type.
verifyObjectClassPropertyback to summary
private List<String> verifyObjectClassProperty()

Verify and obtain the interface list from the properties.

Returns:List<String>

A list with the interface names.

Exceptions
IllegalArgumentException:
If the objectClass property is not set or is empty or if the package version property values are malformed.
verifyStringPropertyback to summary
private String verifyStringProperty(String propName)

Verify and obtain a required String property.

Parameters
propName:String

The name of the property

Returns:String

The value of the property or null if the property is not set.

Exceptions
IllegalArgumentException:
when the property doesn't have the correct data type.
org.osgi.service.remoteserviceadmin back to summary

pack-priv final Class EndpointDescription.UnmodifiableDictionary<K, V>

extends Dictionary<K, V>
Class Inheritance

Unmodifiable Dictionary wrapper for a Map. This class is also used by EndpointPermission.

Field Summary

Modifier and TypeField and Description
private final Map<K, V>

Constructor Summary

AccessConstructor and Description
pack-priv
UnmodifiableDictionary(Map<K, V> wrapped)

Method Summary

Modifier and TypeMethod and Description
public Enumeration<V>
elements()

Implements abstract java.util.Dictionary.elements.

Returns an enumeration of the values in this dictionary.

public V
get(Object
a key in this dictionary. null if the key is not mapped to any value in this dictionary.
key
)

Implements abstract java.util.Dictionary.get.

Returns the value to which the key is mapped in this dictionary.

public boolean
isEmpty()

Implements abstract java.util.Dictionary.isEmpty.

Tests if this dictionary maps no keys to value.

public Enumeration<K>
keys()

Implements abstract java.util.Dictionary.keys.

Returns an enumeration of the keys in this dictionary.

public V
put(K
the hashtable key.
key
,
V
the value.
value
)

Implements abstract java.util.Dictionary.put.

Maps the specified key to the specified value in this dictionary.

public V
remove(Object
the key that needs to be removed.
key
)

Implements abstract java.util.Dictionary.remove.

Removes the key (and its corresponding value) from this dictionary.

public int
size()

Implements abstract java.util.Dictionary.size.

Returns the number of entries (distinct keys) in this dictionary.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Field Detail

wrappedback to summary
private final Map<K, V> wrapped

Constructor Detail

UnmodifiableDictionaryback to summary
pack-priv UnmodifiableDictionary(Map<K, V> wrapped)

Method Detail

elementsback to summary
public Enumeration<V> elements()

Implements abstract java.util.Dictionary.elements.

Doc from java.util.Dictionary.elements.

Returns an enumeration of the values in this dictionary. The general contract for the elements method is that an Enumeration is returned that will generate all the elements contained in entries in this dictionary.

Returns:Enumeration<V>

an enumeration of the values in this dictionary.

Annotations
@Override
getback to summary
public V get(Object key)

Implements abstract java.util.Dictionary.get.

Doc from java.util.Dictionary.get.

Returns the value to which the key is mapped in this dictionary. The general contract for the isEmpty method is that if this dictionary contains an entry for the specified key, the associated value is returned; otherwise, null is returned.

Parameters
key:Object

a key in this dictionary. null if the key is not mapped to any value in this dictionary.

Returns:V

the value to which the key is mapped in this dictionary;

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Implements abstract java.util.Dictionary.isEmpty.

Doc from java.util.Dictionary.isEmpty.

Tests if this dictionary maps no keys to value. The general contract for the isEmpty method is that the result is true if and only if this dictionary contains no entries.

Returns:boolean

true if this dictionary maps no keys to values; false otherwise.

Annotations
@Override
keysback to summary
public Enumeration<K> keys()

Implements abstract java.util.Dictionary.keys.

Doc from java.util.Dictionary.keys.

Returns an enumeration of the keys in this dictionary. The general contract for the keys method is that an Enumeration object is returned that will generate all the keys for which this dictionary contains entries.

Returns:Enumeration<K>

an enumeration of the keys in this dictionary.

Annotations
@Override
putback to summary
public V put(K key, V value)

Implements abstract java.util.Dictionary.put.

Doc from java.util.Dictionary.put.

Maps the specified key to the specified value in this dictionary. Neither the key nor the value can be null.

If this dictionary already contains an entry for the specified key, the value already in this dictionary for that key is returned, after modifying the entry to contain the new element.

If this dictionary does not already have an entry for the specified key, an entry is created for the specified key and value, and null is returned.

The value can be retrieved by calling the get method with a key that is equal to the original key.

Parameters
key:K

the hashtable key.

value:V

the value.

Returns:V

the previous value to which the key was mapped in this dictionary, or null if the key did not have a previous mapping.

Annotations
@Override
removeback to summary
public V remove(Object key)

Implements abstract java.util.Dictionary.remove.

Doc from java.util.Dictionary.remove.

Removes the key (and its corresponding value) from this dictionary. This method does nothing if the key is not in this dictionary.

Parameters
key:Object

the key that needs to be removed.

Returns:V

the value to which the key had been mapped in this dictionary, or null if the key did not have a mapping.

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.Dictionary.size.

Doc from java.util.Dictionary.size.

Returns the number of entries (distinct keys) in this dictionary.

Returns:int

the number of keys in this dictionary.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override