Author: davidb
Date: Mon Jun 8 15:51:23 2009
New Revision: 782687
URL: http://svn.apache.org/viewvc?rev=782687&view=rev
Log:
Made distributed discovery independent of local discovery.
Added:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ServiceEndpointDescriptionImpl.java
(with props)
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/DiscoveredServiceNotification.java
(with props)
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/DiscoveredServiceTracker.java
(with props)
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/Discovery.java
(with props)
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/ServiceEndpointDescription.java
(with props)
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/ServicePublication.java
(with props)
Modified:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/pom.xml
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceDataMonitorListenerImpl.java
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/DiscoveredServiceNotificationImplTest.java
cxf/dosgi/trunk/distribution/discovery-single-bundle/pom.xml
Modified: cxf/dosgi/trunk/discovery/distributed/cxf-discovery/pom.xml
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/pom.xml?rev=782687&r1=782686&r2=782687&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/cxf-discovery/pom.xml (original)
+++ cxf/dosgi/trunk/discovery/distributed/cxf-discovery/pom.xml Mon Jun 8
15:51:23 2009
@@ -56,17 +56,12 @@
<version>${pom.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.cxf.dosgi</groupId>
- <artifactId>cxf-dosgi-ri-discovery-local</artifactId>
- <version>${pom.version}</version>
- </dependency>
-
- <!-- is this really needed? -->
+ <!-- This is a zookeeper dependency that we apparently have to list
here -->
<dependency>
<groupId>org.apache.log4j</groupId>
<artifactId>com.springsource.org.apache.log4j</artifactId>
<version>${log4j.version}</version>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -95,13 +90,15 @@
<Bundle-Activator>org.apache.cxf.dosgi.discovery.zookeeper.Activator</Bundle-Activator>
<Import-Package>
org.apache.zookeeper.*;version="[3.0.0,4.0.0)",
-
org.apache.cxf.dosgi.discovery.local;version=${pom.version},
org.osgi.framework;version="[1.4.0,2.0.0)",
org.osgi.service.discovery;version="[1.0.0,2.0.0)",
org.osgi.util.tracker;version="[1.3.0,2.0.0)",
*
</Import-Package>
-
<Export-Package>org.apache.cxf.dosgi.discovery.zookeeper;version=${pom.version}</Export-Package>
+
<Private-Package>org.apache.cxf.dosgi.discovery.zookeeper</Private-Package>
+ <Export-Package>
+ org.osgi.service.discovery;version="1.0"
+ </Export-Package>
</instructions>
</configuration>
</plugin>
Modified:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceDataMonitorListenerImpl.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceDataMonitorListenerImpl.java?rev=782687&r1=782686&r2=782687&view=diff
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceDataMonitorListenerImpl.java
(original)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceDataMonitorListenerImpl.java
Mon Jun 8 15:51:23 2009
@@ -27,7 +27,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.apache.cxf.dosgi.discovery.local.ServiceEndpointDescriptionImpl;
import org.apache.zookeeper.ZooKeeper;
import org.osgi.service.discovery.DiscoveredServiceNotification;
import org.osgi.service.discovery.DiscoveredServiceTracker;
Added:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ServiceEndpointDescriptionImpl.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ServiceEndpointDescriptionImpl.java?rev=782687&view=auto
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ServiceEndpointDescriptionImpl.java
(added)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ServiceEndpointDescriptionImpl.java
Mon Jun 8 15:51:23 2009
@@ -0,0 +1,125 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cxf.dosgi.discovery.zookeeper;
+
+import static org.osgi.service.discovery.ServicePublication.ENDPOINT_ID;
+import static org.osgi.service.discovery.ServicePublication.ENDPOINT_LOCATION;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.osgi.service.discovery.ServiceEndpointDescription;
+import org.osgi.service.discovery.ServicePublication;
+
+public class ServiceEndpointDescriptionImpl implements
ServiceEndpointDescription {
+
+ private static final Logger LOG =
+ Logger.getLogger(ServiceEndpointDescriptionImpl.class.getName());
+
+ private Set<String> interfaceNames;
+ Map<String, Object> properties;
+
+ public ServiceEndpointDescriptionImpl(String interfaceName) {
+ this(Collections.singletonList(interfaceName));
+ }
+
+ public ServiceEndpointDescriptionImpl(List<String> interfaceNames) {
+ this(interfaceNames,
+ Collections.<String, Object>singletonMap(
+ ServicePublication.SERVICE_INTERFACE_NAME, interfaceNames));
+ }
+
+ public ServiceEndpointDescriptionImpl(List<String> interfaceNames,
+ Map<String, Object> remoteProperties) {
+ this.interfaceNames = new HashSet<String>(interfaceNames);
+ properties = remoteProperties;
+ }
+
+ public Object getProperty(String key) {
+ return properties.get(key);
+ }
+
+ public Map getProperties() {
+ return Collections.unmodifiableMap(properties);
+ }
+
+ public Collection getPropertyKeys() {
+ return getProperties().keySet();
+ }
+
+
+ @Override
+ public int hashCode() {
+ return interfaceNames.hashCode() + 37 * properties.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof ServiceEndpointDescription)) {
+ return false;
+ }
+ ServiceEndpointDescription other = (ServiceEndpointDescription)obj;
+
+ return interfaceNames.equals(other.getProvidedInterfaces())
+ && properties.equals(other.getProperties());
+ }
+
+ public URI getLocation() {
+ Object value = properties.get(ENDPOINT_LOCATION);
+ if (value == null) {
+ return null;
+ }
+
+ try {
+ return new URI(value.toString());
+ } catch (URISyntaxException ex) {
+ LOG.warning("Service document URL is malformed : " +
value.toString());
+ }
+
+ return null;
+ }
+
+ public Collection /*<String>*/ getProvidedInterfaces() {
+ return interfaceNames;
+ }
+
+ public String getVersion(String interfaceName) {
+ return "0.0";
+ }
+
+ public String getEndpointInterfaceName(String interfaceName) {
+ return interfaceName;
+ }
+
+ public String getEndpointID() {
+ Object val = properties.get(ENDPOINT_ID);
+ if (val == null) {
+ return null;
+ } else {
+ return val.toString();
+ }
+ }
+}
Propchange:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ServiceEndpointDescriptionImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ServiceEndpointDescriptionImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/DiscoveredServiceNotification.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/DiscoveredServiceNotification.java?rev=782687&view=auto
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/DiscoveredServiceNotification.java
(added)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/DiscoveredServiceNotification.java
Mon Jun 8 15:51:23 2009
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). 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.service.discovery;
+
+import java.util.Collection;
+
+/**
+ * Interface for notification on discovered services.
+ * <p>
+ * <code>DiscoveredServiceNotification</code> objects are immutable.
+ *
+ * @Immutable
+ * @version $Revision$
+ */
+public interface DiscoveredServiceNotification {
+
+ /**
+ * Notification indicating that a service matching the listening
criteria
+ * has been discovered.
+ * <p>
+ * The value of <code>AVAILABLE</code> is 0x00000001.
+ */
+ public final static int AVAILABLE = 0x00000001;
+
+ /**
+ * Notification indicating that the properties of a previously
discovered
+ * service have changed.
+ * <p>
+ * The value of <code>MODIFIED</code> is 0x00000002.
+ */
+ public final static int MODIFIED = 0x00000002;
+
+ /**
+ * Notification indicating that a previously discovered service is no
longer
+ * known to <code>Discovery</code>.
+ * <p>
+ * The value of <code>UNAVAILABLE</code> is 0x00000004.
+ */
+ public final static int UNAVAILABLE = 0x00000004;
+
+ /**
+ * Notification indicating that the properties of a previously
discovered
+ * service have changed and the new properties no longer match the
+ * listener's filter.
+ * <p>
+ * The value of <code>MODIFIED_ENDMATCH</code> is 0x00000008.
+ */
+ public final static int MODIFIED_ENDMATCH = 0x00000008;
+
+ /**
+ * Returns information currently known to <code>Discovery</code>
regarding
+ * the service endpoint.
+ *
+ * @return metadata of the service <code>Discovery</code> notifies
about. Is
+ * never <code>null</code>.
+ */
+ ServiceEndpointDescription getServiceEndpointDescription();
+
+ /**
+ * Returns the type of notification. The type values are:
+ * <ul>
+ * <li>{...@link #AVAILABLE}</li>
+ * <li>{...@link #MODIFIED}</li>
+ * <li>{...@link #MODIFIED_ENDMATCH}</li>
+ * <li>{...@link #UNAVAILABLE}</li>
+ * </ul>
+ *
+ * @return Type of notification regarding known service metadata.
+ */
+ int getType();
+
+ /**
+ * Returns interface name criteria of the {...@link
DiscoveredServiceTracker}
+ * object matching with the interfaces of the
+ * <code>ServiceEndpointDescription</code> and thus caused the
notification.
+ *
+ * @return <code>Collection (<? extends String>)</code> of
matching interface name criteria of the
+ * <code>DiscoveredServiceTracker</code> object being notified,
or
+ * an empty collection if notification hasn't been caused by a
+ * matching interface name criteria.
+ */
+ Collection/* <? extends String> */getInterfaces();
+
+ /**
+ * Returns filters of the <code>DiscoveredServiceTracker</code> object
+ * matching with the properties of the
+ * <code>ServiceEndpointDescription</code> and thus caused the
notification.
+ *
+ * @return <code>Collection (<? extends String>)</code> of
matching filters of the <code>DiscoveredServiceTracker</code>
+ * object being notified, or an empty collection if notification
+ * hasn't been caused by a matching filter criteria.
+ */
+ Collection/* <? extends String> */getFilters();
+}
\ No newline at end of file
Propchange:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/DiscoveredServiceNotification.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/DiscoveredServiceNotification.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/DiscoveredServiceTracker.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/DiscoveredServiceTracker.java?rev=782687&view=auto
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/DiscoveredServiceTracker.java
(added)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/DiscoveredServiceTracker.java
Mon Jun 8 15:51:23 2009
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). 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.service.discovery;
+
+/**
+ * Interface of trackers for discovered remote services.
+ * <p>
+ * When a service implementing this interface is registered with the framework,
+ * then <code>Discovery</code> will notify it about remote services matching
one
+ * of the provided criteria and will keep notifying it on changes of
information
+ * known to Discovery regarding this services.
+ *
+ * <code>Discovery</code> may deliver notifications on discovered services to a
+ * <code>DiscoveredServiceTracker</code> out of order and may concurrently call
+ * and/or reenter a <code>DiscoveredServiceTracker</code>.
+ *
+ * @ThreadSafe
+ * @version $Revision$
+ */
+public interface DiscoveredServiceTracker {
+
+ /**
+ * Optional ServiceRegistration property which contains service
interfaces
+ * this tracker is interested in.
+ * <p>
+ * Value of this property is of type
+ * <code>Collection (<? extends String>)</code>. May be
+ * <code>null</code> or empty.
+ */
+ public static final String INTERFACE_MATCH_CRITERIA =
"osgi.remote.discovery.interest.interfaces";
+
+ /**
+ * Optional ServiceRegistration property which contains filters for
services
+ * this tracker is interested in.
+ * <p>
+ * Note that these filters need to take into account service publication
+ * properties which are not necessarily the same as properties under
which a
+ * service is registered. See {...@link ServicePublication} for some
standard
+ * properties used to publish service metadata.
+ * <p>
+ * The following sample filter will make <code>Discovery</code> notify
the
+ * <code>DiscoveredServiceTracker</code> about services providing
interface
+ * 'my.company.foo' of version '1.0.1.3':
+ *
<code>"(&(service.interface=my.company.foo)(service.interface.version=my.company.foo|1.0.1.3))"</code>.
+ * <p>
+ * Value of this property is of type
+ * <code>Collection (<? extends String>)</code>. May be
+ * <code>null</code>. or empty
+ */
+ public static final String FILTER_MATCH_CRITERIA =
"osgi.remote.discovery.interest.filters";
+
+ /**
+ * Receives notification that information known to
<code>Discovery</code>
+ * regarding a remote service has changed.
+ * <p>
+ * The tracker is only notified about remote services which fulfill the
+ * matching criteria, either one of the interfaces or one of the
filters,
+ * provided as properties of this service.
+ * <p>
+ * If multiple criteria match, then the tracker is notified about each
of
+ * them. This can be done either by a single notification callback or by
+ * multiple subsequent ones.
+ *
+ * @param notification the <code>DiscoveredServiceNotification</code>
object
+ * describing the change. Is never <code>null</code>.
+ */
+ void serviceChanged(DiscoveredServiceNotification notification);
+}
Propchange:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/DiscoveredServiceTracker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/DiscoveredServiceTracker.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/Discovery.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/Discovery.java?rev=782687&view=auto
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/Discovery.java
(added)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/Discovery.java
Mon Jun 8 15:51:23 2009
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). 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.service.discovery;
+
+/**
+ * Every Discovery Provider registers a service implementing this interface.
+ * This service is registered with extra properties identified at the beginning
+ * of this interface to denote the name of the product providing Discovery
+ * functionality, its version, vendor, used protocols etc..
+ * <p>
+ * Discovery allows to publish services exposed for remote access as well as to
+ * search for remote services. Register a {...@link ServicePublication}
service in
+ * order to publish service metadata and or a {...@link
DiscoveredServiceTracker}
+ * service in order to search for remote services.
+ * <p>
+ * Discovery service implementations usually rely on some discovery protocols
or
+ * other information distribution means.
+ *
+ * @ThreadSafe
+ * @version $Revision$
+ */
+public interface Discovery {
+
+ /**
+ * ServiceRegistration property for the name of the Discovery product.
+ * <p>
+ * Value of this property is of type <code>String</code>.
+ */
+ static final String PRODUCT_NAME =
"osgi.remote.discovery.product";
+
+ /**
+ * ServiceRegistration property for the version of the Discovery
product.
+ * <p>
+ * Value of this property is of type <code>String</code>.
+ */
+ static final String PRODUCT_VERSION =
"osgi.remote.discovery.product.version";
+
+ /**
+ * ServiceRegistration property for the Discovery product vendor name.
+ * <p>
+ * Value of this property is of type <code>String</code>.
+ */
+ static final String VENDOR_NAME =
"osgi.remote.discovery.vendor";
+
+ /**
+ * ServiceRegistration property that lists the discovery protocols used
by
+ * this Discovery service.
+ * <p>
+ * Value of this property is of type
+ * <code>Collection (<? extends String>)</code>.
+ */
+ static final String SUPPORTED_PROTOCOLS =
"osgi.remote.discovery.supported_protocols";
+}
Propchange:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/Discovery.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/Discovery.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/ServiceEndpointDescription.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/ServiceEndpointDescription.java?rev=782687&view=auto
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/ServiceEndpointDescription.java
(added)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/ServiceEndpointDescription.java
Mon Jun 8 15:51:23 2009
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). 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.service.discovery;
+
+import java.net.URI;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * This interface describes an endpoint of a service. This class can be
+ * considered as a wrapper around the property map of a published service and
+ * its endpoint. It provides an API to conveniently access the most important
+ * properties of the service.
+ * <p>
+ * <code>ServiceEndpointDescription</code> objects are immutable.
+ *
+ * @Immutable
+ * @version $Revision$
+ */
+public interface ServiceEndpointDescription {
+
+ /**
+ * Returns the value of the property with key
+ * {...@link ServicePublication#SERVICE_INTERFACE_NAME}.
+ *
+ * @return <code>Collection (<? extends String>)</code> of service
+ * interface names provided by the advertised service endpoint.
The
+ * collection is never <code>null</code> or empty but contains
at
+ * least one service interface.
+ */
+ Collection /* <? extends String> */getProvidedInterfaces();
+
+ /**
+ * Returns non-Java endpoint interface name associated with the given
+ * interface.
+ * <p>
+ * Value of the property with key
+ * {...@link ServicePublication#ENDPOINT_INTERFACE_NAME} is used by this
+ * operation.
+ *
+ * @param interfaceName for which its non-Java endpoint interface name
+ * should be returned.
+ * @return non-Java endpoint interface name, or <code>null</code> if it
+ * hasn't been provided or if given interface name is
+ * <code>null</code>.
+ */
+ String getEndpointInterfaceName(String interfaceName);
+
+ /**
+ * Returns version of the given interface.
+ * <p>
+ * Value of the property with key
+ * {...@link ServicePublication#SERVICE_INTERFACE_VERSION} is used by
this
+ * operation.
+ *
+ * @param interfaceName for which its version should be returned.
+ * @return Version of given service interface, or <code>null</code> if
it
+ * hasn't been provided or if given interface name is
+ * <code>null</code>.
+ */
+ String getVersion(String interfaceName);
+
+ /**
+ * Returns the value of the property with key
+ * {...@link ServicePublication#ENDPOINT_LOCATION}.
+ *
+ * @return The url of the service location, or <code>null</code> if it
+ * hasn't been provided.
+ */
+ URI getLocation();
+
+ /**
+ * Returns the value of the property with key
+ * {...@link ServicePublication#ENDPOINT_ID}.
+ *
+ * @return Unique id of service endpoint, or <code>null</code> if it
hasn't
+ * been provided.
+ */
+ String getEndpointID();
+
+ /**
+ * Getter method for the property value of a given key.
+ *
+ * @param key Name of the property
+ * @return The property value, or <code>null</code> if none is found
for the
+ * given key or if provided key is <code>null</code>.
+ */
+ Object getProperty(String key);
+
+ /**
+ * Returns all names of service endpoint properties.
+ *
+ * @return a <code>Collection (<? extends String>)</code> of
property
+ * names available in the ServiceEndpointDescription. The
collection
+ * is never <code>null</code> or empty but contains at least
names
+ * of mandatory <code>ServicePublication</code> properties.
Since
+ * <code>ServiceEndpointDescription</code> objects are
immutable,
+ * the returned collection is also not going to be updated at a
+ * later point of time.
+ */
+ Collection/* <? extends String> */getPropertyKeys();
+
+ /**
+ * Returns all service endpoint properties.
+ *
+ * @return all properties of the service as a
+ * <code>Map (<String, Object>)</code>. The map is never
+ * <code>null</code> or empty but contains at least mandatory
+ * <code>ServicePublication</code> properties. Since
+ * <code>ServiceEndpointDescription</code> objects are
immutable,
+ * the returned map is also not going to be updated at a later
point
+ * of time.
+ */
+ Map/* <String, Object> */getProperties();
+}
Propchange:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/ServiceEndpointDescription.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/ServiceEndpointDescription.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/ServicePublication.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/ServicePublication.java?rev=782687&view=auto
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/ServicePublication.java
(added)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/ServicePublication.java
Mon Jun 8 15:51:23 2009
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). 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.service.discovery;
+
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Register a service implementing the <code>ServicePublication</code>
interface
+ * in order to publish metadata of a particular service (endpoint) via
+ * Discovery. Metadata which has to be published is given in form of properties
+ * at registration.
+ * <p>
+ * In order to update published service metadata, update the properties
+ * registered with the <code>ServicePublication</code> service. Depending on
+ * Discovery's implementation and underlying protocol it may result in an
update
+ * or new re-publication of the service.
+ * <p>
+ * In order to unpublish the previously published service metadata, unregister
+ * the <code>ServicePublication</code> service.
+ * <p>
+ * Please note that providing the {...@link #SERVICE_INTERFACE_NAME} property
is
+ * mandatory when a <code>ServicePublication</code> service is registered. Note
+ * also that a Discovery implementation may require provision of additional
+ * properties, e.g. some of the standard properties defined below, or may make
+ * special use of them in case they are provided. For example an SLP-based
+ * Discovery might use the value provided with the {...@link
#ENDPOINT_LOCATION}
+ * property for construction of a SLP-URL used to publish the service.
+ * <p>
+ * Also important is that it's not guaranteed that after registering a
+ * <code>ServicePublication</code> object its service metadata is actually
+ * published. Beside the fact that at least one Discovery service has to be
+ * present, the provided properties have to be valid, e.g. shouldn't contain
+ * case variants of the same key name, and the actual publication via Discovery
+ * mechanisms has to succeed.
+ *
+ * @ThreadSafe
+ */
+public interface ServicePublication {
+
+ /**
+ * Mandatory ServiceRegistration property which contains a collection of
+ * full qualified interface names offered by the advertised service
+ * endpoint.
+ * <p>
+ * Value of this property is of type
+ * <code>Collection (<? extends String>)</code>.
+ */
+ public static final String SERVICE_INTERFACE_NAME =
"osgi.remote.service.interfaces";
+
+ /**
+ * Optional ServiceRegistration property which contains a collection of
+ * interface names with their associated version attributes separated by
+ * {...@link #SEPARATOR} e.g. ["my.company.foo|1.3.5",
"my.company.zoo|2.3.5"].
+ * In case no version has been provided for an interface, Discovery may
use
+ * the String-value of
<code>org.osgi.framework.Version.emptyVersion</code>
+ * constant.
+ * <p>
+ * Value of this property is of type
+ * <code>Collection (<? extends String>)</code>, may be
+ * <code>null</code> or empty.
+ */
+ public static final String SERVICE_INTERFACE_VERSION =
"osgi.remote.service.interfaces.version";
+
+ /**
+ * Optional ServiceRegistration property which contains a collection of
+ * interface names with their associated (non-Java) endpoint interface
names
+ * separated by {...@link #SEPARATOR} e.g.:<br>
+ * ["my.company.foo|MyWebService", "my.company.zoo|MyWebService"].
+ * <p>
+ * This (non-Java) endpoint interface name is usually a communication
+ * protocol specific interface, for instance a web service interface
name.
+ * Though this information is usually contained in accompanying
properties
+ * e.g. a wsdl file, Discovery usually doesn't read and interprets such
+ * service meta-data. Providing this information explicitly, might allow
+ * external non-Java applications find services based on this endpoint
+ * interface.
+ * <p>
+ * Value of this property is of type
+ * <code>Collection (<? extends String>)</code>, may be
+ * <code>null</code> or empty.
+ */
+ public static final String ENDPOINT_INTERFACE_NAME =
"osgi.remote.endpoint.interfaces";
+
+ /**
+ * Optional ServiceRegistration property which contains a map of
properties
+ * of the published service.
+ * <p>
+ * Property keys are handled in a case insensitive manner (as OSGi
Framework
+ * does).
+ * <p>
+ * Value of this property is of type <code>Map (String, Object)</code>,
may
+ * be <code>null</code> or empty.
+ */
+ public static final String SERVICE_PROPERTIES
= "osgi.remote.discovery.publication.service.properties";
+
+ /**
+ * Optional property of the published service identifying its location.
This
+ * property is provided as part of the service property map referenced
by
+ * the {...@link #SERVICE_PROPERTIES} ServiceRegistration property.
+ * <p>
+ * Value of this property is of type <code>java.net.URI</code>, may be
+ * <code>null</code>.
+ */
+ public static final String ENDPOINT_LOCATION
= "osgi.remote.endpoint.location";
+
+ /**
+ * Optional property of the published service uniquely identifying its
+ * endpoint. This property is provided as part of the service property
map
+ * referenced by the {...@link #SERVICE_PROPERTIES} ServiceRegistration
+ * property.
+ * <p>
+ * Value of this property is of type <code>String</code>, may be
+ * <code>null</code>.
+ */
+ public static final String ENDPOINT_ID
= "osgi.remote.endpoint.id";
+
+ /**
+ * Separator constant for association of interface-specific values with
the
+ * particular interface name. See also {...@link
#SERVICE_INTERFACE_VERSION}
+ * and {...@link #ENDPOINT_INTERFACE_NAME} properties which describe
such
+ * interface-specific values.
+ */
+ public static final String SEPARATOR
= "|";
+
+ /**
+ * Returns the <code>ServiceReference</code> this publication metadata
is
+ * associated with.
+ *
+ * @return the <code>ServiceReference</code> being published. Is never
+ * <code>null</code>.
+ */
+ ServiceReference getReference();
+}
Propchange:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/ServicePublication.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/discovery/ServicePublication.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/DiscoveredServiceNotificationImplTest.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/DiscoveredServiceNotificationImplTest.java?rev=782687&r1=782686&r2=782687&view=diff
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/DiscoveredServiceNotificationImplTest.java
(original)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/DiscoveredServiceNotificationImplTest.java
Mon Jun 8 15:51:23 2009
@@ -25,7 +25,6 @@
import junit.framework.TestCase;
-import org.apache.cxf.dosgi.discovery.local.ServiceEndpointDescriptionImpl;
import org.osgi.service.discovery.DiscoveredServiceNotification;
import org.osgi.service.discovery.ServiceEndpointDescription;
Modified: cxf/dosgi/trunk/distribution/discovery-single-bundle/pom.xml
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/discovery-single-bundle/pom.xml?rev=782687&r1=782686&r2=782687&view=diff
==============================================================================
--- cxf/dosgi/trunk/distribution/discovery-single-bundle/pom.xml (original)
+++ cxf/dosgi/trunk/distribution/discovery-single-bundle/pom.xml Mon Jun 8
15:51:23 2009
@@ -103,19 +103,19 @@
javax.naming;resolution:=optional,
javax.swing.*;resolution:=optional,
javax.xml.*,
- org.apache.cxf.dosgi.discovery.local;version=${pom.version},
org.osgi.framework;version="[1.4.0,2.0.0)",
org.osgi.service.cm;version="[1.2.0,2.0.0)",
- org.osgi.service.discovery;version="[1.0.0,2.0.0)",
org.osgi.service.packageadmin;version="[1.2.0,2.0.0)",
+ org.osgi.service.discovery;version="[1.0,2.0)",
org.osgi.util.tracker;version="[1.3.0,2.0.0)",
org.w3c.dom,
org.xml.sax.*,
!*
</Import-Package>
+ <!-- TODO move to _exportcontents -->
<Export-Package>
- !*
- </Export-Package>
+ org.osgi.service.discovery;version="1.0"
+ </Export-Package>
<Private-Package>org.apache.cxf.dosgi.discovery.singlebundle</Private-Package>
<Embed-Dependency>*;scope=compile;inline=false</Embed-Dependency>
<Embed-Directory>lib</Embed-Directory>