use of org.eclipse.ecf.core.ContainerCreateException in project ecf by eclipse.
the class AbstractConsumerContainerSelector method createContainer.
/**
* @param containerTypeDescription containerTypeDescription
* @param containerTypeDescriptionName containerTypeDescriptionName
* @param properties properties
* @return IRemoteServiceContainer created container. Should not be <code>null</code>
* @throws SelectContainerException thrown if container cannot be created or configured
* @since 2.0
*/
protected IRemoteServiceContainer createContainer(ContainerTypeDescription containerTypeDescription, String containerTypeDescriptionName, Map properties) throws SelectContainerException {
try {
IContainer container = (properties == null) ? getContainerFactory().createContainer(containerTypeDescriptionName) : getContainerFactory().createContainer(containerTypeDescriptionName, properties);
IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) container.getAdapter(IRemoteServiceContainerAdapter.class);
if (adapter == null)
throw new SelectContainerException("Container config id=" + containerTypeDescriptionName + " does not implement IRemoteServiceContainerAdapter", null, // $NON-NLS-1$ //$NON-NLS-2$
containerTypeDescription);
return new RemoteServiceContainer(container);
} catch (ContainerCreateException e) {
String message = // $NON-NLS-1$
"Cannot create container config id=" + containerTypeDescriptionName;
logException(message, e);
throw new SelectContainerException(message, e, containerTypeDescription);
}
}
use of org.eclipse.ecf.core.ContainerCreateException 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.ContainerCreateException in project ecf by eclipse.
the class XMPPContainerInstantiator method createInstance.
/*
* (non-Javadoc)
*
* @seeorg.eclipse.ecf.core.provider.IContainerInstantiator#createInstance(
* ContainerDescription, java.lang.Object[])
*/
public IContainer createInstance(ContainerTypeDescription description, Object[] args) throws ContainerCreateException {
try {
Integer ka = new Integer(XMPPContainer.DEFAULT_KEEPALIVE);
String name = null;
if (args != null) {
if (args.length > 0) {
name = (String) args[0];
if (args.length > 1) {
ka = getIntegerFromArg(args[1]);
}
}
}
if (name == null) {
if (ka == null) {
return new XMPPContainer();
} else {
return new XMPPContainer(ka.intValue());
}
} else {
if (ka == null) {
ka = new Integer(XMPPContainer.DEFAULT_KEEPALIVE);
}
return new XMPPContainer(name, ka.intValue());
}
} catch (Exception e) {
throw new ContainerCreateException("Exception creating generic container", e);
}
}
Aggregations