use of org.exoplatform.container.xml.Component in project kernel by exoplatform.
the class ContainerUtil method addComponents.
public static void addComponents(ExoContainer container, ConfigurationManager conf) {
Collection components = conf.getComponents();
if (components == null)
return;
Iterator i = components.iterator();
while (i.hasNext()) {
Component component = (Component) i.next();
String type = component.getType();
String key = component.getKey();
try {
Class<?> classType = ClassLoading.loadClass(type, ContainerUtil.class);
if (key == null) {
if (component.isMultiInstance()) {
throw new UnsupportedOperationException("Multi-instance isn't allowed anymore");
} else {
container.registerComponentImplementation(classType);
}
} else {
try {
Class<?> keyType = ClassLoading.loadClass(key, ContainerUtil.class);
if (component.isMultiInstance()) {
throw new UnsupportedOperationException("Multi-instance isn't allowed anymore");
} else {
container.registerComponentImplementation(keyType, classType);
}
} catch (Exception ex) {
container.registerComponentImplementation(key, classType);
}
}
} catch (ClassNotFoundException ex) {
LOG.error("Cannot register the component corresponding to key = '" + key + "' and type = '" + type + "'", ex);
}
}
}
use of org.exoplatform.container.xml.Component in project kernel by exoplatform.
the class TestCollectionValue method getConfiguredCollection.
private XMLCollection getConfiguredCollection(String... profiles) throws Exception {
Configuration config = getConfiguration("collection-configuration.xml", profiles);
Component a = config.getComponent(InitParamsHolder.class.getName());
ObjectParameter op = a.getInitParams().getObjectParam("test.configuration");
XMLObject o = op.getXMLObject();
XMLField xf = o.getField("role");
return xf.getCollection();
}
use of org.exoplatform.container.xml.Component in project kernel by exoplatform.
the class TestComponentPluginProfile method testNoProfile.
public void testNoProfile() throws Exception {
Configuration config = getConfiguration("component-plugin-configuration.xml");
Component component = config.getComponent("Component");
assertEquals(1, component.getComponentPlugins().size());
}
use of org.exoplatform.container.xml.Component in project kernel by exoplatform.
the class TestInitParamProfile method testFooProfile.
public void testFooProfile() throws Exception {
Configuration config = getConfiguration("init-param-configuration.xml", "foo");
Component component = config.getComponent("Component");
InitParams initParams = component.getInitParams();
ValueParam valueParam = initParams.getValueParam("param");
assertEquals("foo", valueParam.getValue());
}
use of org.exoplatform.container.xml.Component in project kernel by exoplatform.
the class TestInitParamProfile method testNoProfile.
public void testNoProfile() throws Exception {
Configuration config = getConfiguration("init-param-configuration.xml");
Component component = config.getComponent("Component");
InitParams initParams = component.getInitParams();
ValueParam valueParam = initParams.getValueParam("param");
assertEquals("empty", valueParam.getValue());
}
Aggregations