Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

Let say we have a server that manage a library in which you can add a book, find a book and get all the books. The server code will probably look like this:

Code Block
javajava
titleBookService.groovy
java
class BookService {

  private List allBooks = new ArrayList()

  Book findBook(String isbn) {
    for (book in allBooks) {
      if (book.isbn == isbn) return book
    }
    return null
  }

  void addBook(Book book) {
    allBooks.add(book)
  }

  Book[] getBooks() {
    return (Book[])allBooks.toArray(new Book[allBooks.size()])
  }

}

with the class Book being something like that.

Code Block
javajava
titleBook.groovy
java
class Book {
  String author
  String title
  String isbn
}


To ignore the metaClass property a custom type mapping must be defined (for details refer to Aegis Binding).

Code Block
xmlxml
titleBook.aegis.xml
xml
<?xml version="1.0" encoding="UTF-8"?>
<mappings xmlns:sample="http://DefaultNamespace">
  <mapping name="sample:Book">
    <property name="metaClass" ignore="true"/>
  </mapping>
</mappings>

...