org.codehaus.enunciate.modules.csharp
Class CSharpDeploymentModule

java.lang.Object
  extended by org.codehaus.enunciate.modules.BasicDeploymentModule
      extended by org.codehaus.enunciate.modules.FreemarkerDeploymentModule
          extended by org.codehaus.enunciate.modules.csharp.CSharpDeploymentModule
All Implemented Interfaces:
EnunciateModelAware, DeploymentModule

public class CSharpDeploymentModule
extends FreemarkerDeploymentModule

C# Module

The C# module generates C# client code for accessing the SOAP endpoints and makes an attempt at compiling the code in a .NET assembly. If the the compile attempt is to be successful, then you must have a C# compiler available on your system path, or specify a "compileExecutable" attribute in the Enunciate configuration file. If the compile attempt fails, only the C# source code will be made available as a client artifact.

The order of the C# deployment module is 0, as it doesn't depend on any artifacts exported by any other module.

Configuration

The C# module is configured with the "csharp" element under the "modules" element of the enunciate configuration file. It supports the following attributes:

The "package-conversions" element

The "package-conversions" subelement of the "csharp" element is used to map packages from the original API packages to C# namespaces. This element supports an arbitrary number of "convert" child elements that are used to specify the conversions. These "convert" elements support the following attributes:

Author:
Ryan Heaton

Field Summary
 
Fields inherited from class org.codehaus.enunciate.modules.BasicDeploymentModule
enunciate
 
Constructor Summary
CSharpDeploymentModule()
           
 
Method Summary
 void addClientPackageConversion(PackageNamespaceConversion conversion)
          Add a client package conversion.
protected  void doBuild()
          Default implementation is a no-op.
protected  void doCompile()
          Default implementation is a no-op.
 void doFreemarkerGenerate()
          Generate using Freemarker.
protected  java.lang.String getBundleFileName()
          The name of the bundle file.
 java.lang.String getCompileCommand()
          The C# compile command.
 java.lang.String getCompileExecutable()
          The path to the compile executable.
 org.apache.commons.digester.RuleSet getConfigurationRules()
          Default implementation returns null.
protected  java.lang.String getDLLFileName()
          The name of the generated C# dll.
protected  java.lang.String getDocXmlFileName()
          The name of the generated C# xml documentation.
 java.lang.String getLabel()
          The label for the C# API.
 java.lang.String getName()
          The name of the deployment module.
protected  freemarker.template.ObjectWrapper getObjectWrapper()
          The object wrapper to use for the model.
 java.util.Map<java.lang.String,java.lang.String> getPackageToNamespaceConversions()
          The package-to-namespace conversions.
protected  java.lang.String getSourceFileName()
          The name of the generated C# source file.
protected  java.net.URL getTemplateURL(java.lang.String template)
          Get a template URL for the template of the given name.
 Validator getValidator()
          Get the validator for this module, or null if none.
 void init(Enunciate enunciate)
          Sets the enunciate mechanism.
 void initModel(EnunciateFreemarkerModel model)
          Initialize the model.
 boolean isDisableCompile()
          Whether to disable the compile step.
 boolean isDisabled()
          Whether this deployment module has been disabled, e.g.
 boolean isRequire()
          Whether to require the C# client code.
 boolean isSingleFilePerClass()
          Whether there should be a single file per class.
protected  boolean isUpToDate(java.io.File genDir)
          Whether the generate dir is up-to-date.
protected  java.lang.String packageToNamespace(java.lang.String pckg)
           
protected  java.lang.String readResource(java.lang.String resource, java.lang.String contains)
          Reads a resource into string form.
 void setBundleFileName(java.lang.String bundleFileName)
          The name of the bundle file.
 void setCompileCommand(java.lang.String compileCommand)
          The C# compile command.
 void setCompileExecutable(java.lang.String compileExecutable)
          The path to the compile executable.
 void setDisableCompile(boolean disableCompile)
          Whether to disable the compile step.
 void setDLLFileName(java.lang.String DLLFileName)
          The name of the generated C# dll.
 void setDocXmlFileName(java.lang.String docXmlFileName)
          The name of the generated C# xml documentation.
 void setLabel(java.lang.String label)
          The label for the C# API.
 void setRequire(boolean require)
          Whether to require the C# client code.
 void setSingleFilePerClass(boolean singleFilePerClass)
          Whether there should be a single file per class.
 void setSourceFileName(java.lang.String sourceFileName)
          The name of the generated C# source file.
 
Methods inherited from class org.codehaus.enunciate.modules.FreemarkerDeploymentModule
close, doGenerate, getConfiguration, getModel, getModelInternal, getTemplateExceptionHandler, getTemplateLoader, processTemplate, processTemplate, processTemplate, processTemplate
 
Methods inherited from class org.codehaus.enunciate.modules.BasicDeploymentModule
debug, doPackage, getAliases, getBuildDir, getCompileDir, getEnunciate, getGenerateDir, getOrder, getPackageDir, info, setBuildDir, setCompileDir, setDisabled, setGenerateDir, setPackageDir, step, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSharpDeploymentModule

public CSharpDeploymentModule()
Method Detail

getName

public java.lang.String getName()
Description copied from interface: DeploymentModule
The name of the deployment module. Identifies its section in the enunciate configuration.

Specified by:
getName in interface DeploymentModule
Overrides:
getName in class BasicDeploymentModule
Returns:
"csharp"

init

public void init(Enunciate enunciate)
          throws EnunciateException
Description copied from class: BasicDeploymentModule
Sets the enunciate mechanism.

Specified by:
init in interface DeploymentModule
Overrides:
init in class BasicDeploymentModule
Parameters:
enunciate - The enunciate mechanism.
Throws:
EnunciateException

initModel

public void initModel(EnunciateFreemarkerModel model)
Description copied from interface: EnunciateModelAware
Initialize the model.

Specified by:
initModel in interface EnunciateModelAware
Overrides:
initModel in class FreemarkerDeploymentModule
Parameters:
model - The model to initialize.

packageToNamespace

protected java.lang.String packageToNamespace(java.lang.String pckg)

doFreemarkerGenerate

public void doFreemarkerGenerate()
                          throws java.io.IOException,
                                 freemarker.template.TemplateException
Description copied from class: FreemarkerDeploymentModule
Generate using Freemarker. Same as FreemarkerDeploymentModule.doGenerate() but can throw a TemplateException.

Specified by:
doFreemarkerGenerate in class FreemarkerDeploymentModule
Throws:
java.io.IOException
freemarker.template.TemplateException

doCompile

protected void doCompile()
                  throws EnunciateException,
                         java.io.IOException
Description copied from class: BasicDeploymentModule
Default implementation is a no-op.

Overrides:
doCompile in class BasicDeploymentModule
Throws:
EnunciateException
java.io.IOException

doBuild

protected void doBuild()
                throws EnunciateException,
                       java.io.IOException
Description copied from class: BasicDeploymentModule
Default implementation is a no-op.

Overrides:
doBuild in class BasicDeploymentModule
Throws:
EnunciateException
java.io.IOException

readResource

protected java.lang.String readResource(java.lang.String resource,
                                        java.lang.String contains)
                                 throws java.io.IOException,
                                        EnunciateException
Reads a resource into string form.

Parameters:
resource - The resource to read.
contains - The description of what the bundle contains.
Returns:
The string form of the resource.
Throws:
java.io.IOException
EnunciateException

getBundleFileName

protected java.lang.String getBundleFileName()
The name of the bundle file.

Returns:
The name of the bundle file.

setBundleFileName

public void setBundleFileName(java.lang.String bundleFileName)
The name of the bundle file.

Parameters:
bundleFileName - The name of the bundle file.

getDLLFileName

protected java.lang.String getDLLFileName()
The name of the generated C# dll.

Returns:
The name of the generated C# file.

setDLLFileName

public void setDLLFileName(java.lang.String DLLFileName)
The name of the generated C# dll.

Parameters:
DLLFileName - The name of the generated C# dll.

getDocXmlFileName

protected java.lang.String getDocXmlFileName()
The name of the generated C# xml documentation.

Returns:
The name of the generated C# xml documentation.

setDocXmlFileName

public void setDocXmlFileName(java.lang.String docXmlFileName)
The name of the generated C# xml documentation.

Parameters:
docXmlFileName - The name of the generated C# xml documentation.

getSourceFileName

protected java.lang.String getSourceFileName()
The name of the generated C# source file.

Returns:
The name of the generated C# source file.

setSourceFileName

public void setSourceFileName(java.lang.String sourceFileName)
The name of the generated C# source file.

Parameters:
sourceFileName - The name of the generated C# source file.

getObjectWrapper

protected freemarker.template.ObjectWrapper getObjectWrapper()
Description copied from class: FreemarkerDeploymentModule
The object wrapper to use for the model.

Overrides:
getObjectWrapper in class FreemarkerDeploymentModule
Returns:
The object wrapper to use for the model.

getTemplateURL

protected java.net.URL getTemplateURL(java.lang.String template)
Get a template URL for the template of the given name.

Parameters:
template - The specified template.
Returns:
The URL to the specified template.

isUpToDate

protected boolean isUpToDate(java.io.File genDir)
Whether the generate dir is up-to-date.

Parameters:
genDir - The generate dir.
Returns:
Whether the generate dir is up-to-date.

isRequire

public boolean isRequire()
Whether to require the C# client code.

Returns:
Whether to require the C# client code.

setRequire

public void setRequire(boolean require)
Whether to require the C# client code.

Parameters:
require - Whether to require the C# client code.

getLabel

public java.lang.String getLabel()
The label for the C# API.

Returns:
The label for the C# API.

setLabel

public void setLabel(java.lang.String label)
The label for the C# API.

Parameters:
label - The label for the C# API.

getCompileExecutable

public java.lang.String getCompileExecutable()
The path to the compile executable.

Returns:
The path to the compile executable.

setCompileExecutable

public void setCompileExecutable(java.lang.String compileExecutable)
The path to the compile executable.

Parameters:
compileExecutable - The path to the compile executable.

getCompileCommand

public java.lang.String getCompileCommand()
The C# compile command.

Returns:
The C# compile command.

setCompileCommand

public void setCompileCommand(java.lang.String compileCommand)
The C# compile command.

Parameters:
compileCommand - The C# compile command.

getPackageToNamespaceConversions

public java.util.Map<java.lang.String,java.lang.String> getPackageToNamespaceConversions()
The package-to-namespace conversions.

Returns:
The package-to-namespace conversions.

isDisableCompile

public boolean isDisableCompile()
Whether to disable the compile step.

Returns:
Whether to disable the compile step.

setDisableCompile

public void setDisableCompile(boolean disableCompile)
Whether to disable the compile step.

Parameters:
disableCompile - Whether to disable the compile step.

isSingleFilePerClass

public boolean isSingleFilePerClass()
Whether there should be a single file per class. Default: false (all classes are contained in a single file).

Returns:
Whether there should be a single file per class.

setSingleFilePerClass

public void setSingleFilePerClass(boolean singleFilePerClass)
Whether there should be a single file per class.

Parameters:
singleFilePerClass - Whether there should be a single file per class.

addClientPackageConversion

public void addClientPackageConversion(PackageNamespaceConversion conversion)
Add a client package conversion.

Parameters:
conversion - The conversion to add.

getConfigurationRules

public org.apache.commons.digester.RuleSet getConfigurationRules()
Description copied from class: BasicDeploymentModule
Default implementation returns null.

Specified by:
getConfigurationRules in interface DeploymentModule
Overrides:
getConfigurationRules in class BasicDeploymentModule
Returns:
null.

getValidator

public Validator getValidator()
Description copied from interface: DeploymentModule
Get the validator for this module, or null if none.

Specified by:
getValidator in interface DeploymentModule
Overrides:
getValidator in class BasicDeploymentModule
Returns:
null

isDisabled

public boolean isDisabled()
Description copied from interface: DeploymentModule
Whether this deployment module has been disabled, e.g. in the config file. Since the discovery mechanism is used to discover the modules on the classpath, it may be necessary to be able to disable a module.

Specified by:
isDisabled in interface DeploymentModule
Overrides:
isDisabled in class BasicDeploymentModule
Returns:
Whether this deployment module has been disabled.