public function __construct(\blaze\collections\map\Properties $properties, \blaze\collections\ListI $ressources) { $driverName = $properties->getProperty('persistence.connection.datasource.class'); $dsUsername = $properties->getProperty('persistence.connection.datasource.username'); $dsPassword = $properties->getProperty('persistence.connection.datasource.password'); $dsOptions = $properties->getProperty('persistence.connection.datasource.options'); if ($driverName != null) { $dsClass = \blaze\lang\ClassWrapper::forName($driverName); $dsHost = $properties->getProperty('persistence.connection.datasource.host'); $dsPort = $properties->getProperty('persistence.connection.datasource.port'); $dsDatabase = $properties->getProperty('persistence.connection.datasource.database'); $this->ds = $dsClass->getMethod('getDataSource')->invokeArgs(null, array($dsHost, $dsPort, $dsDatabase, $dsUsername, $dsPassword, $dsOptions)); } else { $dsn = $properties->getProperty('persistence.connection.datasource.url'); $this->ds = \blaze\ds\DataSourceManager::getInstance()->getDataSource($dsn, $dsUsername, $dsPassword, $dsOptions); } $this->dialect = \blaze\lang\ClassWrapper::forName($properties->getProperty('persistence.dialect'))->newInstance(); foreach ($ressources as $ressource) { $this->loadMapping($ressource); } $this->properties = $properties; $this->ressources = $ressources; $this->freeConnections = new \blaze\collections\queue\Stack(); $this->usedConnections = new \blaze\collections\map\HashMap(); }
/** * This sets up connections to the data sources and creates databases * which are deleted at the end. */ protected function setupConnection() { $this->dsm = DataSourceManager::getInstance(); $this->assertNotNull($this->dsm); for ($i = 0; $i < count($this->bdsc); $i++) { $this->ds[$i] = $this->dsm->getDataSource($this->bdsc[$i]); $this->assertNotNull($this->ds[$i]); } for ($i = 0; $i < count($this->bdsc); $i++) { $this->con[$i] = $this->ds[$i]->getConnection(); $this->assertNotNull($this->con[$i]); } for ($i = 0; $i < count($this->bdsc); $i++) { $this->db[$i] = $this->con[$i]->createDatabase('test_db'); $this->assertNotNull($this->db[$i]); $this->assertEquals('test_db', $this->db[$i]->getDatabaseName()); } }