001 /*---------------- FILE HEADER ------------------------------------------
002
003 This file is part of deegree.
004 Copyright (C) 2001 by:
005 EXSE, Department of Geography, University of Bonn
006 http://www.giub.uni-bonn.de/exse/
007 lat/lon Fitzke/Fretter/Poth GbR
008 http://www.lat-lon.de
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 Contact:
025
026 Andreas Poth
027 lat/lon Fitzke/Fretter/Poth GbR
028 Meckenheimer Allee 176
029 53115 Bonn
030 Germany
031 E-Mail: poth@lat-lon.de
032
033 Jens Fitzke
034 Department of Geography
035 University of Bonn
036 Meckenheimer Allee 166
037 53115 Bonn
038 Germany
039 E-Mail: jens.fitzke@uni-bonn.de
040
041
042 ---------------------------------------------------------------------------*/
043 package org.opengis.webservice;
044
045 // J2SE dependencies
046 import java.util.EventObject;
047
048
049 /**
050 * This is the defining interface for event objects that contains a request,
051 * a response that should be made available for a service.
052 * <p>
053 * the kind of contained imformation can be determined by calling the
054 * {@link #getType} method.
055 *
056 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
057 * @version 2002-04-16
058 * @deprecated Legacy code of deegree 1.x.
059 */
060 public final class WebServiceEvent extends EventObject {
061
062 public static final int REQUEST = 0;
063 public static final int RESPONSE = 1;
064
065 private final WebServiceClient client;
066 private final WebServiceRequest request;
067 private final WebServiceResponse response;
068 private final String id;
069 private final int type;
070 private final String message;
071
072 /**
073 * Creates a new WebServiceEvent object.
074 *
075 * @param source
076 * @param request
077 * @param message
078 */
079 public WebServiceEvent(WebService source, WebServiceRequest request, String message) {
080 super(source);
081 this.client = null;
082 this.request = request;
083 this.response = null;
084 this.id = request.getId();
085 this.type = REQUEST;
086 this.message = message;
087 }
088
089 /**
090 * Creates a new WebServiceEvent object.
091 *
092 * @param source
093 * @param request
094 * @param message
095 * @param client
096 */
097 public WebServiceEvent(WebService source, WebServiceRequest request, String message, WebServiceClient client) {
098 super(source);
099 this.client = client;
100 this.request = request;
101 this.response = null;
102 this.id = request.getId();
103 this.type = REQUEST;
104 this.message = message;
105 }
106
107 /**
108 * Creates a new WebServiceEvent object.
109 *
110 * @param source
111 * @param response
112 * @param message
113 */
114 public WebServiceEvent(WebService source, WebServiceResponse response, String message) {
115 super(source);
116 this.client = null;
117 this.request = null;
118 this.response = response;
119 this.id = (response.getRequest() != null) ? response.getRequest().getId() : "";
120 this.type = RESPONSE;
121 this.message = message;
122 }
123
124 /**
125 * Returns the id of the of the request which performance caused the
126 * event.
127 */
128 public String getId() {
129 return id;
130 }
131
132 /**
133 * Returns the type of event. possible values are:
134 * <ul>
135 * <li>REQUSET
136 * <li>RESPONSE
137 * <li>MESSAGE
138 * <li>EXCEPTION
139 * </ul>
140 * An EXCEPTION will allways be a response to a request or a message.
141 */
142 public int getType() {
143 return type;
144 }
145
146 /**
147 * If the event is a REQUEST type the method returns the request transported
148 * by the event. otherwise <tt>null</tt> will be returned.
149 */
150 public WebServiceRequest getRequest() {
151 return request;
152 }
153
154 /**
155 * If the event is a RESPONSE type the method returns the response transported
156 * by the event. otherwise <tt>null</tt> will be returned.
157 */
158 public WebServiceResponse getResponse() {
159 return response;
160 }
161
162 /**
163 * Returns the instance of the <tt>OGCWebService</tt> that is the source of
164 * the event.
165 */
166 public WebService getEventSource() {
167 return (WebService)super.getSource();
168 }
169
170 /**
171 * Returns the client where to write the result/response or an
172 * error message to
173 */
174 public WebServiceClient getDestination() {
175 return client;
176 }
177
178 public String getMessage(){
179 return message;
180 }
181
182 @Override
183 public String toString() {
184 final String lineSeparator = System.getProperty("line.separator", "\n");
185 return getClass().getSimpleName() + ':' + lineSeparator +
186 "request = " + request + lineSeparator +
187 "response = " + response + lineSeparator +
188 "client = " + client + lineSeparator +
189 "type = " + type + lineSeparator +
190 "message = " + message + lineSeparator;
191 }
192 }