diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-13 01:01:47 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-13 01:01:47 +0000 |
commit | 8ca8c4e81fae5fd2dae35084f97bf5eac6fadd57 (patch) | |
tree | 46cbe64450b9ac745cca4d1c0b85ddc07bf722e5 /sca-java-2.x/trunk | |
parent | cf516d4c043bb85b42f2ea3ad17cb94eee26bc36 (diff) |
Enable the remotable setting on OSGi interfaces
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@898591 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk')
2 files changed, 169 insertions, 111 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java b/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java index ebe4ef2dbc..ff889f8577 100644 --- a/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java +++ b/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java @@ -36,151 +36,207 @@ public interface OSGiProperty { String SCA_SERVICE = "sca.service"; String SCA_REFERENCE_BINDING = "sca.reference.binding"; String SCA_SERVICE_BINDING = "sca.service.binding"; - + /** - * 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 + * Service property identifying the configuration types supported by a + * distribution provider. Registered by the distribution provider on one of + * its services to indicate the supported configuration types. + * <p> + * The value of this property must be of type <code>String</code>, + * <code>String[]</code>, or <code>Collection<String></code>. */ - public final static String REMOTE_CONFIGS_SUPPORTED = "remote.configs.supported"; + public static final 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. + * Service property identifying the intents supported by a distribution + * provider. Registered by the distribution provider on one of its services + * to indicate the vocabulary of implemented intents. * - * The value of this property is of type <code>String+</code>. - * - * @see #SERVICE_INTENTS - * @see #SERVICE_EXPORTED_INTENTS - * @see #SERVICE_EXPORTED_INTENTS_EXTRA + * <p> + * The value of this property must be of type <code>String</code>, + * <code>String[]</code>, or <code>Collection<String></code>. */ - public final static String REMOTE_INTENTS_SUPPORTED = "remote.intents.supported"; + public static final String REMOTE_INTENTS_SUPPORTED = "remote.intents.supported"; + /** - * 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>. + * Service property identifying the configuration types that should be used + * to export the service. Each configuration type represents the + * configuration parameters for an endpoint. A distribution provider should + * create an endpoint for each configuration type that it supports. + * + * <p> + * This property may be supplied in the <code>properties</code> + * <code>Dictionary</code> object passed to the + * <code>BundleContext.registerService</code> method. The value of this + * property must be of type <code>String</code>, <code>String[]</code>, or + * <code>Collection<String></code>. */ - public final static String SERVICE_EXPORTED_CONFIGS = "service.exported.configs"; + public static final String SERVICE_EXPORTED_CONFIGS = "service.exported.configs"; + /** - * 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 <code>String+</code>. + * Service property identifying the 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. + * + * <p> + * This property may be supplied in the <code>properties</code> + * <code>Dictionary</code> object passed to the + * <code>BundleContext.registerService</code> method. The value of this + * property must be of type <code>String</code>, <code>String[]</code>, or + * <code>Collection<String></code>. */ - public final static String SERVICE_EXPORTED_INTENTS = "service.exported.intents"; + public static final String SERVICE_EXPORTED_INTENTS = "service.exported.intents"; + /** - * Extra intents configured in addition to the the intents specified in - * {@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>. + * Service property identifying the extra intents that the distribution + * provider must implement to distribute the service. This property is + * merged with the <code>service.exported.intents</code> property before the + * distribution provider interprets the listed intents; it has therefore the + * same semantics but the property should be configurable so the + * administrator can choose the intents based on the topology. Bundles + * should therefore make this property configurable, for example through the + * Configuration Admin service. + * + * <p> + * This property may be supplied in the <code>properties</code> + * <code>Dictionary</code> object passed to the + * <code>BundleContext.registerService</code> method. The value of this + * property must be of type <code>String</code>, <code>String[]</code>, or + * <code>Collection<String></code>. */ - public final static String SERVICE_EXPORTED_INTENTS_EXTRA = "service.exported.intents.extra"; + public static final 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 ('*' \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+. + * Service property marking the service for export. It defines the + * interfaces under which this service can be exported. This list must be a + * subset of the types under which the service was registered. The single + * value of an asterisk ("*", \u002A) indicates all the + * interface types under which the service was registered excluding the + * non-interface types. It is strongly recommended to only export interface + * types and not concrete classes due to the complexity of creating proxies + * for some type of concrete classes. + * + * <p> + * This property may be supplied in the <code>properties</code> + * <code>Dictionary</code> object passed to the + * <code>BundleContext.registerService</code> method. The value of this + * property must be of type <code>String</code>, <code>String[]</code>, or + * <code>Collection<String></code>. */ - public final static String SERVICE_EXPORTED_INTERFACES = "service.exported.interfaces"; + public static final String SERVICE_EXPORTED_INTERFACES = "service.exported.interfaces"; + /** - * 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. + * Service property identifying the service as imported. This service + * property must be set by a distribution provider to any value when it + * registers the endpoint proxy as an imported service. A bundle can use + * this property to filter out imported services. * - * The value of this property is not defined, setting it is sufficient. + * <p> + * The value of this property may be of any type. */ - public final static String SERVICE_IMPORTED = "service.imported"; + public static final String SERVICE_IMPORTED = "service.imported"; + /** - * A list of intents that this service implements. This property has dual - * purpose. A bundle can use this service property to notify the - * distribution provider that these intents are already implemented by the - * exported service object. For an imported service, a distribution provider - * 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. + * Service property identifying the configuration types used to import the + * service. 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. If multiple configuration types are listed in this property, + * then they must be synonyms for exactly the same remote endpoint that is + * used to export this service. + * + * <p> + * The value of this property must be of type <code>String</code>, + * <code>String[]</code>, or <code>Collection<String></code>. * - * The value of this property is of type <code>String+</code>. + * @see #SERVICE_EXPORTED_CONFIGS + */ + public static final String SERVICE_IMPORTED_CONFIGS = "service.imported.configs"; + + /** + * Service property identifying the intents that this service implement. + * This property has a dual purpose: + * <ul> + * <li>A bundle can use this service property to notify the distribution + * provider that these intents are already implemented by the exported + * service object.</li> + * <li>A distribution provider must use this property to convey the combined + * intents of: The exporting service, and, the intents that the exporting + * distribution provider adds, and the intents that the importing + * distribution provider adds.</li> + * </ul> + * To export a service, a distribution provider must expand any qualified + * intents. Both the exporting and importing distribution providers must + * recognize all intents before a service can be distributed. + * + * <p> + * The value of this property must be of type <code>String</code>, + * <code>String[]</code>, or <code>Collection<String></code>. */ - public final static String SERVICE_INTENTS = "service.intents"; + public static final String SERVICE_INTENTS = "service.intents"; + + /* above are from Ch 13 Remote Service spec. */ + /** - * 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. + * Endpoint property identifying the id for this endpoint. This service + * property must always be set. + * + * <p> + * The value of this property must be of type <code>String</code>. */ - final public static String SERVICE_REMOTE_FRAMEWORK_UUID = "service.remote.framework.id"; + String ENDPOINT_ID = "endpoint.id"; + /** - * 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. + * Endpoint property identifying the service id of the exported service. Can + * be absent or 0 if the corresponding endpoint is not for an OSGi service. + * + * <p> + * The value of this property must be of type <code>Long</code>. */ - final public static String SERVICE_REMOTE_ID = "service.remote.id"; + String ENDPOINT_SERVICE_ID = "endpoint.service.id"; + /** - * 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. + * Endpoint property identifying the universally unique id of the exporting + * framework. Can be absent if the corresponding endpoint is not for an OSGi + * service. + * + * <p> + * The value of this property must be of type <code>String</code>. */ - final public static String SERVICE_REMOTE_URI = "service.remote.uri"; + String ENDPOINT_FRAMEWORK_UUID = "endpoint.framework.uuid"; + /** - * The configuration type used to import this services, as described in - * {@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 <code>String+</code>. + * Prefix for an endpoint property identifying the interface Java package + * version for an interface. For example, the property + * endpoint.package.version.com.acme=1.3 describes the version of the + * package for the com.acme.Foo interface. This endpoint property for an + * interface package does not have to be set. If not set, the value must be + * assumed to be 0. + * + * <p> + * Since endpoint properties are stored in a case insensitive map, case + * variants of a package name are folded together. + * + * <p> + * The value of this property must be of type <code>String</code>. */ - public final String SERVICE_IMPORTED_CONFIGS = "service.imported.configs"; - + String ENDPOINT_PACKAGE_VERSION_ = "endpoint.package.version."; Object getValue(); + void setValue(Object value); String getName(); void setName(String name); - + String getType(); + void setType(String type); - + String getStringValue(); + void setStringValue(String value); } diff --git a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java index 916761f129..0080e69540 100644 --- a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java +++ b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java @@ -424,9 +424,11 @@ public class EndpointIntrospector { throws ClassNotFoundException, InvalidInterfaceException { JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract(); Class<?> interfaceClass = bundle.loadClass(intf); - JavaInterface javaInterface = javaInterfaceFactory.createJavaInterface(interfaceClass); - // [rfeng] For OSGi, the interfaces should be marked as remote + JavaInterface javaInterface = javaInterfaceFactory.createJavaInterface(); + // [rfeng] For OSGi, the interfaces should be marked as remotable javaInterface.setRemotable(true); + // [rfeng] We need to mark the interface to be remotable before the createJavaInterface() is called + javaInterfaceFactory.createJavaInterface(javaInterface, interfaceClass); interfaceContract.setInterface(javaInterface); if (javaInterface.getCallbackClass() != null) { JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(javaInterface.getCallbackClass()); |