public class EndpointDescription
extends java.lang.Object
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.Modifier and Type | Class and Description |
---|---|
(package private) static class |
EndpointDescription.UnmodifiableDictionary<K,V>
Unmodifiable Dictionary wrapper for a Map.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
frameworkUUID |
private java.lang.String |
id |
private java.util.List<java.lang.String> |
interfaces |
private java.util.Map<java.lang.String,java.lang.Object> |
properties |
private static java.lang.String |
SERVICE_EXPORTED_ |
private static int |
SERVICE_EXPORTED_length |
private long |
serviceId |
Constructor and Description |
---|
EndpointDescription(java.util.Map<java.lang.String,?> properties)
Create an Endpoint Description from a Map.
|
EndpointDescription(org.osgi.framework.ServiceReference<?> reference,
java.util.Map<java.lang.String,?> properties)
Create an Endpoint Description based on a Service Reference and a Map of
properties.
|
Modifier and Type | Method and Description |
---|---|
private static void |
append(java.lang.StringBuffer sb,
java.lang.Object[] value)
Append the specified Object array to the specified StringBuffer.
|
private void |
conditionProperties(java.util.Map<java.lang.String,java.lang.Object> props)
Condition the properties.
|
private static <T> java.util.List<T> |
emptyList() |
boolean |
equals(java.lang.Object other)
Compares this
EndpointDescription object to another object. |
java.util.List<java.lang.String> |
getConfigurationTypes()
Returns the configuration types.
|
java.lang.String |
getFrameworkUUID()
Return the framework UUID for the remote service, if present.
|
java.lang.String |
getId()
Returns the endpoint's id.
|
java.util.List<java.lang.String> |
getIntents()
Return the list of intents implemented by this endpoint.
|
java.util.List<java.lang.String> |
getInterfaces()
Provide the list of interfaces implemented by the exported service.
|
org.osgi.framework.Version |
getPackageVersion(java.lang.String packageName)
Provide the version of the given package name.
|
java.util.Map<java.lang.String,java.lang.Object> |
getProperties()
Returns all endpoint properties.
|
long |
getServiceId()
Returns the service id for the service exported through this endpoint.
|
private java.util.List<java.lang.String> |
getStringPlusProperty(java.lang.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.
|
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
isSameService(EndpointDescription other)
Answers if this Endpoint Description refers to the same service instance
as the given Endpoint Description.
|
boolean |
matches(java.lang.String filter)
Tests the properties of this
EndpointDescription against the
given filter using a case insensitive match. |
java.lang.String |
toString()
Returns the string representation of this EndpointDescription.
|
private long |
verifyLongProperty(java.lang.String propName)
Verify and obtain a required long property.
|
private java.util.List<java.lang.String> |
verifyObjectClassProperty()
Verify and obtain the interface list from the properties.
|
private java.lang.String |
verifyStringProperty(java.lang.String propName)
Verify and obtain a required String property.
|
private final java.util.Map<java.lang.String,java.lang.Object> properties
private final java.util.List<java.lang.String> interfaces
private final long serviceId
private final java.lang.String frameworkUUID
private final java.lang.String id
private static final java.lang.String SERVICE_EXPORTED_
private static final int SERVICE_EXPORTED_length
public EndpointDescription(java.util.Map<java.lang.String,?> properties)
The endpoint.id
,
service.imported.configs
and objectClass
properties must be set.
properties
- 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.java.lang.IllegalArgumentException
- When the properties are not proper for
an Endpoint Description.public EndpointDescription(org.osgi.framework.ServiceReference<?> reference, java.util.Map<java.lang.String,?> properties)
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.
reference
- A service reference that can be exported.properties
- 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.java.lang.IllegalArgumentException
- When the properties are not proper for
an Endpoint Descriptionprivate void conditionProperties(java.util.Map<java.lang.String,java.lang.Object> props)
props
- Property map to condition.private java.util.List<java.lang.String> verifyObjectClassProperty()
java.lang.IllegalArgumentException
- If the objectClass property is not set
or is empty or if the package version property values are
malformed.private java.lang.String verifyStringProperty(java.lang.String propName)
propName
- The name of the propertynull
if the property is not
set.java.lang.IllegalArgumentException
- when the property doesn't have the
correct data type.private long verifyLongProperty(java.lang.String propName)
propName
- The name of the propertyjava.lang.IllegalArgumentException
- when the property doesn't have the
correct data type.public java.lang.String getId()
RemoteConstants.ENDPOINT_ID
property.null
. The returned value
has leading and trailing whitespace removed.public java.util.List<java.lang.String> getInterfaces()
objectClass
property.public org.osgi.framework.Version getPackageVersion(java.lang.String packageName)
endpoint.package.version.
, and then using this as an endpoint property
key. For example:
endpoint.package.version.com.acmeThe value of this property is in String format and will be converted to a
Version
object by this method.packageName
- The name of the package for which a version is
requested.Version.emptyVersion
if the package has no version in
this Endpoint Description.java.lang.IllegalArgumentException
- If the version property value is not
String.public long getServiceId()
RemoteConstants.ENDPOINT_SERVICE_ID
endpoint property.public java.util.List<java.lang.String> getConfigurationTypes()
RemoteConstants.SERVICE_IMPORTED_CONFIGS
service property.public java.util.List<java.lang.String> getIntents()
RemoteConstants.SERVICE_INTENTS
service property.private java.util.List<java.lang.String> getStringPlusProperty(java.lang.String key)
key
- The propertyprivate static <T> java.util.List<T> emptyList()
public java.lang.String getFrameworkUUID()
RemoteConstants.ENDPOINT_FRAMEWORK_UUID
endpoint property.null
if this endpoint is not
associated with an OSGi framework having a framework UUID.public java.util.Map<java.lang.String,java.lang.Object> getProperties()
public boolean isSameService(EndpointDescription other)
other
- The Endpoint Description to look atpublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object other)
EndpointDescription
object to another object.
An Endpoint Description is considered to be equal to another Endpoint Description if their ids are equal.
equals
in class java.lang.Object
other
- The EndpointDescription
object to be compared.true
if object
is a EndpointDescription
and is equal to this object; false
otherwise.public boolean matches(java.lang.String filter)
EndpointDescription
against the
given filter using a case insensitive match.filter
- The filter to test.true
If the properties of this
EndpointDescription
match the filter, false
otherwise.java.lang.IllegalArgumentException
- If filter
contains an invalid
filter string that cannot be parsed.public java.lang.String toString()
toString
in class java.lang.Object
private static void append(java.lang.StringBuffer sb, java.lang.Object[] value)
sb
- Receiving StringBuffer.value
- Object array to append to the specified StringBuffer.