[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [xmlblaster] Logging (Factory)



On  6 Nov, Marcel Ruff wrote:
>>
>>
>>>>2. It has its LogPluginInfo (stolen from PluginInfo - but without
>>>>  logging).
>>>>
>>>>      
>>>>
>>>What about keeping our PluginInfo, remove all unnecessary logs and only
>>>keep the single log.warn().

Sorry, I was unclear (and tired). The problem with PluginInfo is not so
much the logging, but that it's construcor requires a PluginManagerBase.
Our plugin manager is however not based on PluginManagerBase, because of
the logging problem, and therefore it can not be used as an argument
when creating PluginInfo.

I think we can chose between:

1. Accepting that logging is special. If you look at log4j for example
   you can see that log4j components is forbidden to use log4j for
   logging: it must use another api!

2. Create a I_PluginManager that PluginInfo take, and that both
   PluginManagerBase and LogDevicePluginManager can implement.

//Peter
>>>
>>>In Global.java you do something like this:
>>>
>>>
>>>   public LogChannel getLog(String key) {
>>>      I_Logger logger = hash.get(key);
>>>      if (logger == null) {
>>>         synchronized (this) {
>>>            if (logger == null) {
>>>               if (creatingInstance) return null; // !!!!
>>>               creatingInstance = true;
>>>               // call plugin ....
>>>               // this.logger = plugin.load()
>>>               creatingInstance = false;
>>>            }
>>>         }
>>>      }
>>>    
>>>
>>
>>Would this really work? Say this happens
>>glob.init->getLog()->getFactory().new PluginInfo->getLog()
>>
>>Would it not deadlock?
>>
> No, the same thread may recursively enter the this synchronize multiple 
> times.
> And as 'creatingInstance' is true the second time, it will return 'null'
> as logging handle - which you check in PluginInfo and probably ignore the
> log.warn (or do a System.err.out()).
> 
> 
>>
>>[snip]
>>  
>>
>>>>What do you say? Is it usable, acceptable, commitable?
>>>>
>>>>      
>>>>
>>>Michele and i just discussed  it.
>>>We are thankful if you donate this to xmlBlaster.org.
>>>
>>>    
>>>
>>
>>Thanks! I take another round tomorrow. Clean some stuff up and
>>documenting it: then commit ;-)
>>
> Ah, yes, don't forget a requirement XML :-)
> 
> thanks
> 
> Marcel
> 
>>
>>And thanks for your allways good input.
>>//Peter
>>  
>>

-- 
------------------------------------------------------------
Peter Antman	Chief Technology Officer, Development
Technology in Media, Box 34105 100 26 Stockholm
WWW: http://www.tim.se	WWW: http://www.backsource.org
Email: pra at tim.se	 
Phone: +46-(0)8-506 381 11 Mobile: +46-(0)704 20 58 11
------------------------------------------------------------