Exemplo n.º 1
0
  /**
   * Performs the publication action by setting up a {@link Server} instance based on this
   * endpoint's configuration.
   *
   * @param addr the optional endpoint address.
   * @throws IllegalStateException if the endpoint cannot be published/republished
   * @throws SecurityException if permission checking is enabled and policy forbids publishing
   * @throws WebServiceException if there is an error publishing the endpoint
   * @see #checkPublishPermission()
   * @see #checkPublishable()
   * @see #getServer(String)
   */
  protected void doPublish(String addr) {
    checkPublishPermission();
    checkPublishable();

    ServerImpl serv = null;

    ClassLoaderHolder loader = null;
    try {
      if (bus != null) {
        ClassLoader newLoader = bus.getExtension(ClassLoader.class);
        if (newLoader != null) {
          loader = ClassLoaderUtils.setThreadContextClassloader(newLoader);
        }
      }
      serv = getServer(addr);
      if (addr != null) {
        EndpointInfo endpointInfo = serv.getEndpoint().getEndpointInfo();
        if (!endpointInfo.getAddress().contains(addr)) {
          endpointInfo.setAddress(addr);
        }
        if (publishedEndpointUrl != null) {
          endpointInfo.setProperty(WSDLGetUtils.PUBLISHED_ENDPOINT_URL, publishedEndpointUrl);
        }
        if (publishedEndpointUrl != null && wsdlLocation != null) {
          // early update the publishedEndpointUrl so that endpoints in the same app sharing the
          // same wsdl
          // do not require all of them to be queried for wsdl before the wsdl is finally fully
          // updated
          Definition def =
              endpointInfo
                  .getService()
                  .getProperty(WSDLServiceBuilder.WSDL_DEFINITION, Definition.class);
          if (def == null) {
            def = bus.getExtension(WSDLManager.class).getDefinition(wsdlLocation);
          }
          new WSDLGetUtils().updateWSDLPublishedEndpointAddress(def, endpointInfo);
        }

        if (null != properties) {
          for (Entry<String, Object> entry : properties.entrySet()) {
            endpointInfo.setProperty(entry.getKey(), entry.getValue());
          }
        }

        this.address = endpointInfo.getAddress();
      }
      serv.start();
      publishable = false;
    } catch (Exception ex) {
      try {
        stop();
      } catch (Exception e) {
        // Nothing we can do.
      }

      throw new WebServiceException(ex);
    } finally {
      if (loader != null) {
        loader.reset();
      }
    }
  }
Exemplo n.º 2
0
 public void setMetadata(List<Source> metadata) {
   checkPublishable();
   this.metadata = metadata;
 }