Jin Zhao wrote:
> 
> Hi Geeks,
> 
> I have a application based on  jakarta-log4j-1.1b, which   uses the old
> OptionHandler to deal with options/properties.
> Now in log4j-1.1b6, OptionHandler is deprecated. Since I know little about
> beans,  my question is, how can I use the current framework to do the old
> job of OptionHandler?

Basically, the JavaBeans method is to ionvoke regular Java methods for
setting properties, and not to rely on methods like getOptionStrings()
and setOption(). The entity setting the property uses reflection or the
JavaBeans introspection (which itself uses reflection) to figure out
which properties are available for a particular Java object and what the
types of those properties are (String, boolean, int, ...)

> 
> For example, I need to know options used in a object, which can be done with
> the old getOptionStrings(). How can I do that now ?

Have a look at PropertySetter, PropertyGetter in org.apache.log4j.config
and java.beans.Introspector. It's basically a matter of using the
JavaBeans Introspector.

> Also what is the replacement of setOption(key, value)?

Object-specific setter methods, for example, setFile(String name) for
FileAppender or setFacility(String factility) for SyslogAppender. There
is no longer a single generic method for setting any option on any
component.

 The reason I use
> these two APIs is because I may not know what kind of properties/options
> included in an object, but I can also set and get them conveniently.

> 
> Here is a quesiton for java bean. Can anybody tell me what design patterns
> used in beans to deal with object and properties? Flyweight?

Reflection. Knowledge of properties is inferred from the component
itself by reflection.

--
Anders Kristensen

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to