private $hubIsAnnounced = false;
/**
- * Node state instance
+ * State instance
*/
- private $nodeStateInstance = null;
+ private $stateInstance = null;
/**
* Protected constructor
// Call parent constructor
parent::__construct($className);
- // Init node state which sets the state to 'init'
- $this->initNodeState();
+ // Init state which sets the state to 'init'
+ $this->initState();
}
/**
*
* @return void
*/
- private function initNodeState() {
+ private function initState() {
// Get the state factory and create the initial state, we don't need
// the state instance here
- NodeStateFactory::createNodeStateInstanceByName('init', $this);
+ StateFactory::createStateInstanceByName('init', $this);
}
/**
}
/**
- * Setter for node state instance
+ * Setter for state instance
*
- * @param $nodeStateInstance Node's current state instance
+ * @param $stateInstance Node's current state instance
* @return void
*/
- public final function setNodeStateInstance (NodeStateable $nodeStateInstance) {
- $this->nodeStateInstance = $nodeStateInstance;
+ public final function setStateInstance (Stateable $stateInstance) {
+ $this->stateInstance = $stateInstance;
}
/**
- * Getter for node state instance
+ * Getter for state instance
*
- * @return $nodeStateInstance Node's current state instance
+ * @return $stateInstance Node's current state instance
*/
- public final function getNodeStateInstance () {
- return $this->nodeStateInstance;
+ public final function getStateInstance () {
+ return $this->stateInstance;
}
/**
$stateName = 'null';
// Get the state instance
- $stateInstance = $this->getNodeStateInstance();
+ $stateInstance = $this->getStateInstance();
- // Is it an instance of NodeStateable?
- if ($stateInstance instanceof NodeStateable) {
+ // Is it an instance of Stateable?
+ if ($stateInstance instanceof Stateable) {
// Then use that state name
$stateName = $stateInstance->getStateName();
} // END - if
$this->debugOutput('BOOTSTRAP: Created new session-id: ' . $this->getSessionId() . '');
// Change the state because the node has auired a hub id
- $this->getNodeStateInstance()->nodeGeneratedSessionId();
+ $this->getStateInstance()->nodeGeneratedSessionId();
}
/**
$this->debugOutput('HUB: Self-announcement: START (taskInstance=' . $taskInstance->__toString(). ')');
// Get a helper instance
- $helperInstance = ObjectFactory::createObjectByConfiguredName('hub_descriptor_class', array($this));
+ $helperInstance = ObjectFactory::createObjectByConfiguredName('hub_announcement_helper_class', array($this));
// Load the announcement descriptor
$helperInstance->loadAnnouncementDescriptor();
// Set some dummy configuration entries, e.g. node_status
- $this->getConfigInstance()->setConfigEntry('node_status', $this->getNodeStateInstance()->getStateName());
+ $this->getConfigInstance()->setConfigEntry('node_status', $this->getStateInstance()->getStateName());
// Compile all variables
$helperInstance->getTemplateInstance()->compileConfigInVariables();
$helperInstance->publishAnnouncementDescriptor();
// Change the state, this should be the last line except debug output
- $this->getNodeStateInstance()->nodeAnnouncedToUpperHubs();
+ $this->getStateInstance()->nodeAnnouncedToUpperHubs();
die("OK!\n");
// Debug output
// ----------------------- Last step from here ------------------------
// Activate the hub. This is ALWAYS the last step in this method
- $this->getNodeStateInstance()->nodeIsActivated();
+ $this->getStateInstance()->nodeIsActivated();
// ---------------------- Last step until here ------------------------
}
public function determineIfHubIsActive () {
// Check the state
// @TODO Add more states e.g. 'firewalled', 'senior'
- $isActive = ($this->getNodeStateInstance() instanceof NodeActiveState);
+ $isActive = ($this->getStateInstance() instanceof NodeActiveState);
// Return value
return $isActive;