1. CC-XJC

CC-XJC

Introduction

CC-XJC is a JAXB 2.0 XJC plugin for adding a copy constructor to schema derived classes. The plugin provides a '-copy-constructor' option which is enabled by adding its jar file to the XJC classpath. When enabled, the following options can be used to control the behavior of the plugin.

  • -cc-visibility

    The '-cc-visibility' option can be used to specify the visibility of generated copy methods. It takes one argument from the list [private, package, protected, public]. This option impacts the number of generated methods. Default: private.

  • -cc-target

    The '-cc-target' option can be used to specify a target JDK version for the generated code. It takes one argument from the list [1.5, 1.6, 1.7]. Default: 1.5.

See the examples for further information.

Support

Development of CC-XJC is community driven. Please file any issues with the MantisBT bugtracker or subscribe to the ccxjc-users mailing list for discussing issues or asking questions. The IdeaTorrent is used to collect ideas. You may also want to use the wiki for providing content related to CC-XJC yourself. Please note that applications provided by Sourceforge require you to login to Sourceforge. If you do not have a Sourceforge account, simply create one at Sourceforge.

Examples

Maven

Maven users simply add the CC-XJC plugin as a dependency to a JAXB plugin of choice. The following example demonstrates the use of the CC-XJC plugin with the Java.net maven-jaxb-plugin.

<plugin>
  <groupId>com.sun.tools.xjc.maven2</groupId>
  <artifactId>maven-jaxb-plugin</artifactId>
  <version>1.1</version>
  <dependencies>
    <dependency>
      <groupId>net.sourceforge.ccxjc</groupId>
      <artifactId>cc-xjc-plugin</artifactId>
      <version>1.0-beta-14</version>
    </dependency>
  </dependencies>
  <executions>
    <execution>
      <id>xjc</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>generate</goal>
      </goals>
      <configuration>
        <schemaDirectory>src/main/schemas</schemaDirectory>
        <args>-copy-constructor -cc-visibility public -cc-target 1.6</args>
        <extension>true</extension>
      </configuration>
    </execution>
  </executions>
</plugin>

Note: To use the Java.net maven-jaxb-plugin the Java.net repositories need to be configured in a POM or the Maven settings.

<repositories>
  <repository>
    <id>http://download.java.net/maven/1</id>
    <url>http://download.java.net/maven/1</url>
    <layout>legacy</layout>
    <releases>
      <enabled>true</enabled>
    </releases>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </repository>
  <repository>
    <id>http://download.java.net/maven/2</id>
    <url>http://download.java.net/maven/2</url>
    <releases>
      <enabled>true</enabled>
    </releases>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </repository>
</repositories>

<pluginRepositories>
  <pluginRepository>
    <id>http://download.java.net/maven/1</id>
    <url>http://download.java.net/maven/1</url>
    <layout>legacy</layout>
    <releases>
      <enabled>true</enabled>
    </releases>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </pluginRepository>
  <pluginRepository>
    <id>http://download.java.net/maven/2</id>
    <url>http://download.java.net/maven/2</url>
    <releases>
      <enabled>true</enabled>
    </releases>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </pluginRepository>
</pluginRepositories>

Download

Releases

Releases are deployed to the central Maven 2 repository and to the Sourceforge file release system. The changes report contains information regarding changes between releases.

Snapshots

Development snapshots are deployed to the CC-XJC snapshot repository and are available for download from there. Please see group net.sourceforge.ccxjc. Maven users may want to add the CC-XJC snapshot repository to a POM or the Maven settings.

<repository>
  <id>http://ccxjc.sourceforge.net/maven2/snapshots</id>
  <url>http://ccxjc.sourceforge.net/maven2/snapshots</url>
  <releases>
    <enabled>false</enabled>
  </releases>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
</repository>

License

The CC-XJC Project Copyright

Copyright (c) 2009 The CC-XJC Project. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE CC-XJC PROJECT AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE CC-XJC PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.