[jboss-cvs] jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console ...
Max Rydahl Andersen
mandersen at jboss.com
Mon Dec 11 17:22:01 EST 2006
User: mandersen
Date: 06/12/11 17:22:00
Modified: hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console
KnownConfigurations.java ConsoleConfiguration.java
Log:
HBX-830 Database errors should not be displayed in Log Error view
HBX-837 Have seperate logs per configuration
Revision Changes Path
1.8 +44 -0 jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/KnownConfigurations.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: KnownConfigurations.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/KnownConfigurations.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- KnownConfigurations.java 27 Oct 2006 13:35:27 -0000 1.7
+++ KnownConfigurations.java 11 Dec 2006 22:21:59 -0000 1.8
@@ -22,7 +22,10 @@
package org.hibernate.console;
import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -41,6 +44,11 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleManager;
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.MessageConsoleStream;
import org.hibernate.SessionFactory;
import org.hibernate.console.node.BaseNode;
import org.hibernate.console.node.ConfigurationListNode;
@@ -91,6 +99,8 @@
return instance;
}
+
+
private abstract class Notification {
public void run(KnownConfigurationsListener listener) {
@@ -168,9 +178,13 @@
}
});
oldConfig.reset();
+ removeLoggingStream( oldConfig );
}
+
+
}
+
/**
* Answer whether the provided configuration name is known by the provider or not.
* The name string corresponds to the Strin returned by ConsoleConfiguration#getName()
@@ -220,6 +234,34 @@
return rootNode;
}
+ // TODO: decouple this logging from Eclipse platform!
+ private Map loggingStreams = new HashMap();
+ public MessageConsoleStream findLoggingStream(String name) {
+ Object[] console = (Object[]) loggingStreams.get(name);
+ if(console==null) {
+ console = new Object[2];
+ String secondaryId = "Hibernate Log - " + (name==null?"<unknown>":name);
+ console[0] = new MessageConsole(secondaryId, null);
+ IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
+ consoleManager.addConsoles(new IConsole[] { (IConsole) console[0] });
+ console[1] = ((MessageConsole)console[0]).newMessageStream();
+ loggingStreams.put(name, console);
+ }
+ return (MessageConsoleStream) console[1];
+ }
+
+ private void removeLoggingStream(ConsoleConfiguration oldConfig) {
+ Object[] object = (Object[]) loggingStreams.remove( oldConfig.getName() );
+ if(object!=null) {
+ MessageConsole mc = (MessageConsole)object[0];
+ MessageConsoleStream stream = (MessageConsoleStream)object[1];
+ try { stream.close(); } catch(IOException ie) { /* ignore */ };
+ IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
+ consoleManager.removeConsoles( new IConsole[] { mc } );
+ }
+ }
+
+
public ConsoleConfiguration find(String lastUsedName) {
if(configurations==null) return null;
if(lastUsedName==null) return null;
@@ -280,4 +322,6 @@
public List getQueryParameterList() {
return queryParameters;
}
+
+
}
1.14 +1 -4 jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ConsoleConfiguration.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- ConsoleConfiguration.java 27 Nov 2006 15:30:22 -0000 1.13
+++ ConsoleConfiguration.java 11 Dec 2006 22:21:59 -0000 1.14
@@ -26,8 +26,6 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
-import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
@@ -44,7 +42,6 @@
import org.dom4j.DocumentException;
import org.dom4j.Node;
import org.dom4j.io.DOMWriter;
-import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.Session;
@@ -153,7 +150,7 @@
*/
public Configuration buildWith(final Configuration cfg, final boolean includeMappings) {
URL[] customClassPathURLS = prefs.getCustomClassPathURLS();
- executionContext = new DefaultExecutionContext( new URLClassLoader( customClassPathURLS, getParentClassLoader() ) );
+ executionContext = new DefaultExecutionContext( getName(), new URLClassLoader( customClassPathURLS, getParentClassLoader() ) );
Configuration result = (Configuration) executionContext.execute(new ExecutionContext.Command() {
More information about the jboss-cvs-commits
mailing list