001: package org.andromda.cartridges.webservice.metafacades;
002:
003: import java.text.Collator;
004: import java.text.MessageFormat;
005: import java.util.ArrayList;
006: import java.util.Collection;
007: import java.util.Collections;
008: import java.util.Comparator;
009: import java.util.HashSet;
010: import java.util.Iterator;
011: import java.util.LinkedHashSet;
012: import java.util.List;
013: import java.util.Set;
014: import java.util.TreeSet;
015:
016: import org.andromda.cartridges.webservice.WebServiceUtils;
017: import org.andromda.core.common.ExceptionUtils;
018: import org.andromda.core.common.Introspector;
019: import org.andromda.core.metafacade.MetafacadeException;
020: import org.andromda.metafacades.uml.AssociationEndFacade;
021: import org.andromda.metafacades.uml.ClassifierFacade;
022: import org.andromda.metafacades.uml.ModelElementFacade;
023: import org.andromda.metafacades.uml.OperationFacade;
024: import org.andromda.metafacades.uml.ParameterFacade;
025: import org.andromda.metafacades.uml.ServiceOperation;
026: import org.andromda.metafacades.uml.UMLMetafacadeProperties;
027: import org.andromda.metafacades.uml.UMLProfile;
028: import org.apache.commons.collections.Closure;
029: import org.apache.commons.collections.CollectionUtils;
030: import org.apache.commons.collections.Predicate;
031: import org.apache.commons.lang.ObjectUtils;
032: import org.apache.commons.lang.StringUtils;
033:
034: /**
035: * MetafacadeLogic implementation for org.andromda.cartridges.webservice.metafacades.WebService.
036: *
037: * @see org.andromda.cartridges.webservice.metafacades.WebService
038: */
039: public class WebServiceLogicImpl extends WebServiceLogic {
040: // ---------------- constructor -------------------------------
041: public WebServiceLogicImpl(Object metaObject, String context) {
042: super (metaObject, context);
043: }
044:
045: /**
046: * @see org.andromda.cartridges.webservice.metafacades.WebService#getAllowedOperations()
047: */
048: protected java.util.Collection handleGetAllowedOperations() {
049: List operations = new ArrayList(this .getOperations());
050: CollectionUtils.filter(operations, new Predicate() {
051: public boolean evaluate(Object object) {
052: boolean valid = WebServiceOperation.class
053: .isAssignableFrom(object.getClass());
054: if (valid) {
055: valid = ((WebServiceOperation) object).isExposed();
056: }
057: return valid;
058: }
059: });
060: if (this .getWSDLOperationSortMode().equals(
061: OPERATION_SORT_MODE_NAME)) {
062: Collections.sort(operations, new OperationNameComparator());
063: }
064: return operations;
065: }
066:
067: /**
068: * @see org.andromda.cartridges.webservice.metafacades.WebService#getAllowedMethods()
069: */
070: protected java.lang.String handleGetAllowedMethods() {
071: Collection methodNames = new ArrayList();
072: Collection operations = this .getAllowedOperations();
073: if (operations != null && !operations.isEmpty()) {
074: Iterator operationIt = operations.iterator();
075: while (operationIt.hasNext()) {
076: OperationFacade operation = (OperationFacade) operationIt
077: .next();
078: methodNames.add(StringUtils.trimToEmpty(operation
079: .getName()));
080: }
081: }
082: return StringUtils.join(methodNames.iterator(), " ");
083: }
084:
085: /**
086: * @see org.andromda.cartridges.webservice.metafacades.WebService#getQName()
087: */
088: protected String handleGetQName() {
089: return MessageFormat
090: .format(this .getQualifiedNameLocalPartPattern(),
091: new Object[] { StringUtils.trimToEmpty(this
092: .getName()) });
093: }
094:
095: /**
096: * @see org.andromda.cartridges.webservice.metafacades.WebService#getNamespace()
097: */
098: protected java.lang.String handleGetNamespace() {
099: String packageName = this .getPackageName();
100: if (this .isReverseNamespace()) {
101: packageName = WebServiceUtils.reversePackage(packageName);
102: }
103: return MessageFormat.format(this .getNamespacePattern(),
104: new Object[] { StringUtils.trimToEmpty(packageName) });
105: }
106:
107: /**
108: * The property defining the default style to give the web services.
109: */
110: private static final String PROPERTY_DEFAULT_STYLE = "defaultStyle";
111:
112: /**
113: * @see org.andromda.cartridges.webservice.metafacades.WebService#getStyle()
114: */
115: protected java.lang.String handleGetStyle() {
116: String style = (String) this
117: .findTaggedValue(UMLProfile.TAGGEDVALUE_WEBSERVICE_STYLE);
118: if (StringUtils.isEmpty(style)) {
119: style = String.valueOf(this
120: .getConfiguredProperty(PROPERTY_DEFAULT_STYLE));
121: }
122: return style;
123: }
124:
125: /**
126: * The property defining the default style to give the web services.
127: */
128: private static final String PROPERTY_DEFAULT_USE = "defaultUse";
129:
130: /**
131: * @see org.andromda.cartridges.webservice.metafacades.WebService#getUse()
132: */
133: protected java.lang.String handleGetUse() {
134: String use = (String) this
135: .findTaggedValue(UMLProfile.TAGGEDVALUE_WEBSERVICE_USE);
136: if (StringUtils.isEmpty(use)) {
137: use = String.valueOf(this
138: .getConfiguredProperty(PROPERTY_DEFAULT_USE));
139: }
140: return use;
141: }
142:
143: /**
144: * Keeps track of whether or not the type has been checked, keeps us from entering infinite loops when calling
145: * loadTypes.
146: */
147: private Collection checkedTypes = new ArrayList();
148:
149: /**
150: * @see org.andromda.cartridges.webservice.metafacades.WebService#getTypeMappingElements()
151: */
152: protected java.util.Collection handleGetTypeMappingElements() {
153: final Collection parameterTypes = new LinkedHashSet();
154: for (final Iterator iterator = this .getAllowedOperations()
155: .iterator(); iterator.hasNext();) {
156: parameterTypes.addAll(((OperationFacade) iterator.next())
157: .getParameters());
158: }
159:
160: final Set types = new TreeSet(new TypeComparator());
161: final Collection nonArrayTypes = new TreeSet(
162: new TypeComparator());
163:
164: // clear out the cache of checkedTypes, otherwise
165: // they'll be ignored the second time this method is
166: // called (if the instance is reused)
167: this .checkedTypes.clear();
168: for (final Iterator iterator = parameterTypes.iterator(); iterator
169: .hasNext();) {
170: this .loadTypes((ModelElementFacade) iterator.next(), types,
171: nonArrayTypes);
172: }
173:
174: final Collection exceptions = new ArrayList();
175: for (final Iterator iterator = this .getAllowedOperations()
176: .iterator(); iterator.hasNext();) {
177: exceptions.addAll(((OperationFacade) iterator.next())
178: .getExceptions());
179: }
180:
181: types.addAll(exceptions);
182:
183: // now since we're at the end, and we know the
184: // non array types won't override any other types
185: // (such as association ends) we
186: // add the non array types to the types
187: types.addAll(nonArrayTypes);
188:
189: return types;
190: }
191:
192: /**
193: * <p/> Loads all <code>types</code> and <code>nonArrayTypes</code> for
194: * the specified <code>type</code>. For each array type we collect the
195: * <code>nonArrayType</code>. Non array types are loaded seperately so
196: * that they are added at the end at the type collecting process. Since the
197: * types collection is a set (by the fullyQualifiedName) we don't want any
198: * non array types to override things such as association ends in the
199: * <code>types</code> collection.
200: * </p>
201: *
202: * @param type the type
203: * @param types the collection to load.
204: * @param nonArrayTypes the collection of non array types.
205: */
206: private void loadTypes(ModelElementFacade modelElement, Set types,
207: Collection nonArrayTypes) {
208: ExceptionUtils.checkNull("types", types);
209: ExceptionUtils.checkNull("nonArrayTypes", nonArrayTypes);
210:
211: try {
212: if (modelElement != null
213: && !this .checkedTypes.contains(modelElement)) {
214: final ClassifierFacade parameterType = this
215: .getType(modelElement);
216:
217: // only continue if the model element has a type
218: if (parameterType != null) {
219: Set allTypes = new HashSet();
220: allTypes.add(parameterType);
221:
222: // add all generalizations and specializations of the type
223: Collection generalizations = parameterType
224: .getAllGeneralizations();
225:
226: if (generalizations != null) {
227: allTypes.addAll(generalizations);
228: }
229:
230: Collection specializations = parameterType
231: .getAllSpecializations();
232:
233: if (specializations != null) {
234: allTypes.addAll(specializations);
235: }
236:
237: this .checkedTypes.add(modelElement);
238:
239: for (final Iterator allTypesIterator = allTypes
240: .iterator(); allTypesIterator.hasNext();) {
241: ClassifierFacade type = (ClassifierFacade) allTypesIterator
242: .next();
243:
244: if (!this .containsManyType(types, modelElement)) {
245: ClassifierFacade nonArrayType = type;
246: final boolean arrayType = type
247: .isArrayType();
248:
249: if (arrayType
250: || this
251: .isValidAssociationEnd(modelElement)) {
252: types.add(modelElement);
253:
254: if (arrayType) {
255: // convert to non-array type since we
256: // check if that one has the stereotype
257: nonArrayType = type.getNonArray();
258:
259: // set the type to the non array type since
260: // that will have the attributes
261: type = nonArrayType;
262: }
263: }
264:
265: if (nonArrayType != null) {
266: if (nonArrayType
267: .hasStereotype(UMLProfile.STEREOTYPE_VALUE_OBJECT)
268: || nonArrayType.isEnumeration()) {
269: // we add the type when its a non array and
270: // has the correct stereotype (even if we have
271: // added the array type above) since we need to
272: // define both an array and non array in the WSDL
273: // if we are defining an array.
274: nonArrayTypes.add(nonArrayType);
275: }
276: }
277: }
278:
279: if (type != null) {
280: final Collection properties = type
281: .getProperties();
282: if (properties != null
283: && !properties.isEmpty()) {
284: for (final Iterator iterator = properties
285: .iterator(); iterator.hasNext();) {
286: final ModelElementFacade property = (ModelElementFacade) iterator
287: .next();
288: this .loadTypes(property, types,
289: nonArrayTypes);
290: }
291: }
292: }
293: }
294: }
295: }
296: } catch (final Throwable throwable) {
297: final String message = "Error performing loadTypes";
298: logger.error(message, throwable);
299: throw new MetafacadeException(message, throwable);
300: }
301: }
302:
303: /**
304: * <p/> Checks to see if the <code>types</code> collection contains the
305: * <code>modelElement</code>. It does this by checking to see if the
306: * model element is either an association end or some type of model element
307: * that has a type that's an array. If it's either an array <strong>OR
308: * </strong> an association end, then we check to see if the type is stored
309: * within the <code>types</code> collection. If so, we return true,
310: * otherwise we return false.
311: * </p>
312: *
313: * @param types the previously collected types.
314: * @param modelElement the model element to check to see if it represents a
315: * <code>many</code> type
316: * @return true/false depending on whether or not the model element is a
317: * many type.
318: */
319: private boolean containsManyType(final Collection types,
320: final Object modelElement) {
321: ClassifierFacade classifier = null;
322: if (modelElement instanceof AssociationEndFacade) {
323: AssociationEndFacade end = (AssociationEndFacade) modelElement;
324: if (end.isMany()) {
325: classifier = ((AssociationEndFacade) modelElement)
326: .getType();
327: }
328: } else if (modelElement instanceof ClassifierFacade) {
329: classifier = (ClassifierFacade) modelElement;
330: } else if (modelElement instanceof ParameterFacade) {
331: classifier = ((ParameterFacade) modelElement).getType();
332: }
333: if (classifier != null) {
334: if (classifier.isArrayType()) {
335: classifier = classifier.getNonArray();
336: }
337: }
338: final ClassifierFacade compareType = classifier;
339: boolean containsManyType = false;
340: if (compareType != null) {
341: containsManyType = CollectionUtils.find(types,
342: new Predicate() {
343: public boolean evaluate(Object object) {
344: boolean valid = false;
345: if (object != null) {
346: ClassifierFacade type = null;
347: if (object instanceof AssociationEndFacade) {
348: AssociationEndFacade end = (AssociationEndFacade) object;
349: if (end.isMany()) {
350: type = ((AssociationEndFacade) object)
351: .getType();
352: }
353: } else if (object instanceof ClassifierFacade) {
354: type = (ClassifierFacade) object;
355: if (type.isArrayType()) {
356: type = type.getNonArray();
357: } else {
358: type = null;
359: }
360: }
361: if (type != null) {
362: valid = type.equals(compareType);
363: }
364: }
365: return valid;
366: }
367: }) != null;
368: }
369: return containsManyType;
370: }
371:
372: /**
373: * Returns true/false depending on whether or not this class represents a valid association end (meaning it has a
374: * multiplicify of many)
375: *
376: * @param modelElement the model element to check.
377: * @return true/false
378: */
379: private boolean isValidAssociationEnd(Object modelElement) {
380: return modelElement instanceof AssociationEndFacade
381: && ((AssociationEndFacade) modelElement).isMany();
382: }
383:
384: /**
385: * @see org.andromda.cartridges.webservice.metafacades.WebService#getProvider()
386: */
387: protected java.lang.String handleGetProvider() {
388: String provider = (String) this
389: .findTaggedValue(UMLProfile.TAGGEDVALUE_WEBSERVICE_PROVIDER);
390: if (StringUtils.isEmpty(provider)) {
391: provider = (String) this
392: .getConfiguredProperty("defaultProvider");
393: }
394: return provider;
395: }
396:
397: /**
398: * @see org.andromda.cartridges.webservice.metafacades.WebService#getWsdlFile()
399: */
400: protected java.lang.String handleGetWsdlFile() {
401: return StringUtils
402: .replace(
403: this .getFullyQualifiedName(),
404: String
405: .valueOf(this
406: .getConfiguredProperty(UMLMetafacadeProperties.NAMESPACE_SEPARATOR)),
407: "/")
408: + ".wsdl";
409: }
410:
411: /**
412: * We use this comparator to actually elimate duplicates instead of sorting like a comparator is normally used.
413: */
414: private final class TypeComparator implements Comparator {
415: private final Collator collator = Collator.getInstance();
416:
417: private TypeComparator() {
418: collator.setStrength(Collator.PRIMARY);
419: }
420:
421: public int compare(Object objectA, Object objectB) {
422: final ModelElementFacade a = (ModelElementFacade) objectA;
423: ModelElementFacade aType = getType(a);
424: if (aType == null) {
425: aType = a;
426: }
427: final ModelElementFacade b = (ModelElementFacade) objectB;
428: ModelElementFacade bType = getType(b);
429: if (bType == null) {
430: bType = b;
431: }
432: return collator.compare(aType.getFullyQualifiedName(),
433: bType.getFullyQualifiedName());
434: }
435: }
436:
437: /**
438: * Gets the <code>type</code> or <code>returnType</code> of the model element (if the model element has a type or
439: * returnType).
440: *
441: * @param modelElement the model element we'll retrieve the type of.
442: */
443: protected ClassifierFacade getType(Object modelElement) {
444: try {
445: final Introspector introspector = Introspector.instance();
446: ClassifierFacade type = null;
447: String typeProperty = "type";
448:
449: // only continue if the model element has a type
450: if (introspector.isReadable(modelElement, typeProperty)) {
451: type = (ClassifierFacade) introspector.getProperty(
452: modelElement, typeProperty);
453: }
454:
455: // try for return type if type wasn't found
456: typeProperty = "returnType";
457: if (type == null
458: && introspector.isReadable(modelElement,
459: typeProperty)) {
460: type = (ClassifierFacade) introspector.getProperty(
461: modelElement, typeProperty);
462: }
463: return type;
464: } catch (final Throwable throwable) {
465: String errMsg = "Error performing WebServiceLogicImpl.getType";
466: logger.error(errMsg, throwable);
467: throw new MetafacadeException(errMsg, throwable);
468: }
469: }
470:
471: static final String NAMESPACE_PREFIX = "namespacePrefix";
472:
473: /**
474: * @see org.andromda.cartridges.webservice.metafacades.WSDLType#getNamespacePrefix()
475: */
476: protected String handleGetNamespacePrefix() {
477: return (String) this .getConfiguredProperty(NAMESPACE_PREFIX);
478: }
479:
480: static final String QNAME_LOCAL_PART_PATTERN = "qualifiedNameLocalPartPattern";
481:
482: /**
483: * Gets the <code>qualifiedNameLocalPartPattern</code> for this service.
484: */
485: protected String getQualifiedNameLocalPartPattern() {
486: return (String) this
487: .getConfiguredProperty(QNAME_LOCAL_PART_PATTERN);
488: }
489:
490: static final String NAMESPACE_PATTERN = "namespacePattern";
491:
492: /**
493: * Gets the <code>namespacePattern</code> for this service.
494: *
495: * @return String the namespace pattern to use.
496: */
497: protected String getNamespacePattern() {
498: return (String) this .getConfiguredProperty(NAMESPACE_PATTERN);
499: }
500:
501: static final String REVERSE_NAMESPACE = "reverseNamespace";
502:
503: /**
504: * Gets whether or not <code>reverseNamespace</code> is true/false for this type.
505: *
506: * @return boolean true/false
507: */
508: protected boolean isReverseNamespace() {
509: return Boolean.valueOf(
510: String.valueOf(this
511: .getConfiguredProperty(REVERSE_NAMESPACE)))
512: .booleanValue();
513: }
514:
515: /**
516: * @see org.andromda.cartridges.webservice.metafacades.WebService#getEjbJndiName()
517: */
518: protected java.lang.String handleGetEjbJndiName() {
519: StringBuffer jndiName = new StringBuffer();
520: String jndiNamePrefix = StringUtils.trimToEmpty(this
521: .getEjbJndiNamePrefix());
522: if (StringUtils.isNotEmpty(jndiNamePrefix)) {
523: jndiName.append(jndiNamePrefix);
524: jndiName.append("/");
525: }
526: jndiName.append("ejb/");
527: jndiName.append(this .getFullyQualifiedName());
528: return jndiName.toString();
529: }
530:
531: /**
532: * Gets the <code>ejbJndiNamePrefix</code> for an EJB provider.
533: *
534: * @return the EJB Jndi name prefix.
535: */
536: protected String getEjbJndiNamePrefix() {
537: final String property = "ejbJndiNamePrefix";
538: return this .isConfiguredProperty(property) ? ObjectUtils
539: .toString(this .getConfiguredProperty(property)) : null;
540: }
541:
542: /**
543: * @see org.andromda.cartridges.webservice.metafacades.WebService#getEjbHomeInterface()
544: */
545: protected java.lang.String handleGetEjbHomeInterface() {
546: return MessageFormat.format(this .getEjbHomeInterfacePattern(),
547: new Object[] {
548: StringUtils.trimToEmpty(this .getPackageName()),
549: StringUtils.trimToEmpty(this .getName()) });
550: }
551:
552: /**
553: * Gets the <code>ejbHomeInterfacePattern</code> for an EJB provider.
554: *
555: * @return the EJB Home interface pattern
556: */
557: protected String getEjbHomeInterfacePattern() {
558: return (String) this
559: .getConfiguredProperty("ejbHomeInterfacePattern");
560: }
561:
562: /**
563: * @see org.andromda.cartridges.webservice.metafacades.WebService#getEjbInterface()
564: */
565: protected java.lang.String handleGetEjbInterface() {
566: return MessageFormat.format(this .getEjbInterfacePattern(),
567: new Object[] {
568: StringUtils.trimToEmpty(this .getPackageName()),
569: StringUtils.trimToEmpty(this .getName()) });
570: }
571:
572: /**
573: * Gets the <code>ejbInterfacePattern</code> for an EJB provider.
574: *
575: * @return the EJB interface pattern
576: */
577: protected String getEjbInterfacePattern() {
578: return (String) this
579: .getConfiguredProperty("ejbInterfacePattern");
580: }
581:
582: private static final String RPC_CLASS_NAME_PATTERN = "rpcClassNamePattern";
583:
584: /**
585: * Gets the <code>rpcClassNamePattern</code> for this service.
586: */
587: protected String getRpcClassNamePattern() {
588: return (String) this
589: .getConfiguredProperty(RPC_CLASS_NAME_PATTERN);
590: }
591:
592: /**
593: * @see org.andromda.cartridges.webservice.metafacades.WebService#getRpcClassName()
594: */
595: protected String handleGetRpcClassName() {
596: return MessageFormat.format(this .getRpcClassNamePattern(),
597: new Object[] {
598: StringUtils.trimToEmpty(this .getPackageName()),
599: StringUtils.trimToEmpty(this .getName()) });
600: }
601:
602: private static final String WSDL_OPERATION_SORT_MODE = "wsdlOperationSortMode";
603:
604: /**
605: * Used to sort operations by <code>name</code>.
606: */
607: private final static class OperationNameComparator implements
608: Comparator {
609: private final Collator collator = Collator.getInstance();
610:
611: private OperationNameComparator() {
612: collator.setStrength(Collator.PRIMARY);
613: }
614:
615: public int compare(Object objectA, Object objectB) {
616: ModelElementFacade a = (ModelElementFacade) objectA;
617: ModelElementFacade b = (ModelElementFacade) objectB;
618:
619: return collator.compare(a.getName(), b.getName());
620: }
621: }
622:
623: /**
624: * The model specifying operations should be sorted by name.
625: */
626: private static final String OPERATION_SORT_MODE_NAME = "name";
627:
628: /**
629: * The model specifying operations should NOT be sorted.
630: */
631: private static final String OPERATION_SORT_MODE_NONE = "none";
632:
633: /**
634: * Gets the sort mode WSDL operations.
635: *
636: * @return String
637: */
638: private String getWSDLOperationSortMode() {
639: Object property = this
640: .getConfiguredProperty(WSDL_OPERATION_SORT_MODE);
641: return property != null
642: || property.equals(OPERATION_SORT_MODE_NAME) ? (String) property
643: : OPERATION_SORT_MODE_NONE;
644: }
645:
646: /**
647: * @see org.andromda.cartridges.webservice.metafacades.WebService#isSecured()
648: */
649: protected boolean handleIsSecured() {
650: Collection roles = this .getAllRoles();
651: return roles != null && !roles.isEmpty();
652: }
653:
654: /**
655: * Overridden to only allow the exposed operations in the returned roles collection.
656: *
657: * @see org.andromda.metafacades.uml.Service#getAllRoles()
658: */
659: public Collection getAllRoles() {
660: final Collection roles = new LinkedHashSet(this .getRoles());
661: CollectionUtils.forAllDo(this .getAllowedOperations(),
662: new Closure() {
663: public void execute(Object object) {
664: if (object != null
665: && ServiceOperation.class
666: .isAssignableFrom(object
667: .getClass())) {
668: roles.addAll(((ServiceOperation) object)
669: .getRoles());
670: }
671: }
672: });
673: return roles;
674: }
675:
676: /**
677: * The pattern used to construct the test package name.
678: */
679: private static final String TEST_PACKAGE_NAME_PATTERN = "testPackageNamePattern";
680:
681: /**
682: * @see org.andromda.cartridges.webservice.metafacades.WebService#getTestPackageName()
683: */
684: protected String handleGetTestPackageName() {
685: return String.valueOf(
686: this .getConfiguredProperty(TEST_PACKAGE_NAME_PATTERN))
687: .replaceAll("\\{0\\}", this .getPackageName());
688: }
689:
690: /**
691: * @see org.andromda.cartridges.webservice.metafacades.WebService#getFullyQualifiedTestName()
692: */
693: protected String handleGetFullyQualifiedTestName() {
694: return this .getTestPackageName() + '.' + this .getTestName();
695: }
696:
697: /**
698: * The pattern used to construct the test name.
699: */
700: private static final String TEST_NAME_PATTERN = "testNamePattern";
701:
702: /**
703: * @see org.andromda.cartridges.webservice.metafacades.WebService#getTestName()
704: */
705: protected String handleGetTestName() {
706: return String.valueOf(
707: this .getConfiguredProperty(TEST_NAME_PATTERN))
708: .replaceAll("\\{0\\}", this .getName());
709: }
710:
711: /**
712: * Represents a "wrapped" style.
713: */
714: private static final String STYLE_WRAPPED = "wrapped";
715:
716: /**
717: * @see org.andromda.cartridges.webservice.metafacades.WebService#isWrappedStyle()
718: */
719: protected boolean handleIsWrappedStyle() {
720: return this .getStyle().equalsIgnoreCase(STYLE_WRAPPED);
721: }
722:
723: /**
724: * Represents a "document" style.
725: */
726: private static final String STYLE_DOCUMENT = "document";
727:
728: /**
729: * @see org.andromda.cartridges.webservice.metafacades.WebService#isDocumentStyle()
730: */
731: protected boolean handleIsDocumentStyle() {
732: return this .getStyle().equalsIgnoreCase(STYLE_DOCUMENT);
733: }
734:
735: /**
736: * Represents a "rpc" style.
737: */
738: private static final String STYLE_RPC = "rpc";
739:
740: /**
741: * @see org.andromda.cartridges.webservice.metafacades.WebService#isRpcStyle()
742: */
743: protected boolean handleIsRpcStyle() {
744: return this .getStyle().equalsIgnoreCase(STYLE_RPC);
745: }
746:
747: /**
748: * Represents an "literal" use.
749: */
750: private static final String USE_LITERAL = "literal";
751:
752: /**
753: * @see org.andromda.cartridges.webservice.metafacades.WebService#isLiteralUse()
754: */
755: protected boolean handleIsLiteralUse() {
756: return this .getStyle().equalsIgnoreCase(USE_LITERAL);
757: }
758:
759: /**
760: * Represents an "encoded" use.
761: */
762: private static final String USE_ENCODED = "encoded";
763:
764: /**
765: * @see org.andromda.cartridges.webservice.metafacades.WebService#isEncodedUse()
766: */
767: protected boolean handleIsEncodedUse() {
768: return this .getStyle().equalsIgnoreCase(USE_ENCODED);
769: }
770:
771: /**
772: * The pattern used to construct the test implementation name.
773: */
774: private static final String TEST_IMPLEMENTATION_NAME_PATTERN = "testImplementationNamePattern";
775:
776: /**
777: * @see org.andromda.cartridges.webservice.metafacades.WebService#getTestImplementationName()
778: */
779: protected String handleGetTestImplementationName() {
780: return String
781: .valueOf(
782: this
783: .getConfiguredProperty(TEST_IMPLEMENTATION_NAME_PATTERN))
784: .replaceAll("\\{0\\}", this .getName());
785: }
786:
787: /**
788: * @see org.andromda.cartridges.webservice.metafacades.WebService#getFullyQualifiedTestImplementationName()
789: */
790: protected String handleGetFullyQualifiedTestImplementationName() {
791: return this .getTestPackageName() + '.'
792: + this.getTestImplementationName();
793: }
794: }
|