in commons-digester3-core/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java [290:350]
public void begin( final String namespace, final String name, final Attributes attributes )
throws Exception
{
Class<?> clazz = this.clazz;
if ( clazz == null )
{
// Identify the name of the class to instantiate
String realClassName = className;
if ( attributeName != null )
{
final String value = attributes.getValue( attributeName );
if ( value != null )
{
realClassName = value;
}
}
if ( getDigester().getLogger().isDebugEnabled() )
{
getDigester().getLogger().debug( format( "[ObjectCreateRule]{%s} New '%s'",
getDigester().getMatch(),
realClassName ) );
}
// Instantiate the new object and push it on the context stack
clazz = getDigester().getClassLoader().loadClass( realClassName );
}
Object instance;
if ( constructorArgumentTypes == null || constructorArgumentTypes.length == 0 )
{
if ( getDigester().getLogger().isDebugEnabled() )
{
getDigester()
.getLogger()
.debug( format( "[ObjectCreateRule]{%s} New '%s' using default empty constructor",
getDigester().getMatch(),
clazz.getName() ) );
}
instance = clazz.newInstance();
}
else
{
if ( proxyManager == null )
{
final Constructor<?> constructor = getAccessibleConstructor( clazz, constructorArgumentTypes );
if ( constructor == null )
{
throw new SAXException(
format( "[ObjectCreateRule]{%s} Class '%s' does not have a constructor with types %s",
getDigester().getMatch(),
clazz.getName(),
Arrays.toString( constructorArgumentTypes ) ) );
}
proxyManager = new ProxyManager( clazz, constructor, defaultConstructorArguments, getDigester() );
}
instance = proxyManager.createProxy();
}
getDigester().push( instance );
}