use of com.opensymphony.xwork2.util.location.LocatableProperties in project struts by apache.
the class SetPropertiesTest method doTestAddingToListsWithObjects.
public void doTestAddingToListsWithObjects(final boolean allowAdditions) {
loadConfigurationProviders(new StubConfigurationProvider() {
@Override
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
builder.factory(ObjectTypeDeterminer.class, new Factory() {
public Object create(Context context) throws Exception {
return new MockObjectTypeDeterminer(null, Cat.class, null, allowAdditions);
}
@Override
public Class type() {
return Cat.class;
}
});
}
});
Foo foo = new Foo();
foo.setMoreCats(new ArrayList());
String spielname = "Spielen";
ValueStack vs = ActionContext.getContext().getValueStack();
vs.getContext().put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
vs.getContext().put(ReflectionContextState.CREATE_NULL_OBJECTS, Boolean.TRUE);
vs.push(foo);
try {
vs.setValue("moreCats[2].name", spielname);
} catch (IndexOutOfBoundsException e) {
if (allowAdditions) {
throw e;
}
}
Object setCat = null;
if (allowAdditions) {
setCat = foo.getMoreCats().get(2);
assertNotNull(setCat);
assertTrue(setCat instanceof Cat);
assertTrue(((Cat) setCat).getName().equals(spielname));
} else {
assertTrue(foo.getMoreCats() == null || foo.getMoreCats().size() == 0);
}
// has been created
if (allowAdditions) {
spielname = "paws";
vs.setValue("moreCats[0].name", spielname);
setCat = foo.getMoreCats().get(0);
assertNotNull(setCat);
assertTrue(setCat instanceof Cat);
assertTrue(((Cat) setCat).getName().equals(spielname));
}
}
use of com.opensymphony.xwork2.util.location.LocatableProperties in project struts by apache.
the class DefaultPropertiesProvider method register.
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
try {
PropertiesSettings defaultSettings = new PropertiesSettings("org/apache/struts2/default");
loadSettings(props, defaultSettings);
} catch (Exception e) {
throw new ConfigurationException("Could not find or error in org/apache/struts2/default.properties", e);
}
}
use of com.opensymphony.xwork2.util.location.LocatableProperties in project onebusaway-application-modules by camsys.
the class SpringContainer method register.
@Override
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
// Since we're about to override...
builder.setAllowDuplicates(true);
builder.factory(ObjectFactory.class, new Factory<ObjectFactory>() {
public ObjectFactory create(Context xworkContext) throws Exception {
SpringObjectFactory f = new SpringObjectFactory();
xworkContext.getContainer().inject(f);
f.setApplicationContext(_applicationContext);
f.setAutowireStrategy(_autoWireStrategy);
return f;
}
@Override
public Class<? extends ObjectFactory> type() {
return ObjectFactory.class;
}
});
}
Aggregations