Imported Package Overview

A schema can import multiple packages. Each imported package must have an import name that is unique within its importing schema branch (across both imported and exported packages) but the imported package name does not have to be globally unique.

Although an imported package name is the same as the exported package name by default, you can change the name when you import the package.

An import name is effectively an alias for a schema-package path. For example, a schema might import a package with a name of Logging that maps to a LoggingUtilities package exported from a RootSchema::BaseSchema::LoggingSchema schema. The import name provides a layer of indirection between the consumer of a package (the importer) and its producer (the exporter). It allows package name conflicts to be resolved by the importer of the package (where an importing schema wants to import two packages with the same name from different producers).

When referring to imported classes, code in the importing schema can prefix imported class names with the imported package name rather than having to specify the full schema path to the package. For details about the :: scope operator that allows you to do this, see "Accessing Meta Data", in Chapter 1.

A schema that exports a package cannot also import it. Packages imported by a schema are available to subschemas of the importing schema. Classes imported by a schema cannot be exported from that schema. You cannot change imported constants.

While local (importing schema) classes can define references to imported classes, imported classes cannot participate in inverse relationships with locally defined classes. Doing so would require modifying the structure of the imported class (to add inverse references), which is not permitted. It would also introduce a very tight (and potentially restrictive) coupling between an exporting schema and its importers.

For details about importing a package, see "Importing a Package", later in this chapter. See also the following subsections.