Import and Access


A package can add external model elements by reference. If the visibility of a given element is public, the package performs an import; if the visibility is private, the package performs an access. Both import and access are shown as stereotyped dependencies, with the dependent package receiving the import or access. Figure 5-4 shows examples of both.


Figure 5-4: Element import and access

Note that if a package imports an element with the same name as an element contained within the package, the import must have an associated alias. Figure 5-5 shows an example of an import with an alias.


Figure 5-5: Element import with alias

The WebServer package refers to the Book class within the Catalog package as CatalogBook going forward. (To avoid confusion, it's probably a good idea to rename one or the other Book class rather than relying on an alias.)

Import and access work the same ways on the package level. Figure 5-6 shows an example of a package import.


Figure 5-6: Package import

As a result of this import, the WebServer package can treat the Book and Author classes as if they belonged to it and not to the Catalog package.

A special case of a package import involves the ‚ «modelLibrary ‚ » stereotype. This stereotype signifies that the client package is using the source package as a library of shared model elements. For example, you might have a package of datatypes (see the section "Other Stereotypes on Classes" in Chapter 1) that you want to share among various packages.




Fast Track Uml 2.0
Fast Track UML 2.0
ISBN: 1590593200
EAN: 2147483647
Year: 2004
Pages: 97

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net