001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)Service.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.engine.xslt.util;
030:
031: import com.sun.jbi.engine.xslt.TEResources;
032:
033: import java.util.Enumeration;
034: import java.util.Vector;
035:
036: import javax.jbi.servicedesc.ServiceEndpoint;
037:
038: /**
039: *
040: *
041: * @author Sun Microsystems Inc.
042: */
043: public class Service implements TEResources {
044: /**
045: *
046: */
047: private ConfigBean mConfigBean = null;
048:
049: /**
050: *
051: */
052: private ServiceEndpoint mReference = null;
053:
054: /**
055: *
056: */
057: private String mDelimiter = null;
058:
059: /**
060: *
061: */
062: private String mEndpoint = null;
063:
064: /**
065: *
066: */
067: private String mId = null;
068:
069: /**
070: *
071: */
072: private String mName = null;
073:
074: /**
075: *
076: */
077: private String mNamespace = null;
078:
079: /**
080: *
081: */
082: private String mStatus = ConfigData.NONACTIVE;
083:
084: /**
085: *
086: */
087: private String mType = null;
088:
089: /**
090: *
091: */
092: private String mXsltFile = null;
093:
094: /**
095: *
096: */
097: private StringTranslator mTranslator = null;
098:
099: /**
100: *
101: */
102: private Vector mColNames = null;
103:
104: /**
105: *
106: */
107: private boolean mFirst = false;
108:
109: /**
110: *
111: */
112: private String mDeploymentType = null;
113:
114: /**
115: * Creates a new Service object.
116: *
117: * @param bean ConfigBean object.
118: */
119: public Service(ConfigBean bean) {
120: mTranslator = new StringTranslator("com.sun.jbi.engine.xslt",
121: this .getClass().getClassLoader());
122: mConfigBean = bean;
123: init();
124: }
125:
126: /**
127: * DOCUMENT ME!
128: *
129: * @param list NOT YET DOCUMENTED
130: */
131: public void setColumnNames(Vector list) {
132: mColNames = list;
133: }
134:
135: /**
136: * DOCUMENT ME!
137: *
138: * @return NOT YET DOCUMENTED
139: */
140: public Vector getColumnNames() {
141: return mColNames;
142: }
143:
144: /**
145: * DOCUMENT ME!
146: *
147: * @param separator NOT YET DOCUMENTED
148: */
149: public void setColumnSeparator(String separator) {
150: mDelimiter = separator;
151: }
152:
153: /**
154: * DOCUMENT ME!
155: *
156: * @return NOT YET DOCUMENTED
157: */
158: public String getColumnSeparator() {
159: return mDelimiter;
160: }
161:
162: /**
163: * DOCUMENT ME!
164: *
165: * @param id NOT YET DOCUMENTED
166: */
167: public void setDeploymentId(String id) {
168: mId = id;
169: }
170:
171: /**
172: * DOCUMENT ME!
173: *
174: * @return NOT YET DOCUMENTED
175: */
176: public String getDeploymentId() {
177: return mId;
178: }
179:
180: /**
181: * DOCUMENT ME!
182: *
183: * @param endname NOT YET DOCUMENTED
184: */
185: public void setEndpoint(String endname) {
186: mEndpoint = endname;
187: }
188:
189: /**
190: * DOCUMENT ME!
191: *
192: * @return NOT YET DOCUMENTED
193: */
194: public String getEndpoint() {
195: return mEndpoint;
196: }
197:
198: /**
199: * DOCUMENT ME!
200: *
201: * @param val NOT YET DOCUMENTED
202: */
203: public void setFirstRowColHeaders(String val) {
204: if (val != null) {
205: mFirst = Boolean.getBoolean(val);
206: }
207: }
208:
209: /**
210: * DOCUMENT ME!
211: *
212: * @return NOT YET DOCUMENTED
213: */
214: public boolean getFirstRowColHeaders() {
215: return mFirst;
216: }
217:
218: /**
219: * DOCUMENT ME!
220: *
221: * @param svcname NOT YET DOCUMENTED
222: */
223: public void setName(String svcname) {
224: mName = svcname;
225: }
226:
227: /**
228: * DOCUMENT ME!
229: *
230: * @return NOT YET DOCUMENTED
231: */
232: public String getName() {
233: return mName;
234: }
235:
236: /**
237: * DOCUMENT ME!
238: *
239: * @param name NOT YET DOCUMENTED
240: */
241: public void setNamespace(String name) {
242: mNamespace = name;
243: }
244:
245: /**
246: * DOCUMENT ME!
247: *
248: * @return NOT YET DOCUMENTED
249: */
250: public String getNamespace() {
251: return mNamespace;
252: }
253:
254: /**
255: * DOCUMENT ME!
256: *
257: * @param ref NOT YET DOCUMENTED
258: */
259: public void setReference(ServiceEndpoint ref) {
260: mReference = ref;
261: }
262:
263: /**
264: * DOCUMENT ME!
265: *
266: * @return NOT YET DOCUMENTED
267: */
268: public ServiceEndpoint getReference() {
269: return mReference;
270: }
271:
272: /**
273: * DOCUMENT ME!
274: *
275: * @return NOT YET DOCUMENTED
276: */
277: public String getStatus() {
278: return mStatus;
279: }
280:
281: /**
282: * DOCUMENT ME!
283: *
284: * @param file NOT YET DOCUMENTED
285: */
286: public void setStyleSheet(String file) {
287: mXsltFile = file;
288: }
289:
290: /**
291: * DOCUMENT ME!
292: *
293: * @return NOT YET DOCUMENTED
294: */
295: public String getStyleSheet() {
296: return mXsltFile;
297: }
298:
299: /**
300: * Sets the deployment type (wsdl_11, wsdl_20 or xml)
301: *
302: * @param type NOT YET DOCUMENTED
303: */
304: public void setDeploymentType(String type) {
305: mDeploymentType = type;
306: }
307:
308: /**
309: * Return the type of the deployment (wsdl_11, wsdl_20 or xml)
310: *
311: * @return NOT YET DOCUMENTED
312: */
313: public String getDeploymentType() {
314: return mDeploymentType;
315: }
316:
317: /**
318: * DOCUMENT ME!
319: *
320: * @param type NOT YET DOCUMENTED
321: */
322: public void setType(String type) {
323: mType = type;
324: }
325:
326: /**
327: * DOCUMENT ME!
328: *
329: * @return NOT YET DOCUMENTED
330: */
331: public String getType() {
332: return mType;
333: }
334:
335: /**
336: *
337: */
338: public void init() {
339: String stylesheet = null;
340: String deploymentid = null;
341: String deploymentType = null;
342: String delimiter = null;
343: String firstRow = null;
344: String namespace = null;
345:
346: mStatus = ConfigData.ACTIVE;
347:
348: Vector vec = (Vector) mConfigBean.getValue(mTranslator
349: .getString(TEResources.XSLTFILE));
350:
351: if (vec != null) {
352: stylesheet = (String) (vec.elementAt(0));
353: }
354:
355: Vector vec2 = (Vector) mConfigBean.getValue(mTranslator
356: .getString(TEResources.DEPLOYMENT_ID));
357:
358: if (vec2 != null) {
359: deploymentid = (String) (vec2.elementAt(0));
360: }
361:
362: Vector someVec = (Vector) mConfigBean
363: .getValue(ConfigData.DEPLOYMENT_TYPE);
364: if (someVec != null) {
365: deploymentType = (String) (someVec.elementAt(0));
366: }
367:
368: setDeploymentType(deploymentType);
369: setStyleSheet(stylesheet);
370: setDeploymentId(deploymentid);
371:
372: Vector vec3 = (Vector) mConfigBean
373: .getValue(ConfigData.COLUMN_SEPARATOR);
374:
375: if (vec3 != null) {
376: String temp = (String) (vec3.elementAt(0));
377:
378: if ((temp != null) && (temp.length() > 0)) {
379: delimiter = temp;
380: System.out.println("#########Retived delimiter is ="
381: + delimiter + "*");
382: }
383: }
384:
385: Vector headers = (Vector) mConfigBean
386: .getValue(ConfigData.COLUMN_HEADER);
387: Vector vec4 = (Vector) mConfigBean
388: .getValue(ConfigData.FIRST_ROW_COL_HEADERS);
389:
390: if (vec4 != null) {
391: firstRow = (String) (vec4.elementAt(0));
392: }
393:
394: setColumnSeparator(delimiter);
395: System.out.println("#####Retived delimiter is==" + delimiter
396: + "*");
397:
398: if (delimiter == null) {
399: setType(mTranslator.getString(TEResources.XML));
400: } else {
401: setType(mTranslator.getString(TEResources.NON_XML));
402: }
403:
404: System.out.println("######Type" + getType());
405: setFirstRowColHeaders(firstRow);
406:
407: if (!getFirstRowColHeaders()) {
408: setColumnNames(headers);
409: }
410:
411: //Changed to use Servie Namespace (service-namespace element in service.xml)
412: Vector vec5 = ((Vector) mConfigBean
413: .getValue(ConfigData.SERVICE_NAMESPACE));
414:
415: if (vec5 != null) {
416: setNamespace((String) vec5.elementAt(0));
417: }
418: }
419:
420: /**
421: *
422: */
423: public void start() {
424: mStatus = ConfigData.START;
425: }
426:
427: /**
428: *
429: */
430: public void stop() {
431: mStatus = ConfigData.STOP;
432: }
433:
434: /**
435: * DOCUMENT ME!
436: *
437: * @return NOT YET DOCUMENTED
438: */
439: public String toString() {
440: //Changed variable name from enum to enumKeys as enum is a keyword in JDK 1.5
441: Enumeration enumKeys = mConfigBean.getTable().keys();
442: StringBuffer buff = new StringBuffer();
443:
444: while (enumKeys.hasMoreElements()) {
445: Object key = enumKeys.nextElement();
446: buff.append("\n| Key =");
447: buff.append(key.toString());
448:
449: Vector vec = (Vector) mConfigBean.getTable().get(key);
450: buff.append("Value=");
451: buff.append(vec.toString());
452: buff.append("|");
453: }
454:
455: return buff.toString();
456: }
457: }
|