Package org.eclipse.ecf.core.provider

## Class BaseContainerInstantiator

- java.lang.Object
- - org.eclipse.ecf.core.provider.BaseContainerInstantiator

All Implemented Interfaces:
  `IContainerInstantiator`

Direct Known Subclasses:
  `BaseContainer.Instantiator`, `BaseRemoteServiceContainerInstantiator`, `RemoteServiceContainerInstantiator`, `RestClientContainerInstantiator`, `ServletServerContainerInstantiator`

    public class BaseContainerInstantiator
    extends Object
    implements IContainerInstantiator

Default implementation of `IContainerInstantiator`. ECF provider implementers may subclass as desired.

### Field Summary

Fields
`protected static Class[][]` `EMPTY_CLASS_ARRAY`
`protected static String[]` `EMPTY_STRING_ARRAY`
`protected static String[]` `NO_ADAPTERS_ARRAY`

### Constructor Summary

Constructors
`BaseContainerInstantiator()`

### Method Summary

All Methods Instance Methods Concrete Methods
`IContainer` `createInstance​(ContainerTypeDescription description, Object[] parameters)` Create instance of IContainer.
`protected Set` `getAdaptersForClass​(Class clazz)`
`protected ID` `getIDParameterValue​(Namespace ns, Map<String,​?> parameters, String key)`
`protected <T> ID` `getIDParameterValue​(Namespace ns, Map<String,​?> parameters, String key, Class<T> type, T def)`
`protected ID` `getIDParameterValue​(Namespace ns, Map<String,​?> parameters, String key, String def)`
`protected Integer` `getIntegerFromArg​(Object arg)`
`protected String[]` `getInterfacesAndAdaptersForClass​(Class clazz)`
`protected Set` `getInterfacesForClass​(Class clazz)`
`protected Set` `getInterfacesForClass​(Set s, Class clazz)`
`protected Map<String,​?>` `getMap​(Object[] parameters)`
`protected String` `getMapParameterString​(Object[] parameters, String key)`
`protected String` `getMapParameterString​(Object[] parameters, String key, String def)`
`protected <T> T` `getParameterValue​(Object[] parameters, String key, Class<T> clazz)`
`protected <T> T` `getParameterValue​(Object[] parameters, String key, Class<T> clazz, T def)`
`protected String` `getParameterValue​(Map<String,​?> parameters, String key)`
`protected <T> T` `getParameterValue​(Map<String,​?> parameters, String key, Class<T> clazz, T def)`
`protected String` `getParameterValue​(Map<String,​?> parameters, String key, String def)`
`protected String` `getStringFromArg​(Object arg)`
`String[]` `getSupportedAdapterTypes​(ContainerTypeDescription description)` Get array of supported adapters for the given container type description.
`String[]` `getSupportedIntents​(ContainerTypeDescription description)`
`Class[][]` `getSupportedParameterTypes​(ContainerTypeDescription description)` Get array of parameter types for given container type description.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### NO_ADAPTERS_ARRAY

    protected static String[] NO_ADAPTERS_ARRAY

#### EMPTY_STRING_ARRAY

    protected static String[] EMPTY_STRING_ARRAY

#### EMPTY_CLASS_ARRAY

    protected static Class[][] EMPTY_CLASS_ARRAY

### Constructor Detail

#### BaseContainerInstantiator

    public BaseContainerInstantiator()

### Method Detail

#### getIntegerFromArg

    protected Integer getIntegerFromArg​(Object arg)

Parameters:
  `arg` - object to get Integer from
Returns:
  Integer created from Object arg
Since:
  3.6

#### getStringFromArg

    protected String getStringFromArg​(Object arg)

Parameters:
  `arg` - object to get String from
Returns:
  String created from Object arg
Since:
  3.6

#### getAdaptersForClass

    protected Set getAdaptersForClass​(Class clazz)

#### getInterfacesForClass

    protected Set getInterfacesForClass​(Set s,
                                        Class clazz)

#### getInterfacesForClass

    protected Set getInterfacesForClass​(Class clazz)

#### getInterfacesAndAdaptersForClass

    protected String[] getInterfacesAndAdaptersForClass​(Class clazz)

#### getMap

    protected Map<String,​?> getMap​(Object[] parameters)

Parameters:
  `parameters` - parameters to get Map from
Returns:
  Map from first of parameters that is instance of Map
Since:
  3.6

#### getParameterValue

    protected <T> T getParameterValue​(Map<String,​?> parameters,
                                      String key,
                                      Class<T> clazz,
                                      T def)

Type Parameters:
  `T` - the expected value type
Parameters:
  `parameters` - Map parameters to get value from
  `key` - the key to use to get value from parameters
  `clazz` - the expected type of the value accessed by key
  `def` - the default of the value accessed by key. May be `null`
Returns:
  T value from parameters with key and of type clazz
Since:
  3.6

#### getParameterValue

    protected String getParameterValue​(Map<String,​?> parameters,
                                       String key,
                                       String def)

Parameters:
  `parameters` - Map parameters to get value from
  `key` - the key to use to get value from parameters
  `def` - the default of the value accessed by key. May be `null`
Returns:
  String value from parameters with key
Since:
  3.6

#### getParameterValue

    protected String getParameterValue​(Map<String,​?> parameters,
                                       String key)

Parameters:
  `parameters` - Map parameters to get value from
  `key` - the key to use to get value from parameters
Returns:
  String value from parameters with key
Since:
  3.6

#### getIDParameterValue

    protected <T> ID getIDParameterValue​(Namespace ns,
                                         Map<String,​?> parameters,
                                         String key,
                                         Class<T> type,
                                         T def)

Type Parameters:
  `T` - the expected value type
Parameters:
  `ns` - namespace to use for ID creation. Must not be `null`
  `parameters` - Map parameters to get value from
  `key` - the key to use to get value from parameters
  `type` - the expected type of the value from parameters
  `def` - a default value to use if value from parameters is null
Returns:
  ID the created ID
Since:
  3.8

#### getIDParameterValue

    protected ID getIDParameterValue​(Namespace ns,
                                     Map<String,​?> parameters,
                                     String key,
                                     String def)

Parameters:
  `ns` - namespace to use for ID creation. Must not be `null`
  `parameters` - Map parameters to get value from
  `key` - the key to use to get value from parameters
  `def` - a default String value to use if value from parameters is null
Returns:
  ID the created ID
Since:
  3.8

#### getIDParameterValue

    protected ID getIDParameterValue​(Namespace ns,
                                     Map<String,​?> parameters,
                                     String key)

Parameters:
  `ns` - namespace to use for ID creation. Must not be `null`
  `parameters` - Map parameters to get value from
  `key` - the key to use to get value from parameters
Returns:
  ID the created ID
Since:
  3.8

#### getParameterValue

    protected <T> T getParameterValue​(Object[] parameters,
                                      String key,
                                      Class<T> clazz,
                                      T def)

Type Parameters:
  `T` - the expected value type
Parameters:
  `parameters` - parameters assumed to contain a Map
  `key` - key to use to get parameter value from Map
  `clazz` - the expected type of the value from Map
  `def` - a default value to use if value from Map is `null`
Returns:
  T the parameter value with key from Map
Since:
  3.6

#### getParameterValue

    protected <T> T getParameterValue​(Object[] parameters,
                                      String key,
                                      Class<T> clazz)

Type Parameters:
  `T` - the expected value type
Parameters:
  `parameters` - parameters assumed to contain a Map
  `key` - key to use to get parameter value from Map
  `clazz` - the expected type of the value from Map
Returns:
  T the parameter value with key from Map
Since:
  3.6

#### getMapParameterString

    protected String getMapParameterString​(Object[] parameters,
                                           String key,
                                           String def)

Parameters:
  `parameters` - parameters assumed to contain a Map
  `key` - key to use to get parameter value from Map
  `def` - a default String value to use if value from Map is `null`
Returns:
  Sting the parameter value with key from Map
Since:
  3.6

#### getMapParameterString

    protected String getMapParameterString​(Object[] parameters,
                                           String key)

Parameters:
  `parameters` - parameters assumed to contain a Map
  `key` - key to use to get parameter value from Map
Returns:
  Sting the parameter value with key from Map
Since:
  3.6

#### 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 interface `IContainerInstantiator`
Parameters:
  `description` - the ContainerTypeDescription associated with the registered container provider implementation
  `parameters` - 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

#### 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 to `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`.

Specified by:
  `getSupportedAdapterTypes` in interface `IContainerInstantiator`
Parameters:
  `description` - the ContainerTypeDescription to report adapters for. Must not be `null`.
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 to `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" });

Specified by:
  `getSupportedParameterTypes` in interface `IContainerInstantiator`
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.

#### getSupportedIntents

    public String[] getSupportedIntents​(ContainerTypeDescription description)

Specified by:
  `getSupportedIntents` in interface `IContainerInstantiator`