Hi Rickard,
Thanks for the great tutorial on DCI with Qi4j!
If I have understood things right, I would suggest a small tweak of
the variable namings and adding some pedagogical comments in the
Main.java class (please correct if something is misunderstood):
===================
// Usecase 1
{
// generic map of DCI context interactions
InteractionContext interactionContext = new
InteractionContext();
// application rootContext with injected interactionContext
map
RootContext rootContext = assembler.objectBuilderFactory()
.newObjectBuilder
( RootContext.class ).use( interactionContext ).newInstance();
// usercontext accessed from rootContext
UserContext userContext =
rootContext.user( user.identity().get() );
// inbox subcontext for the user
InboxContext inboxContext = userContext.inbox();
// assign task to inbox subcontext
inboxContext.assignTo( task );
}
// Usecase 2
TaskEntity task2 = uow.newEntity( TaskEntity.class );
{
// generic map of DCI context interactions
InteractionContext interactionContext = new
InteractionContext();
// application rootContext with injected interactionContext
map
RootContext rootContext =
assembler.objectBuilderFactory().newObjectBuilder( RootContext.class )
.use( interactionContext ).newInstance();
// usercontext accessed from rootContext
UserContext userContext =
rootContext.user( user.identity().get() );
// project subcontext for the user
ProjectContext projectContext =
userContext.project( project.identity().get() );
// example of subcontexts within subcontexts
// inbox "subsubcontext" for the project subcontext
InboxContext inboxContext = projectContext.inbox();
// assign task to inbox "subsubcontext"
inboxContext.assignTo( task2 );
}
===================
Apart from the good explanations on your blog, I found the comments
and renamings above helpful when studying the code.
/ Marc
On 14/03/2010, at 13.55, Rickard Öberg wrote:
Hi,
I have just committed an updated version of my sample from Öredev on
how to implement DCI in Qi4j. You can find it in the qi4j-samples
Git repo. There are 3 versions using POJO's, and 2 using Qi4j.
I've also posted a longish blog post on it. How it works, what the
conseuqences are, and so on. You can read it here:
http://www.jroller.com/rickard/entry/implementing_dci_in_qi4j
As always, any feedback is welcome!
regards, Rickard
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev