Class RemoteServiceContainerInstantiator
- java.lang.Object
-
- org.eclipse.ecf.core.provider.BaseContainerInstantiator
-
- org.eclipse.ecf.remoteservice.provider.RemoteServiceContainerInstantiator
-
- All Implemented Interfaces:
IContainerInstantiator
,IRemoteServiceContainerInstantiator
- Direct Known Subclasses:
PeerRemoteServiceContainerInstantiator
public abstract class RemoteServiceContainerInstantiator extends BaseContainerInstantiator implements IRemoteServiceContainerInstantiator
- Since:
- 8.7
-
-
Field Summary
Fields Modifier and Type Field Description protected static String[]
defaultSupportedAdapterTypes
protected static String[]
defaultSupportedIntents
protected static Class[][]
defaultSupportedParameterTypes
protected List<String>
exporterConfigs
protected Map<String,List<String>>
exporterConfigToImporterConfigs
-
Fields inherited from class org.eclipse.ecf.core.provider.BaseContainerInstantiator
EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, NO_ADAPTERS_ARRAY
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RemoteServiceContainerInstantiator()
protected
RemoteServiceContainerInstantiator(String exportingProvider, String importingProvider)
protected
RemoteServiceContainerInstantiator(List<String> exporterConfigs, Map<String,List<String>> exporterConfigToImporterConfig)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static String[]
addSupportedIntent(String intent, String[] currentSupportedIntents)
protected boolean
checkAsyncIntent(ContainerTypeDescription description, Map<String,?> properties)
protected void
checkConfidential(ContainerTypeDescription description, String uri)
protected boolean
checkConfidentialIntent(ContainerTypeDescription description, String uri, Map<String,?> properties)
protected boolean
checkIntentSupported(ContainerTypeDescription description, String intent)
protected void
checkOSGIIntents(ContainerTypeDescription description, URI uri, Map<String,?> properties)
protected void
checkPrivate(ContainerTypeDescription description, String hostname)
protected boolean
checkPrivateIntent(ContainerTypeDescription description, String hostname, Map<String,?> properties)
IContainer
createInstance(ContainerTypeDescription description, Object[] parameters)
Create instance of IContainer.abstract IContainer
createInstance(ContainerTypeDescription description, Map<String,?> parameters)
String[]
getImportedConfigs(ContainerTypeDescription description, String[] exporterSupportedConfigs)
Get the imported config types for a given ContainerTypeDescription for the given exporter supported config types.Dictionary
getPropertiesForImportedConfigs(ContainerTypeDescription description, String[] importedConfigs, Dictionary exportedProperties)
Get the properties associated with the given description, with the given importedConfigTypes, via the given exportedProperties.protected List<String>
getServiceIntents(Map<String,?> properties)
String[]
getSupportedAdapterTypes(ContainerTypeDescription description)
Get array of supported adapters for the given container type description.String[]
getSupportedConfigs(ContainerTypeDescription description)
Get supported configs for the given ContainerTypeDescription.String[]
getSupportedIntents(ContainerTypeDescription description)
Get supported intents for the given ContainerTypeDescription.Class[][]
getSupportedParameterTypes(ContainerTypeDescription description)
Get array of parameter types for given container type description.protected static String[]
removeSupportedIntent(String intent, String[] currentSupportedIntents)
protected boolean
supportsOSGIAsyncIntent(ContainerTypeDescription description)
protected boolean
supportsOSGIConfidentialIntent(ContainerTypeDescription description)
protected boolean
supportsOSGIPrivateIntent(ContainerTypeDescription description)
protected IContainer
throwCreateException(String message, Throwable cause)
-
Methods inherited from class org.eclipse.ecf.core.provider.BaseContainerInstantiator
getAdaptersForClass, getIDParameterValue, getIDParameterValue, getIDParameterValue, getIntegerFromArg, getInterfacesAndAdaptersForClass, getInterfacesForClass, getInterfacesForClass, getMap, getMapParameterString, getMapParameterString, getParameterValue, getParameterValue, getParameterValue, getParameterValue, getParameterValue, getStringFromArg
-
-
-
-
Constructor Detail
-
RemoteServiceContainerInstantiator
protected RemoteServiceContainerInstantiator(String exportingProvider, String importingProvider)
- Parameters:
exportingProvider
- exporting provider (e.g. server or service host)importingProvider
- importing provider (e.g. client or service client)- Since:
- 8.9
-
RemoteServiceContainerInstantiator
protected RemoteServiceContainerInstantiator(List<String> exporterConfigs, Map<String,List<String>> exporterConfigToImporterConfig)
-
RemoteServiceContainerInstantiator
protected RemoteServiceContainerInstantiator()
-
-
Method Detail
-
getSupportedAdapterTypes
public String[] getSupportedAdapterTypes(ContainerTypeDescription description)
Description copied from interface:IContainerInstantiator
Get array of supported adapters for the given container type description. Providers implement this method to allow clients to inspect the adapter types exposed by the container described by the given description. The returned array entries will be the fully qualified names of the adapter classes. Note that the returned types do not guarantee that a subsequent call toIContainer.getAdapter(Class)
with the same type name as a returned value will return a non-null
result. In other words, even if the class name is in the returned array, subsequent calls toIContainer.getAdapter(Class)
may still returnnull
.- Specified by:
getSupportedAdapterTypes
in interfaceIContainerInstantiator
- Overrides:
getSupportedAdapterTypes
in classBaseContainerInstantiator
- Parameters:
description
- the ContainerTypeDescription to report adapters for. Must not benull
.- Returns:
- String[] of supported adapters. The entries in the returned array
will be the fully qualified class names of adapters supported by
the given description.
null
may be returned by the provider if no adapters are supported for this description.
-
getSupportedParameterTypes
public Class[][] getSupportedParameterTypes(ContainerTypeDescription description)
Description copied from interface:IContainerInstantiator
Get array of parameter types for given container type description. Providers implement this method to allow clients to inspect the available set of parameter types understood for calls toIContainerInstantiator.createInstance(ContainerTypeDescription, Object[])
.Each of the rows of the returned array specifies a Class[] of parameter types. These parameter types correspond to the types of Object[] that can be passed into the second parameter of
IContainerInstantiator.createInstance(ContainerTypeDescription, Object[])
.Consider the following example:
public Class[][] getSupportedParameterTypes() { return new Class[][] { { String.class }, { String.class, String.class } }; }
The above means that there are two acceptable values for the Object [] passed intoIContainerInstantiator.createInstance(ContainerTypeDescription, Object[])
: 1) a single String, and 2) two Strings. These would therefore be acceptable as input to createInstance:IContainer container = ContainerFactory.getDefault().createContainer( description, new Object[] { "Hello" }); IContainer container2 = ContainerFactory.getDefault().createContainer( description, new Object[] { "Hello" });
- Specified by:
getSupportedParameterTypes
in interfaceIContainerInstantiator
- Overrides:
getSupportedParameterTypes
in classBaseContainerInstantiator
- Parameters:
description
- the ContainerTypeDescription to return parameter types for- Returns:
- Class[][] array of Class[]s. Each row in the table corresponds to
a Class[] that describes the types of Objects in Object[] for
second parameter to
IContainerInstantiator.createInstance(ContainerTypeDescription, Object[])
.null
returned if no parameter types supported for given description.
-
getSupportedConfigs
public String[] getSupportedConfigs(ContainerTypeDescription description)
Description copied from interface:IRemoteServiceContainerInstantiator
Get supported configs for the given ContainerTypeDescription. This method will be called to determine what the OSGi remote service supported config types are for the given description during the search for the service exporter provider/containers upon remote service registration.- Specified by:
getSupportedConfigs
in interfaceIRemoteServiceContainerInstantiator
- Parameters:
description
- the ContainerTypeDescription to return the supported configs for. Will not benull
.- Returns:
- String[] the supported config types.
null
may be returned if the given description does not support any config types.
-
getImportedConfigs
public String[] getImportedConfigs(ContainerTypeDescription description, String[] exporterSupportedConfigs)
Description copied from interface:IRemoteServiceContainerInstantiator
Get the imported config types for a given ContainerTypeDescription for the given exporter supported config types. This method will be called to determine what the local container imported configs are for the given description and exporterSupportedConfigTypes. The local provider can decide which (if any) imported config types should be returned and return them.
As an example, consider the config types for the ECF generic provider. A generic server has a config type of 'ecf.generic.server', and the client has 'ecf.generic.server'. If the generic server exports a given service, the exportersSupportedConfigTypes will be '[ecf.generic.server]'. When this method is called with the ecf.generic.client description (i.e. the container type description named 'ecf.generic.client'), it should respond with a non-null, non-empty array...e.g.: [ecf.generic.client]. This indicates that the ecf.generic.client can serve as an importer for the given exporter config type. All, other descriptions should return
null
, to indicate that they cannot import a remote service exported by the given exporterSupportedConfigTypes.- Specified by:
getImportedConfigs
in interfaceIRemoteServiceContainerInstantiator
- Parameters:
description
- the container type description under consideration.exporterSupportedConfigs
- the exporter supported config types under consideration.- Returns:
- String[] indicating the importer's supported config types. Should be
null
, unless one or more of the exporterSupportedConfigTypes is recognized for the given description.
-
getPropertiesForImportedConfigs
public Dictionary getPropertiesForImportedConfigs(ContainerTypeDescription description, String[] importedConfigs, Dictionary exportedProperties)
Description copied from interface:IRemoteServiceContainerInstantiator
Get the properties associated with the given description, with the given importedConfigTypes, via the given exportedProperties.- Specified by:
getPropertiesForImportedConfigs
in interfaceIRemoteServiceContainerInstantiator
- Parameters:
description
- the container type description under consideration.importedConfigs
- the imported config types for the given properties. Will not benull
, and should be the same values as returned fromIRemoteServiceContainerInstantiator.getImportedConfigs(ContainerTypeDescription, String[])
.exportedProperties
- the properties from the exported service. Will not benull
.- Returns:
- Dictionary that has all of the properties for the importedConfigTypes. May be
null
if no properties are associated with the given description, importedConfigTypes, exportedProperties.
-
createInstance
public abstract IContainer createInstance(ContainerTypeDescription description, Map<String,?> parameters) throws ContainerCreateException
- Throws:
ContainerCreateException
-
createInstance
public IContainer createInstance(ContainerTypeDescription description, Object[] parameters) throws ContainerCreateException
Description copied from interface:IContainerInstantiator
Create instance of IContainer. This is the interface that container provider implementations must implement for the containerFactory extension point. The caller may optionally specify both argument types and arguments that will be passed into this method (and therefore to the provider implementation implementing this method). For example:ContainerFactory.getDefault().createContainer("foocontainer",new Object { "hello" });
- Specified by:
createInstance
in interfaceIContainerInstantiator
- Overrides:
createInstance
in classBaseContainerInstantiator
- Parameters:
description
- the ContainerTypeDescription associated with the registered container provider implementationparameters
- parameters specified by the caller. May be null if no parameters are passed in by caller to ContainerFactory.getDefault().createContainer(...)- Returns:
- IContainer instance. The provider implementation must return a valid object implementing IContainer OR throw a ContainerCreateException. Null will not be returned.
- Throws:
ContainerCreateException
- thrown if instance cannot be created
-
throwCreateException
protected IContainer throwCreateException(String message, Throwable cause) throws ContainerCreateException
- Throws:
ContainerCreateException
-
supportsOSGIConfidentialIntent
protected boolean supportsOSGIConfidentialIntent(ContainerTypeDescription description)
- Since:
- 8.13
-
supportsOSGIPrivateIntent
protected boolean supportsOSGIPrivateIntent(ContainerTypeDescription description)
- Since:
- 8.13
-
supportsOSGIAsyncIntent
protected boolean supportsOSGIAsyncIntent(ContainerTypeDescription description)
- Since:
- 8.13
-
getSupportedIntents
public String[] getSupportedIntents(ContainerTypeDescription description)
Description copied from interface:IRemoteServiceContainerInstantiator
Get supported intents for the given ContainerTypeDescription. This method will be called to determine what the OSGi remote service supported intents are for the given description during the search for the service exporter provider/containers upon remote service registration.- Specified by:
getSupportedIntents
in interfaceIContainerInstantiator
- Specified by:
getSupportedIntents
in interfaceIRemoteServiceContainerInstantiator
- Overrides:
getSupportedIntents
in classBaseContainerInstantiator
- Parameters:
description
- the ContainerTypeDescription to return the supported intents for. Will not benull
.- Returns:
- String[] the supported intents.
null
may be returned if the given description does not support any intents.
-
addSupportedIntent
protected static String[] addSupportedIntent(String intent, String[] currentSupportedIntents)
- Since:
- 8.13
-
removeSupportedIntent
protected static String[] removeSupportedIntent(String intent, String[] currentSupportedIntents)
- Since:
- 8.13
-
checkPrivate
protected void checkPrivate(ContainerTypeDescription description, String hostname) throws ContainerIntentException
- Throws:
ContainerIntentException
- Since:
- 8.13
-
checkIntentSupported
protected boolean checkIntentSupported(ContainerTypeDescription description, String intent)
- Since:
- 8.13
-
checkAsyncIntent
protected boolean checkAsyncIntent(ContainerTypeDescription description, Map<String,?> properties) throws ContainerIntentException
- Throws:
ContainerIntentException
- Since:
- 8.13
-
checkPrivateIntent
protected boolean checkPrivateIntent(ContainerTypeDescription description, String hostname, Map<String,?> properties) throws ContainerIntentException
- Throws:
ContainerIntentException
- Since:
- 8.13
-
checkConfidentialIntent
protected boolean checkConfidentialIntent(ContainerTypeDescription description, String uri, Map<String,?> properties) throws ContainerIntentException
- Throws:
ContainerIntentException
- Since:
- 8.13
-
checkConfidential
protected void checkConfidential(ContainerTypeDescription description, String uri) throws ContainerIntentException
- Throws:
ContainerIntentException
- Since:
- 8.13
-
checkOSGIIntents
protected void checkOSGIIntents(ContainerTypeDescription description, URI uri, Map<String,?> properties) throws ContainerIntentException
- Throws:
ContainerIntentException
- Since:
- 8.13
-
-