use of org.hibernate.console.execution.DefaultExecutionContext in project jbosstools-hibernate by jbosstools.
the class HibernateExtension method buildWith.
public IConfiguration buildWith(final IConfiguration cfg, final boolean includeMappings) {
reinitClassLoader();
// TODO handle user libraries here
executionContext = new DefaultExecutionContext(prefs.getName(), classLoader);
IConfiguration result = (IConfiguration) execute(new Command() {
public Object execute() {
ConfigurationFactory cf = new ConfigurationFactory(prefs, fakeDrivers);
return cf.createConfiguration(cfg, includeMappings);
}
});
return result;
}
use of org.hibernate.console.execution.DefaultExecutionContext in project jbosstools-hibernate by jbosstools.
the class ConsoleConfiguration method buildWith.
/**
* @return
*/
public IConfiguration buildWith(final IConfiguration cfg, final boolean includeMappings) {
reinitClassLoader();
executionContext = new DefaultExecutionContext(getName(), classLoader);
IConfiguration result = (IConfiguration) execute(new Command() {
public Object execute() {
ConfigurationFactory csf = new ConfigurationFactory(prefs, fakeDrivers);
return csf.createConfiguration(cfg, includeMappings);
}
});
return result;
}
use of org.hibernate.console.execution.DefaultExecutionContext in project jbosstools-hibernate by jbosstools.
the class DriverDeleteTest method initExecutionContext.
private void initExecutionContext() {
final ConsoleConfigClassLoader urlClassLoader = createJarClassLoader();
DefaultExecutionContext dec = new DefaultExecutionContext(testName.getMethodName(), urlClassLoader);
ExecutionContext.Command command = new ExecutionContext.Command() {
public Object execute() {
try {
Class<?> driverClass = null;
driverClass = (Class<?>) ReflectHelper.classForName(DRIVER_TEST_CLASS);
Driver driver2 = (Driver) driverClass.newInstance();
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
if (contextClassLoader != null) {
driverClass = (Class<?>) contextClassLoader.loadClass(DRIVER_TEST_CLASS);
}
java.util.Properties info = new java.util.Properties();
info.put("user", CONNECTION_USERNAME);
info.put("password", CONNECTION_PASSWORD);
try {
Connection connection = driver2.connect(CONNECTION_URL, info);
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
} catch (SecurityException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return null;
}
};
dec.execute(command);
command = null;
dec = null;
urlClassLoader.close();
}
Aggregations