At 10:14 PM 3/31/2003 -0500, you wrote:
Hello all,
I finally have more time as a major deadline has passed at work. I was thinking about writing an improved JDBC appender. My intention is to create a new appender from scratch. As discussed previously, I figured I would have an abstract base class with an abstract getConnection() class and two concrete derivatives; one for getting the connection from a JNDI context and one for getting the connection from the DriverManager.
As suggested by others, it is preferable to use composition to offer choices. Offering choices by derivation (or inheritance) is OK as long as you have a single choice, for example the connection type. However, if you would also like the offer a choice on say LoggingEvent to DB mapping, then inheritance will result in combinatorial explosion.
OK, I'm not really convinced, but since this is your architecture, I'll defer to your judgment. (See below for a related question.)
2) Is there a good place to look to get a feel for how the configuration works?
The options, a.k.a. properties, of appenders, layouts or filters are inferred dynamically using standard JavaBeans conventions. Any setter method taking a single primitive java type, an Integer, a Long, a String or a Boolean parameter implies an option name. For example, given that the FileAppender class contains setAppend(boolean), setBufferSize(int) and setFile(String) as member methods, then it follows that Append, BufferSize and File are all valid option names. Log4j can also deal with setter methods taking an org.apache.log4j.Level parameter. For example, since the AppenderSkeleton class[1] has setThreshold(Level) as a member method, Threshold is a valid option for all log4j appenders extending the AppenderSkeleton class.
In log4j version 1.3, you can also include sub-components in config files written in XML. Seeing a sub-element within an appender element, DOMConfigurator will automatically instantiate and configure the sub-element. I'll write complete example within the next few days. If I forget, please do not hesitate to remind me.
OK this part seems clear, but...
I'd like to do the connection factory above via an interface a la the layout. How do I make a property whose value is the name of a class that should be instantiated and then passed to the setter?
Thanks, Ray
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]