thekid/rfc — Issue #24: RFC 0024: ResourceManager
Author: thekid
Created: 2011-10-09 14:15:41+00:00
State: open
Labels: draft, rfc

Scope of Change
====
A new singleton named ResourceManager will be added. It will hold
database connections, webservice endpoints, LDAP urls, mail connections
and remote specs.

Rationale
====
While a efficient method exists to manage database connections there is
currently no way for other resources.

Functionality
====

Resource interface
----

```php

```

Resource classes
----
* rdbms.DBConnection (and its subclasses)
* peer.ldap.LdapConnection
* util.log.LogCategory
* util.Properties
* remote.Remote

ResourceManager
----

```php

```

Example #1: Registering the database connection to the "orders" database
----

```php
bind(
'/xp/rdbms/orders',
DriverManager::getConnection('mysql://...')
);
?>
```

Example #2: Get an rdbms.DBConnection instance by name "orders"
----

```php
lookup('/xp/rdbms/orders');
?>
```

Security considerations
====
n/a

Speed impact
====
n/a

Dependencies
====
- xp-framework/rfc #147 - LdapConnection

Related documents
====
- EJB 3.0 Dependency Injection Annotations
http://www.caucho.com/resin-3.0/ejb3/bean-ann.xtp#@Inject

- Initial implementation
http://experiments.xp-framework.net/?people,friebe,resourcepool

- Inversion of Control Containers and the Dependency Injection pattern
http://www.martinfowler.com/articles/injection.html

Comments
====
- friebe, Wed May 11 16:53:13 CEST 2005
Is requires() a good idea? Do we want to "waste" new syntax for this?

- friebe, Fri May 13 11:59:32 CEST 2005
Maybe we should use the static initializer? Is setupFor() a good name?

- friebe, Sun May 29 17:53:17 2005
bind() sounds better.

- friebe, Sun May 29 18:25:54 2005
Static initializer won't work because we're initializing instance
variables. We need to invoke bind() in the constructor.

- friebe, Wed Jun 28 12:10:04 CEST 2006
Maybe ResourcePool::attachTo($this); is better than
ResourcePool::injectFor($this);?

- friebe, Sun Dec 17 17:27:47 2006
RFC rewritten completely