org.jboss.wsf.spi.tools
Class WSContractProvider

java.lang.Object
  extended by org.jboss.wsf.spi.tools.WSContractProvider

public abstract class WSContractProvider
extends java.lang.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

Field Summary
static java.lang.String PROVIDER_PROPERTY
           
 
Constructor Summary
protected WSContractProvider()
           
 
Method Summary
static WSContractProvider newInstance()
          Obtain a new instance of a WSContractProvider.
static WSContractProvider newInstance(java.lang.ClassLoader loader)
          Obtain a new instance of a WSContractProvider.
abstract  void provide(java.lang.Class<?> endpointClass)
          Generates artifacts using the current settings.
abstract  void provide(java.lang.String endpointClass)
          Generates artifacts using the current settings.
abstract  void setClassLoader(java.lang.ClassLoader loader)
          Sets the ClassLoader used to discover types.
abstract  void setGenerateSource(boolean generateSource)
          Enables/Disables Java source generation.
abstract  void setGenerateWsdl(boolean generateWsdl)
          Enables/Disables WSDL generation.
abstract  void setMessageStream(java.io.PrintStream messageStream)
          Sets the PrintStream to use for status feedback.
abstract  void setOutputDirectory(java.io.File directory)
          Sets the main output directory.
abstract  void setResourceDirectory(java.io.File directory)
          Sets the resource directory.
abstract  void setSourceDirectory(java.io.File directory)
          Sets the source directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROVIDER_PROPERTY

public static final java.lang.String PROVIDER_PROPERTY
See Also:
Constant Field Values
Constructor Detail

WSContractProvider

protected WSContractProvider()
Method Detail

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(java.lang.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

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(java.io.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(java.io.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(java.io.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

setClassLoader

public abstract void setClassLoader(java.lang.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(java.lang.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:
java.lang.RuntimeException - if any error occurs during processing, or the class is not found

provide

public abstract void provide(java.lang.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:
java.lang.RuntimeException - if any error occurs during processing

setMessageStream

public abstract void setMessageStream(java.io.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:


Copyright © 2010 JBoss, a division of Red Hat. All Rights Reserved.