AppGranule Code

From DocDataFlow
Jump to: navigation, search

The AppGranule class is derived from the Granule class.

It has a class identifier of

AppGranule is currently a singleton-class: only one instance of AppGranule (or a subclass of AppGranule) is present during a Crawler session. Future versions of Crawler might support multi-app conversions, where the Crawler dataflow is hosted by multiple concurrent apps.

The following static methods are provided:

  • AppGranule.activeAppGranuleFactory(): creates or retrieves the current AppGranule for the currently active app.

The following methods are provided:

  • appGranule.activeDocumentGranuleFactory(): creates or retrieves the DocumentGranule for the currently active document.
  • appGranule.adapterFactory(adapterParentClass): create a new app-specific adapter which is a subclass of the adapterParentClass.

At present, this is used to ask the current appGranule for a disassembler. Because the Crawler system does not know what document types it is processing, it relies on the currently active appGranule to provide it with the correct document disassembler for document conversion.

The predefined ViewExporter uses the equivalent of the following code to get hold of a disassembler:

            var appGranule = AppGranule.activeAppGranuleFactory();
            var disassembler = appGranule.adapterFactory(Disassembler);

The ViewExporter does need to not 'know' what app is currently active: it gets hold of the singleton appGranule, and then asks that appGranule to provide it with a proper disassembler to break the document apart into smaller granules.