org.spicefactory.pimento.generator
Class GeneratorConfig

java.lang.Object
  extended by org.spicefactory.pimento.generator.GeneratorConfig

public class GeneratorConfig
extends Object

The configuration for Cinnamon ActionScript source generation and Parsley XML configuration generation.

Author:
Jens Halm

Constructor Summary
GeneratorConfig(CinnamonConfig config, File templateDir, File sourceOutputDir)
          Creates a new configuration instance.
GeneratorConfig(CinnamonConfig config, File templateDir, File sourceOutputDir, File configOutputFile, String serviceUrl, int timeout)
          Creates a new configuration instance.
 
Method Summary
 void addPackageMapping(String javaPackage, String asPackage)
          Maps the specified Java package to an ActionScript package.
 void addTypeMapping(Class<?> javaType, String asType)
          Adds a type mapping to this configuration.
 String getActionScriptPackage(String javaPackage)
          Returns the ActionScript package corresponding to the specified Java package.
 String getActionScriptType(Class<?> javaType)
          Returns the ActionScript type corresponding to the specified Java type.
 CinnamonConfig getCinnamonConfig()
          Returns the Cinnamon configuration instance.
 File getConfigOutputFile()
          Returns the file to write Parsley XML configuration to.
 NamingStrategy getNamingStrategy()
          Returns the naming strategy that will be used for matching names of ActionScript service interfaces to the names of the implementation classes.
 String getServiceUrl()
          Returns the service URL for this configuration.
 File getSourceOutputDir()
          Returns the source path all generated ActionScript classes and interfaces should be written to.
 File getTemplateDir()
          Returns the directory containing all templates for ActionScript service interfaces and proxies as well as Parsley XML configuration.
 int getTimeout()
          Returns the timeout in milliseconds for all service operations.
 void setNamingStrategy(NamingStrategy namingStrategy)
          Sets the naming strategy that will be used for matching names of ActionScript service interfaces to the names of the implementation classes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneratorConfig

public GeneratorConfig(CinnamonConfig config,
                       File templateDir,
                       File sourceOutputDir)
Creates a new configuration instance. Use this constructor if you don't want Parsley XML configuration files to be generated.

Parameters:
config - the fully processed Cinnamon configuration
templateDir - the directory containing all templates for this generator
sourceOutputDir - the source path all generated ActionScript classes and interfaces should be written to

GeneratorConfig

public GeneratorConfig(CinnamonConfig config,
                       File templateDir,
                       File sourceOutputDir,
                       File configOutputFile,
                       String serviceUrl,
                       int timeout)
Creates a new configuration instance.

Parameters:
config - the fully processed Cinnamon configuration
templateDir - the directory containing all templates for this generator
sourceOutputDir - the source path all generated ActionScript classes and interfaces should be written to
configOutputFile - the file to write Parsley XML configuration to
serviceUrl - the service URL for this configuration
timeout - the timeout in milliseconds for all service operations
Method Detail

addPackageMapping

public void addPackageMapping(String javaPackage,
                              String asPackage)
Maps the specified Java package to an ActionScript package. Only needed when the generated ActionScript classes and interfaces should reside in a different package than their corresponding Java classes.

Parameters:
javaPackage - the Java package
asPackage - the correspondig ActionScript package

getActionScriptPackage

public String getActionScriptPackage(String javaPackage)
Returns the ActionScript package corresponding to the specified Java package. Unless you explicitly registered a mapping for the specified Java package with addPackageMapping the package name will be returned unchanged.

Parameters:
javaPackage - the Java package
Returns:
the correspondig ActionScript package

addTypeMapping

public void addTypeMapping(Class<?> javaType,
                           String asType)
Adds a type mapping to this configuration. Only needed for Java parameter and return types which cannot be mapped automatically.

Parameters:
javaType - the Java type
asType - the correspondig ActionScript type
See Also:
getActionScriptType(java.lang.Class)

getActionScriptType

public String getActionScriptType(Class<?> javaType)
Returns the ActionScript type corresponding to the specified Java type. Needed for translation of method parameter types. All basic data types like String and Number and all types for which ClassMappings have been explicitly registered in the Cinnamon configuration will be translated automatically. You only need to manually add further mappings with addTypeMapping for classes for which you registered custom Converters or for parameter type declarations which use an interface or superclass of a mapped class. For these kinds of declarations the generator cannot "guess" the correspondig ActionScript type.

Parameters:
javaType - the Java type
Returns:
the ActionScript type corresponding to the specified Java type

getNamingStrategy

public NamingStrategy getNamingStrategy()
Returns the naming strategy that will be used for matching names of ActionScript service interfaces to the names of the implementation classes.

Returns:
the naming strategy that will be used for matching names of ActionScript service interfaces to the names of the implementation classes

setNamingStrategy

public void setNamingStrategy(NamingStrategy namingStrategy)
Sets the naming strategy that will be used for matching names of ActionScript service interfaces to the names of the implementation classes. The default implementation is ImplPostfixNamingStrategy.

Parameters:
namingStrategy - the naming strategy that will be used for matching names of ActionScript service interfaces to the names of the implementation classes

getCinnamonConfig

public CinnamonConfig getCinnamonConfig()
Returns the Cinnamon configuration instance.

Returns:
the Cinnamon configuration instance

getTemplateDir

public File getTemplateDir()
Returns the directory containing all templates for ActionScript service interfaces and proxies as well as Parsley XML configuration.

Returns:
the directory containing all templates for this generator

getSourceOutputDir

public File getSourceOutputDir()
Returns the source path all generated ActionScript classes and interfaces should be written to.

Returns:
the source path all generated ActionScript classes and interfaces should be written to

getConfigOutputFile

public File getConfigOutputFile()
Returns the file to write Parsley XML configuration to.

Returns:
the file to write Parsley XML configuration to

getServiceUrl

public String getServiceUrl()
Returns the service URL for this configuration.

Returns:
the service URL for this configuration

getTimeout

public int getTimeout()
Returns the timeout in milliseconds for all service operations.

Returns:
the timeout in milliseconds for all service operations