rgoers commented on PR #1401:
URL: https://github.com/apache/logging-log4j2/pull/1401#issuecomment-1548085067

   I am thinking of when Scoped Variables come into play. Or if thread 
inheritance is required. don't want to have to go into the code and change the 
"name" passed to the factory. Instead, I would like to do:
   
   `Recycler recycler = RecyclerRegistry.get("name", spec)`
   
   where name represents the particular instance I want to access and spec is 
the Specification object. The Spec might contain
   
   private boolean inheritable;
   private String threadRelated;
   
   or other attributes. Based on this the factory could switch from using a 
ThreadLocal Recylcer to a ScopedVariableRecycler once it is available by only 
updating the Registry logic.
   In addition, using a registry means I can access the recycler instance when 
it is needed. Typically, a class has to declare a ThreadLocal as a class member 
and methods within that class reference it. With what I am proposing each 
method simply calls the get method to obtain the Recycler instance. Also, this 
allows:
   
   1. Different use cases to potentially share the same ThreadLocal (depending 
on their spec declaration)
   2. Intelligent cleanup of all Recycler instances. 
    
   Since the Recyclers above are just thin veneer around a ThreadLocal or queue 
the above two items cannot really be done. 
   
   Also, saying static registries are a problem flies in the face that Log4j 
has a ServiceRegistry, PropertiesUtil (the Property Registry), a Plugin 
registry, the LoggerContext is a registry of the application's Loggers, and the 
LoggerContextSelector is a registry of the LoggerContexts.  There are probably 
more but that is just what immediately came to mind.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to