Imported Package Example
As a developer in DemoApplicationSchema, you now want to make use of the services provided by the Logging package. Use the JADE development environment to locate the Logging package and then import it into DemoApplicationSchema. This imports the LogManager, Log, and LogTagDict classes into DemoApplicationSchema, with the features exported by the LoggingPackageSchema developer. You can now use these classes and features in DemoApplicationSchema type-safely, as if they were locally defined classes. For example, you could now define the following references in DemoApplicationSchema to your application class.
myLogManager : LogManager; myExceptionLog : Log; myPollingLog : Log; myMsgLog : Log;
Class names imported in a package may conflict with locally defined classes. In such cases, you can use the package name to resolve name conflicts. For example, if LogManager and Log conflicted with locally defined classes, you could define the above references as follows.
myLogManager : Logging::LogManager; myExceptionLog : Logging::Log; myExceptionTest : Testing::Test; myPollingLog : Logging::Log; myMsgLog : Logging::Log;
Having defined the above references, you could write finalize and initialize methods like those shown in the following examples.
appInit() updating; begin create self.myLogManager transient; self.myExceptionLog := self.myLogManager.createLog('DEMO', 'ExLog', 'c:\temp\ex.log'); self.myPollingLog := self.myLogManager.createLog('DEMO', 'PollLog', 'c:\temp\poll.log'); self.myMsgLog := self.myLogManager.createLog('DEMO', 'MsgLog', 'c:\temp\msg.log'); self.myExceptionLog.open; self.myPollingLog.open; self.myMsgLog.open; self.myMsgLog.log('Opened logs ' & self.myExceptionLog.fileName & ' , ' & self.myPollingLog.fileName & ' , ' & self.myMsgLog.fileName); end;
appFini() updating; begin self.myLogManager.deleteLog(self.myExceptionLog); self.myLogManager.deleteLog(self.myPollingLog); self.myLogManager.deleteLog(self.myMsgLog); delete self.myLogManager; end;
The