public class GenericContainerInstantiator extends Object implements IContainerInstantiator, IRemoteServiceContainerInstantiator
Modifier and Type | Class and Description |
---|---|
protected class |
GenericContainerInstantiator.GenericContainerArgs |
Modifier and Type | Field and Description |
---|---|
protected static String[] |
genericProviderIntents |
static String |
TCPCLIENT_NAME |
static String |
TCPSERVER_NAME |
Constructor and Description |
---|
GenericContainerInstantiator() |
Modifier and Type | Method and Description |
---|---|
protected IContainer |
createClientContainer(GenericContainerInstantiator.GenericContainerArgs gcargs) |
IContainer |
createInstance(ContainerTypeDescription description,
Object[] args)
Create instance of IContainer.
|
protected IContainer |
createServerContainer(GenericContainerInstantiator.GenericContainerArgs gcargs) |
protected Set |
getAdaptersForClass(Class clazz) |
protected GenericContainerInstantiator.GenericContainerArgs |
getClientArgs(Object[] args) |
protected ID |
getIDFromArg(Object arg) |
String[] |
getImportedConfigs(ContainerTypeDescription description,
String[] exporterSupportedConfigs)
Get the imported config types for a given ContainerTypeDescription for the given exporter supported config types.
|
protected Integer |
getIntegerFromArg(Object arg) |
protected String[] |
getInterfacesAndAdaptersForClass(Class clazz) |
protected Set |
getInterfacesForClass(Class clazz) |
protected Set |
getInterfacesForClass(Set s,
Class clazz) |
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 GenericContainerInstantiator.GenericContainerArgs |
getServerArgs(Object[] args) |
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 boolean |
isClient(ContainerTypeDescription description) |
protected static final String[] genericProviderIntents
public static final String TCPCLIENT_NAME
public static final String TCPSERVER_NAME
protected ID getIDFromArg(Object arg) throws IDCreateException
IDCreateException
protected GenericContainerInstantiator.GenericContainerArgs getClientArgs(Object[] args) throws IDCreateException
args
- argumentsIDCreateException
- if the client args cannot be retrieved from given argsprotected boolean isClient(ContainerTypeDescription description)
protected GenericContainerInstantiator.GenericContainerArgs getServerArgs(Object[] args) throws IDCreateException
args
- argumentsIDCreateException
- if the server args cannot be retrieved from given argsprotected IContainer createClientContainer(GenericContainerInstantiator.GenericContainerArgs gcargs) throws Exception
gcargs
- the generic container argsException
- if something goes wrongprotected IContainer createServerContainer(GenericContainerInstantiator.GenericContainerArgs gcargs) throws Exception
gcargs
- the generic container argsException
- if something goes wrongpublic IContainer createInstance(ContainerTypeDescription description, Object[] args) throws ContainerCreateException
IContainerInstantiator
ContainerFactory.getDefault().createContainer("foocontainer",new Object { "hello" });
createInstance
in interface IContainerInstantiator
description
- the ContainerTypeDescription associated with the registered
container provider implementationargs
- parameters specified by the caller. May be null if no
parameters are passed in by caller to
ContainerFactory.getDefault().createContainer(...)ContainerCreateException
- thrown if instance cannot be createdpublic String[] getSupportedAdapterTypes(ContainerTypeDescription description)
IContainerInstantiator
IContainer.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
to IContainer.getAdapter(Class)
may still return
null
.getSupportedAdapterTypes
in interface IContainerInstantiator
description
- the ContainerTypeDescription to report adapters for. Must not
be null
.null
may be returned by
the provider if no adapters are supported for this description.public Class[][] getSupportedParameterTypes(ContainerTypeDescription description)
IContainerInstantiator
IContainerInstantiator.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 into
IContainerInstantiator.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" });
getSupportedParameterTypes
in interface IContainerInstantiator
description
- the ContainerTypeDescription to return parameter types forIContainerInstantiator.createInstance(ContainerTypeDescription, Object[])
.
null
returned if no parameter types supported for
given description.IContainerInstantiator.getSupportedParameterTypes(org.eclipse.ecf.core.ContainerTypeDescription)
public String[] getSupportedIntents(ContainerTypeDescription description)
IRemoteServiceContainerInstantiator
getSupportedIntents
in interface IContainerInstantiator
getSupportedIntents
in interface IRemoteServiceContainerInstantiator
description
- the ContainerTypeDescription to return the supported intents for.
Will not be null
.null
may be returned if the
given description does not support any intents.public String[] getSupportedConfigs(ContainerTypeDescription description)
IRemoteServiceContainerInstantiator
getSupportedConfigs
in interface IRemoteServiceContainerInstantiator
description
- the ContainerTypeDescription to return the supported configs for.
Will not be null
.null
may be returned if the
given description does not support any config types.public String[] getImportedConfigs(ContainerTypeDescription description, String[] exporterSupportedConfigs)
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.
getImportedConfigs
in interface IRemoteServiceContainerInstantiator
description
- the container type description under consideration.exporterSupportedConfigs
- the exporter supported config types under consideration.null
, unless
one or more of the exporterSupportedConfigTypes is recognized for the given description.public Dictionary getPropertiesForImportedConfigs(ContainerTypeDescription description, String[] importedConfigs, Dictionary exportedProperties)
IRemoteServiceContainerInstantiator
getPropertiesForImportedConfigs
in interface IRemoteServiceContainerInstantiator
description
- the container type description under consideration.importedConfigs
- the imported config types for the given properties. Will not be null
, and
should be the same values as returned from IRemoteServiceContainerInstantiator.getImportedConfigs(ContainerTypeDescription, String[])
.exportedProperties
- the properties from the exported service. Will not be null
.null
if
no properties are associated with the given description, importedConfigTypes, exportedProperties.Copyright © 2017 Eclipse Foundation. All rights reserved.