public IContainer removeContainer(IContainer container) { Assert.isNotNull(container); ID containerID = container.getID(); if (containerID == null) return null; return removeContainer(containerID); }
public IContainer addContainer(IContainer container, ContainerTypeDescription typeDescription) { Assert.isNotNull(container); Assert.isNotNull(typeDescription); ID containerID = container.getID(); Assert.isNotNull(containerID, "Container ID cannot be null"); //$NON-NLS-1$ ContainerEntry result = null; synchronized (containers) { result = (ContainerEntry) containers.put(containerID, new ContainerEntry(container, typeDescription)); } if (result == null) fireContainerAdded(container); return container; }
void removeContainerExtensions(IConfigurationElement[] members) { // For each configuration element for (int m = 0; m < members.length; m++) { final IConfigurationElement member = members[m]; // The only required attribute is "factoryName" String factoryName = member.getAttribute(FACTORY_ATTRIBUTE); // Skip over if factory name is invalid if (factoryName == null || "".equals(factoryName)) //$NON-NLS-1$ continue; IContainerManager manager = (IContainerManager) ContainerFactory.getDefault(); IContainer[] containers = manager.getAllContainers(); if (containers == null) continue; for (int i = 0; i < containers.length; i++) { ContainerTypeDescription containerTypeDescription = manager.getContainerTypeDescription(containers[i].getID()); if (containerTypeDescription != null && containerTypeDescription.getName().equals(factoryName)) { // Remove from manager IContainer removedContainer = manager.removeContainer(containers[i]); if (removedContainer != null) { try { containers[i].dispose(); } catch (Exception e) { logException("removeContainerException", "Unexpected exception disposing container id=" + containers[i].getID(), e); //$NON-NLS-1$ //$NON-NLS-2$ } } } } } }
public IContainer createContainer(ContainerTypeDescription containerTypeDescription, Object[] parameters) throws ContainerCreateException { String method = "createContainer"; //$NON-NLS-1$ Trace.entering(ECFPlugin.PLUGIN_ID, ECFDebugOptions.METHODS_ENTERING, ContainerFactory.class, method, new Object[] {containerTypeDescription, Trace.getArgumentsString(parameters)}); if (containerTypeDescription == null) throwContainerCreateException("ContainerTypeDescription cannot be null", null, method); //$NON-NLS-1$ ContainerTypeDescription cd = getDescription0(containerTypeDescription); if (cd == null) throwContainerCreateException("ContainerTypeDescription '" //$NON-NLS-1$ + containerTypeDescription.getName() + "' not found", null, method); //$NON-NLS-1$ IContainerInstantiator instantiator = null; try { instantiator = cd.getInstantiator(); } catch (Exception e) { throwContainerCreateException("createContainer cannot get IContainerInstantiator for description : " //$NON-NLS-1$ + containerTypeDescription, e, method); } // Ask instantiator to actually create instance IContainer container = instantiator.createInstance(containerTypeDescription, parameters); if (container == null) throwContainerCreateException("Instantiator returned null for '" //$NON-NLS-1$ + cd.getName() + "'", null, method); //$NON-NLS-1$ // Add to containers map if container.getID() provides a valid value. ID containerID = container.getID(); if (containerID != null) addContainer(container, cd); Trace.exiting(ECFPlugin.PLUGIN_ID, ECFDebugOptions.METHODS_EXITING, ContainerFactory.class, method, container); return container; }