Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.ws.jaxme.generator
Class XJCTask  view XJCTask download XJCTask.java

java.lang.Object
  extended byorg.apache.tools.ant.ProjectComponent
      extended byorg.apache.tools.ant.Task
          extended byorg.apache.ws.jaxme.generator.XJCTask

public class XJCTask
extends org.apache.tools.ant.Task

An Ant task for running JaxMe, designed to be JAXB compatible.

This task supports the following attributes:

Name Description Required/Default
schema Name of a schema file being compiled This or nested <schema> elements are required
binding An external binding file being applied to the schema file No
force Setting this option to true forces the up-to-date check to fail. This option is mainly useful while working on the JaxMe generator. For JaxMe users, which only change schema files, this option isn't of much use. It is designed for JaxMe developers. No, false
package Specifies the generated Java sources package name. Overrides package specifications in the schema bindings, if any. No, a package may be specified in the schema bindings.
target Specifies the target directory, where generated sources are being created. A package structure will be created below that directory. For example, with target="src" and package="org.acme", you will have files being created in "src/org/acme". No, defaults to the current directory
readonly Generated Java source files are in read-only mode, if true is specified No, defaults to false
extension If set to true, the XJC binding compiler will run in the extension mode. Otherwise, it will run in the strict conformance mode. No, defaults to false
stackSize Specify the thread stack size for the XJC binding compiler (J2SE SDK v1.4 or higher). The XJC binding compiler can fail to compile large schemas with StackOverflowError and, in that case, this option can be used to extend the stack size. If unspecified, the default VM size is used. The format is equivalent to the -Xss command-line argument for Sun Microsystems JVM. This value can be specified in bytes (stackSize="2097152"), kilobytes (stackSize="2048kb"), or megabytes (stackSize="2mb").
This attribute is ignored by the JaxMe ant task and present for compatibility reasons only.
No, defaults to false
removeOldOutput If one or more nested <produces> elements are specified and this attribute is set to true, then the Ant task will ensure that only generated files will remain. In other words, if you had removed an element named "Foo" from the previous schema version, then the Ant task will remove "Foo.java". No, defaults to false
validating Sets whether the XML schema parser is validating. By default it isn't. No, defaults to false

Besides the attributes, the ant task also supports the following nested elements:

Name Description Required/Multiplicity
schema Multiple schema files may be compiled in one or more nested <schema> elements. The element syntax is equivalent to a nested <fileset>. Use of a nested <schema> element is mutually exclusive with the use of a "schema" attribute. 0 - Unbounded
binding Multiple external binding files may be specified. The element syntax is equivalent to a nested <fileset>. Use of a nested <binding> element is mutually exclusive with the use of a "binding" attribute. 0 - Unbounded
classpath This nested element is ignored by the JaxMe ant task and exists for compatibility to the JAXB ant task only. In the case of JAXB it specifies a classpath for loading user defined types (required in the case of a <javaType> customization) 0 - Unbounded
arg This nested element is ignored by the JaxMe ant task and exists for compatibility to the JAXB ant task only. In the case of JAXB it specifies additional command line arguments being passed to the XJC. For details about the syntax, see the relevant section in the Ant manual.
This nested element can be used to specify various options not natively supported in the xjc Ant task. For example, currently there is no native support for the following xjc command-line options:
  • -nv
  • -catalog
  • -use-runtime
  • -schema
  • -dtd
  • -relaxng
0 - Unbounded
dtd If this nested element is used to specify, that the input files aren't instances of XML Schema, but DTD's. The nested element may have an attribute "targetNamespace", which specifies an optional target namespace. No
depends By default the JaxMe Ant tasks up-to-date check considers the specified schema and binding files only. This is insufficient, if other schema files are included, imported or redefined.
The nested <depends> element allows to specify additional files to consider for the up-to-date check. Typically these are the additional schema files.
Syntactically the <depends> element specifies a nested <fileset>.
0 - Unbounded
produces Specifies the set of files being created by the JaxMe ant task. These files are considered as targets for the up-to-date check. The syntax of the <produces> element is equivalent to a nested <fileset>. However, you typically do not need to set the "dir" attribute, because it defaults to the target directory. 0 - Unbounded
property Sets a property value. These properties may be used by the various source generators to configure the behaviour. For example, the JDBC schema reader uses the options "jdbc.driver", "jdbc.url", "jdbc.user", and "jdbc.password" to configure the database connection. Each property must have attributes "name" (the property name) and "value" (the property value). 0 - Unbounded
schemaReader Configures the schema reader to use. Defaults to "org.apache.ws.jaxme.generator.sg.impl.JAXBSchemaReader", which is the JAXB compliant schema reader. An alternative schema readers is, for example, "org.apache.ws.jaxme.generator.sg.impl.JaxMeSchemaReader" (a subclass of JAXBSchemaReader with JaxMe specific extensions). 0 - 1
sgFactoryChain If the schema reader is an instance of org.apache.ws.jaxme.generator.sg.impl.JAXBSchemaReader, then you may add instances of org.apache.ws.jaxme.generator.sg.SGFactoryChain to the schema generation process. For example, such chains are used to create the persistency layer. The best example is the org.apache.ws.jaxme.pm.generator.jdbc.JaxMeJdbcSG, which is able to populate the schema with tables and columns read from a database via JDBC metadata. 0 - Unbounded

By default, the JaxMe ant task will always run the generator and create new files. This is typically inappropriate for an ant script where your desire is to have as little modifications as possible, because new files also need to be recompiled, which is slow and time consuming.

To achieve a better behaviour, use the nested <produces> and <depends> elements. If one or more <produces> element is specified, then an up-to-date check is performed as follows:

  1. If either of the filesets specified by the <produces> elements is empty, then the binding compiler will run.
  2. Otherwise the sets of source and target files will be created. The set of source files is specified by the "schema" and "binding" attributes, and by the nested <schema>, <binding>, and <depends> elements. If any of the files in the source set is newer than any of the files in the target set, then the binding comoiler will run.


Nested Class Summary
static class XJCTask.ClassType
           
static class XJCTask.Dtd
          This class is used to store the nested element "dtd".
 class XJCTask.MyClassLoader
           
static class XJCTask.Property
           
 
Field Summary
private  java.io.File binding
           
private  java.util.List bindings
           
private  java.util.List depends
           
private  XJCTask.Dtd dtd
           
private  boolean extension
           
private  boolean force
           
private  boolean isSettingLoggerFactory
           
private  boolean isValidating
           
private  java.lang.String packageName
           
private  java.util.List produces
           
private  java.util.List properties
           
private  boolean readOnly
           
private  boolean removeOldOutput
           
private  java.io.File schema
           
private  XJCTask.ClassType schemaReader
           
private  java.util.List schemas
           
private  java.util.List sgFactoryChains
           
private  java.lang.String stackSize
           
private  java.io.File target
           
 
Fields inherited from class org.apache.tools.ant.Task
description, location, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
XJCTask()
           
 
Method Summary
 void addArg(org.apache.tools.ant.types.Commandline.Argument pArg)
          This nested element is ignored by the JaxMe ant task and exists for compatibility to the JAXB ant task only.
 void addBinding(org.apache.tools.ant.types.FileSet pBindings)
          Multiple external binding files may be specified.
 void addClasspath(org.apache.tools.ant.types.Path pClasspath)
          This nested element is ignored by the JaxMe ant task and exists for compatibility to the JAXB ant task only.
 void addDepends(org.apache.tools.ant.types.FileSet pDepends)
          By default the JaxMe Ant tasks up-to-date check considers the specified schema and binding files only.
 void addSchema(org.apache.tools.ant.types.FileSet pSchemas)
          Multiple schema files may be compiled in one or more nested <schema> elements.
 XJCTask.Dtd createDtd()
          Creates a nested element "dtd".
 org.apache.tools.ant.types.FileSet createProduces()
          Specifies the set of files being created by the JaxMe ant task.
 XJCTask.Property createProperty()
          Sets a property value.
 XJCTask.ClassType createSchemaReader()
          Configures the schema reader to use.
 XJCTask.ClassType createSGFactoryChain()
          Configures a new instance of org.apache.ws.jaxme.generator.sg.SGFactoryChain being included into the schema generation process.
 void execute()
          Called by the project to let the task do its work.
 void finish()
           
 java.io.File getBinding()
          Returns an external binding file being applied to the schema file.
private  java.io.File[] getBindingFiles()
           
 org.apache.tools.ant.types.FileSet[] getBindings()
          Multiple external binding files may be specified.
 org.apache.tools.ant.types.FileSet[] getDepends()
          By default the JaxMe Ant tasks up-to-date check considers the specified schema and binding files only.
private  java.io.File[] getDependsFiles()
           
 java.lang.String getDescription()
          Returns the ant tasks description.
 XJCTask.Dtd getDtd()
          Returns the nested element "dtd".
private  java.io.File[] getFiles(org.apache.tools.ant.types.FileSet[] pFileSets)
           
 java.lang.String getPackage()
          Returns the generated Java sources package name.
 org.apache.tools.ant.types.FileSet[] getProduces()
          Returns the set of files being created by the JaxMe ant task.
 XJCTask.Property[] getProperties()
          Returns the configured property values.
 java.io.File getSchema()
          Returns the name of the schema file being compiled.
private  java.io.File[] getSchemaFiles()
           
 SchemaReader getSchemaReader()
          Returns the configured schema reader to use.
 org.apache.tools.ant.types.FileSet[] getSchemas()
          Multiple schema files may be compiled in one or more nested <schema> elements.
 XJCTask.ClassType[] getSGFactoryChains()
          Returns the array of configured instances of org.apache.ws.jaxme.generator.sg.SGFactoryChain.
 java.lang.String getStackSize()
          Returns the thread stack size for the XJC binding compiler (J2SE SDK v1.4 or higher).
 java.io.File getTarget()
          Returns the target directory, where generated sources are being created.
 org.apache.ws.jaxme.logging.LoggerFactory initLogging()
           
 boolean isExtension()
          Returns, whether the XJC binding compiler will run in the extension mode.
 boolean isForce()
          Setting this option to true forces the up-to-date check to fail.
 boolean isReadOnly()
          Returns, whether generated Java source files are in read-only mode.
 boolean isRemoveOldOutput()
          If one or more nested <produces> elements are specified and this attribute is set to true, then the Ant task will ensure that only generated files will remain.
 boolean isSettingLoggerFactory()
          Returns whether the ant task is setting the org.apache.ws.jaxme.logging.LoggerFactory.
 boolean isUpToDate(java.io.File[] pSchemaFiles, java.io.File[] pBindingFiles, java.io.File[] pDependsFiles, java.util.List pProducesList)
           
 boolean isValidating()
          Returns whether the XML schema parser is validating.
 void setBinding(java.io.File pBinding)
          Sets an external binding file being applied to the schema file.
 void setExtension(boolean pExtension)
          Sets, whether the XJC binding compiler will run in the extension mode.
 void setForce(boolean pForce)
          Setting this option to true forces the up-to-date check to fail.
 void setPackage(java.lang.String pPackageName)
          Sets the generated Java sources package name.
 void setPackageName(java.lang.String pPackageName)
          Deprecated. Use setPackage(String) 55 .
 void setReadOnly(boolean pReadOnly)
          Sets, whether generated Java source files are in read-only mode.
 void setRemoveOldOutput(boolean pRemoveOldOutput)
          If one or more nested <produces> elements are specified and this attribute is set to true, then the Ant task will ensure that only generated files will remain.
 void setSchema(java.io.File pSchema)
          Sets the name of the schema file being compiled.
 void setSettingLoggerFactory(boolean pIsSettingLoggerFactory)
          Sets whether the ant task is setting the org.apache.ws.jaxme.logging.LoggerFactory.
 void setStackSize(java.lang.String pStackSize)
          Sets the thread stack size for the XJC binding compiler (J2SE SDK v1.4 or higher).
 void setTarget(java.io.File pTarget)
          Sets the target directory, where generated sources are being created.
 void setValidating(boolean pValidating)
          Sets whether the XML schema parser is validating.
 void stopLogging(org.apache.ws.jaxme.logging.LoggerFactory pFactory)
           
 
Methods inherited from class org.apache.tools.ant.Task
getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

binding

private java.io.File binding

schema

private java.io.File schema

target

private java.io.File target

packageName

private java.lang.String packageName

readOnly

private boolean readOnly

extension

private boolean extension

removeOldOutput

private boolean removeOldOutput

force

private boolean force

isValidating

private boolean isValidating

isSettingLoggerFactory

private boolean isSettingLoggerFactory

stackSize

private java.lang.String stackSize

bindings

private java.util.List bindings

schemas

private java.util.List schemas

depends

private java.util.List depends

produces

private java.util.List produces

sgFactoryChains

private java.util.List sgFactoryChains

schemaReader

private XJCTask.ClassType schemaReader

properties

private java.util.List properties

dtd

private XJCTask.Dtd dtd
Constructor Detail

XJCTask

public XJCTask()
Method Detail

createProperty

public XJCTask.Property createProperty()

Sets a property value. These properties may be used by the various source generators to configure the behaviour. For example, the JDBC schema reader uses the options "jdbc.driver", "jdbc.url", "jdbc.user", and "jdbc.password" to configure the database connection. Each property must have attributes "name" (the property name) and "value" (the property value).


getProperties

public XJCTask.Property[] getProperties()

Returns the configured property values. These properties may be used by the various source generators to configure the behaviour. For example, the JDBC schema reader uses the options "jdbc.driver", "jdbc.url", "jdbc.user", and "jdbc.password" to configure the database connection. Each property must have attributes "name" (the property name) and "value" (the property value).


createSchemaReader

public XJCTask.ClassType createSchemaReader()

Configures the schema reader to use. Defaults to "org.apache.ws.jaxme.generator.sg.impl.JAXBSchemaReader", which is the JAXB compliant schema reader. An alternative schema readers is, for example, "org.apache.ws.jaxme.generator.sg.impl.JaxMeSchemaReader" (a subclass of JAXBSchemaReader with JaxMe specific extensions).


getSchemaReader

public SchemaReader getSchemaReader()

Returns the configured schema reader to use. Defaults to "org.apache.ws.jaxme.generator.sg.impl.JAXBSchemaReader", which is the JAXB compliant schema reader. An alternative schema readers is, for example, "org.apache.ws.jaxme.generator.sg.impl.JaxMeSchemaReader" (a subclass of JAXBSchemaReader with JaxMe specific extensions).


createSGFactoryChain

public XJCTask.ClassType createSGFactoryChain()

Configures a new instance of org.apache.ws.jaxme.generator.sg.SGFactoryChain being included into the schema generation process. This option is valid only, if the schema reader is an instance of org.apache.ws.jaxme.generator.sg.impl.JAXBSchemaReader, because its method JAXBSchemaReader.addSGFactoryChain(Class)>JAXBSchemaReader.addSGFactoryChain(Class) 55 must be invoked.

The order of the chain elements may be significant. The schema reader itself will always be the last element in the chain.


getSGFactoryChains

public XJCTask.ClassType[] getSGFactoryChains()

Returns the array of configured instances of org.apache.ws.jaxme.generator.sg.SGFactoryChain. The order of the array is significant. The schema reader itself will always be the last element in the chain. Therefore, it is not present in the array.


getDescription

public java.lang.String getDescription()

Returns the ant tasks description.


setValidating

public void setValidating(boolean pValidating)

Sets whether the XML schema parser is validating.


isValidating

public boolean isValidating()

Returns whether the XML schema parser is validating.


isForce

public boolean isForce()

Setting this option to true forces the up-to-date check to fail. This option is mainly useful while working on the JaxMe generator. For JaxMe users, which only change schema files, this option isn't of much use. It is designed for JaxMe developers.


setForce

public void setForce(boolean pForce)

Setting this option to true forces the up-to-date check to fail. This option is mainly useful while working on the JaxMe generator. For JaxMe users, which only change schema files, this option isn't of much use. It is designed for JaxMe developers.


isSettingLoggerFactory

public boolean isSettingLoggerFactory()

Returns whether the ant task is setting the org.apache.ws.jaxme.logging.LoggerFactory. This option is only useful, if you are using the Ant task from another Java class and not from within Ant.


setSettingLoggerFactory

public void setSettingLoggerFactory(boolean pIsSettingLoggerFactory)

Sets whether the ant task is setting the org.apache.ws.jaxme.logging.LoggerFactory. This option is only useful, if you are using the Ant task from another Java class and not from within Ant.


getBinding

public java.io.File getBinding()

Returns an external binding file being applied to the schema file.


setBinding

public void setBinding(java.io.File pBinding)

Sets an external binding file being applied to the schema file.


isExtension

public boolean isExtension()

Returns, whether the XJC binding compiler will run in the extension mode. By default, it will run in the strict conformance mode.


setExtension

public void setExtension(boolean pExtension)

Sets, whether the XJC binding compiler will run in the extension mode. By default, it will run in the strict conformance mode.


getPackage

public java.lang.String getPackage()

Returns the generated Java sources package name. A non-null package specification overrides package specifications in the schema bindings, if any.


setPackage

public void setPackage(java.lang.String pPackageName)

Sets the generated Java sources package name. A non-null package specification overrides package specifications in the schema bindings, if any.


setPackageName

public void setPackageName(java.lang.String pPackageName)
Deprecated. Use setPackage(String) 55 .


isReadOnly

public boolean isReadOnly()

Returns, whether generated Java source files are in read-only mode.


setReadOnly

public void setReadOnly(boolean pReadOnly)

Sets, whether generated Java source files are in read-only mode.


isRemoveOldOutput

public boolean isRemoveOldOutput()

If one or more nested <produces> elements are specified and this attribute is set to true, then the Ant task will ensure that only generated files will remain. In other words, if you had removed an element named "Foo" from the previous schema version, then the Ant task will remove "Foo.java".


setRemoveOldOutput

public void setRemoveOldOutput(boolean pRemoveOldOutput)

If one or more nested <produces> elements are specified and this attribute is set to true, then the Ant task will ensure that only generated files will remain. In other words, if you had removed an element named "Foo" from the previous schema version, then the Ant task will remove "Foo.java".


getSchema

public java.io.File getSchema()

Returns the name of the schema file being compiled.


setSchema

public void setSchema(java.io.File pSchema)

Sets the name of the schema file being compiled.


getStackSize

public java.lang.String getStackSize()

Returns the thread stack size for the XJC binding compiler (J2SE SDK v1.4 or higher). The XJC binding compiler can fail to compile large schemas with StackOverflowError and, in that case, this option can be used to extend the stack size. If unspecified, the default VM size is used. The format is equivalent to the -Xss command-line argument for Sun Microsystems JVM. This value can be specified in bytes (stackSize="2097152"), kilobytes (stackSize="2048kb"), or megabytes (stackSize="2mb").

This attribute is ignored by the JaxMe ant task and present for compatibility reasons only.


setStackSize

public void setStackSize(java.lang.String pStackSize)

Sets the thread stack size for the XJC binding compiler (J2SE SDK v1.4 or higher). The XJC binding compiler can fail to compile large schemas with StackOverflowError and, in that case, this option can be used to extend the stack size. If unspecified, the default VM size is used. The format is equivalent to the -Xss command-line argument for Sun Microsystems JVM. This value can be specified in bytes (stackSize="2097152"), kilobytes (stackSize="2048kb"), or megabytes (stackSize="2mb").

This attribute is ignored by the JaxMe ant task and present for compatibility reasons only.


getTarget

public java.io.File getTarget()

Returns the target directory, where generated sources are being created. A package structure will be created below that directory. For example, with target="src" and package="org.acme", you will have files being created in "src/org/acme".


setTarget

public void setTarget(java.io.File pTarget)

Sets the target directory, where generated sources are being created. A package structure will be created below that directory. For example, with target="src" and package="org.acme", you will have files being created in "src/org/acme".


addSchema

public void addSchema(org.apache.tools.ant.types.FileSet pSchemas)

Multiple schema files may be compiled in one or more nested <schema> elements. The element syntax is equivalent to a nested <fileset>. Use of a nested <schema> element is mutually exclusive with the use of a "schema" attribute.


getSchemas

public org.apache.tools.ant.types.FileSet[] getSchemas()

Multiple schema files may be compiled in one or more nested <schema> elements. The element syntax is equivalent to a nested <fileset>. Use of a nested <schema> element is mutually exclusive with the use of a "schema" attribute.


addBinding

public void addBinding(org.apache.tools.ant.types.FileSet pBindings)

Multiple external binding files may be specified. The element syntax is equivalent to a nested <fileset>. Use of a nested <binding> element is mutually exclusive with the use of a "binding" attribute.


getBindings

public org.apache.tools.ant.types.FileSet[] getBindings()

Multiple external binding files may be specified. The element syntax is equivalent to a nested <fileset>. Use of a nested <binding> element is mutually exclusive with the use of a "binding" attribute.


addClasspath

public void addClasspath(org.apache.tools.ant.types.Path pClasspath)

This nested element is ignored by the JaxMe ant task and exists for compatibility to the JAXB ant task only. In the case of JAXB it specifies a classpath for loading user defined types (required in the case of a <javaType> customization)


addArg

public void addArg(org.apache.tools.ant.types.Commandline.Argument pArg)

This nested element is ignored by the JaxMe ant task and exists for compatibility to the JAXB ant task only. In the case of JAXB it specifies additional command line arguments being passed to the XJC. For details about the syntax, see the relevant section in the Ant manual.
This nested element can be used to specify various options not natively supported in the xjc Ant task. For example, currently there is no native support for the following xjc command-line options:

  • -nv
  • -catalog
  • -use-runtime
  • -schema
  • -dtd
  • -relaxng


addDepends

public void addDepends(org.apache.tools.ant.types.FileSet pDepends)

By default the JaxMe Ant tasks up-to-date check considers the specified schema and binding files only. This is insufficient, if other schema files are included, imported or redefined.
The nested <depends> element allows to specify additional files to consider for the up-to-date check. Typically these are the additional schema files.
Syntactically the <depends> element specifies a nested <fileset>.


getDepends

public org.apache.tools.ant.types.FileSet[] getDepends()

By default the JaxMe Ant tasks up-to-date check considers the specified schema and binding files only. This is insufficient, if other schema files are included, imported or redefined.
The nested <depends> element allows to specify additional files to consider for the up-to-date check. Typically these are the additional schema files.
Syntactically the <depends> element specifies a nested <fileset>.


createProduces

public org.apache.tools.ant.types.FileSet createProduces()

Specifies the set of files being created by the JaxMe ant task. These files are considered as targets for the up-to-date check. The syntax of the <produces> element is equivalent to a nested <fileset>.


getProduces

public org.apache.tools.ant.types.FileSet[] getProduces()

Returns the set of files being created by the JaxMe ant task. These files are considered as targets for the up-to-date check. The syntax of the <produces> element is equivalent to a nested <fileset>.


createDtd

public XJCTask.Dtd createDtd()
Creates a nested element "dtd".


getDtd

public XJCTask.Dtd getDtd()
Returns the nested element "dtd".


finish

public void finish()

getFiles

private java.io.File[] getFiles(org.apache.tools.ant.types.FileSet[] pFileSets)

getSchemaFiles

private java.io.File[] getSchemaFiles()

getBindingFiles

private java.io.File[] getBindingFiles()

getDependsFiles

private java.io.File[] getDependsFiles()

isUpToDate

public boolean isUpToDate(java.io.File[] pSchemaFiles,
                          java.io.File[] pBindingFiles,
                          java.io.File[] pDependsFiles,
                          java.util.List pProducesList)

stopLogging

public void stopLogging(org.apache.ws.jaxme.logging.LoggerFactory pFactory)

initLogging

public org.apache.ws.jaxme.logging.LoggerFactory initLogging()

execute

public void execute()
Description copied from class: org.apache.tools.ant.Task
Called by the project to let the task do its work. This method may be called more than once, if the task is invoked more than once. For example, if target1 and target2 both depend on target3, then running "ant target1 target2" will run all tasks in target3 twice.