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: import net.sourceforge.squirrel_sql.plugins.sqlval.WebServicePreferences;
26: import net.sourceforge.squirrel_sql.plugins.sqlval.WebServiceSession;
27: import net.sourceforge.squirrel_sql.plugins.sqlval.WebServiceSessionProperties;
28:
29: import net.sourceforge.squirrel_sql.client.session.ISession;
30:
31: /**
32: * This <CODE>ICommand</CODE> will connect to the SQL Validation web service.
33: *
34: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
35: */
36: public class ConnectCommand implements ICommand {
37: private static final StringManager s_stringMgr = StringManagerFactory
38: .getStringManager(ConnectCommand.class);
39:
40: private final ISession _session;
41: private final WebServicePreferences _prefs;
42: private final WebServiceSessionProperties _sessionProps;
43:
44: public ConnectCommand(ISession session,
45: WebServicePreferences prefs,
46: WebServiceSessionProperties sessionProps) {
47: super ();
48: if (session == null) {
49: throw new IllegalArgumentException("ISession == null");
50: }
51: if (prefs == null) {
52: throw new IllegalArgumentException(
53: "WebServicePreferences == null");
54: }
55: if (sessionProps == null) {
56: throw new IllegalArgumentException(
57: "WebServiceSessionProperties == null");
58: }
59:
60: _session = session;
61: _prefs = prefs;
62: _sessionProps = sessionProps;
63: }
64:
65: /**
66: * Connect to the web service.
67: */
68: public void execute() throws BaseException {
69: try {
70: final WebServiceSession wss = _sessionProps
71: .getWebServiceSession();
72: if (!wss.isOpen()) {
73: wss.open();
74: // i18n[sqlval.connected=Connected to the SQL Validation web service]
75: _session.showMessage(s_stringMgr
76: .getString("sqlval.connected"));
77: }
78: } catch (Throwable th) {
79: throw new BaseException(th);
80: }
81: }
82: }
|