1 |
<?php |
<?php |
2 |
/** |
/** |
|
* --- @about |
|
|
* |
|
3 |
* This file contains the DataSource::Locator class. |
* This file contains the DataSource::Locator class. |
4 |
|
* |
5 |
* It acts as a container for DataSource connection |
* It acts as a container for DataSource connection |
6 |
* metadata. Think of it as an enhanced dsn. |
* metadata. Think of it as an enhanced dsn. |
7 |
* |
* |
8 |
* It gets used by DataSource::GenericDataSource |
* It gets used by DataSource::Generic |
9 |
* to be informed about the most important stuff it |
* to be informed about the most important stuff it |
10 |
* has to do. |
* has to do. |
11 |
* |
* |
12 |
* |
* |
|
* @author Andreas Motl <andreas.motl@ilo.de> |
|
13 |
* @package org.netfrag.glib |
* @package org.netfrag.glib |
14 |
* @module DataSource::Locator |
* @module DataSource::Locator |
15 |
* |
* |
19 |
* $Id$ |
* $Id$ |
20 |
* |
* |
21 |
* $Log$ |
* $Log$ |
22 |
|
* Revision 1.4 2003/03/05 15:26:23 joko |
23 |
|
* updated docu (phpDocumentor testing....) |
24 |
|
* |
25 |
|
* Revision 1.3 2003/03/05 15:21:54 joko |
26 |
|
* updated docu (phpDocumentor testing....) |
27 |
|
* |
28 |
|
* Revision 1.2 2003/03/05 15:01:10 joko |
29 |
|
* updated docu |
30 |
|
* |
31 |
* Revision 1.1 2003/03/05 12:04:37 joko |
* Revision 1.1 2003/03/05 12:04:37 joko |
32 |
* + initial commit |
* + initial commit |
33 |
* |
* |
35 |
*/ |
*/ |
36 |
|
|
37 |
/** |
/** |
38 |
* --- @description |
* It helps DataSource::Generic working in different "operation modes". |
39 |
* |
* |
40 |
* --- It helps GenericDataSource working in different "operation modes". |
* - Pass-Through-Reference: php Object will get passed through all layers |
41 |
|
* - Pass-Through-Memory: reference to a memory area will get used |
42 |
|
* + Build-Locator: build locator from datasource-type and adapter-type |
43 |
|
* - Use-Locator: directly use DataSource::Locator instance passed in |
44 |
|
* - Merge-Locators: merge metadata of two or more DataSource::Locator instances |
45 |
|
* - Build-AutoLocator: use global constants making up our metadata |
46 |
|
* |
47 |
|
* <b>It can/should contain:</b> |
48 |
|
* (flexible, just some parameters are required for each operation mode) |
49 |
|
* - an oldschool "dsn"-string (e.g. for rdbms-connection via PEAR) |
50 |
|
* + name of a Proxy module to use to *wrap/hide* the connection/transport-layer |
51 |
|
* (e.g. DataSource::Proxy::XMLRPC via DesignPattern::RemoteProxy) |
52 |
|
* + metadata (a hash) directly describing *where* to connect to (e.g. 'Host', 'Port') |
53 |
|
* - an instance of an already instantiated arbitrary datasource handler (e.g. 'source') |
54 |
|
* this will get propagated (pass-through-mode) |
55 |
|
* - a datasource-type (of 'rpc|mysql|csv-file|xml-file') |
56 |
|
* this will be mapped to a module name and used as a *Proxy* |
57 |
|
* by the DataSource::Generic at runtime |
58 |
|
* + an adapter-type (of 'phpHtmlLib|pear') |
59 |
|
* this will be mapped to a module name and used as an *Adapter* |
60 |
|
* by the DataSource::Generic at runtime |
61 |
|
* - names of global constants where to find these informations |
62 |
|
* - datasource-type ('rpc|csv-file|...') <-> datasource-family ('orm|rdbms|odbms') |
63 |
|
* |
64 |
|
* |
65 |
|
* <b>It can do</b> |
66 |
|
* + builds a larger locator from a minimum of information passed in via constructor-arguments |
67 |
|
* o direct fallback mode to some predefined constant names if locator is empty and above method fails |
68 |
|
* o direct fallback mode to some predefined values if just *everything* fails |
69 |
* |
* |
|
* o Pass-Through-Reference: php Object will get passed through all layers |
|
|
* o Pass-Through-Memory: reference to a memory area will get used |
|
|
* x Build-Locator: build locator from datasource-type and adapter-type |
|
|
* o Use-Locator: directly use DataSource::Locator instance passed in |
|
|
* o Merge-Locators: merge metadata of two or more DataSource::Locator instances |
|
|
* o Build-AutoLocator: use global constants making up our metadata |
|
|
* |
|
|
* |
|
|
* --- It can/should contain (flexible, just some parameters are required for each operation mode) |
|
|
* |
|
|
* o an oldschool "dsn"-string (e.g. for rdbms-connection via PEAR) |
|
|
* x name of a Proxy module to use to *wrap/hide* the connection/transport-layer |
|
|
* (e.g. DataSource::Proxy::XMLRPC via DesignPattern::RemoteProxy) |
|
|
* x metadata (a hash) directly describing *where* to connect to (e.g. 'Host', 'Port') |
|
|
* o an instance of an already instantiated arbitrary datasource handler (e.g. 'source') |
|
|
* this will get propagated (pass-through-mode) |
|
|
* x a datasource-type (of 'rpc|mysql|csv-file|xml-file') |
|
|
* this will be mapped to a module name and used as a *Proxy* |
|
|
* by the GenericDataSource at runtime |
|
|
* x an adapter-type (of 'phpHtmlLib|pear') |
|
|
* this will be mapped to a module name and used as an *Adapter* |
|
|
* by the GenericDataSource at runtime |
|
|
* o names of global constants where to find these informations |
|
|
* o datasource-type ('rpc|csv-file|...') <-> datasource-family ('orm|rdbms|odbms') |
|
|
* |
|
|
* |
|
|
* --- It can do |
|
|
* x builds a larger locator from a minimum of information passed in via constructor-arguments |
|
|
* o direct fallback mode to some predefined constant names if locator is empty and above method fails |
|
|
* o direct fallback mode to some predefined values if just *everything* fails |
|
70 |
* |
* |
71 |
* |
* <b>How to use?</b> |
|
* --- How to use? |
|
72 |
* |
* |
73 |
* Pass an array holding "locator metadata" to the constructor. |
* Pass an array holding "locator metadata" to the constructor. |
74 |
* This module takes care of the rest. |
* This module takes care of the rest. |
81 |
* [adapter_type => 'phpHtmlLib',] |
* [adapter_type => 'phpHtmlLib',] |
82 |
* metadata => array( Host => 'localhost', Port => '8765' ), |
* metadata => array( Host => 'localhost', Port => '8765' ), |
83 |
* ); |
* ); |
84 |
* $source = new GenericDataSource($locator); |
* $source = new DataSource::Generic($locator); |
85 |
* $this->set_data_source( &$source ); |
* $this->set_data_source( &$source ); |
86 |
* |
* |
87 |
* 2. [proposal] for common/oldschool datahandles.... |
* 2. [proposal] for common/oldschool datahandles.... |
88 |
* $locator = array( |
* $locator = array( |
89 |
* dsn => 'known dsn markup', |
* dsn => 'known dsn markup', |
90 |
* ); |
* ); |
91 |
* $source = new GenericDataSource($locator); |
* $source = new DataSource::Generic($locator); |
92 |
* $this->set_data_source( &$source ); |
* $this->set_data_source( &$source ); |
93 |
* |
* |
94 |
* |
* |
95 |
* |
* |
96 |
* @author Andreas Motl <andreas.motl@ilo.de> |
* @author Andreas Motl <andreas.motl@ilo.de> |
97 |
|
* @link http://www.netfrag.org/~joko/ |
98 |
* @copyright (c) 2003 - All Rights reserved. |
* @copyright (c) 2003 - All Rights reserved. |
|
* @license GNU LGPL (GNU Lesser General Public License) |
|
99 |
* |
* |
100 |
* @author-url http://www.netfrag.org/~joko/ |
* @license GNU LGPL (GNU Lesser General Public License) |
101 |
* @license-url http://www.gnu.org/licenses/lgpl.txt |
* @link http://www.gnu.org/licenses/lgpl.txt |
102 |
* |
* |
103 |
* @author Andreas Motl <andreas.motl@ilo.de> |
* @subpackage DataSource |
104 |
* @package org.netfrag.glib |
* @name DataSource::Locator |
105 |
* @module DataSource::Locator |
* @filesource |
106 |
* |
* |
107 |
*/ |
*/ |
108 |
|
|
175 |
// name of an Adapter module |
// name of an Adapter module |
176 |
var $_adapter_type; |
var $_adapter_type; |
177 |
|
|
178 |
// additional information required (passed on to the Proxy by GenericDataSource) |
// additional information required (passed on to the Proxy by DataSource::Generic) |
179 |
var $_metadata = array(); |
var $_metadata = array(); |
180 |
|
|
181 |
//var $_dsn; |
//var $_dsn; |
289 |
$metadata = array( |
$metadata = array( |
290 |
//package => 'Data::Driver::Proxy', |
//package => 'Data::Driver::Proxy', |
291 |
//package => 'DataSource::Proxy::XMLRPC', |
//package => 'DataSource::Proxy::XMLRPC', |
292 |
//package => 'DataSource::GenericDataSource', |
//package => 'DataSource::Generic', |
293 |
//package => 'DesignPattern::RemoteProxy', |
//package => 'DesignPattern::RemoteProxy', |
294 |
Host => RPC_HOSTNAME, |
Host => RPC_HOSTNAME, |
295 |
Port => RPC_PORT, |
Port => RPC_PORT, |