Search in sources :

Example 6 with ExternalComponentPlugins

use of org.exoplatform.container.xml.ExternalComponentPlugins in project kernel by exoplatform.

the class ExoContainer method getExternalComponentPluginsUnused.

/**
 * Gives all the {@link ExternalComponentPlugins} that have not been used, <code>null</code>
 * if there are all used.
 */
protected Collection<ExternalComponentPlugins> getExternalComponentPluginsUnused() {
    Configuration configuration = getConfiguration();
    if (configuration == null)
        return null;
    Collection<ExternalComponentPlugins> result = null;
    for (Iterator<ExternalComponentPlugins> it = configuration.getExternalComponentPluginsIterator(); it.hasNext(); ) {
        ExternalComponentPlugins plugins = it.next();
        boolean toAdd = false;
        String target = plugins.getTargetComponent();
        if (target == null)
            toAdd = true;
        else if (configuration.getComponent(target) == null) {
            try {
                Class<?> c = ClassLoading.loadClass(target, ExoContainer.class);
                if (c.isAnnotation()) {
                // We assume that the target is a qualifier so we cannot know if it is normal
                // or not as it could be auto-registered and we don't know the bind type
                } else if (getComponentAdapterOfType(c) == null) {
                    // There is no ComponentAdapter corresponding to this
                    // particular class even the auto-registration could
                    // not allow to find a candidate so we can consider it
                    // as unused
                    toAdd = true;
                }
            } catch (ClassNotFoundException e) {
                if (LOG.isTraceEnabled())
                    LOG.trace("The class {} could not be found", target);
            // We assume that the target is meant to be used with
            // the annotation Named so we cannot know if it is normal
            // or not as it could be auto-registered and we don't know
            // the bind type
            }
        }
        if (toAdd) {
            if (result == null) {
                result = new ArrayList<ExternalComponentPlugins>();
            }
            result.add(plugins);
        }
    }
    return result;
}
Also used : Configuration(org.exoplatform.container.xml.Configuration) ExternalComponentPlugins(org.exoplatform.container.xml.ExternalComponentPlugins)

Example 7 with ExternalComponentPlugins

use of org.exoplatform.container.xml.ExternalComponentPlugins in project kernel by exoplatform.

the class TestExternalComponentPluginsProfile method testNoProfile.

public void testNoProfile() throws Exception {
    Configuration config = getConfiguration("external-component-plugins.xml");
    int size = 0;
    for (Iterator<ExternalComponentPlugins> it = config.getExternalComponentPluginsIterator(); it.hasNext(); ) {
        ExternalComponentPlugins ecp = it.next();
        assertEquals(1, ecp.getComponentPlugins().size());
        size++;
    }
    assertEquals(1, size);
}
Also used : Configuration(org.exoplatform.container.xml.Configuration) ExternalComponentPlugins(org.exoplatform.container.xml.ExternalComponentPlugins)

Example 8 with ExternalComponentPlugins

use of org.exoplatform.container.xml.ExternalComponentPlugins in project kernel by exoplatform.

the class TestExternalComponentPluginsProfile method testFooBarProfiles.

public void testFooBarProfiles() throws Exception {
    Configuration config = getConfiguration("external-component-plugins.xml", "foo", "bar");
    int size = 0;
    for (Iterator<ExternalComponentPlugins> it = config.getExternalComponentPluginsIterator(); it.hasNext(); ) {
        ExternalComponentPlugins ecp = it.next();
        assertEquals(3, ecp.getComponentPlugins().size());
        size++;
    }
    assertEquals(3, size);
}
Also used : Configuration(org.exoplatform.container.xml.Configuration) ExternalComponentPlugins(org.exoplatform.container.xml.ExternalComponentPlugins)

Aggregations

ExternalComponentPlugins (org.exoplatform.container.xml.ExternalComponentPlugins)8 Configuration (org.exoplatform.container.xml.Configuration)5 ComponentLifecycle (org.exoplatform.container.component.ComponentLifecycle)2 ConfigurationManager (org.exoplatform.container.configuration.ConfigurationManager)2 Component (org.exoplatform.container.xml.Component)2 InputStream (java.io.InputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 PrivilegedActionException (java.security.PrivilegedActionException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Singleton (javax.inject.Singleton)1 ComponentTask (org.exoplatform.container.ComponentTask)1 ConcurrentContainerMT (org.exoplatform.container.ConcurrentContainerMT)1 CyclicDependencyException (org.exoplatform.container.CyclicDependencyException)1 Dependency (org.exoplatform.container.Dependency)1 ExoContainer (org.exoplatform.container.ExoContainer)1 DefinitionException (org.exoplatform.container.context.DefinitionException)1 ContainerException (org.exoplatform.container.spi.ContainerException)1