You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2009/08/19 01:04:29 UTC

svn commit: r805623 [2/2] - in /tuscany/java/sca/modules/node-impl-osgi: META-INF/ src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/ src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/ src/main/java/org/apache/tuscany/sca/osg...

Modified: tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteAdminEvent.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteAdminEvent.java?rev=805623&r1=805622&r2=805623&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteAdminEvent.java (original)
+++ tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteAdminEvent.java Tue Aug 18 23:04:29 2009
@@ -1,148 +1,116 @@
-/*
- *
- * 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.tuscany.sca.osgi.service.remoteadmin;
 
-import java.util.EventObject;
-
 import org.osgi.framework.Bundle;
 
 /**
+ * 
  * Provides the event information for a Remote Admin event.
  * 
  * @Immutable
  */
-public class RemoteAdminEvent extends EventObject {
+public class RemoteAdminEvent {
     /**
-     * A fatal exporting error occurred. The Export Registration has been
-     * closed.
+     * Add an import registration. The Remote Services Admin will call this
+     * method when it imports a service. When this service is registered, the
+     * Remote Service Admin must notify the listener of all existing Import
+     * Registrations.
+     * 
      */
-    public final static int EXPORT_ERROR = 0x1;
+    public static final int IMPORT_REGISTRATION = 1;
 
     /**
      * Add an export registration. The Remote Services Admin will call this
-     * method when it exports a service. When this service is registered,
-     * the Remote Service Admin must notify the listener of all existing
-     * Export Registrations.
+     * method when it exports a service. When this service is registered, the
+     * Remote Service Admin must notify the listener of all existing Export
+     * Registrations.
      */
-    public final static int EXPORT_REGISTRATION = 0x2;
+    public static final int EXPORT_REGISTRATION = 2;
 
     /**
-     * Remove an export registration. The Remote Services Admin will call
-     * this method when it removes the export of a service.
+     * Remove an export registration. The Remote Services Admin will call this
+     * method when it removes the export of a service.
+     * 
      */
-    public final static int EXPORT_UNREGISTRATION = 0x4;
+    public static final int EXPORT_UNREGISTRATION = 3;
 
     /**
-     * A problematic situation occurred, the export is still active.
+     * Remove an import registration. The Remote Services Admin will call this
+     * method when it removes the import of a service.
+     * 
      */
-    public final static int EXPORT_WARNING = 0x8;
+    public static final int IMPORT_UNREGISTRATION = 4;
 
     /**
      * A fatal importing error occurred. The Import Registration has been
      * closed.
      */
-    public final static int IMPORT_ERROR = 0x10;
+    public static final int IMPORT_ERROR = 5;
 
     /**
-     * Add an import registration. The Remote Services Admin will call this
-     * method when it imports a service. When this service is registered,
-     * the Remote Service Admin must notify the listener of all existing
-     * Import Registrations.
+     * A fatal exporting error occurred. The Export Registration has been
+     * closed.
      */
-    public final static int IMPORT_REGISTRATION = 0x20;
+    public static final int EXPORT_ERROR = 6;
 
     /**
-     * Remove an import registration. The Remote Services Admin will call
-     * this method when it removes the import of a service.
+     * A problematic situation occurred, the export is still active.
      */
-    public final static int IMPORT_UNREGISTRATION = 0x40;
-
+    public static final int EXPORT_WARNING = 7;
     /**
      * A problematic situation occurred, the import is still active.
      */
-    public final static int IMPORT_WARNING = 0x80;
+    public static final int IMPORT_WARNING = 8;
 
-    private static final long serialVersionUID = -6562225073284539118L;
-    private Throwable exception;
-    private ExportRegistration exportRegistration;
     private ImportRegistration importRegistration;
+    private ExportRegistration exportRegistration;
+    private Throwable exception;
     private int type;
+    private Bundle source;
 
-    public RemoteAdminEvent(Bundle source, int type, ExportRegistration registration, Throwable exception) {
-        super(source);
-        this.type = type;
-        this.exportRegistration = registration;
-        this.exception = exception;
-    }
-
-    public RemoteAdminEvent(Bundle source, int type, ImportRegistration registration, Throwable exception) {
-        super(source);
+    RemoteAdminEvent(int type,
+                     Bundle source,
+                     ImportRegistration importRegistration,
+                     ExportRegistration exportRegistration,
+                     Throwable exception) {
         this.type = type;
-        this.importRegistration = registration;
+        this.source = source;
+        this.importRegistration = importRegistration;
+        this.exportRegistration = exportRegistration;
         this.exception = exception;
     }
 
     /**
-     * Returns the exception
-     * 
-     * @return
+     * @return the importRegistration
      */
-    public Throwable getException() {
-        return exception;
+    public ImportRegistration getImportRegistration() {
+        return importRegistration;
     }
 
     /**
-     * Returns the exportRegistration
-     * 
-     * @return
+     * @return the exportRegistration
      */
     public ExportRegistration getExportRegistration() {
         return exportRegistration;
     }
 
     /**
-     * Returns the importRegistration
-     * 
-     * @return
+     * @return the exception
      */
-    public ImportRegistration getImportRegistration() {
-        return importRegistration;
+    public Throwable getException() {
+        return exception;
     }
 
     /**
-     * Returns the source
-     * 
-     * @return
+     * @return the type
      */
-    public Bundle getSource() {
-        return (Bundle)source;
+    public int getType() {
+        return type;
     }
 
     /**
-     * Returns the type
-     * 
-     * @return
+     * @return the source
      */
-    public int getType() {
-        return type;
+    public Bundle getSource() {
+        return source;
     }
-
 }

Modified: tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteAdminListener.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteAdminListener.java?rev=805623&r1=805622&r2=805623&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteAdminListener.java (original)
+++ tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteAdminListener.java Tue Aug 18 23:04:29 2009
@@ -1,23 +1,3 @@
-/*
- *
- * 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.tuscany.sca.osgi.service.remoteadmin;
 
 /**
@@ -26,11 +6,10 @@
  * 
  * @ThreadSafe
  */
+
 public interface RemoteAdminListener {
     /**
-     * Notify of a remote admin event
-     * 
-     * @param event The remote admin event
+     * @param event
      */
-    public void remoteAdminEvent(RemoteAdminEvent event);
+    void remoteAdminEvent(RemoteAdminEvent event);
 }

Modified: tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteConstants.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteConstants.java?rev=805623&r1=805622&r2=805623&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteConstants.java (original)
+++ tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteConstants.java Tue Aug 18 23:04:29 2009
@@ -1,130 +1,119 @@
-/*
- *
- * 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.tuscany.sca.osgi.service.remoteadmin;
 
 /**
  * Provide the definition of the constants used in the Remote Services API.
+ * 
  */
 public class RemoteConstants {
-    /**
-     * The property key for the endpoint URI. This is a unique id for an
-     * endpoint following the URI syntax. As far as this specification is
-     * concerned, this unique id is opaque.
-     */
-    public static final String ENDPOINT_URI = "endpoint.uri";
+    private RemoteConstants() {
+    }
 
     /**
-     * The key for a framework property that defines the UUID of the framework.
-     * The property must be set by the framework or through configuration before
-     * the VM is started or some bundle. The value must be a Universally Unique
-     * Id, it must not contain any dots ('.' .).
-     */
-    public static final String FRAMEWORK_UUID = "org.osgi.framework.uuid";
-
-    /**
-     * The configuration types supported by this Distribution Provider. Services
-     * that are suitable for distribution list the configuration types that
-     * describe the configuration information for that service in the
-     * SERVICE_EXPORTED_CONFIGS or SERVICE_IMPORTED_CONFIGS property. A
-     * distribution provider must register a service that has this property and
-     * enumerate all configuration types that it supports. The type of this
-     * property String+
+     * The configuration types supported by this Distribution Provider.
+     * 
+     * Services that are suitable for distribution list the configuration types
+     * that describe the configuration information for that service in the
+     * {@link #SERVICE_EXPORTED_CONFIGS} or {@link #SERVICE_IMPORTED_CONFIGS}
+     * property.
+     * 
+     * A distribution provider must register a service that has this property
+     * and enumerate all configuration types that it supports.
+     * 
+     * The type of this property <code>String+</code>
      * 
-     * @see SERVICE_EXPORTED_CONFIGS
-     * @see SERVICE_IMPORTED_CONFIGS
+     * @see #SERVICE_EXPORTED_CONFIGS
+     * @see #SERVICE_IMPORTED_CONFIGS
      */
-    public static final String REMOTE_CONFIGS_SUPPORTED = "remote.configs.supported";
+    public final static String REMOTE_CONFIGS_SUPPORTED = "remote.configs.supported";
 
     /**
      * Service property that lists the intents supported by the distribution
-     * provider. Each distribution provider must register a service that has
-     * this property and enumerate all the supported intents, having any
-     * qualified intents expanded. The value of this property is of type
-     * String+. 
-     * 
-     * @see SERVICE_INTENTS
-     * @see SERVICE_EXPORTED_INTENTS
-     * @see SERVICE_EXPORTED_INTENTS_EXTRA
+     * provider.
+     * 
+     * Each distribution provider must register a service that has this property
+     * and enumerate all the supported intents, having any qualified intents
+     * expanded.
+     * 
+     * The value of this property is of type <code>String+</code>.
+     * 
+     * @see #SERVICE_INTENTS
+     * @see #SERVICE_EXPORTED_INTENTS
+     * @see #SERVICE_EXPORTED_INTENTS_EXTRA
      */
-    public static final String REMOTE_INTENTS_SUPPORTED = "remote.intents.supported";
+    public final static String REMOTE_INTENTS_SUPPORTED = "remote.intents.supported";
 
     /**
-     * A list of configuration types that should be used to export the service.
-     * Configuration types can be synonymous or alternatives. In principle, a
-     * distribution provider should create an endpoint for each recognized
-     * configuration type, the deployer is responsible that synonyms do not
-     * clash. Each configuration type has an associated specification that
-     * describes how the configuration data for the exported service is
-     * represented in an OSGi framework. The value of this property is of type
-     * String+.
+     * Defines the interfaces under which this service can be exported.
+     * 
+     * This list must be a subset of the types listed in the objectClass service
+     * property. The single value of an asterisk ('*' \u002A) indicates all
+     * interfaces in the registration's objectClass property (not classes). It
+     * is highly recommended to only export interfaces and not concrete classes
+     * due to the complexity of creating proxies for some type of classes.
+     * 
+     * The value of this property is of type String+.
      */
-    public static final String SERVICE_EXPORTED_CONFIGS = "service.exported.configs";
+    public final static String SERVICE_EXPORTED_INTERFACES = "service.exported.interfaces";
 
     /**
      * A list of intents that the distribution provider must implement to
      * distribute the service. Intents listed in this property are reserved for
      * intents that are critical for the code to function correctly, for
      * example, ordering of messages. These intents should not be configurable.
-     * The value of this property is of type String+.
+     * 
+     * The value of this property is of type <code>String+</code>.
      */
-    public static final String SERVICE_EXPORTED_INTENTS = "service.exported.intents";
+    public final static String SERVICE_EXPORTED_INTENTS = "service.exported.intents";
 
     /**
      * Extra intents configured in addition to the the intents specified in
-     * SERVICE_EXPORTED_INTENTS. These intents are merged with the service.
-     * exported.intents and therefore have the same semantics. They are extra,
-     * so that the SERVICE_EXPORTED_INTENTS can be set by the bundle developer
-     * and this property is then set by the administrator/deployer. Bundles
-     * should make this property configurable, for example through the
-     * Configuration Admin service. The value of this property is of type
-     * String+.
-     */
-    public static final String SERVICE_EXPORTED_INTENTS_EXTRA = "service.exported.intents.extra";
+     * {@link #SERVICE_EXPORTED_INTENTS}.
+     * 
+     * These intents are merged with the service.exported.intents and therefore
+     * have the same semantics. They are extra, so that the
+     * {@link #SERVICE_EXPORTED_INTENTS} can be set by the bundle developer and
+     * this property is then set by the administrator/deployer. Bundles should
+     * make this property configurable, for example through the Configuration
+     * Admin service.
+     * 
+     * The value of this property is of type <code>String+</code>.
+     */
+    public final static String SERVICE_EXPORTED_INTENTS_EXTRA = "service.exported.intents.extra";
 
     /**
-     * Defines the interfaces under which this service can be exported. This
-     * list must be a subset of the types listed in the objectClass service
-     * property. The single value of an asterisk ('*' *) indicates all
-     * interfaces in the registration's objectClass property (not classes). It
-     * is highly recommended to only export interfaces and not concrete classes
-     * due to the complexity of creating proxies for some type of classes. The
-     * value of this property is of type String+.
+     * A list of configuration types that should be used to export the service.
+     * 
+     * Configuration types can be <em>synonymous</em> or <em>alternatives</em>.
+     * In principle, a distribution provider should create an endpoint for each
+     * recognized configuration type, the deployer is responsible that synonyms
+     * do not clash.
+     * 
+     * Each configuration type has an associated specification that describes
+     * how the configuration data for the exported service is represented in an
+     * OSGi framework.
+     * 
+     * The value of this property is of type <code>String+</code>.
      */
-    public static final String SERVICE_EXPORTED_INTERFACES = "service.exported.interfaces";
+    public final static String SERVICE_EXPORTED_CONFIGS = "service.exported.configs";
 
     /**
-     * Must be set by a distribution provider to true when it registers the
-     * end-point proxy as an imported service. Can be used by a bundle to
-     * prevent it from getting an imported service. The value of this property
-     * is not defined, setting it is sufficient.
+     * Must be set by a distribution provider to <code>true</code> when it
+     * registers the end-point proxy as an imported service. Can be used by a
+     * bundle to prevent it from getting an imported service.
+     * 
+     * The value of this property is not defined, setting it is sufficient.
      */
-    public static final String SERVICE_IMPORTED = "service.imported";
+    public final static String SERVICE_IMPORTED = "service.imported";
 
     /**
      * The configuration type used to import this services, as described in
-     * SERVICE_EXPORTED_CONFIGS. Any associated properties for this
+     * {@link #SERVICE_EXPORTED_CONFIGS}. Any associated properties for this
      * configuration types must be properly mapped to the importing system. For
      * example, a URL in these properties must point to a valid resource when
      * used in the importing framework. Configuration types in this property
-     * must be synonymous. The value of this property is of type String+.
+     * must be synonymous.
+     *
+     * The value of this property is of type <code>String+</code>.
      */
     public final String SERVICE_IMPORTED_CONFIGS = "service.imported.configs";
 
@@ -136,8 +125,32 @@
      * must use this property to convey the combined intents of the exporting
      * service and the intents that the distribution providers add. To export a
      * service, a distribution provider must recognize all these intents and
-     * expand any qualified intents. The value of this property is of type
-     * String+.
+     * expand any qualified intents.
+     * 
+     * The value of this property is of type <code>String+</code>.
+     */
+    public final static String SERVICE_INTENTS = "service.intents";
+
+    /**
+     * The property key for the endpoint URI. This is a unique id for an
+     * endpoint following the URI syntax. As far as this specification is
+     * concerned, this unique id is opaque.
+     */
+    final public static String ENDPOINT_URI = "endpoint.uri";
+
+    /**
+     * The property key for the endpoint service id. This is a unique id for a
+     * service based on the framework id '.' service id or another model. As far as this specification is
+     * concerned, this unique id is opaque.
+     */
+    final public static String ENDPOINT_REMOTE_SERVICE_ID = "endpoint.remote.service.id";
+
+    /**
+     * The key for a framework property that defines the UUID of the framework.
+     * 
+     * The property must be set by the framework or through configuration before
+     * the VM is started or some bundle. The value must be a Universally Unique
+     * Id, it must not contain any dots ('.' \u002E).
      */
-    public static final String SERVICE_INTENTS = "service.intents";
+    public final static String FRAMEWORK_UUID = "org.osgi.framework.uuid";
 }

Modified: tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteServiceAdmin.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteServiceAdmin.java?rev=805623&r1=805622&r2=805623&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteServiceAdmin.java (original)
+++ tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/RemoteServiceAdmin.java Tue Aug 18 23:04:29 2009
@@ -1,54 +1,39 @@
-/*
- * 
- * 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.tuscany.sca.osgi.service.remoteadmin;
 
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
-import org.osgi.framework.ServiceReference;
+import org.osgi.framework.*;
 
 /**
- * A Remote Service Admin manages the import and export of services. A
- * Distribution Provider can expose a control interface. This interface allows
- * the a remote controller to control the export and import of services. The API
- * allows a remote controller to export a service, to import a service, and find
- * out about the current imports and exports.
+ * A Remote Service Admin manages the import and export of services.
+ * 
+ * A Distribution Provider can expose a control interface. This interface allows
+ * the a remote controller to control the export and import of services.
+ * 
+ * The API allows a remote controller to export a service, to import a service,
+ * and find out about the current imports and exports.
  * 
  * @ThreadSafe
  */
-
 public interface RemoteServiceAdmin {
+
     /**
      * Export a service to an endpoint. The Remote Service Admin must create an
      * endpoint that can be used by other Distrbution Providers to connect to
      * this Remote Service Admin and use the exported service. This method can
-     * return null if the service could not be exported.
+     * return null if the service could not be exported. ### do we need
+     * exceptions?
      * 
-     * @param ref The Service Reference to export
-     * @return Export Registration that combines the Endpoint Description and
-     *         the Service Reference or <code>null</code if the service could
-     *         not be exported
+     * @param ref
+     *            The Service Reference to export
+     * @return An Export Registration that combines the Endpoint Description and
+     *         the Service Reference or
+     *         <code>null</code> if the service could not be exported
+     * @throws IllegalArgumentException 
+     * @throws UnsupportedOperationException 
      */
-    public List<ExportRegistration> exportService(ServiceReference ref);
+    List/*<ExportRegistration>*/exportService(ServiceReference ref) throws IllegalArgumentException,
+        UnsupportedOperationException;
 
     /**
      * Export a service to a given endpoint. The Remote Service Admin must
@@ -56,46 +41,51 @@
      * Distrbution Providers to connect to this Remote Service Admin and use the
      * exported service. This method can return null if the service could not be
      * exported because the endpoint could not be implemented by this Remote
-     * Service Admin.
+     * Service Admin. ### do we need exceptions?
      * 
-     * @param ref The Service Reference to export
-     * @param properties The properties to create a local endpoint that can be
-     *            implemented by this Remote Service Admin. If this is null, the
-     *            endpoint will be determined by the properties on the service,
-     * @see exportService(ServiceReference). The properties are the same as
-     *      given for an exported service. They are overlaid over any properties
-     *      the service defines
-     * @return Export Registration that combines the Endpoint Description and
-     *         the Service Reference or <code>null</code if the service could
-     *         not be exported
+     * @param ref
+     *            The Service Reference to export
+     * @param properties
+     *            The properties to create a local endpoint that can be implemented by
+     *            this Remote Service Admin. If this is null, the endpoint will
+     *            be determined by the properties on the service, see
+     *            {@link #exportService(ServiceReference)}. The properties are
+     *            the same as given for an exported service. They are overlaid 
+     *            over any properties the service defines.
+     * @return An Export Registration that combines the Endpoint Description and
+     *         the Service Reference or
+     *         <code>null</code> if the service could not be exported
+     * @throws IllegalArgumentException 
+     * @throws UnsupportedOperationException 
      */
-    public List<ExportRegistration> exportService(ServiceReference ref, Map<String, Object> properties);
+    List/*<ExportRegistration>*/exportService(ServiceReference ref, Map/*<String,Object>*/properties)
+        throws IllegalArgumentException, UnsupportedOperationException;
 
     /**
-     * Answer the currently active Export Registrations.
+     * Import a service from an endpoint. The Remote Service Admin must use the
+     * given endpoint to create a proxy. This method can return null if the
+     * service could not be imported. ### do we need exceptions?
      * 
-     * @return Returns A collection of Export Registrations that are currently
-     *         active.
+     * @param endpoint
+     *            The Endpoint Description to be used for import
+     * @return An Import Registration that combines the Endpoint Description and
+     *         the Service Reference or
+     *         <code>null</code> if the endpoint could not be imported
      */
-    public Collection<ExportRegistration> getExportedServices();
+    ImportRegistration importService(EndpointDescription endpoint);
 
     /**
-     * Answer the currently active Import Registrations.
+     * Answer the currently active Export Registrations.
      * 
-     * @return Returns A collection of Import Registrations that are currently
-     *         active.
+     * @return A collection of Export Registrations that are currently active.
      */
-    public Collection<ImportRegistration> getImportedEndpoints();
+    Collection/*<? extends ExportRegistration>*/getExportedServices();
 
     /**
-     * Import a service from an endpoint. The Remote Service Admin must use the
-     * given endpoint to create a proxy. This method can return null if the
-     * service could not be imported.
+     * Answer the currently active Import Registrations.
      * 
-     * @param endpoint The Endpoint Description to be used for import
-     * @return An Import Registration that combines the Endpoint Description and
-     *         the Service Reference or <code>null</code if the endpoint could
-     *         not be imported
+     * @return A collection of Import Registrations that are currently active.
      */
-    public ImportRegistration importService(EndpointDescription endpoint);
+    Collection/*<? extends ImportRegistration>*/getImportedEndpoints();
+
 }

Modified: tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/impl/EndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/impl/EndpointDescriptionImpl.java?rev=805623&r1=805622&r2=805623&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/impl/EndpointDescriptionImpl.java (original)
+++ tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/impl/EndpointDescriptionImpl.java Tue Aug 18 23:04:29 2009
@@ -19,14 +19,10 @@
 
 package org.apache.tuscany.sca.osgi.service.remoteadmin.impl;
 
-import static org.apache.tuscany.sca.osgi.service.remoteadmin.RemoteConstants.SERVICE_EXPORTED_INTERFACES;
-
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
@@ -38,37 +34,50 @@
 import org.apache.tuscany.sca.osgi.service.remoteadmin.EndpointDescription;
 import org.apache.tuscany.sca.osgi.service.remoteadmin.RemoteConstants;
 import org.apache.tuscany.sca.policy.Intent;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
 import org.osgi.framework.Version;
 
 /**
  * Implementation of {@link EndpointDescription}
  */
-public class EndpointDescriptionImpl implements EndpointDescription {
-    private Endpoint endpoint;
-
+public class EndpointDescriptionImpl extends EndpointDescription {
     private static final Logger logger = Logger.getLogger(EndpointDescriptionImpl.class.getName());
+    private Endpoint endpoint;
 
-    private Collection<String> interfaces;
-    private Map<String, Object> properties;
+    /**
+     * @param properties
+     * @throws IllegalArgumentException
+     */
+    public EndpointDescriptionImpl(Map properties) throws IllegalArgumentException {
+        super(properties);
+        this.endpoint = (Endpoint)getProperties().get(Endpoint.class.getName());
+    }
 
-    public EndpointDescriptionImpl(Collection<String> interfaceNames) {
-        this(interfaceNames, Collections.<String, Object> singletonMap(SERVICE_EXPORTED_INTERFACES, interfaceNames));
+    /**
+     * @param ref
+     * @throws IllegalArgumentException
+     */
+    public EndpointDescriptionImpl(ServiceReference ref) throws IllegalArgumentException {
+        super(ref);
+        this.endpoint = (Endpoint)getProperties().get(Endpoint.class.getName());
     }
 
-    public EndpointDescriptionImpl(Collection<String> interfaceNames, Map<String, Object> remoteProperties) {
-        this.interfaces = new HashSet<String>(interfaceNames);
-        this.properties =
-            remoteProperties == null ? new HashMap<String, Object>() : new HashMap<String, Object>(remoteProperties);
-        this.properties.put(RemoteConstants.SERVICE_EXPORTED_INTERFACES, interfaceNames);
-        this.endpoint = (Endpoint) properties.get(Endpoint.class.getName());
+    public EndpointDescriptionImpl(Collection<String> interfaces, String remoteServiceId, String uri) {
+        super(getProperties(interfaces, remoteServiceId, uri));
+        this.endpoint = (Endpoint)getProperties().get(Endpoint.class.getName());
     }
 
-    public EndpointDescriptionImpl(String interfaceName) {
-        this(Collections.singleton(interfaceName));
+    private static Map<String, Object> getProperties(Collection<String> interfaces, String remoteServiceId, String uri) {
+        Map<String, Object> props = new HashMap<String, Object>();
+        props.put(Constants.OBJECTCLASS, interfaces.toArray(new String[interfaces.size()]));
+        props.put(RemoteConstants.ENDPOINT_REMOTE_SERVICE_ID, remoteServiceId);
+        props.put(RemoteConstants.ENDPOINT_URI, uri);
+        return props;
     }
 
     public EndpointDescriptionImpl(Endpoint endpoint) {
-        this(getInterfaces(endpoint), getProperties(endpoint));
+        this(getProperties(endpoint));
         this.endpoint = endpoint;
     }
 
@@ -97,31 +106,20 @@
         return Version.emptyVersion;
     }
 
-    /**
-     * @see org.apache.tuscany.sca.osgi.service.remoteadmin.EndpointDescription#getInterfaces()
-     */
-    public List<String> getInterfaces() {
-        return new ArrayList<String>(interfaces);
-    }
-
     private static List<String> getInterfaces(Endpoint endpoint) {
         Interface intf = endpoint.getInterfaceContract().getInterface();
         JavaInterface javaInterface = (JavaInterface)intf;
         return Collections.singletonList(javaInterface.getName());
     }
 
-    /**
-     * @see org.apache.tuscany.sca.osgi.service.remoteadmin.EndpointDescription#getProperties()
-     */
-    public Map<String, Object> getProperties() {
-        return Collections.unmodifiableMap(properties); // endpoint.getService().getExtensions();
-    }
-
     private static Map<String, Object> getProperties(Endpoint endpoint) {
         Map<String, Object> props = new HashMap<String, Object>();
         props.put(RemoteConstants.ENDPOINT_URI, endpoint.getURI());
+        props.put(RemoteConstants.ENDPOINT_REMOTE_SERVICE_ID, UUID.randomUUID().toString());
         props.put(RemoteConstants.SERVICE_EXPORTED_CONFIGS, new String[] {"sca"});
         props.put(Endpoint.class.getName(), endpoint);
+        List<String> interfaces = getInterfaces(endpoint);
+        props.put(Constants.OBJECTCLASS, interfaces.toArray(new String[interfaces.size()]));
         return props;
     }
 
@@ -135,11 +133,11 @@
     /**
      * @see org.apache.tuscany.sca.osgi.service.remoteadmin.EndpointDescription#getURI()
      */
-    public URI getURI() {
+    public String getURI() {
         if (endpoint != null) {
-            return URI.create(endpoint.getURI());
+            return endpoint.getURI();
         } else {
-            return URI.create("urn:" + UUID.randomUUID());
+            return super.getURI();
         }
     }
 

Modified: tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/impl/RemoteControllerImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/impl/RemoteControllerImpl.java?rev=805623&r1=805622&r2=805623&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/impl/RemoteControllerImpl.java (original)
+++ tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/impl/RemoteControllerImpl.java Tue Aug 18 23:04:29 2009
@@ -31,9 +31,7 @@
 import static org.apache.tuscany.sca.osgi.service.remoteadmin.RemoteConstants.SERVICE_EXPORTED_CONFIGS;
 import static org.apache.tuscany.sca.osgi.service.remoteadmin.RemoteConstants.SERVICE_IMPORTED;
 
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -42,18 +40,21 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.tuscany.sca.common.java.collection.CollectionMap;
 import org.apache.tuscany.sca.core.LifeCycleListener;
 import org.apache.tuscany.sca.osgi.service.remoteadmin.EndpointDescription;
 import org.apache.tuscany.sca.osgi.service.remoteadmin.EndpointListener;
 import org.apache.tuscany.sca.osgi.service.remoteadmin.ExportRegistration;
 import org.apache.tuscany.sca.osgi.service.remoteadmin.ImportRegistration;
-import org.apache.tuscany.sca.osgi.service.remoteadmin.RemoteServiceAdmin;
 import org.apache.tuscany.sca.osgi.service.remoteadmin.RemoteAdminEvent;
 import org.apache.tuscany.sca.osgi.service.remoteadmin.RemoteAdminListener;
+import org.apache.tuscany.sca.osgi.service.remoteadmin.RemoteServiceAdmin;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
 import org.osgi.framework.Filter;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
@@ -79,12 +80,12 @@
     private ServiceTracker remotableServices;
 
     // Service listeners keyed by the filter
-    private MappedCollections<String, ListenerInfo> serviceListeners = new MappedCollections<String, ListenerInfo>();
+    private CollectionMap<String, ListenerInfo> serviceListeners = new CollectionMap<String, ListenerInfo>();
 
-    private MappedCollections<ServiceReference, ExportRegistration> exportedServices =
-        new MappedCollections<ServiceReference, ExportRegistration>();
-    private MappedCollections<EndpointDescription, ImportRegistration> importedServices =
-        new MappedCollections<EndpointDescription, ImportRegistration>();
+    private CollectionMap<ServiceReference, ExportRegistration> exportedServices =
+        new CollectionMap<ServiceReference, ExportRegistration>();
+    private CollectionMap<EndpointDescription, ImportRegistration> importedServices =
+        new CollectionMap<EndpointDescription, ImportRegistration>();
 
     private Filter remotableServiceFilter;
 
@@ -186,7 +187,7 @@
                 RemoteServiceAdmin remoteAdmin = (RemoteServiceAdmin)ra;
                 List<ExportRegistration> exportRegistrations = remoteAdmin.exportService(reference);
                 if (exportRegistrations != null && !exportRegistrations.isEmpty()) {
-                    exportedServices.putValue(reference, exportRegistrations);
+                    exportedServices.putValues(reference, exportRegistrations);
                 }
             }
         }
@@ -196,28 +197,40 @@
      * @see org.osgi.framework.hooks.service.ListenerHook#added(java.util.Collection)
      */
     public void added(Collection listeners) {
-        Collection<ListenerInfo> listenerInfos = (Collection<ListenerInfo>)listeners;
-        boolean changed = false;
-        for (ListenerInfo l : listenerInfos) {
-            if (!l.isRemoved() && l.getBundleContext() != context) {
-                String key = l.getFilter();
-                if (key == null) {
-                    // key = "";
-                    // FIXME: It should always match, let's ignore it for now
-                    logger.warning("Service listner without a filter is skipped: " + l);
-                    continue;
-                }
-                Collection<ListenerInfo> infos = serviceListeners.get(key);
-                if (infos == null) {
-                    infos = new HashSet<ListenerInfo>();
-                    serviceListeners.put(key, infos);
+        try {
+            Collection<ListenerInfo> listenerInfos = (Collection<ListenerInfo>)listeners;
+            boolean changed = false;
+            for (ListenerInfo l : listenerInfos) {
+                if (!l.isRemoved() && l.getBundleContext() != context) {
+                    String key = l.getFilter();
+                    if (key == null) {
+                        // key = "";
+                        // FIXME: It should always match, let's ignore it for now
+                        logger.warning("Service listner without a filter is skipped: " + l);
+                        continue;
+                    }
+                    Collection<ListenerInfo> infos = serviceListeners.get(key);
+                    if (infos == null) {
+                        infos = new HashSet<ListenerInfo>();
+                        serviceListeners.put(key, infos);
+                    }
+                    infos.add(l);
+                    changed = true;
                 }
-                infos.add(l);
-                changed = true;
             }
-        }
-        if (changed) {
-            updateEndpointListenerScope();
+            if (changed) {
+                updateEndpointListenerScope();
+            }
+        } catch (Throwable e) {
+            logger.log(Level.SEVERE, e.getMessage(), e);
+            if (e instanceof Error) {
+                throw (Error)e;
+            } else if (e instanceof RuntimeException) {
+                throw (RuntimeException)e;
+            } else {
+                // Should not happen
+                throw new RuntimeException(e);
+            }
         }
     }
 
@@ -229,7 +242,7 @@
         endpointListener.setProperties(props);
     }
 
-    private MappedCollections<Class<?>, ListenerInfo> findServiceListeners(EndpointDescription endpointDescription,
+    private CollectionMap<Class<?>, ListenerInfo> findServiceListeners(EndpointDescription endpointDescription,
                                                                            String matchedFilter) {
         // First find all the listeners that have the matching filter
         Collection<ListenerInfo> listeners = serviceListeners.get(matchedFilter);
@@ -239,8 +252,8 @@
 
         // Try to partition the listeners by the interface classes 
         List<String> interfaceNames = endpointDescription.getInterfaces();
-        MappedCollections<Class<?>, ListenerInfo> interfaceToListeners =
-            new MappedCollections<Class<?>, ListenerInfo>();
+        CollectionMap<Class<?>, ListenerInfo> interfaceToListeners =
+            new CollectionMap<Class<?>, ListenerInfo>();
         for (String i : interfaceNames) {
             for (ListenerInfo listener : listeners) {
                 try {
@@ -258,21 +271,33 @@
      * @see org.osgi.framework.hooks.service.ListenerHook#removed(java.util.Collection)
      */
     public void removed(Collection listeners) {
-        Collection<ListenerInfo> listenerInfos = (Collection<ListenerInfo>)listeners;
-        boolean changed = false;
-        for (ListenerInfo l : listenerInfos) {
-            if (registration != null && l.getBundleContext() != context) {
-                String key = l.getFilter();
-                if (key == null) {
-                    continue;
-                }
-                if (serviceListeners.removeValue(key, l)) {
-                    changed = true;
+        try {
+            Collection<ListenerInfo> listenerInfos = (Collection<ListenerInfo>)listeners;
+            boolean changed = false;
+            for (ListenerInfo l : listenerInfos) {
+                if (registration != null && l.getBundleContext() != context) {
+                    String key = l.getFilter();
+                    if (key == null) {
+                        continue;
+                    }
+                    if (serviceListeners.removeValue(key, l)) {
+                        changed = true;
+                    }
                 }
             }
-        }
-        if (changed) {
-            updateEndpointListenerScope();
+            if (changed) {
+                updateEndpointListenerScope();
+            }
+        } catch (Throwable e) {
+            logger.log(Level.SEVERE, e.getMessage(), e);
+            if (e instanceof Error) {
+                throw (Error)e;
+            } else if (e instanceof RuntimeException) {
+                throw (RuntimeException)e;
+            } else {
+                // Should not happen
+                throw new RuntimeException(e);
+            }
         }
     }
 
@@ -316,7 +341,7 @@
             return;
         }
 
-        MappedCollections<Class<?>, ListenerInfo> interfaceToListeners = findServiceListeners(endpoint, matchedFilter);
+        CollectionMap<Class<?>, ListenerInfo> interfaceToListeners = findServiceListeners(endpoint, matchedFilter);
         for (Map.Entry<Class<?>, Collection<ListenerInfo>> e : interfaceToListeners.entrySet()) {
             Class<?> interfaceClass = e.getKey();
             Collection<ListenerInfo> listeners = e.getValue();
@@ -326,8 +351,8 @@
 
             Map<String, Object> props = new HashMap<String, Object>(endpoint.getProperties());
             props.put(Bundle.class.getName(), bundle);
-            EndpointDescription description =
-                new EndpointDescriptionImpl(Collections.singletonList(interfaceClass.getName()), props);
+            props.put(Constants.OBJECTCLASS, new String[] {interfaceClass.getName()});
+            EndpointDescription description = new EndpointDescriptionImpl(props);
 
             if (admins != null) {
                 for (Object ra : admins) {
@@ -369,35 +394,4 @@
         serviceListeners.clear();
     }
 
-    private static class MappedCollections<K, V> extends HashMap<K, Collection<V>> {
-        private static final long serialVersionUID = -8926174610229029369L;
-
-        public boolean putValue(K key, V value) {
-            Collection<V> collection = get(key);
-            if (collection == null) {
-                collection = new ArrayList<V>();
-                put(key, collection);
-            }
-            return collection.add(value);
-        }
-
-        public boolean putValue(K key, Collection<? extends V> value) {
-            Collection<V> collection = get(key);
-            if (collection == null) {
-                collection = new ArrayList<V>();
-                put(key, collection);
-            }
-            return collection.addAll(value);
-        }
-
-        public boolean removeValue(K key, V value) {
-            Collection<V> collection = get(key);
-            if (collection == null) {
-                return false;
-            }
-            return collection.remove(value);
-        }
-
-    }
-
 }

Modified: tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/impl/RemoteServiceAdminImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/impl/RemoteServiceAdminImpl.java?rev=805623&r1=805622&r2=805623&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/impl/RemoteServiceAdminImpl.java (original)
+++ tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/remoteadmin/impl/RemoteServiceAdminImpl.java Tue Aug 18 23:04:29 2009
@@ -27,8 +27,8 @@
 import org.apache.tuscany.sca.osgi.service.remoteadmin.EndpointDescription;
 import org.apache.tuscany.sca.osgi.service.remoteadmin.ExportRegistration;
 import org.apache.tuscany.sca.osgi.service.remoteadmin.ImportRegistration;
-import org.apache.tuscany.sca.osgi.service.remoteadmin.RemoteServiceAdmin;
 import org.apache.tuscany.sca.osgi.service.remoteadmin.RemoteAdminListener;
+import org.apache.tuscany.sca.osgi.service.remoteadmin.RemoteServiceAdmin;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -105,7 +105,7 @@
      * @see org.apache.tuscany.sca.osgi.service.remoteadmin.RemoteServiceAdmin#exportService(org.osgi.framework.ServiceReference,
      *      java.util.Map)
      */
-    public List<ExportRegistration> exportService(ServiceReference ref, Map<String, Object> properties) {
+    public List<ExportRegistration> exportService(ServiceReference ref, Map properties) {
         List<ExportRegistration> exportRegistrations = exporter.exportService(ref);
         if (exportRegistrations != null) {
             exportedServices.addAll(exportRegistrations);