commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Baltz, Kenneth" <>
Subject RE: Digester Creational Rule Question
Date Fri, 07 Feb 2003 17:01:26 GMT
I believe you need a FactoryCreate rule.  This allows you to instantiate the
object of your choice after looking at the attributes.  Take a look at
ObjectCreationFactory in the Javadoc.  You'll have to create your own
instance of this object; it's easier if you extend
AbstractObjectCreationFactory.  I'm afraid I don't know what the XML config
looks like for this rule.  


-----Original Message-----
From: Maher Martin []
Sent: Friday, February 07, 2003 2:17 AM
To: ''
Subject: Digester Creational Rule Question


I've looked through all the examples I could find on using the Digester and
till now I haven't come across any way or instantiating a specific Bean
class depending on an attribute within the pattern of the element I'm
matching against. To explain what I'm trying to do consider the scenario


I've the following class structure

class BaseInput {}

class InputTypeX extends BaseInput {}

class InputTypeY extends BaseInput {}


and the following XML structure

	<input type="X">

	<input type="Y">

	<input type="X">


What I would like to do is during pattern matching, instantiate the correct
bean class depending on the input type. If the input contains the type="X"
then I want to instantiate the bean class "InputTypeX" and so on. Is this
possible with digester when specifying rules within an XML file? I know one
way of doing this would be to rename the <input> element to <input-x> or
<input-y> and instantiate the class based on the element name, but I want to
try and avoid this if possible.


Martin Maher

Webasto Informationssysteme GmbH
Department TTI
Gautinger Sta├če 23
D-82131 Stockdorf
Phone: (+49) (0)89 85794 1851
Fax: (+49) (0)89 899214 1851

 <<Maher Martin.vcf>> 

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message