You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Leo Sutic <le...@inspireinfrastructure.com> on 2003/03/03 11:48:22 UTC

[logkit] Closeable


> From: Peter Donald [mailto:peter@realityforge.org] 
> 
> Hi,
> 
> I have added a Closeable interface into Logkit

OK, but even with a closeable interface the question is:

  If a LogTarget wraps another LogTarget, should it
  close the wrapped target when it is closed?

The answer so far is *no*. OK, so we can solve this in
two ways (I'm sure there are more):

 1. Include a flag indicating close or not:

      LogTarget myWrappedTarget = 
          new WrappedLogTarget (targetToWrap, 
                                true /* close targetToWrap when 
                                        myWrappedTarget is closed */ );

    Default to false (don't close) to maintain backwards
    compatibility.

 2. Change the answer to "yes" - that is, if a LogTarget wraps 
    another LogTarget, it should close the wrapped target when 
    it is closed. We can then inhibit the closing by introducing 
    a NonClosingWrapper that will *not* propagate the close()
    call to the wrapped target.

    a:
      LogTarget myWrappedTarget = 
          new WrappedLogTarget (targetToWrap);
      myWrappedTarget.close (); // Closes targetToWrap as well

    b:
      LogTarget myWrappedTarget = 
          new WrappedLogTarget (
              new NonClosingWrapper (targetToWrap));
      myWrappedTarget.close (); // Does not close targetToWrap 

Thoughts?

We could get this thing into LogKit1.2.1 or LogKit1.3.

/LS


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: [logkit] Closeable

Posted by Peter Donald <pe...@realityforge.org>.
On Wed, 5 Mar 2003 00:36, Leo Sutic wrote:
> > Why can't a central manager component who tracks all targets do
> > the closing?
>
> Well, let's turn the question around: Why should we force that pattern
> on the developer? The idea of having wrappers working like the
> InputStream wrappers is because Java developers will understand how
> it works as it is similar to patterns established by InputStream etc.
>
> I'm sure that you can solve it with a central manager component, but
> why make that the only pattern?

Mainly as it is the pattern for the rest of the LogTargets. You need 
centralized management to know when you can validly close them etc. as they 
could also be shared. 

That said feel free to add an optional closing param to ctor :)

-- 
Cheers,

Peter Donald
--------------------------------
My opinions may have changed, 
but not the fact that I am right
-------------------------------- 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


RE: [logkit] Closeable

Posted by "Noel J. Bergman" <no...@devtech.com>.
Leo,

What I described as a mechanism by which you could, yes, implement such a
scheme.  But the actual implementation of the scheme is opaque.

	--- Noel

-----Original Message-----
From: Leo Sutic [mailto:leo.sutic@inspireinfrastructure.com]
Sent: Wednesday, March 05, 2003 7:42
To: 'Avalon Developers List'
Subject: RE: [logkit] Closeable


Would this be similar to some reference-counting scheme?

I.e. for each new client, increment an "open" counter, and for
each close, decrement that counter. Final closure when counter
hits zero again?

/LS

> From: Noel J. Bergman [mailto:noel@devtech.com]
>
> That provides a
> non-centralized mechanism for managing final closure.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


RE: [logkit] Closeable

Posted by Leo Sutic <le...@inspireinfrastructure.com>.
Would this be similar to some reference-counting scheme?

I.e. for each new client, increment an "open" counter, and for
each close, decrement that counter. Final closure when counter
hits zero again?

/LS

> From: Noel J. Bergman [mailto:noel@devtech.com] 
>
> That provides a 
> non-centralized mechanism for managing final closure.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


RE: [logkit] Closeable

Posted by "Noel J. Bergman" <no...@devtech.com>.
Leo,

The fact that LogTargets can be shared is compelling.  One way to do this
would be for each LogTarget to provide a pseudo-target to log clients.  That
provides a non-centralized mechanism for managing final closure.  This is
similar to the pattern used by COS Event Services for multiplexing.  I'm
probably not explaining this well, but if you want I can give it another
shot later.

	--- Noel


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


RE: [logkit] Closeable

Posted by Leo Sutic <le...@inspireinfrastructure.com>.

> From: Peter Donald [mailto:peter@realityforge.org] 
> 
> On Mon, 3 Mar 2003 21:48, Leo Sutic wrote:
> > > From: Peter Donald [mailto:peter@realityforge.org]
> > >
> > > Hi,
> > >
> > > I have added a Closeable interface into Logkit
> >
> > OK, but even with a closeable interface the question is:
> >
> >   If a LogTarget wraps another LogTarget, should it
> >   close the wrapped target when it is closed?
> >
> > The answer so far is *no*. OK, so we can solve this in
> > two ways (I'm sure there are more):
> 
> Does it need solving? In many situations one target may be in 
> a chain and the wrapper logtarget may wrap part of the chain. 
> Having the wrapper close the target could effect other targets 
> who share the chains.

Yes, that's why both my attempts make it optional to close the
wrapped target.

> Why can't a central manager component who tracks all targets do 
> the closing?

Well, let's turn the question around: Why should we force that pattern 
on the developer? The idea of having wrappers working like the
InputStream wrappers is because Java developers will understand how
it works as it is similar to patterns established by InputStream etc.

I'm sure that you can solve it with a central manager component, but
why make that the only pattern?

As Michael Bachran stated in:

    http://marc.theaimsgroup.com/?l=avalon-dev&m=104496210014916&w=2

there is a use case for having wrapper targets close the wrapped target.

/LS


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: [logkit] Closeable

Posted by Peter Donald <pe...@realityforge.org>.
On Mon, 3 Mar 2003 21:48, Leo Sutic wrote:
> > From: Peter Donald [mailto:peter@realityforge.org]
> >
> > Hi,
> >
> > I have added a Closeable interface into Logkit
>
> OK, but even with a closeable interface the question is:
>
>   If a LogTarget wraps another LogTarget, should it
>   close the wrapped target when it is closed?
>
> The answer so far is *no*. OK, so we can solve this in
> two ways (I'm sure there are more):

Does it need solving? In many situations one target may be in a chain and the 
wrapper logtarget may wrap part of the chain. Having the wrapper close the 
target could effect other targets who share the chains. Why can't a central 
manager component who tracks all targets do the closing?

-- 
Cheers,

Peter Donald
-----------------------------------------------------
When a stupid man is doing something he's ashamed of, 
he always declares that it is his duty.
					George Bernard Shaw 
-----------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org