Define the concept of a "port" in an UML Composite Structure Diagram
In a UML Composite Structure Diagram开发者_开发技巧: What is a "port"? And how would I implement one in, say Java?
I would put forward that, in an OO language like Java, the port concept utilised by composite structure diagrams is (usually) actually implemented as the calling of a method of a member object by the containing object after a call is made on a method of the containing object.
This is a bit like the Facade or Delegation patterns, except that the containing object actually must "own" the member object.
See the Delegation WikiPedia article for sample implementations in a number of languages.
To answer the first part of the question, from the UML User Manual (2nd Edition) (admittedly in relation to components):
A port is an explicit window into an encapsulated component. In an encapsulated component, all of the interactions into and out of the component pass through ports. The externally visible behavior of the component is the sum of its ports, no more and no less. In addition, a port has identity.
...and from UML distilled (3rd Edition):
Ports allow you to group the required and provided interfaces into logical interactions that a component has with the outside world.
A port is a connection of your system to other systems (outside of your model). http://en.wikipedia.org/wiki/Composite_structure_diagram
It is completely open how and with which technologies a port is implemented. An XML Web Service would be a technology example that could be used to implement a port.
I don't think there is a java to Composite Structure diagram mapping. Usually class diagram to java mapping (e.g code generation) for creating the skeleton of the application and sequence diagram to java for reversing method flows.
Except that all other attends have just been research projects. Omondo has made an attend creating composite structure diagram from a class but the port has no equivalent in the project to java.
When some external component required service to a component using its provided interfaces through port, then port delegate the responsibility to particular internal component's part like Facade or Delegation patterns but what will the behavior of port when component's part requires some service using required interface through port, either port behave like the stub or in some other way?
精彩评论