コード例 #1
0
ファイル: JaxwsModule.java プロジェクト: stoicflame/enunciate
 protected void addReferencedDataTypeDefinitions(EndpointInterface ei) {
   LinkedList<Element> contextStack = new LinkedList<Element>();
   contextStack.push(ei);
   try {
     for (WebMethod webMethod : ei.getWebMethods()) {
       addReferencedTypeDefinitions(webMethod, contextStack);
     }
   } finally {
     contextStack.pop();
   }
 }
コード例 #2
0
ファイル: JaxwsModule.java プロジェクト: stoicflame/enunciate
  @Override
  public void call(EnunciateContext context) {
    jaxwsContext =
        new EnunciateJaxwsContext(this.jaxbModule.getJaxbContext(), isUseSourceParameterNames());
    boolean aggressiveWebMethodExcludePolicy = isAggressiveWebMethodExcludePolicy();

    Map<String, String> eiPaths = new HashMap<String, String>();
    File sunJaxwsXmlFile = getSunJaxwsXmlFile();
    if (sunJaxwsXmlFile != null) {
      XMLConfiguration config;
      try {
        config = new XMLConfiguration(sunJaxwsXmlFile);
      } catch (ConfigurationException e) {
        throw new EnunciateException(e);
      }

      List<HierarchicalConfiguration> endpoints = config.configurationsAt("endpoint");
      for (HierarchicalConfiguration endpoint : endpoints) {
        String impl = endpoint.getString("[@implementation]", null);
        String urlPattern = endpoint.getString("[@url-pattern]", null);
        if (impl != null && urlPattern != null) {
          eiPaths.put(impl, urlPattern);
        }
      }
    }

    DataTypeDetectionStrategy detectionStrategy = getDataTypeDetectionStrategy();
    if (detectionStrategy != DataTypeDetectionStrategy.passive) {
      Set<? extends Element> elements =
          detectionStrategy == DataTypeDetectionStrategy.local
              ? context.getLocalApiElements()
              : context.getApiElements();
      for (Element declaration : elements) {
        if (declaration instanceof TypeElement) {
          TypeElement element = (TypeElement) declaration;

          XmlRegistry registryMetadata = declaration.getAnnotation(XmlRegistry.class);
          if (registryMetadata != null) {
            this.jaxbModule.addPotentialJaxbElement(element, new LinkedList<Element>());
          }

          if (isEndpointInterface(element)) {
            EndpointInterface ei =
                new EndpointInterface(
                    element, elements, aggressiveWebMethodExcludePolicy, jaxwsContext);
            for (EndpointImplementation implementation : ei.getEndpointImplementations()) {
              String urlPattern = eiPaths.get(implementation.getQualifiedName().toString());
              if (urlPattern != null) {
                if (!urlPattern.startsWith("/")) {
                  urlPattern = "/" + urlPattern;
                }

                if (urlPattern.endsWith("/*")) {
                  urlPattern =
                      urlPattern.substring(0, urlPattern.length() - 2) + ei.getServiceName();
                }

                implementation.setPath(urlPattern);
              }
            }
            jaxwsContext.add(ei);
            addReferencedDataTypeDefinitions(ei);
          }
        }
      }
    }

    if (jaxwsContext.getEndpointInterfaces().size() > 0) {
      this.apiRegistry.getServiceApis().add(jaxwsContext);
      if (!this.apiRegistry.getSyntaxes().contains(jaxwsContext.getJaxbContext())) {
        this.apiRegistry.getSyntaxes().add(jaxwsContext.getJaxbContext());
      }
    }
  }