提交 f1482f1d 编写于 作者: A Alexander Fedorov

#2556 remove SESSION_INFO extends DBGSessionInfo from template

Former-commit-id: db1b56b8
上级 0278cd89
......@@ -40,7 +40,7 @@ public abstract class DBGBaseController implements DBGController {
}
@Override
public DBGSession connect(DBRProgressMonitor monitor) throws DBGException {
public DBGSession<?> connect(DBRProgressMonitor monitor) throws DBGException {
DBPDataSource dataSource = dataSourceContainer.getDataSource();
if (!dataSourceContainer.isConnected()) {
throw new DBGException("Not connected to database");
......@@ -55,22 +55,22 @@ public abstract class DBGBaseController implements DBGController {
}
}
protected abstract DBGSession createSession(DBRProgressMonitor monitor, DBPDataSource dataSource) throws DBGException;
protected abstract DBGSession<?> createSession(DBRProgressMonitor monitor, DBPDataSource dataSource) throws DBGException;
@Override
public void resume(DBRProgressMonitor monitor, DBGSession session) throws DBGException {
public void resume(DBRProgressMonitor monitor, DBGSession<?> session) throws DBGException {
// TODO Auto-generated method stub
}
@Override
public void suspend(DBRProgressMonitor monitor, DBGSession session) throws DBGException {
public void suspend(DBRProgressMonitor monitor, DBGSession<?> session) throws DBGException {
// TODO Auto-generated method stub
}
@Override
public void terminate(DBRProgressMonitor monitor, DBGSession session) throws DBGException {
public void terminate(DBRProgressMonitor monitor, DBGSession<?> session) throws DBGException {
}
......
......@@ -17,23 +17,20 @@
*/
package org.jkiss.dbeaver.debug;
import java.util.Map;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.registry.DataSourceDescriptor;
/**
* This interface is expected to be used in synch manner
*/
public interface DBGController {
DBGSession connect(DBRProgressMonitor monitor) throws DBGException;
DBGSession<?> connect(DBRProgressMonitor monitor) throws DBGException;
void resume(DBRProgressMonitor monitor, DBGSession session) throws DBGException;
void resume(DBRProgressMonitor monitor, DBGSession<?> session) throws DBGException;
void suspend(DBRProgressMonitor monitor, DBGSession session) throws DBGException;
void suspend(DBRProgressMonitor monitor, DBGSession<?> session) throws DBGException;
void terminate(DBRProgressMonitor monitor, DBGSession session) throws DBGException;
void terminate(DBRProgressMonitor monitor, DBGSession<?> session) throws DBGException;
void dispose() throws DBGException;
......
......@@ -19,10 +19,11 @@
package org.jkiss.dbeaver.debug;
import java.util.List;
import java.util.Map;
public interface DBGSession<SESSION_INFO extends DBGSessionInfo, DEBUG_OBJECT extends DBGObject> {
public interface DBGSession<DEBUG_OBJECT extends DBGObject> {
SESSION_INFO getSessionInfo();
Map<String, Object> getSessionInfo();
String getTitle();
......
......@@ -27,13 +27,13 @@ public interface DBGSessionManager {
List<? extends DBGSessionInfo> getSessions() throws DBGException;
DBGSession<? extends DBGSessionInfo, ? extends DBGObject> getDebugSession(Object id) throws DBGException;
DBGSession<? extends DBGObject> getDebugSession(Object id) throws DBGException;
List<DBGSession<?, ?>> getDebugSessions() throws DBGException;
List<DBGSession<?>> getDebugSessions() throws DBGException;
void terminateSession(Object id);
DBGSession<? extends DBGSessionInfo, ? extends DBGObject> createDebugSession(DBCExecutionContext connection) throws DBGException;
DBGSession<? extends DBGObject> createDebugSession(DBCExecutionContext connection) throws DBGException;
boolean isSessionExists(Object id);
......
......@@ -48,11 +48,11 @@ public class PostgreDebugController extends DBGBaseController {
}
@Override
protected DBGSession createSession(DBRProgressMonitor monitor, DBPDataSource dataSource) throws DBGException {
protected DBGSession<?> createSession(DBRProgressMonitor monitor, DBPDataSource dataSource) throws DBGException {
PostgreDebugSessionManager sessionManager = getSessionManager(monitor);
try {
JDBCExecutionContext sessionContext = (JDBCExecutionContext) getDataSourceContainer().getDataSource().openIsolatedContext(monitor, "Debug session");
return this.sessionManager.createDebugSession(sessionContext);
return sessionManager.createDebugSession(sessionContext);
} catch (DBException e) {
throw new DBGException("Can't initiate debug session", e);
}
......
......@@ -27,8 +27,13 @@ import org.jkiss.dbeaver.debug.DBGException;
import org.jkiss.dbeaver.debug.DBGSession;
import org.jkiss.dbeaver.debug.DBGStackFrame;
import org.jkiss.dbeaver.debug.DBGVariable;
import org.jkiss.dbeaver.ext.postgresql.debug.internal.impl.*;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext;
import org.jkiss.dbeaver.ext.postgresql.debug.internal.impl.PostgreDebugBreakpoint;
import org.jkiss.dbeaver.ext.postgresql.debug.internal.impl.PostgreDebugBreakpointProperties;
import org.jkiss.dbeaver.ext.postgresql.debug.internal.impl.PostgreDebugObject;
import org.jkiss.dbeaver.ext.postgresql.debug.internal.impl.PostgreDebugSession;
import org.jkiss.dbeaver.ext.postgresql.debug.internal.impl.PostgreDebugSessionInfo;
import org.jkiss.dbeaver.ext.postgresql.debug.internal.impl.PostgreDebugSessionManager;
import org.jkiss.dbeaver.ext.postgresql.debug.internal.impl.PostgreDebugVariable;
@SuppressWarnings("nls")
public class Debugger {
......@@ -206,7 +211,7 @@ public class Debugger {
PostgreDebugSession debugSession = null;
List<DBGSession<?, ?>> sessions = pgDbgManager.getDebugSessions();
List<DBGSession<?>> sessions = pgDbgManager.getDebugSessions();
Scanner scArg;
......@@ -220,7 +225,7 @@ public class Debugger {
int sessNo = 1;
for (DBGSession<?, ?> s : sessions) {
for (DBGSession<?> s : sessions) {
System.out.println(String.format(" (%d) %s", sessNo++, s.toString()));
}
......@@ -333,7 +338,7 @@ public class Debugger {
break;
}
pgDbgManager.terminateSession(debugSessionC.getSessionInfo().getPid());
pgDbgManager.terminateSession(debugSessionC.getSessionId());
System.out.println("Session closed");
......@@ -657,7 +662,7 @@ public class Debugger {
System.out.println("no debug sessions");
break;
}
for (DBGSession<?, ?> s : pgDbgManager.getDebugSessions()) {
for (DBGSession<?> s : pgDbgManager.getDebugSessions()) {
System.out.println(s);
}
......
......@@ -18,21 +18,31 @@
package org.jkiss.dbeaver.ext.postgresql.debug.internal.impl;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.debug.*;
import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import java.sql.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.debug.DBGBreakpoint;
import org.jkiss.dbeaver.debug.DBGBreakpointProperties;
import org.jkiss.dbeaver.debug.DBGException;
import org.jkiss.dbeaver.debug.DBGSession;
import org.jkiss.dbeaver.debug.DBGStackFrame;
import org.jkiss.dbeaver.debug.DBGVariable;
import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
@SuppressWarnings("nls")
public class PostgreDebugSession implements DBGSession<PostgreDebugSessionInfo, PostgreDebugObject> {
public class PostgreDebugSession implements DBGSession<PostgreDebugObject> {
private static final Log log = Log.getLog(PostgreDebugSession.class);
......@@ -140,9 +150,9 @@ public class PostgreDebugSession implements DBGSession<PostgreDebugSessionInfo,
}
@Override
public PostgreDebugSessionInfo getSessionInfo() {
public Map<String, Object> getSessionInfo() {
return sessionDebugInfo;
return sessionDebugInfo.toMap();
}
@Override
......
......@@ -18,6 +18,9 @@
package org.jkiss.dbeaver.ext.postgresql.debug.internal.impl;
import java.util.HashMap;
import java.util.Map;
import org.jkiss.dbeaver.debug.DBGSessionInfo;
@SuppressWarnings("nls")
......@@ -72,4 +75,15 @@ public class PostgreDebugSessionInfo implements DBGSessionInfo {
+ state + ", query: " + query.replace('\n', '\\');
}
public Map<String, Object> toMap() {
//FIXME: declare constants elsewhere, it is the part of metadata
Map<String, Object> map = new HashMap<String, Object>();
map.put("pid", pid);
map.put("user", user);
map.put("application", application);
map.put("state", state);
map.put("query", query);
return map;
}
}
......@@ -131,7 +131,7 @@ public class PostgreDebugSessionManager implements DBGSessionManager {
}
@Override
public DBGSession<PostgreDebugSessionInfo, PostgreDebugObject> getDebugSession(Object id)
public DBGSession<PostgreDebugObject> getDebugSession(Object id)
throws DBGException {
return sessions.get(id);
}
......@@ -174,8 +174,8 @@ public class PostgreDebugSessionManager implements DBGSessionManager {
}
@Override
public List<DBGSession<?, ?>> getDebugSessions() throws DBGException {
return new ArrayList<DBGSession<?, ?>>(sessions.values());
public List<DBGSession<?>> getDebugSessions() throws DBGException {
return new ArrayList<DBGSession<?>>(sessions.values());
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册