001: /*
002: * This file is part of PFIXCORE.
003: *
004: * PFIXCORE is free software; you can redistribute it and/or modify
005: * it under the terms of the GNU Lesser General Public License as published by
006: * the Free Software Foundation; either version 2 of the License, or
007: * (at your option) any later version.
008: *
009: * PFIXCORE is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public License
015: * along with PFIXCORE; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: */
019:
020: package de.schlund.pfixcore.webservice.config;
021:
022: import java.io.IOException;
023: import java.io.ObjectInputStream;
024: import java.io.ObjectOutputStream;
025: import java.io.Serializable;
026: import java.lang.reflect.Method;
027: import java.lang.reflect.Modifier;
028: import java.net.URL;
029: import java.util.HashMap;
030:
031: import de.schlund.pfixcore.webservice.Constants;
032: import de.schlund.pfixcore.webservice.fault.FaultHandler;
033:
034: /**
035: * GlobalServiceConfig.java
036: *
037: * Created: 27.07.2004
038: *
039: * @author mleidig@schlund.de
040: */
041: public class GlobalServiceConfig implements Serializable {
042:
043: private String server;
044: private String reqPath = "/xml/webservice";
045: private Boolean wsdlSupport = Boolean.TRUE;
046: private String wsdlRepo = "/wsdl";
047: private Boolean stubGeneration = Boolean.TRUE;
048: private String stubRepo = "/wsscript";
049: private String jsNamespace = Constants.STUBGEN_JSNAMESPACE_COMPAT;
050: private String protocolType = Constants.PROTOCOL_TYPE_ANY;
051: private String encStyle = Constants.ENCODING_STYLE_RPC;
052: private String encUse = Constants.ENCODING_USE_ENCODED;
053: private Boolean jsonClassHinting = Boolean.FALSE;
054: private String sessType = Constants.SESSION_TYPE_SERVLET;
055: private String scopeType = Constants.SERVICE_SCOPE_APPLICATION;
056: private Boolean sslForce = Boolean.FALSE;
057: private String ctxName;
058: private Boolean ctxSync = Boolean.TRUE;
059: private Boolean admin = Boolean.FALSE;
060: private Boolean monitoring = Boolean.FALSE;
061: private String monitorScope = Constants.MONITOR_SCOPE_SESSION;
062: private Integer monitorSize = 20;
063: private Boolean logging = Boolean.FALSE;
064: private transient FaultHandler faultHandler;
065: private URL defaultBeanMetaDataUrl;
066:
067: public GlobalServiceConfig() {
068: }
069:
070: public String getServer() {
071: return server;
072: }
073:
074: public void setServer(String server) {
075: this .server = server;
076: }
077:
078: public String getRequestPath() {
079: return reqPath;
080: }
081:
082: public void setRequestPath(String reqPath) {
083: this .reqPath = reqPath;
084: }
085:
086: public String getWSDLRepository() {
087: return wsdlRepo;
088: }
089:
090: public void setWSDLRepository(String wsdlRepo) {
091: this .wsdlRepo = wsdlRepo;
092: }
093:
094: public Boolean getWSDLSupportEnabled() {
095: return wsdlSupport;
096: }
097:
098: public void setWSDLSupportEnabled(Boolean wsdlSupport) {
099: this .wsdlSupport = wsdlSupport;
100: }
101:
102: public String getStubRepository() {
103: return stubRepo;
104: }
105:
106: public void setStubRepository(String stubRepo) {
107: this .stubRepo = stubRepo;
108: }
109:
110: public Boolean getStubGenerationEnabled() {
111: return stubGeneration;
112: }
113:
114: public void setStubGenerationEnabled(Boolean stubGeneration) {
115: this .stubGeneration = stubGeneration;
116: }
117:
118: public String getStubJSNamespace() {
119: return jsNamespace;
120: }
121:
122: public void setStubJSNamespace(String jsNamespace) {
123: this .jsNamespace = jsNamespace;
124: }
125:
126: public String getProtocolType() {
127: return protocolType;
128: }
129:
130: public void setProtocolType(String protocolType) {
131: this .protocolType = protocolType;
132: }
133:
134: public String getEncodingStyle() {
135: return encStyle;
136: }
137:
138: public void setEncodingStyle(String encStyle) {
139: this .encStyle = encStyle;
140: }
141:
142: public String getEncodingUse() {
143: return encUse;
144: }
145:
146: public void setEncodingUse(String encUse) {
147: this .encUse = encUse;
148: }
149:
150: public Boolean getJSONClassHinting() {
151: return jsonClassHinting;
152: }
153:
154: public void setJSONClassHinting(Boolean jsonClassHinting) {
155: this .jsonClassHinting = jsonClassHinting;
156: }
157:
158: public String getSessionType() {
159: return sessType;
160: }
161:
162: public void setSessionType(String sessType) {
163: this .sessType = sessType;
164: }
165:
166: public void setScopeType(String scopeType) {
167: this .scopeType = scopeType;
168: }
169:
170: public String getScopeType() {
171: return scopeType;
172: }
173:
174: public Boolean getSSLForce() {
175: return sslForce;
176: }
177:
178: public void setSSLForce(Boolean sslForce) {
179: this .sslForce = sslForce;
180: }
181:
182: public String getContextName() {
183: return ctxName;
184: }
185:
186: public void setContextName(String ctxName) {
187: this .ctxName = ctxName;
188: }
189:
190: public boolean getSynchronizeOnContext() {
191: return ctxSync;
192: }
193:
194: public void setSynchronizeOnContext(Boolean ctxSync) {
195: this .ctxSync = ctxSync;
196: }
197:
198: public Boolean getAdminEnabled() {
199: return admin;
200: }
201:
202: public void setAdminEnabled(Boolean admin) {
203: this .admin = admin;
204: }
205:
206: public Boolean getMonitoringEnabled() {
207: return monitoring;
208: }
209:
210: public void setMonitoringEnabled(Boolean monitoring) {
211: this .monitoring = monitoring;
212: }
213:
214: public String getMonitoringScope() {
215: return monitorScope;
216: }
217:
218: public void setMonitoringScope(String monitorScope) {
219: this .monitorScope = monitorScope;
220: }
221:
222: public Integer getMonitoringHistorySize() {
223: return monitorSize;
224: }
225:
226: public void setMonitoringHistorySize(Integer monitorSize) {
227: this .monitorSize = monitorSize;
228: }
229:
230: public Boolean getLoggingEnabled() {
231: return logging;
232: }
233:
234: public void setLoggingEnabled(Boolean logging) {
235: this .logging = logging;
236: }
237:
238: public FaultHandler getFaultHandler() {
239: return faultHandler;
240: }
241:
242: public void setFaultHandler(FaultHandler faultHandler) {
243: this .faultHandler = faultHandler;
244: }
245:
246: public URL getDefaultBeanMetaDataURL() {
247: return defaultBeanMetaDataUrl;
248: }
249:
250: public void setDefaultBeanMetaDataURL(URL defaultBeanMetaDataUrl) {
251: this .defaultBeanMetaDataUrl = defaultBeanMetaDataUrl;
252: }
253:
254: @Override
255: public boolean equals(Object obj) {
256:
257: if (obj instanceof GlobalServiceConfig) {
258: GlobalServiceConfig ref = (GlobalServiceConfig) obj;
259: Method[] meths = getClass().getDeclaredMethods();
260: for (int i = 0; i < meths.length; i++) {
261: Method meth = meths[i];
262: if (meth.getName().startsWith("get")
263: && Modifier.isPublic(meth.getModifiers())
264: && !meth.getName().equals(
265: "getDefaultBeanMetaDataURL")) {
266: try {
267: Object res = meth.invoke(this , new Object[0]);
268: Object refRes = meth.invoke(ref, new Object[0]);
269: if (res == null ^ refRes == null) {
270: System.out.println("Difference found: "
271: + meth.getName() + " " + res + " "
272: + refRes);
273: return false;
274: }
275: if (res != null && !res.equals(refRes)) {
276: System.out.println("Difference found: "
277: + meth.getName() + " " + res + " "
278: + refRes);
279: return false;
280: }
281: } catch (Exception x) {
282: x.printStackTrace();
283: return false;
284: }
285: }
286: }
287: return true;
288: }
289: return false;
290: }
291:
292: private void writeObject(ObjectOutputStream out) throws IOException {
293: out.defaultWriteObject();
294: if (faultHandler != null)
295: out.writeObject(faultHandler.getClass().getName());
296: else
297: out.writeObject(null);
298: if (faultHandler != null && faultHandler.getParams() != null)
299: out.writeObject(faultHandler.getParams());
300: else
301: out.writeObject(null);
302: }
303:
304: @SuppressWarnings("unchecked")
305: private void readObject(ObjectInputStream in) throws IOException,
306: ClassNotFoundException {
307: in.defaultReadObject();
308: String str = (String) in.readObject();
309: if (str != null) {
310: Class<?> clazz = Class.forName(str);
311: try {
312: faultHandler = (FaultHandler) clazz.newInstance();
313: HashMap<String, String> params = (HashMap<String, String>) in
314: .readObject();
315: if (params != null)
316: faultHandler.setParams(params);
317: } catch (IllegalAccessException x) {
318:
319: } catch (InstantiationException x) {
320:
321: }
322: }
323: }
324:
325: }
|