use of org.eclipse.ecf.core.IContainerFactory in project ecf by eclipse.
the class AbstractContainerSelector method createContainer.
/**
* @param serviceReference serviceReference
* @param properties overriding properties
* @param containerTypeDescription containerTypeDescription
* @param intents intents
* @return IContainer created container. May be null if instance cannot be created (e.g. because of intent requirements)
* @throws SelectContainerException thrown if some create or configure failure
* @since 4.6
*/
protected IContainer createContainer(ServiceReference serviceReference, Map<String, Object> properties, ContainerTypeDescription containerTypeDescription, String[] intents) throws SelectContainerException {
IContainerFactory containerFactory = getContainerFactory();
final Object containerFactoryArguments = getContainerFactoryArguments(serviceReference, properties, containerTypeDescription, intents);
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) {
if (e instanceof ContainerIntentException) {
// $NON-NLS-1$ //$NON-NLS-2$
LogUtility.logError("createContainer", DebugOptions.CONTAINER_SELECTOR, this.getClass(), "Container creation does not satisfy required intent=" + ((ContainerIntentException) e).getIntentName(), e);
return null;
} else
throw new SelectContainerException(// $NON-NLS-1$
"Exception creating or configuring container", // $NON-NLS-1$
e, containerTypeDescription);
}
}
use of org.eclipse.ecf.core.IContainerFactory in project ecf by eclipse.
the class NoRegistryContainerFactoryTest method testCreateContainer.
public void testCreateContainer() throws Exception {
IContainerFactory f = Activator.getDefault().getContainerFactory();
IContainer c = f.createContainer(getClass().getName());
assertNotNull(c);
}
Aggregations