final WebContinuation kont = FlowHelper.getWebContinuation(objectModel);
// Hack? I use JXPath to determine the properties of the bean object
final JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass());
DynamicPropertyHandler h = null;
final PropertyDescriptor[] props;
if (bi.isDynamic()) {
Class cl = bi.getDynamicPropertyHandlerClass();
try {
h = (DynamicPropertyHandler) cl.newInstance();
} catch (Exception exc) {
exc.printStackTrace();
h = null;
}
props = null;
} else {
h = null;
props = bi.getPropertyDescriptors();
}
final DynamicPropertyHandler handler = h;
this.velocityContext = new Context() {
public Object put(String key, Object value) {
if (key.equals("flowContext")
|| key.equals("continuation")) {
return value;
}
if (handler != null) {
handler.setProperty(bean, key, value);
return value;
} else {
for (int i = 0; i < props.length; i++) {
if (props[i].getName().equals(key)) {
try {
return props[i].getWriteMethod().invoke(bean, new Object[]{value});
} catch (Exception ignored) {
break;
}
}
}
return value;
}
}
public boolean containsKey(Object key) {
if (key.equals("flowContext")
|| key.equals("continuation")) {
return true;
}
if (handler != null) {
String[] result = handler.getPropertyNames(bean);
for (int i = 0; i < result.length; i++) {
if (key.equals(result[i])) {
return true;
}
}
} else {
for (int i = 0; i < props.length; i++) {
if (key.equals(props[i].getName())) {
return true;
}
}
}
return false;
}
public Object[] getKeys() {
Object[] result = null;
if (handler != null) {
result = handler.getPropertyNames(bean);
} else {
result = new Object[props.length];
for (int i = 0; i < props.length; i++) {
result[i] = props[i].getName();
}
}
Set set = new HashSet();
for (int i = 0; i < result.length; i++) {
set.add(result[i]);
}
set.add("flowContext");
set.add("continuation");
result = new Object[set.size()];
set.toArray(result);
return result;
}
public Object get(String key) {
if (key.equals("flowContext")) {
return bean;
}
if (key.equals("continuation")) {
return kont;
}
if (handler != null) {
return handler.getProperty(bean, key.toString());
} else {
for (int i = 0; i < props.length; i++) {
if (props[i].getName().equals(key)) {
try {
return props[i].getReadMethod().invoke(bean, null);