protected IContainer createContainer(ServiceReference serviceReference,
Map<String, Object> properties,
ContainerTypeDescription containerTypeDescription)
throws SelectContainerException {
IContainerFactory containerFactory = getContainerFactory();
final Object containerFactoryArguments = getContainerFactoryArguments(
serviceReference, properties, containerTypeDescription);
try {
if (containerFactoryArguments instanceof String) {
return containerFactory.createContainer(
containerTypeDescription,
(String) containerFactoryArguments);
} else if (containerFactoryArguments instanceof ID) {
return containerFactory.createContainer(
containerTypeDescription,
(ID) containerFactoryArguments);
} else if (containerFactoryArguments instanceof Object[]) {
return containerFactory.createContainer(
containerTypeDescription,
(Object[]) containerFactoryArguments);
} else if (containerFactoryArguments instanceof Map) {
return containerFactory.createContainer(
containerTypeDescription,
(Map) containerFactoryArguments);
}
return containerFactory.createContainer(containerTypeDescription);
} catch (ContainerCreateException e) {
throw new SelectContainerException(
"Exception creating or configuring container", e, //$NON-NLS-1$
containerTypeDescription);
}