Introduction
A Java Interface, as defined in the Java language syntax, is not limited to having operations - it can have Java Field,
Class, or Interface members. For this reason, Java Interfaces are modeled as classes stereotyped
<<JavaInterface>>.
The UML interface has no direct mapping to a language construct in Java or J2EE development.
Interfaces in Java Design
Even though UML interfaces do not map to a language construct in Java or J2EE, there are situations where the designer
might want to use them. Some possible reasons are:
-
potentially target other languages and technologies
-
express the idea of an interface without initially deciding if a Java Interface, or some kind of delegate or access
class, will be used
If the implementation language is Java, you might decide to use <<JavaInterface>> stereotyped classes in
the Design Model in place of UML interfaces. This allows the Design Model
to evolve more easily and remain consistent with the Implementation Model (see Concept: Mapping from Design to Code).
Note that <<JavaInterface>> stereotyped classes cannot be represented as lollipops on the outside of
UML subsystems or components. Instead, the exposed interfaces are shown as publicly visible elements owned by a
subsystem or as publicly visible elements residing on a UML component.
Interfaces in EJB Design
EJB interfaces are specializations of Java interfaces. Their stereotypes are described in Guideline: Identifying Enterprise JavaBeans (EJBs).
The designer might use UML interfaces, <<JavaInterface>> stereotyped classes, or EJB-specific stereotyped
classes to model interfaces depending on how closely the designer wants to map to a particular implementation.
|