Source Code Cross Referenced for WebServiceSession.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » plugins » sqlval » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database Client » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.plugins.sqlval 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.squirrel_sql.plugins.sqlval;
002:
003:        /*
004:         * Copyright (C) 2002-2003 Colin Bell and Olof Edlund
005:         * colbell@users.sourceforge.net
006:         *
007:         * This code is based on the example web service client code originally written
008:         * by Olof Edlund.
009:         * 
010:         * This library is free software; you can redistribute it and/or
011:         * modify it under the terms of the GNU Lesser General Public
012:         * License as published by the Free Software Foundation; either
013:         * version 2.1 of the License, or (at your option) any later version.
014:         *
015:         * This library is distributed in the hope that it will be useful,
016:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
017:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
018:         * Lesser General Public License for more details.
019:         *
020:         * You should have received a copy of the GNU Lesser General Public
021:         * License along with this library; if not, write to the Free Software
022:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
023:         */
024:        import java.rmi.RemoteException;
025:
026:        import javax.xml.namespace.QName;
027:        import javax.xml.rpc.ParameterMode;
028:        import javax.xml.rpc.ServiceException;
029:
030:        import org.apache.axis.client.Call;
031:        import org.apache.axis.client.Service;
032:        import org.apache.axis.encoding.XMLType;
033:
034:        import com.mimer.ws.validateSQL.SessionData;
035:
036:        public class WebServiceSession {
037:            /** Preferences. */
038:            private final WebServicePreferences _prefs;
039:
040:            /** Session properties. */
041:            private final WebServiceSessionProperties _sessionProps;
042:
043:            private SessionData _sessionData;
044:
045:            public WebServiceSession(WebServicePreferences prefs,
046:                    WebServiceSessionProperties sessionProps) {
047:                super ();
048:                if (prefs == null) {
049:                    throw new IllegalArgumentException(
050:                            "WebServicePreferences == null");
051:                }
052:                if (sessionProps == null) {
053:                    throw new IllegalArgumentException(
054:                            "WebServiceSessionProperties == null");
055:                }
056:                _prefs = prefs;
057:                _sessionProps = sessionProps;
058:            }
059:
060:            public boolean isOpen() {
061:                return _sessionData != null;
062:            }
063:
064:            /**
065:             * Open a sesion to the web service.
066:             */
067:            public void open() throws RemoteException, ServiceException {
068:                Service l_service = new Service();
069:                Call l_call = (Call) l_service.createCall();
070:
071:                //Set the target server and name space
072:                l_call.setTargetEndpointAddress(IWebServiceURL.WEB_SERVICE_URL);
073:                l_call.setOperationName(new QName("SQL99Validator",
074:                        "openSession"));
075:
076:                // Supply the user name. If you use anonymous you will be logged in and
077:                // the pw will be ignored
078:                l_call.addParameter("a_userName", XMLType.XSD_STRING,
079:                        ParameterMode.IN);
080:
081:                // The pw. If user name is anonymous this can be anything. But it has to
082:                // be supplied anyway.
083:                l_call.addParameter("a_password", XMLType.XSD_STRING,
084:                        ParameterMode.IN);
085:
086:                //The name of the calling client program.
087:                //This is optional. If you don't want to give out this info, please enter "N/A"
088:                l_call.addParameter("a_callingProgram", XMLType.XSD_STRING,
089:                        ParameterMode.IN);
090:
091:                //And the version of the calling program.
092:                //This is optional. If you don't want to give out this info, please enter "N/A"
093:                l_call.addParameter("a_callingProgramVersion",
094:                        XMLType.XSD_STRING, ParameterMode.IN);
095:
096:                //The target DBMS, could be Mimer SQL Engine, Oracle, ...
097:                //This is optional. If you don't want to give out this info, please enter "N/A"
098:                l_call.addParameter("a_targetDbms", XMLType.XSD_STRING,
099:                        ParameterMode.IN);
100:
101:                //The version of the target DBMS
102:                //This is optional. If you don't want to give out this info, please enter "N/A"
103:                l_call.addParameter("a_targetDbmsVersion", XMLType.XSD_STRING,
104:                        ParameterMode.IN);
105:
106:                //The connection Technology used, could be ODBC, JDBC, ADO
107:                //This is optional. If you don't want to give out this info, please enter "N/A"
108:                l_call.addParameter("a_connectionTechnology",
109:                        XMLType.XSD_STRING, ParameterMode.IN);
110:
111:                //Version
112:                //This is optional. If you don't want to give out this info, please enter "N/A"
113:                l_call.addParameter("a_connectionTechnologyVersion",
114:                        XMLType.XSD_STRING, ParameterMode.IN);
115:
116:                //Set this to 1 if your application is interactive where the user enters queries and then runs them
117:                //Set it to 2 if it is non interactive, such as for instance a JDBC Bridge driver that intercepts SQL
118:                l_call.addParameter("a_interactive", XMLType.XSD_INT,
119:                        ParameterMode.IN);
120:
121:                QName l_qn = new QName(IWebServiceURL.REQUEST_URL,
122:                        "SessionData");
123:
124:                l_call
125:                        .registerTypeMapping(
126:                                SessionData.class,
127:                                l_qn,
128:                                new org.apache.axis.encoding.ser.BeanSerializerFactory(
129:                                        SessionData.class, l_qn),
130:                                new org.apache.axis.encoding.ser.BeanDeserializerFactory(
131:                                        SessionData.class, l_qn));
132:
133:                //Set the return type
134:                l_call.setReturnType(l_qn);
135:
136:                // Open the session.
137:                final boolean anonLogon = _prefs.getUseAnonymousLogon();
138:                final boolean anonClient = _prefs.getUseAnonymousClient();
139:                final boolean anonDBMS = _sessionProps.getUseAnonymousDBMS();
140:
141:                final Object[] parms = new Object[] {
142:                        anonLogon ? "anonymous" : _prefs.getUserName(),
143:                        anonLogon ? "N/A" : _prefs.retrievePassword(),
144:                        anonClient ? "N/A" : _prefs.getClientName(),
145:                        anonClient ? "N/A" : _prefs.getClientVersion(),
146:                        anonDBMS ? "N/A" : _sessionProps.getTargetDBMSName(),
147:                        anonDBMS ? "N/A" : _sessionProps.getTargetDBMSVersion(),
148:                        anonDBMS ? "N/A" : _sessionProps
149:                                .getConnectionTechnology(),
150:                        anonDBMS ? "N/A" : _sessionProps
151:                                .getConnectionTechnologyVersion(),
152:                        Integer.valueOf(1) // 1 = interactive, 0 = batch
153:                };
154:                _sessionData = (SessionData) l_call.invoke(parms);
155:            }
156:
157:            /**
158:             * Close the session.
159:             */
160:            public void close() {
161:                _sessionData = null;
162:            }
163:
164:            /**
165:             * Return the target URL to the open session.
166:             * 
167:             * @return	Target URL.
168:             * 
169:             * @throws	IllegalStateException
170:             * 			Thrown if connection has not yet been opened.
171:             */
172:            String getTargetURL() {
173:                validateState();
174:                return _sessionData.getTarget();
175:            }
176:
177:            /**
178:             * Return the ID of the web service session.
179:             * 
180:             * @return	session ID
181:             * 
182:             * @throws	IllegalStateException
183:             * 			Thrown if connection has not yet been opened.
184:             */
185:            int getSessionID() {
186:                validateState();
187:                return _sessionData.getSessionId();
188:            }
189:
190:            /**
191:             * Return the key of the web service session.
192:             * 
193:             * @return	session key
194:             * 
195:             * @throws	IllegalStateException
196:             * 			Thrown if connection has not yet been opened.
197:             */
198:            int getSessionKey() {
199:                validateState();
200:                return _sessionData.getSessionKey();
201:            }
202:
203:            private void validateState() {
204:                if (_sessionData == null) {
205:                    throw new IllegalStateException(
206:                            "Connection to web service has not been opened");
207:                }
208:            }
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.