Exported Package Example

As the developer of LoggingPackageSchema, you decide that you want to make the public and read-only features (excluding create and delete methods, which cannot be exported) of LogManager, Log, and LogTagDict available for other schemas to use.

To do this using packages

  1. Define a package called Logging. Schemas can export multiple packages, but we only need one in this example.

  2. Add the LogManager class to the Logging package. When you add this class, you can specify the features of the class that you want to export so that you define an exported LogManager class, as follows.

    LogManager
        (
        exportedPropertyDefinitions
            allLogs;
        exportedMethodDefinitions
            createLog;
            deleteLog;
        )

    Note that only a subset of the LogManager implementation has been exported (create, delete, initialize, and finalize methods have not been exported). The exported LogManager class effectively provides an interface to services provided by the implementation LogManager class.

  3. Add the Log class to the Logging package and specify the features to be exported, as shown in the following pseudo schema file.

    Log
        (
        exportedPropertyDefinitions
            appTag;
            fileName;
            logTag;
        exportedMethodDefinitions
            close;
            log;
            open;
        )

    Again, only a subset of the Log class has been exported.

  4. Add the LogTagDict class to the Logging package, as follows.

    LogTagDict
        (
        )
  5. Specify the application that will be used at run time to initialize the package when it is opened (that is, when a process that uses the package is initiated) and to finalize the package when it is closed (that is, when the process terminates). When the package is opened, the initialize method of the specified application is invoked and when the package is closed, the finalize method of the specified application is invoked. You can use these methods to perform package-specific initialization and finalization logic.

The Logging package is now ready to be imported for use in another schema.