// Inherited.
  @Override
  public void initModel(EnunciateFreemarkerModel model) {
    super.initModel(model);

    if (!isDisabled()) {
      EnunciateConfiguration config = model.getEnunciateConfig();
      for (WsdlInfo wsdlInfo : model.getNamespacesToWSDLs().values()) {
        for (EndpointInterface ei : wsdlInfo.getEndpointInterfaces()) {
          String path = "/soap/" + ei.getServiceName();
          if (config != null) {
            path = config.getDefaultSoapSubcontext() + '/' + ei.getServiceName();
            if (config.getSoapServices2Paths().containsKey(ei.getServiceName())) {
              path = config.getSoapServices2Paths().get(ei.getServiceName());
            }
          }

          ei.putMetaData("soapPath", path);
        }
      }

      if (!exporterFound) {
        warn(
            "The Enunciate XFire runtime wasn't found on the Enunciate classpath. This could be fatal to the runtime application.");
      }
    }
  }
 public void visitClassType(ClassType classType) {
   MapType mapType = MapTypeUtil.findMapType(classType);
   if (mapType != null) {
     setMapXmlType(mapType);
   } else {
     XmlType xmlType = null;
     EnunciateFreemarkerModel model = (EnunciateFreemarkerModel) FreemarkerModel.get();
     ClassDeclaration declaration = classType.getDeclaration();
     if (declaration != null) {
       XmlType knownType = model.getKnownType(declaration);
       if (knownType != null) {
         xmlType = knownType;
       } else {
         // type not known, not specified.  Last chance: look for the type definition.
         TypeDefinition typeDefinition = model.findTypeDefinition(declaration);
         if (typeDefinition != null) {
           xmlType = new XmlClassType(typeDefinition);
         }
       }
     }
     this.xmlType = xmlType;
     if (xmlType == null) {
       this.errorMessage =
           "Unknown xml type for class: "
               + classType
               + ".  If this is a class that is already compiled, you either need to specify an 'api-import' "
               + "element in the configuration file, or your class needs to be explicitly exported. See the FAQ "
               + "( http://tinyurl.com/cte3oq ) for details.";
     }
   }
 }
  @Override
  public void doFreemarkerGenerate() throws IOException, TemplateException {
    if (!isUpToDate()) {
      EnunciateFreemarkerModel model = getModel();
      // generate the rpc request/response beans.
      for (WsdlInfo wsdlInfo : model.getNamespacesToWSDLs().values()) {
        for (EndpointInterface ei : wsdlInfo.getEndpointInterfaces()) {
          for (WebMethod webMethod : ei.getWebMethods()) {
            for (WebMessage webMessage : webMethod.getMessages()) {
              if (webMessage instanceof RPCInputMessage) {
                model.put("message", webMessage);
                processTemplate(getRPCRequestBeanTemplateURL(), model);
              } else if (webMessage instanceof RPCOutputMessage) {
                model.put("message", webMessage);
                processTemplate(getRPCResponseBeanTemplateURL(), model);
              }
            }
          }
        }
      }

      model.put("xfireBeansImport", getXfireBeansImport());
      model.put("docsDir", enunciate.getProperty("docs.webapp.dir"));
      processTemplate(getXfireServletTemplateURL(), model);
      processTemplate(getParameterNamesTemplateURL(), model);
    } else {
      info("Skipping generation of XFire support classes as everything appears up-to-date....");
    }

    getEnunciate()
        .addArtifact(new FileArtifact(getName(), "xfire-server.src.dir", getGenerateDir()));
    getEnunciate().addAdditionalSourceRoot(getGenerateDir());
  }
 @Override
 public ValidationResult validate(EnunciateFreemarkerModel model) {
   ValidationResult result = super.validate(model);
   for (SchemaInfo schemaInfo : model.getNamespacesToSchemas().values()) {
     for (Registry registry : schemaInfo.getRegistries()) {
       Collection<LocalElementDeclaration> localElements = registry.getLocalElementDeclarations();
       for (LocalElementDeclaration localElement : localElements) {
         JsonElementWrapper elementWrapper = localElement.getAnnotation(JsonElementWrapper.class);
         if (elementWrapper != null) {
           String jsonName = elementWrapper.namespace() + elementWrapper.name();
           Declaration previous = this.jsonNameDeclarations.put(jsonName, localElement);
           if (previous != null) {
             result.addError(
                 localElement,
                 "JSON name conflict with " + String.valueOf(previous.getPosition()));
           }
         }
       }
     }
   }
   return result;
 }