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.util.HashMap;
029:
030: import de.schlund.pfixcore.webservice.fault.FaultHandler;
031:
032: /**
033: * ServiceConfig.java
034: *
035: * Created: 27.07.2004
036: *
037: * @author mleidig@schlund.de
038: */
039: public class ServiceConfig implements Serializable {
040:
041: private GlobalServiceConfig globConf;
042:
043: private String name;
044: private String itfName;
045: private String implName;
046:
047: private String ctxName;
048: private Boolean ctxSync;
049: private String sessType;
050: private String scopeType;
051: private Boolean sslForce;
052: private String protocolType;
053: private String encStyle;
054: private String encUse;
055: private Boolean jsonClassHinting;
056: private transient FaultHandler faultHandler;
057: private String jsNamespace;
058:
059: public ServiceConfig(GlobalServiceConfig globConf) {
060: this .globConf = globConf;
061: }
062:
063: public GlobalServiceConfig getGlobalServiceConfig() {
064: return globConf;
065: }
066:
067: public void setGlobalServiceConfig(GlobalServiceConfig globConf) {
068: this .globConf = globConf;
069: }
070:
071: public String getName() {
072: return name;
073: }
074:
075: public void setName(String name) {
076: this .name = name;
077: }
078:
079: public String getInterfaceName() {
080: return itfName;
081: }
082:
083: public void setInterfaceName(String itfName) {
084: this .itfName = itfName;
085: }
086:
087: public String getImplementationName() {
088: return implName;
089: }
090:
091: public void setImplementationName(String implName) {
092: this .implName = implName;
093: }
094:
095: public String getContextName() {
096: if (ctxName == null && globConf != null)
097: return globConf.getContextName();
098: return ctxName;
099: }
100:
101: public void setContextName(String ctxName) {
102: this .ctxName = ctxName;
103: }
104:
105: public boolean getSynchronizeOnContext() {
106: if (ctxSync == null && globConf != null)
107: return globConf.getSynchronizeOnContext();
108: return ctxSync;
109: }
110:
111: public void setSynchronizeOnContext(Boolean ctxSync) {
112: this .ctxSync = ctxSync;
113: }
114:
115: public String getSessionType() {
116: if (sessType == null && globConf != null)
117: return globConf.getSessionType();
118: return sessType;
119: }
120:
121: public void setSessionType(String sessType) {
122: this .sessType = sessType;
123: }
124:
125: public String getScopeType() {
126: if (scopeType == null && globConf != null)
127: return globConf.getScopeType();
128: return scopeType;
129: }
130:
131: public void setScopeType(String scopeType) {
132: this .scopeType = scopeType;
133: }
134:
135: public Boolean getSSLForce() {
136: if (sslForce == null && globConf != null)
137: return globConf.getSSLForce();
138: return sslForce;
139: }
140:
141: public void setSSLForce(Boolean sslForce) {
142: this .sslForce = sslForce;
143: }
144:
145: public String getProtocolType() {
146: if (protocolType == null && globConf != null)
147: return globConf.getProtocolType();
148: return protocolType;
149: }
150:
151: public void setProtocolType(String protocolType) {
152: this .protocolType = protocolType;
153: }
154:
155: public String getEncodingStyle() {
156: if (encStyle == null && globConf != null)
157: return globConf.getEncodingStyle();
158: return encStyle;
159: }
160:
161: public void setEncodingStyle(String encStyle) {
162: this .encStyle = encStyle;
163: }
164:
165: public String getEncodingUse() {
166: if (encUse == null && globConf != null)
167: return globConf.getEncodingUse();
168: return encUse;
169: }
170:
171: public void setEncodingUse(String encUse) {
172: this .encUse = encUse;
173: }
174:
175: public Boolean getJSONClassHinting() {
176: if (jsonClassHinting == null && globConf != null)
177: return globConf.getJSONClassHinting();
178: return jsonClassHinting;
179: }
180:
181: public void setJSONClassHinting(Boolean jsonClassHinting) {
182: this .jsonClassHinting = jsonClassHinting;
183: }
184:
185: public String getStubJSNamespace() {
186: if (jsNamespace == null && globConf != null)
187: return globConf.getStubJSNamespace();
188: return jsNamespace;
189: }
190:
191: public void setStubJSNamespace(String jsNamespace) {
192: this .jsNamespace = jsNamespace;
193: }
194:
195: public FaultHandler getFaultHandler() {
196: if (faultHandler == null && globConf != null)
197: return globConf.getFaultHandler();
198: return faultHandler;
199: }
200:
201: public void setFaultHandler(FaultHandler faultHandler) {
202: this .faultHandler = faultHandler;
203: }
204:
205: @Override
206: public boolean equals(Object obj) {
207: if (obj instanceof ServiceConfig) {
208: ServiceConfig ref = (ServiceConfig) obj;
209: Method[] meths = getClass().getDeclaredMethods();
210: for (int i = 0; i < meths.length; i++) {
211: Method meth = meths[i];
212: if (meth.getName().startsWith("get")
213: && Modifier.isPublic(meth.getModifiers())) {
214: try {
215: Object res = meth.invoke(this , new Object[0]);
216: Object refRes = meth.invoke(ref, new Object[0]);
217: if (res == null ^ refRes == null) {
218: System.out.println("Difference found: "
219: + meth.getName() + " " + res + " "
220: + refRes);
221: return false;
222: }
223: if (res != null && !res.equals(refRes)) {
224: System.out.println("Difference found: "
225: + meth.getName() + " " + res + " "
226: + refRes);
227: return false;
228: }
229: } catch (Exception x) {
230: x.printStackTrace();
231: return false;
232: }
233: }
234: }
235: return true;
236: }
237: return false;
238: }
239:
240: private void writeObject(ObjectOutputStream out) throws IOException {
241: out.defaultWriteObject();
242: if (faultHandler != null)
243: out.writeObject(faultHandler.getClass().getName());
244: else
245: out.writeObject(null);
246: if (faultHandler != null && faultHandler.getParams() != null)
247: out.writeObject(faultHandler.getParams());
248: else
249: out.writeObject(null);
250: }
251:
252: @SuppressWarnings("unchecked")
253: private void readObject(ObjectInputStream in) throws IOException,
254: ClassNotFoundException {
255: in.defaultReadObject();
256: String str = (String) in.readObject();
257: if (str != null) {
258: Class<?> clazz = Class.forName(str);
259: try {
260: faultHandler = (FaultHandler) clazz.newInstance();
261: HashMap<String, String> params = (HashMap<String, String>) in
262: .readObject();
263: if (params != null)
264: faultHandler.setParams(params);
265: } catch (IllegalAccessException x) {
266:
267: } catch (InstantiationException x) {
268:
269: }
270: }
271: }
272:
273: }
|