Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAXB - generated classes implement interface

Is there a way to configure JAXB to so that a generated class implements a specified interface? I'm intending to use JAXB generated classes as DAO's and they should be able implement my DAO interface.

like image 303
C. Ross Avatar asked May 26 '10 19:05

C. Ross


People also ask

How do you use XJC generated classes?

Open a command prompt. Run the JAXB schema compiler, xjc command from the directory where the schema file is located. The xjc schema compiler tool is located in the app_server_root \bin\ directory. Use the generated JAXB objects within a Java application to manipulate XML content through the generated JAXB classes.

Is XJC a JAXB?

Use the JAXB schema compiler, xjc command to generate JAXB-annotated Java classes. The schema compiler is located in the app_server_root \bin\ directory. The schema compiler produces a set of packages containing Java source files and JAXB property files depending on the binding options used for compilation.

What is XJB file in JAXB?

xjb extension to resolve any conflicts in the WSDL or schema. For example if two elements have the same name and you want to distinguish between them you can rename one by specifying it the bindings file.


2 Answers

Unfortunately, it looks like the interface-injection plugin mentioned in some of the other answers is no longer well supported. In fact, I'm having trouble finding the JAR for download.

Thankfully, the JAXB2 Basics Plugins provides a similar mechanism for adding an interface to the generated JAXB stubs (see the Inheritance plugin).

The JAXB2 Basics Plugins documentation includes instructions for using the plugin with Ant and Maven.

The JAXB2 Basics Plugins provides a number of other utilities which you might also find useful (such as autogeneration of equals, hashCode, and toString methods).

like image 55
Jim Hurne Avatar answered Oct 03 '22 21:10

Jim Hurne


The interface injection plugin for XJC lets you do this.

like image 34
skaffman Avatar answered Oct 03 '22 20:10

skaffman