Difference between revisions of "AppGranule Code"

From DocDataFlow
Jump to: navigation, search
 
(5 intermediate revisions by one user not shown)
Line 1: Line 1:
The AppGranule class is derived from the [[Granule|''Granule'']] class.
+
The AppGranule class is derived from the [[Granule Code|''Granule'']] class.
  
It has a [[Class Identifier|''class identifier'']] of "com.rorohiko.granule.app".
+
It has a [[Class identifier|''class identifier'']] of <code>com.rorohiko.granule.app</code>.
  
AppGranule is a singleton-class: only one instance of AppGranule (or a subclass of AppGranule) is present during a Crawler session.
+
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:
 
The following static methods are provided:
  
AppGranule.activeAppGranuleFactory(): creates or retrieves the current AppGranule for the currently active app.  
+
* <code>AppGranule.activeAppGranuleFactory()</code>: 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.
+
* <code>appGranule.activeDocumentGranuleFactory()</code>: 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.  
+
* <code>appGranule.adapterFactory(adapterParentClass)</code>: 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.

Latest revision as of 01:51, 30 December 2013

The AppGranule class is derived from the Granule class.

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

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.