Class WSContractProvider

java.lang.Object
org.jboss.ws.api.tools.WSContractProvider
Direct Known Subclasses:
CXFProviderImpl

public abstract class WSContractProvider extends Object
WSContractProvider is responsible for generating the required portable JAX-WS artifacts for a service endpoint implementation. This includes class files for wrapper types and fault beans. WSDL may be optionally generated as well using this API.

The following example generates class files, source files and WSDL for an endpoint:

 WSContractProvider provider = WSContractProvider.newInstance();
 provider.setGenerateSource(true);
 provider.setGenerateWsdl(true);
 provider.setOutputDirectory(new File("output"));
 provider.setMessageStream(System.out);
 provider.provide(TestMe.class);
 

Thread-Safety:

This class expects to be thread-confined, so it can not be shared between threads.
Author:
Jason T. Greene, Richard Opalka
  • Field Details

  • Constructor Details

    • WSContractProvider

      protected WSContractProvider()
  • Method Details

    • newInstance

      public static WSContractProvider newInstance()
      Obtain a new instance of a WSContractProvider. This will use the current thread's context class loader to locate the WSContractProviderFactory implementation.
      Returns:
      a new WSContractProvider
    • newInstance

      public static WSContractProvider newInstance(ClassLoader loader)
      Obtain a new instance of a WSContractProvider. The specified ClassLoader will be used to locate the WSContractProviderFactory implementation
      Parameters:
      loader - the ClassLoader to use
      Returns:
      a new WSContractProvider
    • setGenerateWsdl

      public abstract void setGenerateWsdl(boolean generateWsdl)
      Enables/Disables WSDL generation.
      Parameters:
      generateWsdl - whether or not to generate WSDL
    • setExtension

      public abstract void setExtension(boolean extension)
      Enables/Disables SOAP 1.2 binding extension
      Parameters:
      extension - whether or not to enable SOAP 1.2 binding extension
    • setGenerateSource

      public abstract void setGenerateSource(boolean generateSource)
      Enables/Disables Java source generation.
      Parameters:
      generateSource - whether or not to generate Java source.
    • setOutputDirectory

      public abstract void setOutputDirectory(File directory)
      Sets the main output directory. If the directory does not exist, it will be created.
      Parameters:
      directory - the root directory for generated files
    • setResourceDirectory

      public abstract void setResourceDirectory(File directory)
      Sets the resource directory. This directory will contain any generated WSDL and XSD files. If the directory does not exist, it will be created. If not specified, the output directory will be used instead.
      Parameters:
      directory - the root directory for generated resource files
    • setSourceDirectory

      public abstract void setSourceDirectory(File directory)
      Sets the source directory. This directory will contain any generated Java source. If the directory does not exist, it will be created. If not specified, the output directory will be used instead.
      Parameters:
      directory - the root directory for generated source code
    • setPortSoapAddress

      public abstract void setPortSoapAddress(String address)
      Sets the soap:address to be used for the generated port in the wsdl. This is ignored if WSDL generation is disabled.
      Parameters:
      address - soap address
    • setClassLoader

      public abstract void setClassLoader(ClassLoader loader)
      Sets the ClassLoader used to discover types. This defaults to the one used in instantiation.
      Parameters:
      loader - the ClassLoader to use
    • provide

      public abstract void provide(String endpointClass)
      Generates artifacts using the current settings. This method may be invoked more than once (e.g. multiple endpoints).
      Parameters:
      endpointClass - the name of the endpoint implementation bean
      Throws:
      RuntimeException - if any error occurs during processing, or the class is not found
    • provide

      public abstract void provide(Class<?> endpointClass)
      Generates artifacts using the current settings. This method may be invoked more than once (e.g. multiple endpoints).
      Parameters:
      endpointClass - the endpoint implementation bean
      Throws:
      RuntimeException - if any error occurs during processing
    • setMessageStream

      public abstract void setMessageStream(PrintStream messageStream)
      Sets the PrintStream to use for status feedback. The simplest example would be to use System.out.

      Example output:

       Generating WSDL: 
       TestMeService.wsdl 
       Writing Source:
       org/jboss/ws/tools/jaxws/TestMe.java
       org/jboss/ws/tools/jaxws/TestMeResponse.java 
       Writing Classes:
       org/jboss/ws/tools/jaxws/TestMe.class
       org/jboss/ws/tools/jaxws/TestMeResponse.class
       
      Parameters:
      messageStream - the stream to use for status messages: