protected String standardTransactionName;
protected String connectionName;
public Object construct(WireContext wireContext) {
// get the hibernate-session-factory
SessionFactory sessionFactory = null;
if (factoryName!=null) {
sessionFactory = (SessionFactory) wireContext.get(factoryName);
} else {
Environment environment = wireContext.getEnvironment();
if (environment!=null) {
sessionFactory = environment.get(SessionFactory.class);
} else {
sessionFactory = wireContext.get(SessionFactory.class);
}
}
if (sessionFactory==null) {
throw new WireException("couldn't find hibernate-session-factory "+(factoryName!=null ? "'"+factoryName+"'" : "by type ")+"to open a hibernate-session");
}
// open the hibernate-session
Session session = null;
if (connectionName!=null) {
Connection connection = (Connection) wireContext.get(connectionName);
log.finest("creating hibernate session with connection "+connection);
session = sessionFactory.openSession(connection);
} else {
log.finest("creating hibernate session");
session = sessionFactory.openSession();
}
return session;
}