[slf4j-user] Marker for object identification?

Boris Unckel boris.unckel.mlg at gmx.net
Thu Feb 8 23:12:44 CET 2007


Hi,

Ceki Gülcü wrote:
> That's a tough one. You could indeed create a marker with a given name, 
> delete it, and then recreate it with the same name. There could be classes 
> or objects referring to the old marker instance. They would be holding a 
> "dangling" reference. The old and new markers would behave the same, and 
> could be used interchangeably, as long as they contained the same children.
>
> Anyway, since most markers don't have children, and since deleting a marker 
> is only necessary when creating many markers dynamically, deletion should 
> not cause problems, even if it could be problematic under different 
> circumstances.
>
>   
>> So removing is not the best solution?
>>     
>
> I don't know. Do you have anything better in mind? :-)
Looks quite difficult[1]. As posted before in this thread a solution is 
needed (if MDC is not the best solution).

One possibility:
A child marker does not inherit "by reference" but "by value". Would mean:

p = Marker.getMarker("Parent");
c = p.getChild("child");
Marker.remove(p);
afterRemoveParent = Marker.getMarker("Parent");
// afterRemoveParent.equals(p) == true
afterRemoveChild = afterRemoveParent.getChild("child");
// afterRemoveChild.equals(c) == true

Comparing with '==' instead of the 'equals' method is in most cases bad 
practise, so most use cases could live with that compromise
to use the equals method.

Regards
Boris

[1] He very much enjoys writing software, altough he is discovering that 
it is far more difficult than what it might seem initially.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/slf4j-user/attachments/20070208/2aef0632/attachment.htm>


More information about the slf4j-user mailing list