01: package net.sourceforge.squirrel_sql.plugins.sqlval.cmd;
02:
03: /*
04: * Copyright (C) 2002-2003 Colin Bell
05: * colbell@users.sourceforge.net
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this library; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: */
21: import net.sourceforge.squirrel_sql.fw.util.BaseException;
22: import net.sourceforge.squirrel_sql.fw.util.ICommand;
23: import net.sourceforge.squirrel_sql.fw.util.StringManager;
24: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
25:
26: import net.sourceforge.squirrel_sql.client.session.ISession;
27:
28: import net.sourceforge.squirrel_sql.plugins.sqlval.WebServicePreferences;
29: import net.sourceforge.squirrel_sql.plugins.sqlval.WebServiceSession;
30: import net.sourceforge.squirrel_sql.plugins.sqlval.WebServiceSessionProperties;
31:
32: /**
33: * This <CODE>ICommand</CODE> will disconnect from the SQL Validation web service.
34: *
35: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
36: */
37: public class DisconnectCommand implements ICommand {
38: private static final StringManager s_stringMgr = StringManagerFactory
39: .getStringManager(DisconnectCommand.class);
40:
41: private final ISession _session;
42: private final WebServicePreferences _prefs;
43: private final WebServiceSessionProperties _sessionProps;
44:
45: public DisconnectCommand(ISession session,
46: WebServicePreferences prefs,
47: WebServiceSessionProperties sessionProps) {
48: super ();
49: if (session == null) {
50: throw new IllegalArgumentException("ISession == null");
51: }
52: if (prefs == null) {
53: throw new IllegalArgumentException(
54: "WebServicePreferences == null");
55: }
56: if (sessionProps == null) {
57: throw new IllegalArgumentException(
58: "WebServiceSessionProperties == null");
59: }
60:
61: _session = session;
62: _prefs = prefs;
63: _sessionProps = sessionProps;
64: }
65:
66: /**
67: * Disconnect from the web service.
68: */
69: public void execute() throws BaseException {
70: try {
71: final WebServiceSession wss = _sessionProps
72: .getWebServiceSession();
73: if (wss.isOpen()) {
74: wss.close();
75: // i18n[sqlval.disconnected=Disconnected from the SQL Validation web service]
76: _session.showMessage(s_stringMgr
77: .getString("sqlval.disconnected"));
78: }
79: } catch (Throwable th) {
80: throw new BaseException(th);
81: }
82: }
83: }
|