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;
}
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);
}
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);
}
Aggregations