Package org.codehaus.enunciate.config

Examples of org.codehaus.enunciate.config.WsdlInfo


  private boolean considerFacets = false;
  private String var = "endpointInterface";

  //Inherited.
  protected Iterator<EndpointInterface> getLoop(TemplateModel model) throws TemplateException {
    WsdlInfo wsdl = this.wsdl;
    if (wsdl == null) {
      throw new MissingParameterException("wsdl");
    }

    Collection<EndpointInterface> eis = new ArrayList<EndpointInterface>(wsdl.getEndpointInterfaces());
    if (considerFacets) {
      Iterator<EndpointInterface> vit = eis.iterator();
      while (vit.hasNext()) {
        EndpointInterface next = vit.next();
        if (!FacetFilter.accept(next)) {
View Full Code Here


  public void add(EndpointInterface ei) {
    String namespace = ei.getTargetNamespace();

    String prefix = addNamespace(namespace);

    WsdlInfo wsdlInfo = namespacesToWsdls.get(namespace);
    if (wsdlInfo == null) {
      wsdlInfo = new WsdlInfo();
      wsdlInfo.setId(prefix);
      namespacesToWsdls.put(namespace, wsdlInfo);
      wsdlInfo.setTargetNamespace(namespace);
    }

    for (WebMethod webMethod : ei.getWebMethods()) {
      for (WebMessage webMessage : webMethod.getMessages()) {
        for (WebMessagePart messagePart : webMessage.getParts()) {
          if (messagePart.isImplicitSchemaElement()) {
            ImplicitSchemaElement implicitElement = (ImplicitSchemaElement) messagePart;
            String particleNamespace = messagePart.getParticleQName().getNamespaceURI();
            SchemaInfo schemaInfo = namespacesToSchemas.get(particleNamespace);
            if (schemaInfo == null) {
              schemaInfo = new SchemaInfo();
              schemaInfo.setId(addNamespace(particleNamespace));
              schemaInfo.setNamespace(particleNamespace);
              namespacesToSchemas.put(particleNamespace, schemaInfo);
            }
            schemaInfo.getImplicitSchemaElements().add(implicitElement);
          }
        }
      }
    }

    wsdlInfo.getEndpointInterfaces().add(ei);
    this.endpointInterfaces.add(ei);

    if (includeReferencedClasses()) {
      REFERENCE_STACK.get().addFirst("endpoint interface " + ei.getQualifiedName());
      addReferencedTypeDefinitions(ei);
View Full Code Here

  private WsdlInfo wsdl;

  // Inherited.
  protected Iterator<WebMessage> getLoop(TemplateModel model) throws TemplateException {
    WebMethod webMethod = this.webMethod;
    WsdlInfo wsdlInfo = this.wsdl;
    if ((webMethod == null) && (wsdlInfo == null)) {
      throw new MissingParameterException("Either a webMethod or a wsdl must be specified to iterate over web messages.", "webMethod");
    }

    Collection<WebMessage> messages;
    if (webMethod != null) {
      messages = webMethod.getMessages();
    }
    else {
      messages = new ArrayList<WebMessage>();
      HashSet<String> foundFaults = new HashSet<String>();
      for (EndpointInterface ei : wsdlInfo.getEndpointInterfaces()) {
        if (!considerFacets || FacetFilter.accept(ei)) {
          Collection<WebMethod> webMethods = ei.getWebMethods();
          for (WebMethod method : webMethods) {
            for (WebMessage webMessage : method.getMessages()) {
              if (webMessage.isFault() && !foundFaults.add(((WebFault) webMessage).getQualifiedName())) {
View Full Code Here

      for (JsonTypeDefinition jsonTypeDefinition : schema.getTypes()) {
        gatherFacets(jsonTypeDefinition, facets);
      }
    }
    else if (WsdlInfo.class.isInstance(unwrapped)) {
      WsdlInfo wsdl = (WsdlInfo) unwrapped;
      for (EndpointInterface ei : wsdl.getEndpointInterfaces()) {
        gatherFacets(ei, facets);
      }
    }
    else if ("rest".equals(unwrapped)) {
      for (RootResource rootResource : getModel().getRootResources()) {
View Full Code Here

          }
        }
      }

      for (WsdlConfig customConfig : this.wsdlConfigs) {
        WsdlInfo wsdlInfo = ns2wsdl.get(customConfig.getNamespace());

        if (wsdlInfo != null) {
          if (customConfig.getUseFile() != null) {
            File useFile = getEnunciate().resolvePath(customConfig.getUseFile());
            if (!useFile.exists()) {
              throw new IllegalStateException("File " + useFile + " does not exist.");
            }
            wsdlInfo.setProperty("filename", useFile.getName());
            wsdlInfo.setProperty("file", useFile);
          }

          if (customConfig.getFile() != null) {
            wsdlInfo.setProperty("filename", customConfig.getFile());
          }

          wsdlInfo.setProperty("inlineSchema", customConfig.isInlineSchema());
        }
      }

      EnunciateConfiguration config = model.getEnunciateConfig();
      for (WsdlInfo wsdlInfo : model.getNamespacesToWSDLs().values()) {
        for (EndpointInterface ei : wsdlInfo.getEndpointInterfaces()) {
          if (!ei.getMetaData().containsKey("soapPath")) {
            //if we don't have the soap path set by some other jax-ws implementation provider module
            //then we need to set it ourselves.

            String path = "/soap/" + ei.getServiceName();
View Full Code Here

    int originalNSSize = model.getNamespacesToPrefixes().size();
    EndpointInterface ei1 = new EndpointInterface(getDeclaration("org.codehaus.enunciate.samples.services.NamespacedWebService"));
    String targetNamespace = ei1.getTargetNamespace();
    model.add(ei1);
    assertNotNull(model.getNamespacesToPrefixes().get(targetNamespace));
    WsdlInfo wsdlInfo = model.getNamespacesToWSDLs().get(targetNamespace);
    assertNotNull("The model should have created a wsdl information associated with a new endpoint interface.", wsdlInfo);
    assertTrue(model.endpointInterfaces.contains(ei1));
    assertTrue(wsdlInfo.getEndpointInterfaces().contains(ei1));
    assertEquals(targetNamespace, wsdlInfo.getTargetNamespace());

    EndpointInterface ei2 = new EndpointInterface(getDeclaration("org.codehaus.enunciate.samples.services.NoNamespaceWebServiceImpl"));
    targetNamespace = ei2.getTargetNamespace();
    model.add(ei2);
    assertNotNull(model.getNamespacesToPrefixes().get(targetNamespace));
    wsdlInfo = model.getNamespacesToWSDLs().get(targetNamespace);
    assertNotNull("The model should have created a wsdl information associated with a new endpoint interface.", wsdlInfo);
    assertTrue(model.endpointInterfaces.contains(ei2));
    assertTrue(wsdlInfo.getEndpointInterfaces().contains(ei2));
    assertEquals(targetNamespace, wsdlInfo.getTargetNamespace());

    EndpointInterface ei3 = new EndpointInterface(getDeclaration("org.codehaus.enunciate.samples.services.SuperNoNamespaceWebServiceImpl"));
    targetNamespace = ei3.getTargetNamespace();
    model.add(ei3);
    assertNotNull(model.getNamespacesToPrefixes().get(targetNamespace));
    wsdlInfo = model.getNamespacesToWSDLs().get(targetNamespace);
    assertNotNull("The model should have created a wsdl information associated with a new endpoint interface.", wsdlInfo);
    assertTrue(model.endpointInterfaces.contains(ei3));
    assertTrue(wsdlInfo.getEndpointInterfaces().contains(ei3));
    assertEquals(targetNamespace, wsdlInfo.getTargetNamespace());

    assertEquals(3, model.endpointInterfaces.size());
    assertEquals(originalNSSize + 2, model.getNamespacesToPrefixes().size());
    assertEquals("There should be two endpoint interfaces in the WSDL.", 2, wsdlInfo.getEndpointInterfaces().size());
  }
View Full Code Here

    customSchemaInfo.setNamespace("urn:custom");
    final Map<String, SchemaInfo> ns2schema = new HashMap<String, SchemaInfo>();
    ns2schema.put(defaultSchemaInfo.getNamespace(), defaultSchemaInfo);
    ns2schema.put(customSchemaInfo.getNamespace(), customSchemaInfo);

    WsdlInfo defaultWsdlInfo = new WsdlInfo();
    defaultWsdlInfo.setTargetNamespace("urn:default");
    WsdlInfo customWsdlInfo = new WsdlInfo();
    customWsdlInfo.setTargetNamespace("urn:custom");
    final Map<String, WsdlInfo> ns2wsdl = new HashMap<String, WsdlInfo>();
    ns2wsdl.put(defaultWsdlInfo.getTargetNamespace(), defaultWsdlInfo);
    ns2wsdl.put(customWsdlInfo.getTargetNamespace(), customWsdlInfo);

    final Map<String, String> ns2prefix = new HashMap<String, String>();
    ns2prefix.put("urn:default", "default1");
    ns2prefix.put("urn:custom", "default2");

    final EnunciateFreemarkerModel model = new EnunciateFreemarkerModel() {
      @Override
      public Map<String, String> getNamespacesToPrefixes() {
        return ns2prefix;
      }

      @Override
      public Map<String, SchemaInfo> getNamespacesToSchemas() {
        return ns2schema;
      }

      @Override
      public Map<String, WsdlInfo> getNamespacesToWSDLs() {
        return ns2wsdl;
      }
    };

    final ArrayList<URL> processList = new ArrayList<URL>(Arrays.asList(XMLDeploymentModule.class.getResource("xml.fmt")));
    XMLDeploymentModule module = new XMLDeploymentModule() {
      @Override
      public EnunciateFreemarkerModel getModel() {
        return model;
      }

      @Override
      protected boolean isUpToDate(File artifactDir) {
        return false;
      }

      @Override
      public void processTemplate(URL templateURL, Object model) {
        processList.remove(templateURL);
      }
    };
    SchemaConfig customSchemaConfig = new SchemaConfig();
    customSchemaConfig.setFile("custom.xsd");
    customSchemaConfig.setLocation("urn:custom.xsd");
    customSchemaConfig.setNamespace("urn:custom");
    module.addSchemaConfig(customSchemaConfig);

    WsdlConfig wsdlConfig = new WsdlConfig();
    wsdlConfig.setNamespace("urn:custom");
    wsdlConfig.setFile("custom.wsdl");
    module.addWsdlConfig(wsdlConfig);

    Enunciate enunciate = new Enunciate(new String[0]);
    File generateDir = enunciate.createTempDir();
    enunciate.setGenerateDir(generateDir);
    module.init(enunciate);
    module.initModel(model);
    module.doFreemarkerGenerate();

    assertTrue("Not all templates were processed.  Unprocessed templates: " + processList.toString(), processList.isEmpty());
    assertEquals("default1.xsd", defaultSchemaInfo.getProperty("filename"));
    assertEquals("default1.xsd", defaultSchemaInfo.getProperty("location"));
    assertEquals("custom.xsd", customSchemaInfo.getProperty("filename"));
    assertEquals("urn:custom.xsd", customSchemaInfo.getProperty("location"));
    assertEquals("default1.wsdl", defaultWsdlInfo.getProperty("filename"));
    assertEquals("custom.wsdl", customWsdlInfo.getProperty("filename"));
    File artifactDir = new File(generateDir, "xml");
    assertEquals(new File(artifactDir, "default1.xsd"), defaultSchemaInfo.getProperty("file"));
    assertEquals(new File(artifactDir, "default1.wsdl"), defaultWsdlInfo.getProperty("file"));
    assertEquals(new File(artifactDir, "custom.xsd"), customSchemaInfo.getProperty("file"));
    assertEquals(new File(artifactDir, "custom.wsdl"), customWsdlInfo.getProperty("file"));

  }
View Full Code Here

TOP

Related Classes of org.codehaus.enunciate.config.WsdlInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.