Search code examples
architectureumlcomponent-diagram

How do you express multiplicity and polymorphism in a UML component diagram?


I want to model a web application server in UML.

Immediately after startup, there will be no web applications running on that server.

As clients begin to connect, the server will be creating web application instances to serve them. How do I express the fact that there will be an arbitrary number of instances of web application running on the server? How do I wire the single "http transaction" interface of the server to each "http transaction" interface of an arbitrary number of web applications?

The server will be capable of serving five different kinds of web applications to different clients, depending on the web path that they visit. I can model each one of the five different web applications separately, but how do I represent, in the diagram of the web application server, that the server is capable of not only instantiating an arbitrary number of instances of web application, but also, that each one of them will be an instance of one of the five available types?


Solution

  • If you're modeling the server internals and have instances corresponding to the web application, you'd use a * multiplicity on the application instance side associated with a server. Having 5 different kind of application instances would be shown with a specialization of the the app instance (inheritance), making the top level application instance abstract.

    You could use a similar approach for a component diagram, making the application instances parts of multiplicity * nested in the server component. You'd use a delegation connector between a port on the server component and an inner port on the part. I have a small doubt about the semantics of such delegating connector (if it dispatches all the messages to all the multiple parts or not) and would suggest to add a nested dispatcher part (same level of nesting as the app instances) to show that there may be some routing (server->dispatcher->instance).

    If you're modeling the deployment diagram, you may show the application instance as an execution environment, connected through network connection, for example with a gateway, and use multiplicities also on connections (see example here)