// Disable language support
$templateInstance->enableLanguageSupport(false);
+ // Enable compacting/rewriting of the XML to save bandwidth from XML
+ // comments. This is expensive and should be avoided in general.
+ $templateInstance->enableXmlCompacting();
+
// Set it for later use
$this->setTemplateInstance($templateInstance);
// Read the XML descriptor
$this->getTemplateInstance()->loadAnnouncementTemplate('self_announcement');
- // Get the prepared content
- $announcementContent = $this->getTemplateInstance()->getRawTemplateData();
+ // Render the XML content
+ $this->getTemplateInstance()->renderXmlContent();
+ }
+
+ /**
+ * Publishes the node's descriptor XML to all found upper nodes when the
+ * node has not yet published it's descriptor to a bootstrap node. This is
+ * done by getting the raw XML content and inserting all variables into
+ * the code. After this wents fine, the rendered content got "packaged"
+ * for network delivery.
+ *
+ * @return void
+ */
+ public function publishAnnouncementDescriptor () {
+ // Is the node in the approx state? (active)
+ $this->getNodeInstance()->getStateInstance()->validateNodeStateIsActive();
+
+ // Compile the template, this inserts the loaded node data into the gaps.
+ $this->getTemplateInstance()->compileTemplate();
+
+ // Prepare the compressor for our package, GZIP should be fine but we
+ // keep it open here so you can experiment with the settings and don't
+ // need to touch any code.
+ $compressorInstance = ObjectFactory::createObjectByConfiguredName('raw_package_compressor_class');
+
+ // Prepare the decorator compressor (for later flawless and easy updates)
+ $compressorInstance = ObjectFactory::createObjectByConfiguredName('deco_package_compressor_class', array($compressorInstance));
+
+ // Now prepare the network package for delivery so only need to do this
+ // once just before the "big announcement loop".
+ $packageInstance = ObjectFactory::createObjectByConfiguredName('network_package_class', array($compressorInstance));
+
+ // Enable re-queue support which re-queues the below feeded content
+ // into the delivery method all over again.
+ $packageInstance->enableDataReQueueing();
+
+ // Next, feed the content in. The network package class is a pipe-through class.
+ $packageInstance->queueRawDataFromTemplate($this->getTemplateInstance());
- // Render it here
- $this->getTemplateInstance()->renderXmlContent($announcementContent);
+ // Debug only:
+ /* DEBUG: */ die(print_r($this->getTemplateInstance(), true));
}
}