use of org.hibernate.console.HibernateConsoleRuntimeException in project jbosstools-hibernate by jbosstools.
the class ServiceImpl method newReverseEngineeringStrategy.
private Object newReverseEngineeringStrategy(final String className, Object delegate) {
try {
Class<?> clazz = ReflectHelper.classForName(className);
Class<?> revEngClass = ReflectHelper.classForName("org.hibernate.cfg.reveng.ReverseEngineeringStrategy");
Constructor<?> constructor = clazz.getConstructor(new Class[] { revEngClass });
return constructor.newInstance(new Object[] { delegate });
} catch (NoSuchMethodException e) {
try {
Class<?> clazz = ReflectHelper.classForName(className);
return clazz.newInstance();
} catch (Exception eq) {
throw new HibernateConsoleRuntimeException(eq);
}
} catch (Exception e) {
throw new HibernateConsoleRuntimeException(e);
}
}
use of org.hibernate.console.HibernateConsoleRuntimeException in project jbosstools-hibernate by jbosstools.
the class EclipseConsoleConfigurationPreferences method readStateFrom.
public static EclipseConsoleConfigurationPreferences[] readStateFrom(File f) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser;
try {
parser = factory.newDocumentBuilder();
Document doc = parser.parse(f);
Element root = doc.getDocumentElement();
// TODO: only get nearest children.
NodeList elementsByTagName = root.getElementsByTagName(CONFIGURATION_TAG);
EclipseConsoleConfigurationPreferences[] result = new EclipseConsoleConfigurationPreferences[elementsByTagName.getLength()];
for (int i = 0; i < elementsByTagName.getLength(); i++) {
result[i] = new EclipseConsoleConfigurationPreferences();
result[i].readStateFrom((Element) elementsByTagName.item(i));
}
return result;
} catch (SAXException sa) {
throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.EclipseConsoleConfigurationPreferences_errors_while_parsing + f, sa);
} catch (ParserConfigurationException e) {
throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.EclipseConsoleConfigurationPreferences_errors_while_parsing + f, e);
} catch (IOException e) {
throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.EclipseConsoleConfigurationPreferences_errors_while_parsing + f, e);
}
}
use of org.hibernate.console.HibernateConsoleRuntimeException in project jbosstools-hibernate by jbosstools.
the class EclipseConsoleConfigurationPreferences method getCustomClassPathURLS.
public URL[] getCustomClassPathURLS() {
try {
IJavaProject project = ProjectUtils.findJavaProject(getProjectName());
String[] additonal = new String[0];
if (project != null && useProjectClasspath() && project.exists()) {
try {
additonal = JavaRuntime.computeDefaultRuntimeClassPath(project);
} catch (CoreException e) {
throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.EclipseConsoleConfigurationPreferences_could_not_compute_def_classpath + project);
}
}
URL[] rawLocationsURLForResources = ClassLoaderHelper.getRawLocationsURLForResources(customClasspath);
URL[] result = new URL[rawLocationsURLForResources.length + additonal.length];
for (int i = 0; i < rawLocationsURLForResources.length; i++) {
result[i] = rawLocationsURLForResources[i];
}
for (int i = 0; i < additonal.length; i++) {
String url = additonal[i];
result[i + rawLocationsURLForResources.length] = new File(url).toURI().toURL();
}
return result;
} catch (MalformedURLException mue) {
throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.EclipseConsoleConfigurationPreferences_could_not_resolve_classpaths, mue);
}
}
use of org.hibernate.console.HibernateConsoleRuntimeException in project jbosstools-hibernate by jbosstools.
the class BuildSessionFactoryAction method doRun.
protected void doRun() {
for (Iterator<?> i = getSelectedNonResources().iterator(); i.hasNext(); ) {
try {
Object node = i.next();
if (node instanceof ConsoleConfiguration) {
ConsoleConfiguration config = (ConsoleConfiguration) node;
if (config.isSessionFactoryCreated()) {
config.reset();
} else {
config.build();
config.buildSessionFactory();
}
updateState(config);
}
} catch (HibernateConsoleRuntimeException he) {
HibernateConsolePlugin.getDefault().showError(viewer.getControl().getShell(), HibernateConsoleMessages.BuildSessionFactoryAction_exception_while_start_hibernate, he);
} catch (UnsupportedClassVersionError ucve) {
HibernateConsolePlugin.getDefault().showError(viewer.getControl().getShell(), HibernateConsoleMessages.BuildSessionFactoryAction_start_hibernate_resulted, ucve);
}
}
}
Aggregations