}
});
discussion = forum.startDiscussion(
DomainRegistry.forumIdentityService(),
new Author("jdoe", "John Doe", "jdoe@saasovation.com"),
"All About DDD");
DomainRegistry.discussionRepository().save(discussion);
DomainEventPublisher
.instance()
.subscribe(new DomainEventSubscriber<PostedToDiscussion>() {
public void handleEvent(PostedToDiscussion aDomainEvent) {
tenant = aDomainEvent.tenant();
forumId = aDomainEvent.forumId();
discussionId = aDomainEvent.discussionId();
postId = aDomainEvent.postId();
subject = aDomainEvent.subject();
bodyText = aDomainEvent.bodyText();
}
public Class<PostedToDiscussion> subscribedToEventType() {
return PostedToDiscussion.class;
}
});
post = discussion.post(
DomainRegistry.forumIdentityService(),
new Author("jdoe", "John Doe", "jdoe@saasovation.com"),
"All About DDD",
"I'd like to start a discussion all about doing domain-driven design.");
postAgain = discussion.post(
DomainRegistry.forumIdentityService(),
new Author("bobw", "Bob Williams", "bobw@saasovation.com"),
"RE: All About DDD",
"Well, I think it's a great idea!");
DomainRegistry.postRepository().save(post);
DomainRegistry.postRepository().save(postAgain);