Let's look at an example. We have an existing interface to a system that returns javabeans;
public class BookBean
{
private String title;
private String isbn;
private Person author;
public String getTitle()
{
return title;
}
public String getIsbn()
{
return isbn;
}
public Person getAuthor()
{
return author;
}
public void setTitle( String title )
{
this.title = title;
}
public void setIsbn( String isbn )
{
this.isbn = isbn;
}
public void setAuthot( Person author )
{
this.author = author;
}
}
We need to map the Qi4j model against the existing javabeans according to a strict set of rules. Among other things;
And we will end up with something like this;
@Mixins( LibraryMixin.class )
public interface LibraryService extends Library, ServiceComposite
{}
public interface Book
{
Property<String> title();
Property<String> isbn();
Property<Person> author();
}
public interface BookComposite extends Book, JavabeanSupport, Composite
{}
public interface Person
{
Property....
}
public interface PersonComposite extends Person, JavabeanSupport, Composite
{}
Well, you need to write the Qi4j Library interface which calls the LibraryPojo in whatever way that happens to be, and then build the result Book object with the return BookBean as the javabean backing the composite. It looks something like this;
CompositeBuilder<Book> builder = factory.newCompositeBuilder( Book.class );
builder.use( bean );
return builder.newInstance();
}
}