use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
use Org\Mxchange\CoreFramework\Generic\FrameworkException;
use Org\Mxchange\CoreFramework\Handler\Stream\IoHandler;
+use Org\Mxchange\CoreFramework\Middleware\Compressor\CompressorChannel;
// Import SPL stuff
use \SplFileInfo;
*/
private $fileIoInstance = NULL;
+ /**
+ * A Compressor instance
+ */
+ private $compressorChannelInstance = NULL;
+
/**
* The protected constructor. Do never instance from outside! You need to
* set a local file path. The class will then validate it.
$databaseInstance = new CachedLocalFileDatabase();
// Get a new compressor channel instance
- $compressorInstance = ObjectFactory::createObjectByConfiguredName('compressor_channel_class');
+ $compressorChannelInstance = ObjectFactory::createObjectByConfiguredName('compressor_channel_class');
// Set the compressor channel
- $databaseInstance->setCompressorChannel($compressorInstance);
+ $databaseInstance->setCompressorChannelInstance($compressorChannelInstance);
// Get a file IO handler
$fileIoInstance = ObjectFactory::createObjectByConfiguredName('file_io_class');
$this->fileIoInstance = $fileIoInstance;
}
+ /**
+ * Setter for compressor channel
+ *
+ * @param $compressorChannelInstance An instance of a CompressorChannel class
+ * @return void
+ */
+ protected final function setCompressorChannelInstance (CompressorChannel $compressorChannelInstance) {
+ $this->compressorChannelInstance = $compressorChannelInstance;
+ }
+
+ /**
+ * Getter for compressor channel
+ *
+ * @return $compressorChannelInstance An instance of a CompressorChannel class
+ */
+ protected final function getCompressorChannelInstance () {
+ return $this->compressorChannelInstance;
+ }
+
/**
* Reads a local data file and returns it's contents in an array
*
$compressedData = $compressedData['data'];
// Decompress it
- $serializedData = $this->getCompressorChannel()->getCompressor()->decompressStream($compressedData);
+ $serializedData = $this->getCompressorChannelInstance()->getCompressor()->decompressStream($compressedData);
// Unserialize it
$dataArray = json_decode($serializedData, true);
// Serialize and compress it
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Flushing ' . count($dataArray) . ' elements to database file ' . $infoInstance . ' ...');
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: dataArray=' . print_r($dataArray, true));
- $compressedData = $this->getCompressorChannel()->getCompressor()->compressStream(json_encode($dataArray));
+ $compressedData = $this->getCompressorChannelInstance()->getCompressor()->compressStream(json_encode($dataArray));
// Write this data BASE64 encoded to the file
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Writing ' . strlen($compressedData) . ' bytes ...');