Search in sources :

Example 31 with ContainerTypeDescription

use of org.eclipse.ecf.core.ContainerTypeDescription in project ecf by eclipse.

the class AbstractConsumerContainerSelector method createAndConfigureConsumerContainer.

protected IRemoteServiceContainer createAndConfigureConsumerContainer(String[] remoteSupportedConfigs, Map remoteExportedProperties) throws SelectContainerException {
    if (remoteSupportedConfigs == null || remoteSupportedConfigs.length == 0)
        return null;
    // Get container factory
    IContainerFactory containerFactory = getContainerFactory();
    if (containerFactory == null)
        return null;
    // Get all container type descriptions from factory
    List containerTypeDescriptions = containerFactory.getDescriptions();
    if (containerTypeDescriptions == null)
        return null;
    // Go through all containerTypeDescriptions
    for (Iterator i = containerTypeDescriptions.iterator(); i.hasNext(); ) {
        ContainerTypeDescription desc = (ContainerTypeDescription) i.next();
        // For each one, get the localImportedConfigs for the remote
        // supported configs
        String[] localImportedConfigs = desc.getImportedConfigs(remoteSupportedConfigs);
        // If their are some local imported configs for this description
        if (localImportedConfigs != null) {
            // Then get the imported config properties
            Dictionary importedConfigProperties = desc.getPropertiesForImportedConfigs(localImportedConfigs, PropertiesUtil.createDictionaryFromMap(remoteExportedProperties));
            // Then select a specific local imported config (typically the
            // first on in the array)
            String selectedConfig = selectLocalImportedConfig(localImportedConfigs, importedConfigProperties);
            // If we have one to use, then create the container
            if (selectedConfig != null) {
                IRemoteServiceContainer rsContainer = createContainer(desc, selectedConfig, PropertiesUtil.createMapFromDictionary(importedConfigProperties));
                if (rsContainer != null)
                    return rsContainer;
            }
        }
    }
    return null;
}
Also used : Dictionary(java.util.Dictionary) IRemoteServiceContainer(org.eclipse.ecf.remoteservice.IRemoteServiceContainer) IContainerFactory(org.eclipse.ecf.core.IContainerFactory) ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) Iterator(java.util.Iterator) List(java.util.List)

Example 32 with ContainerTypeDescription

use of org.eclipse.ecf.core.ContainerTypeDescription in project ecf by eclipse.

the class AbstractConsumerContainerSelector method matchSupportedConfigs.

protected boolean matchSupportedConfigs(IContainer container, String[] remoteSupportedConfigs) {
    if (remoteSupportedConfigs == null)
        return false;
    ContainerTypeDescription description = getContainerTypeDescription(container);
    if (description == null)
        return false;
    String[] importedConfigs = description.getImportedConfigs(remoteSupportedConfigs);
    return (importedConfigs == null || importedConfigs.length == 0) ? false : true;
}
Also used : ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription)

Example 33 with ContainerTypeDescription

use of org.eclipse.ecf.core.ContainerTypeDescription in project ecf by eclipse.

the class AbstractHostContainerSelector method getContainerTypeDescriptionsForDefaultConfigTypes.

protected ContainerTypeDescription[] getContainerTypeDescriptionsForDefaultConfigTypes(ContainerTypeDescription[] descriptions) {
    String[] defaultConfigTypes = getDefaultConfigTypes();
    if (defaultConfigTypes == null || defaultConfigTypes.length == 0)
        return null;
    List results = new ArrayList();
    for (int i = 0; i < descriptions.length; i++) {
        // For each description, get supported config types
        String[] supportedConfigTypes = descriptions[i].getSupportedConfigs();
        if (supportedConfigTypes != null && matchDefaultConfigTypes(defaultConfigTypes, supportedConfigTypes))
            results.add(descriptions[i]);
    }
    return (ContainerTypeDescription[]) results.toArray(new ContainerTypeDescription[] {});
}
Also used : ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 34 with ContainerTypeDescription

use of org.eclipse.ecf.core.ContainerTypeDescription in project ecf by eclipse.

the class AbstractRemoteServiceRegisterTest method getServerContainerAdapter.

private IRemoteServiceContainerAdapter getServerContainerAdapter() {
    if (this.server != null)
        return (IRemoteServiceContainerAdapter) this.server.getAdapter(IRemoteServiceContainerAdapter.class);
    IContainer[] containers = getContainerManager().getAllContainers();
    String containerType = getServerContainerTypeName();
    for (int i = 0; i < containers.length; i++) {
        ContainerTypeDescription ctd = getContainerManager().getContainerTypeDescription(containers[i].getID());
        if (ctd != null && ctd.getName().equals(containerType))
            return (IRemoteServiceContainerAdapter) containers[i].getAdapter(IRemoteServiceContainerAdapter.class);
    }
    return null;
}
Also used : ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) IContainer(org.eclipse.ecf.core.IContainer)

Example 35 with ContainerTypeDescription

use of org.eclipse.ecf.core.ContainerTypeDescription in project ecf by eclipse.

the class ContainerFactoryServiceCreateTest method testCreateBaseContainer1.

public void testCreateBaseContainer1() throws Exception {
    final ContainerTypeDescription desc = getContainerFactoryService().getDescriptionByName(BASE_CONTAINER_TYPE_NAME);
    assertNotNull(desc);
    final IContainer base = getContainerFactoryService().createContainer(desc, IDFactory.getDefault().createGUID());
    assertNotNull(base);
}
Also used : ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) IContainer(org.eclipse.ecf.core.IContainer)

Aggregations

ContainerTypeDescription (org.eclipse.ecf.core.ContainerTypeDescription)54 IContainer (org.eclipse.ecf.core.IContainer)20 List (java.util.List)5 Namespace (org.eclipse.ecf.core.identity.Namespace)5 ExtensionRegistryRunnable (org.eclipse.ecf.core.util.ExtensionRegistryRunnable)5 ArrayList (java.util.ArrayList)3 Dictionary (java.util.Dictionary)3 Properties (java.util.Properties)3 IContainerManager (org.eclipse.ecf.core.IContainerManager)3 IRemoteServiceContainer (org.eclipse.ecf.remoteservice.IRemoteServiceContainer)3 URI (java.net.URI)2 URL (java.net.URL)2 Hashtable (java.util.Hashtable)2 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)2 ID (org.eclipse.ecf.core.identity.ID)2 IConnectHandlerPolicy (org.eclipse.ecf.core.security.IConnectHandlerPolicy)2 RestClientContainer (org.eclipse.ecf.remoteservice.rest.client.RestClientContainer)2 RpcClientContainer (org.eclipse.ecf.remoteservice.rpc.client.RpcClientContainer)2 Bundle (org.osgi.framework.Bundle)2 ServiceFactory (org.osgi.framework.ServiceFactory)2