use of org.exoplatform.container.xml.ObjectParameter in project kernel by exoplatform.
the class PortalContainerConfig method create.
/**
* Create the default {@link PortalContainerDefinition} corresponding to the given parameters
* @param params the parameter to initialize
*/
private PortalContainerDefinition create(InitParams params) {
ObjectParameter oDpd = null;
if (params != null) {
oDpd = params.getObjectParam("default.portal.definition");
}
PortalContainerDefinition def = null;
if (oDpd != null) {
// A default portal definition has been found
final Object o = oDpd.getObject();
if (o instanceof PortalContainerDefinition) {
// The nested object is of the right type
def = (PortalContainerDefinition) o;
} else {
// The nested object is not of the right type, thus it will be ignored
LOG.warn("The object parameter 'default.portal.definition' should be of type " + PortalContainerDefinition.class);
}
}
if (def == null) {
def = new PortalContainerDefinition();
}
initName(params, def);
initRestContextName(params, def);
initRealmName(params, def);
initializeSettings(def, false);
return def;
}
use of org.exoplatform.container.xml.ObjectParameter in project kernel by exoplatform.
the class TestConfigurationService method testConfigurationService.
public void testConfigurationService(InitParams params) throws Exception {
ObjectParameter objParam = params.getObjectParam("new.user.configuration");
objParam.getObject();
}
use of org.exoplatform.container.xml.ObjectParameter in project kernel by exoplatform.
the class TestExoCacheFactoryImpl method testArguments.
public void testArguments() throws Exception {
try {
new ExoCacheFactoryImpl(pc.getContext(), null);
fail("An IllegalArgumentException should occur");
} catch (IllegalArgumentException e) {
// OK
}
try {
new ExoCacheFactoryImpl(pc.getContext(), new InitParams());
fail("An IllegalArgumentException should occur");
} catch (IllegalArgumentException e) {
// OK
}
InitParams params;
try {
params = new InitParams();
ValueParam vp = new ValueParam();
vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
params.addParam(vp);
new ExoCacheFactoryImpl(pc.getContext(), params);
fail("An IllegalArgumentException should occur");
} catch (IllegalArgumentException e) {
// OK
}
try {
params = new InitParams();
ValueParam vp = new ValueParam();
vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
vp.setValue("");
params.addParam(vp);
new ExoCacheFactoryImpl(pc.getContext(), params);
fail("An IllegalArgumentException should occur");
} catch (IllegalArgumentException e) {
// OK
}
try {
params = new InitParams();
ValueParam vp = new ValueParam();
vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
vp.setValue("localhost:11211");
params.addParam(vp);
new ExoCacheFactoryImpl(pc.getContext(), params);
} catch (Exception e) {
fail("No exception was expected");
}
try {
params = new InitParams();
ValueParam vp = new ValueParam();
vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
vp.setValue("localhost:11211");
params.addParam(vp);
ObjectParameter op = new ObjectParameter();
op.setName(ExoCacheFactoryImpl.CONNECTION_FACTORY_CREATOR);
op.setObject(new Object());
params.addParam(op);
new ExoCacheFactoryImpl(pc.getContext(), params);
fail("An IllegalArgumentException should occur");
} catch (IllegalArgumentException e) {
// OK
}
try {
params = new InitParams();
ValueParam vp = new ValueParam();
vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
vp.setValue("localhost:11211");
params.addParam(vp);
ObjectParameter op = new ObjectParameter();
op.setName(ExoCacheFactoryImpl.CONNECTION_FACTORY_CREATOR);
op.setObject(new BinaryConnectionFactoryCreator());
params.addParam(op);
new ExoCacheFactoryImpl(pc.getContext(), params);
} catch (Exception e) {
fail("No exception was expected");
}
try {
params = new InitParams();
ValueParam vp = new ValueParam();
vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
vp.setValue("localhost:11211");
params.addParam(vp);
ObjectParameter op = new ObjectParameter();
op.setName(ExoCacheFactoryImpl.CONNECTION_FACTORY_CREATOR);
op.setObject(new BinaryConnectionFactoryCreator());
params.addParam(op);
ValueParam vp2 = new ValueParam();
vp2.setName(ExoCacheFactoryImpl.DEFAULT_EXPIRATION_TIMEOUT);
vp2.setValue("foo");
params.addParam(vp2);
new ExoCacheFactoryImpl(pc.getContext(), params);
fail("An exception was expected");
} catch (Exception e) {
// OK
}
try {
params = new InitParams();
ValueParam vp = new ValueParam();
vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
vp.setValue("localhost:11211");
params.addParam(vp);
ObjectParameter op = new ObjectParameter();
op.setName(ExoCacheFactoryImpl.CONNECTION_FACTORY_CREATOR);
op.setObject(new BinaryConnectionFactoryCreator());
params.addParam(op);
ValueParam vp2 = new ValueParam();
vp2.setName(ExoCacheFactoryImpl.DEFAULT_EXPIRATION_TIMEOUT);
vp2.setValue("1000");
params.addParam(vp2);
new ExoCacheFactoryImpl(pc.getContext(), params);
} catch (Exception e) {
fail("No exception was expected");
}
}
use of org.exoplatform.container.xml.ObjectParameter in project kernel by exoplatform.
the class TestField method getConfiguredCollection.
private XMLCollection getConfiguredCollection(String... profiles) throws Exception {
Configuration config = getConfiguration("field-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.ObjectParameter in project kernel by exoplatform.
the class TestConfigurationXML method testSystemPropertyResolving.
public void testSystemPropertyResolving() throws Exception {
System.setProperty("c_value", "c_external_value");
System.setProperty("d_value", "d_external_value");
System.setProperty("false_value", "false");
System.setProperty("true_value", "true");
System.setProperty("FALSE_value", "FALSE");
System.setProperty("TRUE_value", "TRUE");
System.setProperty("integer_value", "5");
System.setProperty("long_value", "41");
System.setProperty("double_value", "172.5");
//
IBindingFactory bfact = BindingDirectory.getFactory(XMLObject.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
URL url = TestConfigurationXML.class.getResource("../../../../test-resolved-property.xml");
Configuration conf = (Configuration) uctx.unmarshalDocument(url.openStream(), null);
assertNotNull(conf);
//
Component component = conf.getComponent("component");
assertNotNull(component);
//
assertValueParam("a_value", component, "a");
assertValueParam("${b_value}", component, "b");
assertValueParam("c_external_value", component, "c");
assertValueParam("_d_external_value_", component, "d");
//
assertPropertyParam("a_value", component, "e", "e_a");
assertPropertyParam("${b_value}", component, "e", "e_b");
assertPropertyParam("c_external_value", component, "e", "e_c");
assertPropertyParam("_d_external_value_", component, "e", "e_d");
//
ObjectParameter o = component.getInitParams().getObjectParam("f");
assertNotNull(o);
Person p = (Person) o.getObject();
assertNotNull(p);
assertEquals("a_value", p.address_a);
assertEquals("${b_value}", p.address_b);
assertEquals("c_external_value", p.address_c);
assertEquals("_d_external_value_", p.address_d);
assertEquals(true, p.male_a);
assertEquals(false, p.male_b);
assertEquals(true, p.male_c);
assertEquals(false, p.male_d);
assertEquals(true, p.male_e);
assertEquals(false, p.male_f);
assertEquals(4, p.age_a);
assertEquals(5, p.age_b);
assertEquals(40, p.weight_a);
assertEquals(41, p.weight_b);
assertEquals(172.4D, p.size_a);
assertEquals(172.5D, p.size_b);
}
Aggregations