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: * @(#)ServicelistBean.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.sequencing.servicelist;
030:
031: import java.util.ArrayList;
032: import java.util.Hashtable;
033: import java.util.Iterator;
034:
035: import javax.jbi.servicedesc.ServiceEndpoint;
036:
037: /**
038: * Class ServicelistBean.
039: *
040: * @author Sun Microsystems, Inc.
041: */
042: public class ServicelistBean implements java.io.Serializable {
043: /**
044: * Field mServicelist
045: */
046: private java.util.ArrayList mServicelist;
047:
048: /**
049: * Stores executing instances and states
050: */
051: private Hashtable mExecutingLists;
052:
053: /**
054: * Service reference.
055: */
056: private ServiceEndpoint mServiceReference;
057:
058: /**
059: * Field deployment Id
060: */
061: private java.lang.String mDeploymentId;
062:
063: /**
064: * Endpoint name
065: */
066: private String mEndpointName;
067:
068: /**
069: * Interface local name.
070: */
071: private String mInterfaceName;
072:
073: /**
074: * Namespace for interface
075: */
076: private String mInterfaceNamespace;
077:
078: /**
079: * Field mListdescription
080: */
081: private java.lang.String mListdescription;
082:
083: /**
084: * Mep
085: */
086: private String mMep;
087:
088: /**
089: * Field namespace uri
090: */
091: private String mNamespace;
092:
093: /**
094: * Field mOperation
095: */
096: private java.lang.String mOperation = "execute";
097:
098: /**
099: * Operation namespace
100: */
101: private String mOperationNamespace;
102:
103: /**
104: * Field mServicename
105: */
106: private java.lang.String mServicename;
107:
108: /**
109: * Denotes if this list has executing instances
110: */
111: private boolean mExecuting;
112:
113: /**
114: * Creates a new ServicelistBean object.
115: */
116: public ServicelistBean() {
117: super ();
118: setOperation("execute");
119: mServicelist = new ArrayList();
120: mExecutingLists = new Hashtable();
121: }
122:
123: /**
124: * Sets the value of field 'deploymntId'.
125: *
126: * @param asaid the value of field 'deploymentId'.
127: */
128: public void setDeploymentId(java.lang.String asaid) {
129: this .mDeploymentId = asaid;
130: }
131:
132: /**
133: * Returns the value of field 'deploymentId'.
134: *
135: * @return the value of field 'deploymentId'.
136: */
137: public java.lang.String getDeploymentId() {
138: return this .mDeploymentId;
139: }
140:
141: /**
142: * Sets the endpoint name.
143: *
144: * @param endpoint endpoint.
145: */
146: public void setEndpointName(String endpoint) {
147: mEndpointName = endpoint;
148: }
149:
150: /**
151: * gets the endpoint name.
152: *
153: * @return endpoint name.
154: */
155: public String getEndpointName() {
156: return mEndpointName;
157: }
158:
159: /**
160: * Retrieves the executing state of instances.
161: *
162: * @return boolean true if has executing instances
163: */
164: public synchronized boolean isExecuting() {
165: try {
166: Iterator iter = mExecutingLists.keySet().iterator();
167:
168: while (iter.hasNext()) {
169: String id = (String) iter.next();
170: Integer i = (Integer) mExecutingLists.get(id);
171:
172: if (i.intValue() != ServicelistState.COMPLETED) {
173: if (i.intValue() != ServicelistState.ERROR) {
174: return true;
175: }
176: }
177: }
178: } catch (Throwable e) {
179: return true;
180: }
181:
182: return false;
183: }
184:
185: /**
186: * Setter for property mInterfaceName.
187: *
188: * @param mInterfaceName New value of property mInterfaceName.
189: */
190: public void setInterfaceName(java.lang.String mInterfaceName) {
191: this .mInterfaceName = mInterfaceName;
192: }
193:
194: /**
195: * Getter for property mInterfaceName.
196: *
197: * @return Value of property mInterfaceName.
198: */
199: public java.lang.String getInterfaceName() {
200: return mInterfaceName;
201: }
202:
203: /**
204: * Setter for property mInterfaceNamespace.
205: *
206: * @param mInterfaceNamespace New value of property mInterfaceNamespace.
207: */
208: public void setInterfaceNamespace(
209: java.lang.String mInterfaceNamespace) {
210: this .mInterfaceNamespace = mInterfaceNamespace;
211: }
212:
213: /**
214: * Getter for property mInterfaceNamespace.
215: *
216: * @return Value of property mInterfaceNamespace.
217: */
218: public java.lang.String getInterfaceNamespace() {
219: return mInterfaceNamespace;
220: }
221:
222: /**
223: * Sets the value of field 'listdescription'.
224: *
225: * @param listdescription the value of field 'listdescription'.
226: */
227: public void setListdescription(java.lang.String listdescription) {
228: this .mListdescription = listdescription;
229: }
230:
231: /**
232: * Returns the value of field 'listdescription'.
233: *
234: * @return the value of field 'listdescription'.
235: */
236: public java.lang.String getListdescription() {
237: return this .mListdescription;
238: }
239:
240: /**
241: * Sets the MEP.
242: *
243: * @param mep exchange pattern
244: */
245: public void setMep(String mep) {
246: mMep = mep;
247: }
248:
249: /**
250: * Gets the MEP.
251: *
252: * @return mep
253: */
254: public String getMep() {
255: return mMep;
256: }
257:
258: /**
259: * Method set Servicenamespace.
260: *
261: * @param namespace Namespace URI
262: */
263: public void setNamespace(String namespace) {
264: this .mNamespace = namespace;
265: }
266:
267: /**
268: * Method get Servicenamespace.
269: *
270: * @return namespace Namespace URI
271: */
272: public String getNamespace() {
273: return mNamespace;
274: }
275:
276: /**
277: * Sets the value of field 'operation'.
278: *
279: * @param operation the value of field 'operation'.
280: */
281: public void setOperation(java.lang.String operation) {
282: this .mOperation = operation;
283: }
284:
285: /**
286: * Returns the value of field 'operation'.
287: *
288: * @return the value of field 'operation'.
289: */
290: public java.lang.String getOperation() {
291: return this .mOperation;
292: }
293:
294: /**
295: * Sets the value of field 'operation'.
296: *
297: * @param operationnamespace the value of field 'operation'.
298: */
299: public void setOperationNamespace(
300: java.lang.String operationnamespace) {
301: this .mOperationNamespace = operationnamespace;
302: }
303:
304: /**
305: * Returns the value of field 'operation'.
306: *
307: * @return the value of field 'operation'.
308: */
309: public java.lang.String getOperationNamespace() {
310: return this .mOperationNamespace;
311: }
312:
313: /**
314: * Method setService.
315: *
316: * @param serviceArray array of services
317: */
318: public void setService(
319: com.sun.jbi.engine.sequencing.servicelist.ServiceBean[] serviceArray) {
320: mServicelist.clear();
321:
322: for (int i = 0; i < serviceArray.length; i++) {
323: mServicelist.add(serviceArray[i]);
324: }
325: }
326:
327: /**
328: * Method setService.
329: *
330: * @param index index for the service
331: * @param vService the service bean
332: *
333: * @throws java.lang.IndexOutOfBoundsException excpetion
334: * @throws IndexOutOfBoundsException exception
335: */
336: public void setService(
337: int index,
338: com.sun.jbi.engine.sequencing.servicelist.ServiceBean vService)
339: throws java.lang.IndexOutOfBoundsException {
340: //-- check bounds for index
341: if ((index < 0) || (index > mServicelist.size())) {
342: throw new IndexOutOfBoundsException();
343: }
344:
345: mServicelist.set(index, vService);
346: }
347:
348: /**
349: * Method getService.
350: *
351: * @return ServiceBean object.
352: */
353: public com.sun.jbi.engine.sequencing.servicelist.ServiceBean[] getService() {
354: int size = mServicelist.size();
355: com.sun.jbi.engine.sequencing.servicelist.ServiceBean[] mArray = new com.sun.jbi.engine.sequencing.servicelist.ServiceBean[size];
356:
357: for (int index = 0; index < size; index++) {
358: mArray[index] = (com.sun.jbi.engine.sequencing.servicelist.ServiceBean) mServicelist
359: .get(index);
360: }
361:
362: return mArray;
363: }
364:
365: /**
366: * Method getService.
367: *
368: * @param index the index of service in the list
369: *
370: * @return ServiceBean
371: *
372: * @throws java.lang.IndexOutOfBoundsException exception
373: * @throws IndexOutOfBoundsException exception
374: */
375: public com.sun.jbi.engine.sequencing.servicelist.ServiceBean getService(
376: int index) throws java.lang.IndexOutOfBoundsException {
377: //-- check bounds for index
378: if ((index < 0) || (index > mServicelist.size())) {
379: throw new IndexOutOfBoundsException();
380: }
381:
382: return (com.sun.jbi.engine.sequencing.servicelist.ServiceBean) mServicelist
383: .get(index);
384: }
385:
386: /**
387: * Method getServiceCount.
388: *
389: * @return service count
390: */
391: public int getServiceCount() {
392: return mServicelist.size();
393: }
394:
395: /**
396: * Sets the service reference.
397: *
398: * @param ref service reference
399: */
400: public void setServiceReference(ServiceEndpoint ref) {
401: mServiceReference = ref;
402: }
403:
404: /**
405: * Gets the service reference.
406: *
407: * @return service reference
408: */
409: public ServiceEndpoint getServiceReference() {
410: return mServiceReference;
411: }
412:
413: /**
414: * Sets the value of field 'servicename'.
415: *
416: * @param servicename the value of field 'servicename'.
417: */
418: public void setServicename(java.lang.String servicename) {
419: this .mServicename = servicename;
420: }
421:
422: /**
423: * Returns the value of field 'servicename'.
424: *
425: * @return the value of field 'servicename'.
426: */
427: public java.lang.String getServicename() {
428: return this .mServicename;
429: }
430:
431: /**
432: * Method addService.
433: *
434: * @param vService adds service
435: *
436: * @throws java.lang.IndexOutOfBoundsException exception.
437: */
438: public void addService(
439: com.sun.jbi.engine.sequencing.servicelist.ServiceBean vService)
440: throws java.lang.IndexOutOfBoundsException {
441: mServicelist.add(vService);
442: }
443:
444: /**
445: * Method addService.
446: *
447: * @param index index for service
448: * @param vService service
449: *
450: * @throws java.lang.IndexOutOfBoundsException exception
451: */
452: public void addService(
453: int index,
454: com.sun.jbi.engine.sequencing.servicelist.ServiceBean vService)
455: throws java.lang.IndexOutOfBoundsException {
456: mServicelist.add(index, vService);
457: }
458:
459: /**
460: * Method clearService.
461: */
462: public void clearService() {
463: mServicelist.clear();
464: }
465:
466: /**
467: * Method removeService.
468: *
469: * @param vService Service name
470: *
471: * @return true if removed
472: */
473: public boolean removeService(
474: com.sun.jbi.engine.sequencing.servicelist.ServiceBean vService) {
475: boolean removed = mServicelist.remove(vService);
476:
477: return removed;
478: }
479:
480: /**
481: * Sets the executing state.
482: *
483: * @param id true denotes atleast one execuitng insatnce
484: * @param state state
485: */
486: public synchronized void updateState(String id, int state) {
487: try {
488: mExecutingLists.put(id, new Integer(state));
489: } catch (Throwable e) {
490: ;
491: }
492: }
493: }
|