Difference between revisions of "AppGranule Code"

From DocDataFlow
Jump to: navigation, search
Line 7: Line 7:
 
The following static methods are provided:
 
The following static methods are provided:
  
AppGranule.activeAppGranuleFactory(): creates or retrieves the current AppGranule for the currently active app.  
+
* AppGranule.activeAppGranuleFactory(): creates or retrieves the current AppGranule for the currently active app.  
  
 
The following methods are provided:
 
The following methods are provided:
  
appGranule.activeDocumentGranuleFactory(): creates or retrieves the DocumentGranule for the currently active document.
+
* 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.  
+
* 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.
 
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.

Revision as of 01:22, 30 December 2013

The AppGranule class is derived from the Granule class.

It has a class identifier of "com.rorohiko.granule.app".

AppGranule is a singleton-class: only one instance of AppGranule (or a subclass of AppGranule) is present during a Crawler session.

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.