• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PostConstruct and SequenceDiagram

 
Antonio Rafael Rodrigues
Ranch Hand
Posts: 74
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.
Do you know how to represent the @PostConstruct ( or any other event ) in the sequence diagram?
I've some initial operations that I'd like to put in a method annotated with @PostConstruct, but I don't find a good way to represent that, bucause it's not part of the flow.

Thanks in advance.
 
Antonio Rafael Rodrigues
Ranch Hand
Posts: 74
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nobody?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35269
383
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a good question. I took the Java EE 5 version of the exam so didn't have to deal with this.

I'm thinking that it would be similar to modeling an aspect. Which I didn't know how to do either so I looked online. Figure 5 in here is one approach.

I'm also adding this post to our UML forum since it isn't an exam specific question.
 
Mike Degteariov
Ranch Hand
Posts: 145
8
Java Mac MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Antonio,

I saw your topic the day you posted it, but as I did not know the answer I could not reply.

Now I think I also need to use @PostConstruct in my CDI beans, and I start thinking about how to show it.

I think that maybe it is a good idea to use "found message" to show @PostConstruct in sequence diagram.

http://www.uml-diagrams.org/sequence-diagrams.html#found-message

Found Message is a message where the receiving event is known, but there is no (known) sending event. It is interpreted as if the origin of the message is outside the scope of the description. This may for example be noise or other activity that we do not want to describe in detail. The semantics is simply the trace: <receiveEvent>, while send event is absent.
Found Messages are denoted with a small black circle at the starting end of the message.


Let me know what you think about this approach. Also let me know if you have found a better way of showing @PostConstruct method.

Jeanne, your feedback will also be greatly appreciated.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35269
383
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike,
I like the "found message" idea. I don't know what the "correct" answer is, but that seems like a reasonable approach.
 
Antonio Rafael Rodrigues
Ranch Hand
Posts: 74
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that found message is fair enough, but it could be proper for some cases and not so good for others. For example, sometimes we rely on the fact that the event will be called in the sequence that we imagine and the produced result from this event will be used in the sequence.

I tried to draw the post construct event in a jsf managed bean, I think the two aren't "correct" but the second one (sq2.png) seems to be fairer.

It doens't represent the correct flow, but make it clear about the way the developer will have to take.

What do you think?

The diagrams are attached.
sq1.png
[Thumbnail for sq1.png]
sq2.png
[Thumbnail for sq2.png]
 
Mike Degteariov
Ranch Hand
Posts: 145
8
Java Mac MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Antonio, I am going to use latter. First diagram implies that the @POstConstruct method is triggered by JSF, which is just not right.

@PostConstruct methods are called by some part of the container as part of life cycle. I think the concept of "found message" fits here.
 
Antonio Rafael Rodrigues
Ranch Hand
Posts: 74
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I agree.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic