use of org.hibernate.console.execution.ExecutionContext.Command in project jbosstools-hibernate by jbosstools.
the class ConsoleConfiguration method buildMappings.
public void buildMappings() {
execute(new Command() {
public Object execute() {
getConfiguration().buildMappings();
return null;
}
});
getHibernateExtension().buildMappings();
}
use of org.hibernate.console.execution.ExecutionContext.Command in project jbosstools-hibernate by jbosstools.
the class IndexRebuildHandler method run.
private void run(final ConsoleConfiguration consoleConfig, final Set<Class> classes) {
try {
consoleConfig.execute(new Command() {
public Object execute() {
final IConfiguration cfg = consoleConfig.getConfiguration();
if (cfg == null) {
return null;
}
IHSearchService service = HSearchServiceLookup.findService(HSearchConsoleConfigurationPreferences.getHSearchVersion(consoleConfig.getName()));
service.newIndexRebuild(consoleConfig.getSessionFactory(), classes);
return null;
}
});
MessageDialog.openInformation(HibernateConsolePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), "Initial index rebuild", "Initial index rebuild succesfully finished");
} catch (Exception e) {
MessageDialog.openError(HibernateConsolePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), "Initial index rebuild failed", e.getMessage());
}
}
use of org.hibernate.console.execution.ExecutionContext.Command in project jbosstools-hibernate by jbosstools.
the class CodeGenerationLaunchDelegate method runExporters.
private IArtifactCollector runExporters(final ExporterAttributes attributes, final ExporterFactory[] exporterFactories, final Set<String> outputDirectories, final IProgressMonitor monitor) throws CoreException {
monitor.beginTask(HibernateConsoleMessages.CodeGenerationLaunchDelegate_generating_code_for + attributes.getConsoleConfigurationName(), exporterFactories.length + 1);
if (monitor.isCanceled())
return null;
ConsoleConfiguration cc = KnownConfigurations.getInstance().find(attributes.getConsoleConfigurationName());
if (attributes.isReverseEngineer()) {
monitor.subTask(HibernateConsoleMessages.CodeGenerationLaunchDelegate_reading_jdbc_metadata);
}
final IConfiguration cfg = buildConfiguration(attributes, cc, ResourcesPlugin.getWorkspace().getRoot());
monitor.worked(1);
if (monitor.isCanceled())
return null;
final IService service = cc.getHibernateExtension().getHibernateService();
return (IArtifactCollector) cc.execute(new Command() {
public Object execute() {
IArtifactCollector artifactCollector = service.newArtifactCollector();
// Global properties
Properties props = new Properties();
// $NON-NLS-1$
props.put(CodeGenerationStrings.EJB3, "" + attributes.isEJB3Enabled());
// $NON-NLS-1$
props.put(CodeGenerationStrings.JDK5, "" + attributes.isJDK5Enabled());
for (int i = 0; i < exporterFactories.length; i++) {
monitor.subTask(exporterFactories[i].getExporterDefinition().getDescription());
Properties globalProperties = new Properties();
globalProperties.putAll(props);
IExporter exporter;
try {
exporter = exporterFactories[i].createConfiguredExporter(cfg, attributes.getOutputPath(), attributes.getTemplatePath(), globalProperties, outputDirectories, artifactCollector, service);
} catch (CoreException e) {
throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_error_while_setting_up + exporterFactories[i].getExporterDefinition(), e);
}
try {
exporter.start();
} catch (HibernateException he) {
throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_error_while_running + exporterFactories[i].getExporterDefinition().getDescription(), he);
}
monitor.worked(1);
}
return artifactCollector;
}
});
}
use of org.hibernate.console.execution.ExecutionContext.Command in project jbosstools-hibernate by jbosstools.
the class ConsoleConfiguration method buildSessionFactory.
public void buildSessionFactory() {
execute(new Command() {
public Object execute() {
if (sessionFactory != null) {
throw new HibernateConsoleRuntimeException(ConsoleMessages.ConsoleConfiguration_factory_not_closed_before_build_new_factory);
}
sessionFactory = getConfiguration().buildSessionFactory();
fireFactoryBuilt();
return null;
}
});
getHibernateExtension().buildSessionFactory();
}
use of org.hibernate.console.execution.ExecutionContext.Command 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;
}
Aggregations