/** * @return String[] supported configs * @since 3.1 */ public String[] getSupportedConfigs() { try { IContainerInstantiator ci = getInstantiator(); return (ci instanceof IRemoteServiceContainerInstantiator) ? ((IRemoteServiceContainerInstantiator) ci).getSupportedConfigs(this) : null; } catch (Exception e) { traceAndLogException(IStatus.ERROR, "getSupportedConfigs", e); //$NON-NLS-1$ return null; } }
public String[] getSupportedConfigs(ContainerTypeDescription description) { return new String[] {description.getName()}; }
protected IContainerInstantiator getInstantiator() throws ClassNotFoundException, InstantiationException, IllegalAccessException { synchronized (this) { if (instantiator == null) initializeInstantiator(); return instantiator; } }
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; }
protected void runWithoutRegistry() throws Exception { ECFPlugin.this.context.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(BaseContainer.Instantiator.NAME, new BaseContainer.Instantiator()), null); } });
public ContainerTypeDescription[] getDescriptionsForContainerAdapter(Class containerAdapter) { if (containerAdapter == null) throw new NullPointerException("containerAdapter cannot be null"); //$NON-NLS-1$ List result = new ArrayList(); List descriptions = getDescriptions(); for (Iterator i = descriptions.iterator(); i.hasNext();) { ContainerTypeDescription description = (ContainerTypeDescription) i.next(); String[] supportedAdapters = description.getSupportedAdapterTypes(); if (supportedAdapters != null) { for (int j = 0; j < supportedAdapters.length; j++) { if (supportedAdapters[j].equals(containerAdapter.getName())) result.add(description); } } } return (ContainerTypeDescription[]) result.toArray(new ContainerTypeDescription[] {}); }
ECFPlugin.this.context.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(BaseContainer.Instantiator.NAME, new BaseContainer.Instantiator()), null);
/** * @return String[] of container's intents. * * @since 3.0 */ public String[] getSupportedIntents() { try { IContainerInstantiator ci = getInstantiator(); return (ci instanceof IRemoteServiceContainerInstantiator) ? ((IRemoteServiceContainerInstantiator) ci).getSupportedIntents(this) : null; } catch (Exception e) { traceAndLogException(IStatus.ERROR, "getSupportedIntents", e); //$NON-NLS-1$ return null; } }
public String[] getImportedConfigs(ContainerTypeDescription description, String[] exporterSupportedConfigs) { return new String[] {description.getName()}; }
final ContainerTypeDescription scd = new ContainerTypeDescription(name, (IContainerInstantiator) exten, description, server, hidden);
/** * @param exporterSupportedConfigs exporter supported configs * @return String[] imported configs * @since 3.1 */ public String[] getImportedConfigs(String[] exporterSupportedConfigs) { if (exporterSupportedConfigs == null) return null; try { IContainerInstantiator ci = getInstantiator(); return (ci instanceof IRemoteServiceContainerInstantiator) ? ((IRemoteServiceContainerInstantiator) ci).getImportedConfigs(this, exporterSupportedConfigs) : null; } catch (Exception e) { traceAndLogException(IStatus.ERROR, "getImportedConfigs", e); //$NON-NLS-1$ return null; } }
protected ContainerTypeDescription addDescription0(ContainerTypeDescription containerTypeDescription) { if (containerTypeDescription == null) return null; synchronized (containerdescriptions) { return (ContainerTypeDescription) containerdescriptions.put(containerTypeDescription.getName(), containerTypeDescription); } }
/** * @param importedConfigs imported configs * @param exportedProperties exported properties * @return Dictionary dictionary of properties for imported configs * @since 3.1 */ public Dictionary getPropertiesForImportedConfigs(String[] importedConfigs, Dictionary exportedProperties) { if (importedConfigs == null) return null; try { IContainerInstantiator ci = getInstantiator(); return (ci instanceof IRemoteServiceContainerInstantiator) ? ((IRemoteServiceContainerInstantiator) ci).getPropertiesForImportedConfigs(this, importedConfigs, exportedProperties) : null; } catch (Exception e) { traceAndLogException(IStatus.ERROR, "getPropertiesForImportedConfigs", e); //$NON-NLS-1$ return null; } }
protected boolean containsDescription0(ContainerTypeDescription containerTypeDescription) { if (containerTypeDescription == null) return false; synchronized (containerdescriptions) { return containerdescriptions.containsKey(containerTypeDescription.getName()); } }
/** * Get array of parameter types for this ContainerTypeDescription. Each of * the rows of the returned array specifies a Class[] of parameter types. * These parameter types correspond to the types of Objects that can be * passed into the second parameter of * {@link IContainerInstantiator#createInstance(ContainerTypeDescription, Object[])}. * For example, if this method returns a Class [] = {{ String.class, * String.class }, { String.class }} this indicates that a call to * createInstance(description,new String[] { "hello", "there" }) and a call * to createInstance(description,new String[] { "hello" }) will be * understood by the underlying provider implementation. * * @return Class[][] array of Class arrays. Each row corresponds to a * Class[] that describes the types of Objects for second parameter * to * {@link IContainerInstantiator#createInstance(ContainerTypeDescription, Object[])}. * If no parameter types are understood as arguments, a Class[0][0] * array will be returned */ public Class[][] getSupportedParameterTypes() { Class[][] result = {{}}; try { Class[][] r = getInstantiator().getSupportedParameterTypes(this); if (r != null) result = r; } catch (Exception e) { traceAndLogException(IStatus.ERROR, "getSupportedParameterTypes", e); //$NON-NLS-1$ } return result; }
protected ContainerTypeDescription getDescription0(ContainerTypeDescription containerTypeDescription) { if (containerTypeDescription == null) return null; synchronized (containerdescriptions) { return (ContainerTypeDescription) containerdescriptions.get(containerTypeDescription.getName()); } }
String[] result = new String[0]; try { String[] r = getInstantiator().getSupportedAdapterTypes(this); if (r != null) result = r; } catch (Exception e) { traceAndLogException(IStatus.ERROR, "getSupportedAdapterTypes", e); //$NON-NLS-1$
protected ContainerTypeDescription removeDescription0(ContainerTypeDescription containerTypeDescription) { if (containerTypeDescription == null) return null; synchronized (containerdescriptions) { return (ContainerTypeDescription) containerdescriptions.remove(containerTypeDescription.getName()); } }
public Object addingService(ServiceReference reference) { ContainerTypeDescription ctd = (ContainerTypeDescription) context.getService(reference); if (ctd != null && ctd.getName() != null) ContainerFactory.getDefault().addDescription(ctd); return ctd; }
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$ } } } } } }