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