public HibernateSessionBinding() {
super("hibernate-session");
}
public Object parse(Element element, Parse parse, Parser parser) {
HibernateSessionDescriptor descriptor = new HibernateSessionDescriptor();
if (element.hasAttribute("factory")) {
descriptor.setFactoryName(element.getAttribute("factory"));
}
Boolean tx = XmlUtil.attributeBoolean(element, "tx", false, parse);
if (tx!=null) {
descriptor.setTx(tx);
}
Boolean useCurrent = XmlUtil.attributeBoolean(element, "current", false, parse);
// if usage of current session is specified
if (useCurrent!=null) {
// set it accordingly
descriptor.setUseCurrent(useCurrent);
// and set the default of close appropriately
descriptor.setClose( !useCurrent );
}
Boolean close = XmlUtil.attributeBoolean(element, "close", false, parse);
if (close!=null) {
descriptor.setClose(close);
}
if (element.hasAttribute("standard-transaction")) {
descriptor.setStandardTransactionName(element.getAttribute("standard-transaction"));
}
if (element.hasAttribute("connection")) {
descriptor.setConnectionName(element.getAttribute("connection"));
}
return descriptor;
}