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: * @(#)EndpointBean.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.binding.jms;
030:
031: import com.sun.jbi.binding.jms.mq.MQConnection;
032: import com.sun.jbi.binding.jms.mq.MQDestination;
033: import com.sun.jbi.binding.jms.mq.MQSession;
034:
035: import com.sun.jbi.binding.jms.config.ConfigConstants;
036: import java.util.ArrayList;
037:
038: import java.util.Hashtable;
039: import java.util.Iterator;
040: import java.util.List;
041:
042: import javax.jbi.servicedesc.ServiceEndpoint;
043:
044: import javax.xml.namespace.QName;
045:
046: /**
047: * This Bean object holds all the attributes of an endpoint.
048: *
049: * @author Sun Microsystems Inc.
050: */
051: public final class EndpointBean {
052:
053: private Object mWsdlDefinition;
054: /**
055: *
056: */
057: /**
058: *
059: */
060:
061: /**
062: *
063: */
064: private ServiceEndpoint mServiceEndpoint;
065:
066: /**
067: * Table for storing the xml tags and values present in the config file.
068: * This table stores throws jmsbinding sepcific configuration information
069: * correspondint to each endpoint.
070: */
071: private Hashtable mConfigTable = null;
072:
073: /**
074: *
075: */
076: /**
077: *
078: */
079:
080: /**
081: *
082: */
083: private List mOperations = null;
084:
085: /**
086: *
087: */
088:
089: /**
090: *
091: */
092: private MQConnection mConnection;
093:
094: /**
095: *
096: */
097:
098: /**
099: *
100: */
101: private MQDestination mDestination;
102:
103: /**
104: *
105: */
106:
107: /**
108: *
109: */
110: private MQSession mReceiverSession;
111:
112: /**
113: * Deployment Id.
114: */
115: private String mDeploymentId;
116:
117: /**
118: *
119: */
120:
121: /**
122: *
123: */
124: private Thread mReceiverThread;
125:
126: /**
127: *
128: */
129: private int mStyle;
130:
131: /**
132: * Role.
133: */
134: private int mRole;
135:
136: /**
137: * Status.
138: */
139: private EndpointStatus mStatus;
140:
141: private String mDeploymentType;
142:
143: /**
144: * Constructor. Creates a new Table.
145: */
146: public EndpointBean() {
147: mConfigTable = new Hashtable();
148: mOperations = new ArrayList();
149: }
150:
151: /**
152: *
153: *
154: * @return operation list.
155: */
156: public List getAllOperations() {
157: return mOperations;
158: }
159:
160: /**
161: *
162: *
163: * @param con conneciton.
164: */
165: public void setConnection(MQConnection con) {
166: mConnection = con;
167: }
168:
169: /**
170: *
171: *
172: * @return connection.
173: */
174: public MQConnection getConnection() {
175: return mConnection;
176: }
177:
178: /**
179: *
180: *
181: * @return qname of operation.
182: */
183: public QName getDefaultOperation() {
184: QName operation = null;
185:
186: try {
187: OperationBean op = (OperationBean) mOperations.get(0);
188: operation = new QName(op.getNamespace(), op.getName());
189: } catch (Exception e) {
190: ;
191: }
192:
193: return operation;
194: }
195:
196: public void setWsdlDefinition(Object def) {
197: mWsdlDefinition = def;
198: }
199:
200: public Object getWsdlDefinition() {
201: return mWsdlDefinition;
202: }
203:
204: /**
205: * Sets the deployment Id corresponding to this endpoint Bean.
206: *
207: * @param asId Application Sub assembly ID.
208: */
209: public void setDeploymentId(String asId) {
210: mDeploymentId = asId;
211: }
212:
213: /**
214: * Fetches the deployment Id coresponding to this bean.
215: *
216: * @return Application Sub assembly ID
217: */
218: public String getDeploymentId() {
219: return mDeploymentId;
220: }
221:
222: /**
223: *
224: *
225: * @param dest mq destination.
226: */
227: public void setDestination(MQDestination dest) {
228: mDestination = dest;
229: }
230:
231: /**
232: *
233: *
234: * @return destination.
235: */
236: public MQDestination getDestination() {
237: return mDestination;
238: }
239:
240: /**
241: *
242: *
243: * @param ref service reference.
244: */
245: public void setServiceEndpoint(ServiceEndpoint ref) {
246: mServiceEndpoint = ref;
247: }
248:
249: /**
250: *
251: *
252: * @return endpoint reference.
253: */
254: public ServiceEndpoint getServiceEndpoint() {
255: return mServiceEndpoint;
256: }
257:
258: /**
259: *
260: *
261: * @param operation operation.
262: *
263: * @return input type for the operation.
264: */
265: public String getInputType(String operation) {
266: String inputtype = null;
267: Iterator iter = mOperations.iterator();
268:
269: while (iter.hasNext()) {
270: OperationBean op = (OperationBean) iter.next();
271:
272: if (op.getName().trim().equals(operation)) {
273: inputtype = op.getInputType();
274:
275: break;
276: }
277: }
278:
279: return inputtype;
280: }
281:
282: /**
283: *
284: *
285: * @param operation operation.
286: *
287: * @return String representing the operation , if not present then null
288: */
289: public String getMEP(String operation) {
290: String mep = null;
291: Iterator iter = mOperations.iterator();
292:
293: while (iter.hasNext()) {
294: OperationBean op = (OperationBean) iter.next();
295:
296: if (op.getName().trim().equals(operation)) {
297: mep = op.getMep();
298:
299: break;
300: }
301: }
302:
303: return mep;
304: }
305:
306: /**
307: *
308: *
309: * @param operation operation name.
310: *
311: * @return output typr for this operation.
312: */
313: public String getOutputType(String operation) {
314: String outputtype = null;
315: Iterator iter = mOperations.iterator();
316:
317: while (iter.hasNext()) {
318: OperationBean op = (OperationBean) iter.next();
319:
320: if (op.getName().trim().equals(operation)) {
321: outputtype = op.getOutputType();
322:
323: break;
324: }
325: }
326:
327: return outputtype;
328: }
329:
330: /**
331: *
332: *
333: * @param session session.
334: */
335: public void setReceiverSession(MQSession session) {
336: mReceiverSession = session;
337: }
338:
339: /**
340: *
341: *
342: * @return session.
343: */
344: public MQSession getReceiverSession() {
345: return mReceiverSession;
346: }
347:
348: /**
349: * Setter for property mReceiverThread.
350: *
351: * @param mReceiverThread New value of property mReceiverThread.
352: */
353: public void setReceiverThread(java.lang.Thread mReceiverThread) {
354: this .mReceiverThread = mReceiverThread;
355: }
356:
357: /**
358: * Getter for property mReceiverThread.
359: *
360: * @return Value of property mReceiverThread.
361: */
362: public java.lang.Thread getReceiverThread() {
363: return mReceiverThread;
364: }
365:
366: /**
367: *
368: *
369: * @param session session.
370: */
371: public void setSendSession(MQSession session) {
372: }
373:
374: /**
375: *
376: *
377: * @param style style.
378: */
379: public void setStyle(int style) {
380: mStyle = style;
381: }
382:
383: /**
384: *
385: *
386: * @return style.
387: */
388: public int getStyle() {
389: return mStyle;
390: }
391:
392: /**
393: * Returns a unique name which is a combination of service name and
394: * endpoint name.
395: *
396: * @return unique name of this endpoint. Its a combination of service name
397: * and endpoint name.
398: */
399: public String getUniqueName() {
400: String servicenamespace = getValue(ConfigConstants.SERVICE_NAMESPACE);
401:
402: String servicename = getValue(ConfigConstants.SERVICENAME);
403: String endpointname = getValue(ConfigConstants.ENDPOINTNAME);
404: QName ser = null;
405: try {
406: ser = new QName(servicenamespace, servicename);
407: } catch (Exception e) {
408: ;
409: }
410:
411: if (ser == null) {
412: return endpointname;
413: }
414: if (mRole == ConfigConstants.PROVIDER) {
415: return ser.toString() + endpointname;
416: } else {
417: return ser.toString();
418: }
419:
420: }
421:
422: /**
423: * Sets the value for the key in the table.
424: *
425: * @param key for which value has to be retrieved.
426: * @param value corresponding to the key
427: */
428: public void setValue(String key, String value) {
429: if (key == null) {
430: return;
431: }
432:
433: if (value == null) {
434: value = "";
435: }
436:
437: mConfigTable.put(key, value);
438: }
439:
440: /**
441: * Returns the value associated with the key from the table.
442: *
443: * @param key the tag name for wcich value is required.
444: *
445: * @return value corresponding to the tag as in config file.
446: */
447: public String getValue(String key) {
448: if (key == null) {
449: return null;
450: }
451:
452: return (String) mConfigTable.get(key);
453: }
454:
455: /**
456: *
457: *
458: * @param role role.
459: */
460: public void setRole(int role) {
461: if ((role != ConfigConstants.PROVIDER)
462: && (role != ConfigConstants.CONSUMER)) {
463: mRole = ConfigConstants.CONSUMER;
464: } else {
465: mRole = role;
466: }
467: }
468:
469: /**
470: *
471: *
472: * @return role.
473: */
474: public int getRole() {
475: return mRole;
476: }
477:
478: /**
479: *
480: *
481: * @param name name.
482: * @param mep mep.
483: * @param input input type.
484: * @param output output type.
485: */
486: public void addOperation(String namespace, String name, String mep,
487: String input, String output) {
488: OperationBean op = new OperationBean(namespace, name, mep,
489: input, output);
490: /*System.out.println("Adding operation " + namespace + "|" +
491: name + mep + "|" + input + "|"
492: + output);
493: */
494: mOperations.add(op);
495: }
496:
497: /**
498: * Maintains the status of the endpoint bean.
499: *
500: * @param status endpoint status.
501: */
502: public void setStatus(EndpointStatus status) {
503: mStatus = status;
504: }
505:
506: /**
507: * Returns the state of the endpoint.
508: *
509: * @return endpoint status.
510: */
511: public EndpointStatus getStatus() {
512: return mStatus;
513: }
514:
515: /**
516: * Getter for property mDeploymentType.
517: * @return Value of property mDeploymentType.
518: */
519: public java.lang.String getDeploymentType() {
520: return mDeploymentType;
521: }
522:
523: /**
524: * Setter for property mDeploymentType.
525: * @param mDeploymentType New value of property mDeploymentType.
526: */
527: public void setDeploymentType(java.lang.String mDeploymentType) {
528: this.mDeploymentType = mDeploymentType;
529: }
530:
531: }
|