Search in sources :

Example 1 with Component

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);
        }
    }
}
Also used : Iterator(java.util.Iterator) Collection(java.util.Collection) Component(org.exoplatform.container.xml.Component) PrivilegedActionException(java.security.PrivilegedActionException) DefinitionException(org.exoplatform.container.context.DefinitionException) UnproxyableResolutionException(javax.enterprise.inject.UnproxyableResolutionException) IOException(java.io.IOException)

Example 2 with Component

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();
}
Also used : XMLField(org.exoplatform.xml.object.XMLField) Configuration(org.exoplatform.container.xml.Configuration) ObjectParameter(org.exoplatform.container.xml.ObjectParameter) XMLObject(org.exoplatform.xml.object.XMLObject) Component(org.exoplatform.container.xml.Component)

Example 3 with Component

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());
}
Also used : Configuration(org.exoplatform.container.xml.Configuration) Component(org.exoplatform.container.xml.Component)

Example 4 with Component

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());
}
Also used : InitParams(org.exoplatform.container.xml.InitParams) Configuration(org.exoplatform.container.xml.Configuration) Component(org.exoplatform.container.xml.Component) ValueParam(org.exoplatform.container.xml.ValueParam)

Example 5 with Component

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());
}
Also used : InitParams(org.exoplatform.container.xml.InitParams) Configuration(org.exoplatform.container.xml.Configuration) Component(org.exoplatform.container.xml.Component) ValueParam(org.exoplatform.container.xml.ValueParam)

Aggregations

Component (org.exoplatform.container.xml.Component)16 Configuration (org.exoplatform.container.xml.Configuration)9 ConfigurationManager (org.exoplatform.container.configuration.ConfigurationManager)6 InitParams (org.exoplatform.container.xml.InitParams)5 ObjectParameter (org.exoplatform.container.xml.ObjectParameter)4 ValueParam (org.exoplatform.container.xml.ValueParam)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 PrivilegedActionException (java.security.PrivilegedActionException)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 AbstractComponentAdapter (org.exoplatform.container.AbstractComponentAdapter)2 ComponentTask (org.exoplatform.container.ComponentTask)2 CyclicDependencyException (org.exoplatform.container.CyclicDependencyException)2 Dependency (org.exoplatform.container.Dependency)2 DefinitionException (org.exoplatform.container.context.DefinitionException)2 ComponentAdapter (org.exoplatform.container.spi.ComponentAdapter)2 ExternalComponentPlugins (org.exoplatform.container.xml.ExternalComponentPlugins)2 XMLField (org.exoplatform.xml.object.XMLField)2 XMLObject (org.exoplatform.xml.object.XMLObject)2 IBindingFactory (org.jibx.runtime.IBindingFactory)2