On Sun, 17 Feb 2002 04:58, Leo Sutic wrote:
> Suppose we have:
>
> interface ComponentManager {
>   Component lookup (String role);
> }
>
> and we have a container
>
> class Container {
>   ComponentManager manager;
> }
>
> that passes on requests to
>
> interface RequestHandler {
>   void handle (Request req);
> }
>
> Now, how does the Container tell the CM to release components that
> the RequestHandler used in handle(Request)?

Look at phoenix or alternatively it could look like this.

class Container {
  HashMap components;
}

class ContainerComponentManager implements ComponentManager {
}

> The thing I do not see how it works is: How can the container, unless
> it knows more about the CM than what the release-less interface provides,
> release components?

The CM is just a facade about the underlying store in the container - you can 
provide whatever mechanisms you want by putting a lil logic in the CM.

> Also, how do you handle the case when you have a component that uses
> a pooled resource, but is rarely used?
>
> For example:
>
> class SeldomlyUsedComponent implements Poolable {
>
>   DBConnection connection;
>
>   public doThis () {
>     connection.x ();
>   }
> }
>
> Should SeldomlyUsedComponent lookup the connection in doThis, and in
> that case, who manages the per-request CM management?

public doThis( Request r ) {
  ((DBConnection)r.getComponentManager().lookup( DBConnection.ROLE )).x();
}

-- 
Cheers,

Pete

The big mistake that men make is that when they turn thirteen or fourteen and
all of a sudden they've reached puberty, they believe that they like women.
Actually, you're just horny. It doesn't mean you like women any more at
twenty-one than you did at ten.                --Jules Feiffer (cartoonist)

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to