1 package org.andromda.cartridges.webservice.metafacades;
2
3 import java.text.Collator;
4 import java.text.MessageFormat;
5 import java.util.ArrayList;
6 import java.util.Collection;
7 import java.util.Collections;
8 import java.util.Comparator;
9 import java.util.HashSet;
10 import java.util.Iterator;
11 import java.util.LinkedHashSet;
12 import java.util.List;
13 import java.util.Set;
14 import java.util.TreeSet;
15
16 import org.andromda.cartridges.webservice.WebServiceUtils;
17 import org.andromda.core.common.ExceptionUtils;
18 import org.andromda.core.common.Introspector;
19 import org.andromda.core.metafacade.MetafacadeException;
20 import org.andromda.metafacades.uml.AssociationEndFacade;
21 import org.andromda.metafacades.uml.ClassifierFacade;
22 import org.andromda.metafacades.uml.ModelElementFacade;
23 import org.andromda.metafacades.uml.OperationFacade;
24 import org.andromda.metafacades.uml.ParameterFacade;
25 import org.andromda.metafacades.uml.ServiceOperation;
26 import org.andromda.metafacades.uml.UMLMetafacadeProperties;
27 import org.andromda.metafacades.uml.UMLProfile;
28 import org.apache.commons.collections.Closure;
29 import org.apache.commons.collections.CollectionUtils;
30 import org.apache.commons.collections.Predicate;
31 import org.apache.commons.lang.ObjectUtils;
32 import org.apache.commons.lang.StringUtils;
33
34
35 /***
36 * MetafacadeLogic implementation for org.andromda.cartridges.webservice.metafacades.WebService.
37 *
38 * @see org.andromda.cartridges.webservice.metafacades.WebService
39 */
40 public class WebServiceLogicImpl
41 extends WebServiceLogic
42 {
43
44 public WebServiceLogicImpl(
45 Object metaObject,
46 String context)
47 {
48 super(metaObject, context);
49 }
50
51 /***
52 * @see org.andromda.cartridges.webservice.metafacades.WebService#getAllowedOperations()
53 */
54 protected java.util.Collection handleGetAllowedOperations()
55 {
56 List operations = new ArrayList(this.getOperations());
57 CollectionUtils.filter(
58 operations,
59 new Predicate()
60 {
61 public boolean evaluate(Object object)
62 {
63 boolean valid = WebServiceOperation.class.isAssignableFrom(object.getClass());
64 if (valid)
65 {
66 valid = ((WebServiceOperation)object).isExposed();
67 }
68 return valid;
69 }
70 });
71 if (this.getWSDLOperationSortMode().equals(OPERATION_SORT_MODE_NAME))
72 {
73 Collections.sort(
74 operations,
75 new OperationNameComparator());
76 }
77 return operations;
78 }
79
80 /***
81 * @see org.andromda.cartridges.webservice.metafacades.WebService#getAllowedMethods()
82 */
83 protected java.lang.String handleGetAllowedMethods()
84 {
85 Collection methodNames = new ArrayList();
86 Collection operations = this.getAllowedOperations();
87 if (operations != null && !operations.isEmpty())
88 {
89 Iterator operationIt = operations.iterator();
90 while (operationIt.hasNext())
91 {
92 OperationFacade operation = (OperationFacade)operationIt.next();
93 methodNames.add(StringUtils.trimToEmpty(operation.getName()));
94 }
95 }
96 return StringUtils.join(
97 methodNames.iterator(),
98 " ");
99 }
100
101 /***
102 * @see org.andromda.cartridges.webservice.metafacades.WebService#getQName()
103 */
104 protected String handleGetQName()
105 {
106 return MessageFormat.format(
107 this.getQualifiedNameLocalPartPattern(),
108 new Object[] {StringUtils.trimToEmpty(this.getName())});
109 }
110
111 /***
112 * @see org.andromda.cartridges.webservice.metafacades.WebService#getNamespace()
113 */
114 protected java.lang.String handleGetNamespace()
115 {
116 String packageName = this.getPackageName();
117 if (this.isReverseNamespace())
118 {
119 packageName = WebServiceUtils.reversePackage(packageName);
120 }
121 return MessageFormat.format(
122 this.getNamespacePattern(),
123 new Object[] {StringUtils.trimToEmpty(packageName)});
124 }
125
126 /***
127 * The property defining the default style to give the web services.
128 */
129 private static final String PROPERTY_DEFAULT_STYLE = "defaultStyle";
130
131 /***
132 * @see org.andromda.cartridges.webservice.metafacades.WebService#getStyle()
133 */
134 protected java.lang.String handleGetStyle()
135 {
136 String style = (String)this.findTaggedValue(UMLProfile.TAGGEDVALUE_WEBSERVICE_STYLE);
137 if (StringUtils.isEmpty(style))
138 {
139 style = String.valueOf(this.getConfiguredProperty(PROPERTY_DEFAULT_STYLE));
140 }
141 return style;
142 }
143
144 /***
145 * The property defining the default style to give the web services.
146 */
147 private static final String PROPERTY_DEFAULT_USE = "defaultUse";
148
149 /***
150 * @see org.andromda.cartridges.webservice.metafacades.WebService#getUse()
151 */
152 protected java.lang.String handleGetUse()
153 {
154 String use = (String)this.findTaggedValue(UMLProfile.TAGGEDVALUE_WEBSERVICE_USE);
155 if (StringUtils.isEmpty(use))
156 {
157 use = String.valueOf(this.getConfiguredProperty(PROPERTY_DEFAULT_USE));
158 }
159 return use;
160 }
161
162 /***
163 * Keeps track of whether or not the type has been checked, keeps us from entering infinite loops when calling
164 * loadTypes.
165 */
166 private Collection checkedTypes = new ArrayList();
167
168 /***
169 * @see org.andromda.cartridges.webservice.metafacades.WebService#getTypeMappingElements()
170 */
171 protected java.util.Collection handleGetTypeMappingElements()
172 {
173 final Collection parameterTypes = new LinkedHashSet();
174 for (final Iterator iterator = this.getAllowedOperations().iterator(); iterator.hasNext();)
175 {
176 parameterTypes.addAll(((OperationFacade)iterator.next()).getParameters());
177 }
178
179 final Set types = new TreeSet(new TypeComparator());
180 final Collection nonArrayTypes = new TreeSet(new TypeComparator());
181
182
183
184
185 this.checkedTypes.clear();
186 for (final Iterator iterator = parameterTypes.iterator(); iterator.hasNext();)
187 {
188 this.loadTypes((ModelElementFacade)iterator.next(), types, nonArrayTypes);
189 }
190
191 final Collection exceptions = new ArrayList();
192 for (final Iterator iterator = this.getAllowedOperations().iterator(); iterator.hasNext();)
193 {
194 exceptions.addAll(((OperationFacade)iterator.next()).getExceptions());
195 }
196
197 types.addAll(exceptions);
198
199
200
201
202
203 types.addAll(nonArrayTypes);
204
205 return types;
206 }
207
208 /***
209 * <p/> Loads all <code>types</code> and <code>nonArrayTypes</code> for
210 * the specified <code>type</code>. For each array type we collect the
211 * <code>nonArrayType</code>. Non array types are loaded seperately so
212 * that they are added at the end at the type collecting process. Since the
213 * types collection is a set (by the fullyQualifiedName) we don't want any
214 * non array types to override things such as association ends in the
215 * <code>types</code> collection.
216 * </p>
217 *
218 * @param type the type
219 * @param types the collection to load.
220 * @param nonArrayTypes the collection of non array types.
221 */
222 private void loadTypes(ModelElementFacade modelElement, Set types, Collection nonArrayTypes)
223 {
224 ExceptionUtils.checkNull("types", types);
225 ExceptionUtils.checkNull("nonArrayTypes", nonArrayTypes);
226
227 try
228 {
229 if (modelElement != null && !this.checkedTypes.contains(modelElement))
230 {
231 final ClassifierFacade parameterType = this.getType(modelElement);
232
233
234 if (parameterType != null)
235 {
236 Set allTypes = new HashSet();
237 allTypes.add(parameterType);
238
239
240 Collection generalizations = parameterType.getAllGeneralizations();
241
242 if (generalizations != null)
243 {
244 allTypes.addAll(generalizations);
245 }
246
247 Collection specializations = parameterType.getAllSpecializations();
248
249 if (specializations != null)
250 {
251 allTypes.addAll(specializations);
252 }
253
254 this.checkedTypes.add(modelElement);
255
256 for (final Iterator allTypesIterator = allTypes.iterator(); allTypesIterator.hasNext();)
257 {
258 ClassifierFacade type = (ClassifierFacade) allTypesIterator.next();
259
260 if (!this.containsManyType(types, modelElement))
261 {
262 ClassifierFacade nonArrayType = type;
263 final boolean arrayType = type.isArrayType();
264
265 if (arrayType || this.isValidAssociationEnd(modelElement))
266 {
267 types.add(modelElement);
268
269 if (arrayType)
270 {
271
272
273 nonArrayType = type.getNonArray();
274
275
276
277 type = nonArrayType;
278 }
279 }
280
281 if (nonArrayType != null)
282 {
283 if (nonArrayType.hasStereotype(UMLProfile.STEREOTYPE_VALUE_OBJECT)
284 || nonArrayType.isEnumeration())
285 {
286
287
288
289
290
291 nonArrayTypes.add(nonArrayType);
292 }
293 }
294 }
295
296 if (type != null)
297 {
298 final Collection properties = type.getProperties();
299 if (properties != null && !properties.isEmpty())
300 {
301 for (final Iterator iterator = properties.iterator(); iterator.hasNext();)
302 {
303 final ModelElementFacade property = (ModelElementFacade) iterator.next();
304 this.loadTypes(property, types, nonArrayTypes);
305 }
306 }
307 }
308 }
309 }
310 }
311 }
312 catch (final Throwable throwable)
313 {
314 final String message = "Error performing loadTypes";
315 logger.error(message, throwable);
316 throw new MetafacadeException(message, throwable);
317 }
318 }
319
320 /***
321 * <p/> Checks to see if the <code>types</code> collection contains the
322 * <code>modelElement</code>. It does this by checking to see if the
323 * model element is either an association end or some type of model element
324 * that has a type that's an array. If it's either an array <strong>OR
325 * </strong> an association end, then we check to see if the type is stored
326 * within the <code>types</code> collection. If so, we return true,
327 * otherwise we return false.
328 * </p>
329 *
330 * @param types the previously collected types.
331 * @param modelElement the model element to check to see if it represents a
332 * <code>many</code> type
333 * @return true/false depending on whether or not the model element is a
334 * many type.
335 */
336 private boolean containsManyType(
337 final Collection types,
338 final Object modelElement)
339 {
340 ClassifierFacade classifier = null;
341 if (modelElement instanceof AssociationEndFacade)
342 {
343 AssociationEndFacade end = (AssociationEndFacade)modelElement;
344 if (end.isMany())
345 {
346 classifier = ((AssociationEndFacade)modelElement).getType();
347 }
348 }
349 else if (modelElement instanceof ClassifierFacade)
350 {
351 classifier = (ClassifierFacade)modelElement;
352 }
353 else if (modelElement instanceof ParameterFacade)
354 {
355 classifier = ((ParameterFacade)modelElement).getType();
356 }
357 if (classifier != null)
358 {
359 if (classifier.isArrayType())
360 {
361 classifier = classifier.getNonArray();
362 }
363 }
364 final ClassifierFacade compareType = classifier;
365 boolean containsManyType = false;
366 if (compareType != null)
367 {
368 containsManyType =
369 CollectionUtils.find(
370 types,
371 new Predicate()
372 {
373 public boolean evaluate(Object object)
374 {
375 boolean valid = false;
376 if (object != null)
377 {
378 ClassifierFacade type = null;
379 if (object instanceof AssociationEndFacade)
380 {
381 AssociationEndFacade end = (AssociationEndFacade)object;
382 if (end.isMany())
383 {
384 type = ((AssociationEndFacade)object).getType();
385 }
386 }
387 else if (object instanceof ClassifierFacade)
388 {
389 type = (ClassifierFacade)object;
390 if (type.isArrayType())
391 {
392 type = type.getNonArray();
393 }
394 else
395 {
396 type = null;
397 }
398 }
399 if (type != null)
400 {
401 valid = type.equals(compareType);
402 }
403 }
404 return valid;
405 }
406 }) != null;
407 }
408 return containsManyType;
409 }
410
411 /***
412 * Returns true/false depending on whether or not this class represents a valid association end (meaning it has a
413 * multiplicify of many)
414 *
415 * @param modelElement the model element to check.
416 * @return true/false
417 */
418 private boolean isValidAssociationEnd(Object modelElement)
419 {
420 return modelElement instanceof AssociationEndFacade && ((AssociationEndFacade)modelElement).isMany();
421 }
422
423 /***
424 * @see org.andromda.cartridges.webservice.metafacades.WebService#getProvider()
425 */
426 protected java.lang.String handleGetProvider()
427 {
428 String provider = (String)this.findTaggedValue(UMLProfile.TAGGEDVALUE_WEBSERVICE_PROVIDER);
429 if (StringUtils.isEmpty(provider))
430 {
431 provider = (String)this.getConfiguredProperty("defaultProvider");
432 }
433 return provider;
434 }
435
436 /***
437 * @see org.andromda.cartridges.webservice.metafacades.WebService#getWsdlFile()
438 */
439 protected java.lang.String handleGetWsdlFile()
440 {
441 return StringUtils.replace(
442 this.getFullyQualifiedName(),
443 String.valueOf(this.getConfiguredProperty(UMLMetafacadeProperties.NAMESPACE_SEPARATOR)),
444 "/") + ".wsdl";
445 }
446
447 /***
448 * We use this comparator to actually elimate duplicates instead of sorting like a comparator is normally used.
449 */
450 private final class TypeComparator
451 implements Comparator
452 {
453 private final Collator collator = Collator.getInstance();
454
455 private TypeComparator()
456 {
457 collator.setStrength(Collator.PRIMARY);
458 }
459
460 public int compare(
461 Object objectA,
462 Object objectB)
463 {
464 final ModelElementFacade a = (ModelElementFacade)objectA;
465 ModelElementFacade aType = getType(a);
466 if (aType == null)
467 {
468 aType = a;
469 }
470 final ModelElementFacade b = (ModelElementFacade)objectB;
471 ModelElementFacade bType = getType(b);
472 if (bType == null)
473 {
474 bType = b;
475 }
476 return collator.compare(
477 aType.getFullyQualifiedName(),
478 bType.getFullyQualifiedName());
479 }
480 }
481
482 /***
483 * Gets the <code>type</code> or <code>returnType</code> of the model element (if the model element has a type or
484 * returnType).
485 *
486 * @param modelElement the model element we'll retrieve the type of.
487 */
488 protected ClassifierFacade getType(Object modelElement)
489 {
490 try
491 {
492 final Introspector introspector = Introspector.instance();
493 ClassifierFacade type = null;
494 String typeProperty = "type";
495
496
497 if (introspector.isReadable(modelElement, typeProperty))
498 {
499 type = (ClassifierFacade)introspector.getProperty(modelElement, typeProperty);
500 }
501
502
503 typeProperty = "returnType";
504 if (type == null && introspector.isReadable(modelElement, typeProperty))
505 {
506 type = (ClassifierFacade)introspector.getProperty(modelElement, typeProperty);
507 }
508 return type;
509 }
510 catch (final Throwable throwable)
511 {
512 String errMsg = "Error performing WebServiceLogicImpl.getType";
513 logger.error(errMsg, throwable);
514 throw new MetafacadeException(errMsg, throwable);
515 }
516 }
517
518 static final String NAMESPACE_PREFIX = "namespacePrefix";
519
520 /***
521 * @see org.andromda.cartridges.webservice.metafacades.WSDLType#getNamespacePrefix()
522 */
523 protected String handleGetNamespacePrefix()
524 {
525 return (String)this.getConfiguredProperty(NAMESPACE_PREFIX);
526 }
527
528 static final String QNAME_LOCAL_PART_PATTERN = "qualifiedNameLocalPartPattern";
529
530 /***
531 * Gets the <code>qualifiedNameLocalPartPattern</code> for this service.
532 */
533 protected String getQualifiedNameLocalPartPattern()
534 {
535 return (String)this.getConfiguredProperty(QNAME_LOCAL_PART_PATTERN);
536 }
537
538 static final String NAMESPACE_PATTERN = "namespacePattern";
539
540 /***
541 * Gets the <code>namespacePattern</code> for this service.
542 *
543 * @return String the namespace pattern to use.
544 */
545 protected String getNamespacePattern()
546 {
547 return (String)this.getConfiguredProperty(NAMESPACE_PATTERN);
548 }
549
550 static final String REVERSE_NAMESPACE = "reverseNamespace";
551
552 /***
553 * Gets whether or not <code>reverseNamespace</code> is true/false for this type.
554 *
555 * @return boolean true/false
556 */
557 protected boolean isReverseNamespace()
558 {
559 return Boolean.valueOf(String.valueOf(this.getConfiguredProperty(REVERSE_NAMESPACE))).booleanValue();
560 }
561
562 /***
563 * @see org.andromda.cartridges.webservice.metafacades.WebService#getEjbJndiName()
564 */
565 protected java.lang.String handleGetEjbJndiName()
566 {
567 StringBuffer jndiName = new StringBuffer();
568 String jndiNamePrefix = StringUtils.trimToEmpty(this.getEjbJndiNamePrefix());
569 if (StringUtils.isNotEmpty(jndiNamePrefix))
570 {
571 jndiName.append(jndiNamePrefix);
572 jndiName.append("/");
573 }
574 jndiName.append("ejb/");
575 jndiName.append(this.getFullyQualifiedName());
576 return jndiName.toString();
577 }
578
579 /***
580 * Gets the <code>ejbJndiNamePrefix</code> for an EJB provider.
581 *
582 * @return the EJB Jndi name prefix.
583 */
584 protected String getEjbJndiNamePrefix()
585 {
586 final String property = "ejbJndiNamePrefix";
587 return this.isConfiguredProperty(property) ? ObjectUtils.toString(this.getConfiguredProperty(property)) : null;
588 }
589
590 /***
591 * @see org.andromda.cartridges.webservice.metafacades.WebService#getEjbHomeInterface()
592 */
593 protected java.lang.String handleGetEjbHomeInterface()
594 {
595 return MessageFormat.format(
596 this.getEjbHomeInterfacePattern(),
597 new Object[] {StringUtils.trimToEmpty(this.getPackageName()), StringUtils.trimToEmpty(this.getName())});
598 }
599
600 /***
601 * Gets the <code>ejbHomeInterfacePattern</code> for an EJB provider.
602 *
603 * @return the EJB Home interface pattern
604 */
605 protected String getEjbHomeInterfacePattern()
606 {
607 return (String)this.getConfiguredProperty("ejbHomeInterfacePattern");
608 }
609
610 /***
611 * @see org.andromda.cartridges.webservice.metafacades.WebService#getEjbInterface()
612 */
613 protected java.lang.String handleGetEjbInterface()
614 {
615 return MessageFormat.format(
616 this.getEjbInterfacePattern(),
617 new Object[] {StringUtils.trimToEmpty(this.getPackageName()), StringUtils.trimToEmpty(this.getName())});
618 }
619
620 /***
621 * Gets the <code>ejbInterfacePattern</code> for an EJB provider.
622 *
623 * @return the EJB interface pattern
624 */
625 protected String getEjbInterfacePattern()
626 {
627 return (String)this.getConfiguredProperty("ejbInterfacePattern");
628 }
629
630 private static final String RPC_CLASS_NAME_PATTERN = "rpcClassNamePattern";
631
632 /***
633 * Gets the <code>rpcClassNamePattern</code> for this service.
634 */
635 protected String getRpcClassNamePattern()
636 {
637 return (String)this.getConfiguredProperty(RPC_CLASS_NAME_PATTERN);
638 }
639
640 /***
641 * @see org.andromda.cartridges.webservice.metafacades.WebService#getRpcClassName()
642 */
643 protected String handleGetRpcClassName()
644 {
645 return MessageFormat.format(
646 this.getRpcClassNamePattern(),
647 new Object[] {StringUtils.trimToEmpty(this.getPackageName()), StringUtils.trimToEmpty(this.getName())});
648 }
649
650 private static final String WSDL_OPERATION_SORT_MODE = "wsdlOperationSortMode";
651
652 /***
653 * Used to sort operations by <code>name</code>.
654 */
655 private final static class OperationNameComparator
656 implements Comparator
657 {
658 private final Collator collator = Collator.getInstance();
659
660 private OperationNameComparator()
661 {
662 collator.setStrength(Collator.PRIMARY);
663 }
664
665 public int compare(
666 Object objectA,
667 Object objectB)
668 {
669 ModelElementFacade a = (ModelElementFacade)objectA;
670 ModelElementFacade b = (ModelElementFacade)objectB;
671
672 return collator.compare(
673 a.getName(),
674 b.getName());
675 }
676 }
677
678 /***
679 * The model specifying operations should be sorted by name.
680 */
681 private static final String OPERATION_SORT_MODE_NAME = "name";
682
683 /***
684 * The model specifying operations should NOT be sorted.
685 */
686 private static final String OPERATION_SORT_MODE_NONE = "none";
687
688 /***
689 * Gets the sort mode WSDL operations.
690 *
691 * @return String
692 */
693 private String getWSDLOperationSortMode()
694 {
695 Object property = this.getConfiguredProperty(WSDL_OPERATION_SORT_MODE);
696 return property != null || property.equals(OPERATION_SORT_MODE_NAME) ? (String)property : OPERATION_SORT_MODE_NONE;
697 }
698
699 /***
700 * @see org.andromda.cartridges.webservice.metafacades.WebService#isSecured()
701 */
702 protected boolean handleIsSecured()
703 {
704 Collection roles = this.getAllRoles();
705 return roles != null && !roles.isEmpty();
706 }
707
708 /***
709 * Overridden to only allow the exposed operations in the returned roles collection.
710 *
711 * @see org.andromda.metafacades.uml.Service#getAllRoles()
712 */
713 public Collection getAllRoles()
714 {
715 final Collection roles = new LinkedHashSet(this.getRoles());
716 CollectionUtils.forAllDo(
717 this.getAllowedOperations(),
718 new Closure()
719 {
720 public void execute(Object object)
721 {
722 if (object != null && ServiceOperation.class.isAssignableFrom(object.getClass()))
723 {
724 roles.addAll(((ServiceOperation)object).getRoles());
725 }
726 }
727 });
728 return roles;
729 }
730
731 /***
732 * The pattern used to construct the test package name.
733 */
734 private static final String TEST_PACKAGE_NAME_PATTERN = "testPackageNamePattern";
735
736 /***
737 * @see org.andromda.cartridges.webservice.metafacades.WebService#getTestPackageName()
738 */
739 protected String handleGetTestPackageName()
740 {
741 return String.valueOf(this.getConfiguredProperty(TEST_PACKAGE_NAME_PATTERN)).replaceAll(
742 "//{0//}",
743 this.getPackageName());
744 }
745
746 /***
747 * @see org.andromda.cartridges.webservice.metafacades.WebService#getFullyQualifiedTestName()
748 */
749 protected String handleGetFullyQualifiedTestName()
750 {
751 return this.getTestPackageName() + '.' + this.getTestName();
752 }
753
754 /***
755 * The pattern used to construct the test name.
756 */
757 private static final String TEST_NAME_PATTERN = "testNamePattern";
758
759 /***
760 * @see org.andromda.cartridges.webservice.metafacades.WebService#getTestName()
761 */
762 protected String handleGetTestName()
763 {
764 return String.valueOf(this.getConfiguredProperty(TEST_NAME_PATTERN)).replaceAll(
765 "//{0//}",
766 this.getName());
767 }
768
769 /***
770 * Represents a "wrapped" style.
771 */
772 private static final String STYLE_WRAPPED = "wrapped";
773
774 /***
775 * @see org.andromda.cartridges.webservice.metafacades.WebService#isWrappedStyle()
776 */
777 protected boolean handleIsWrappedStyle()
778 {
779 return this.getStyle().equalsIgnoreCase(STYLE_WRAPPED);
780 }
781
782 /***
783 * Represents a "document" style.
784 */
785 private static final String STYLE_DOCUMENT = "document";
786
787 /***
788 * @see org.andromda.cartridges.webservice.metafacades.WebService#isDocumentStyle()
789 */
790 protected boolean handleIsDocumentStyle()
791 {
792 return this.getStyle().equalsIgnoreCase(STYLE_DOCUMENT);
793 }
794
795 /***
796 * Represents a "rpc" style.
797 */
798 private static final String STYLE_RPC = "rpc";
799
800 /***
801 * @see org.andromda.cartridges.webservice.metafacades.WebService#isRpcStyle()
802 */
803 protected boolean handleIsRpcStyle()
804 {
805 return this.getStyle().equalsIgnoreCase(STYLE_RPC);
806 }
807
808 /***
809 * Represents an "literal" use.
810 */
811 private static final String USE_LITERAL = "literal";
812
813 /***
814 * @see org.andromda.cartridges.webservice.metafacades.WebService#isLiteralUse()
815 */
816 protected boolean handleIsLiteralUse()
817 {
818 return this.getStyle().equalsIgnoreCase(USE_LITERAL);
819 }
820
821 /***
822 * Represents an "encoded" use.
823 */
824 private static final String USE_ENCODED = "encoded";
825
826 /***
827 * @see org.andromda.cartridges.webservice.metafacades.WebService#isEncodedUse()
828 */
829 protected boolean handleIsEncodedUse()
830 {
831 return this.getStyle().equalsIgnoreCase(USE_ENCODED);
832 }
833
834 /***
835 * The pattern used to construct the test implementation name.
836 */
837 private static final String TEST_IMPLEMENTATION_NAME_PATTERN = "testImplementationNamePattern";
838
839 /***
840 * @see org.andromda.cartridges.webservice.metafacades.WebService#getTestImplementationName()
841 */
842 protected String handleGetTestImplementationName()
843 {
844 return String.valueOf(this.getConfiguredProperty(TEST_IMPLEMENTATION_NAME_PATTERN)).replaceAll(
845 "//{0//}",
846 this.getName());
847 }
848
849 /***
850 * @see org.andromda.cartridges.webservice.metafacades.WebService#getFullyQualifiedTestImplementationName()
851 */
852 protected String handleGetFullyQualifiedTestImplementationName()
853 {
854 return this.getTestPackageName() + '.' + this.getTestImplementationName();
855 }
856 }