in src/java/org/apache/fulcrum/parser/DefaultParserService.java [263:348]
public <P extends ValueParser> P getParser(Class<P> ppClass) throws InstantiationException
{
P vp = null;
try
{
if (useFulcrumPool) {
try
{
P parserInstance = (P) fulcrumPoolService.getInstance(ppClass);
vp = parserInstance;
}
catch (PoolException pe)
{
throw new InstantiationException("Parser class '" + ppClass + "' is illegal. " + pe.getMessage());
}
} else if ( ppClass.equals(BaseValueParser.class) )
{
BaseValueParser parserInstance = null;
try {
parserInstance = valueParserPool.borrowObject();
vp = (P) parserInstance;
if (vp == null) {
throw new InstantiationException("Could not borrow object from pool: " + valueParserPool);
}
} catch (Exception e) {
try {
valueParserPool.invalidateObject(parserInstance);
parserInstance = null;
} catch (Exception e1) {
throw new InstantiationException("Could not invalidate object " + e1.getMessage() + " after exception: " + e.getMessage());
}
}
} else if ( ppClass.equals(DefaultParameterParser.class) )
{
DefaultParameterParser parserInstance = null;
try {
parserInstance = parameterParserPool.borrowObject();
vp = (P) parserInstance;
if (vp == null) {
throw new InstantiationException("Could not borrow object from pool: " + parameterParserPool);
}
} catch (Exception e) {
try {
parameterParserPool.invalidateObject(parserInstance);
parserInstance = null;
} catch (Exception e1) {
throw new InstantiationException("Could not invalidate object " + e1.getMessage() + " after exception: " + e.getMessage());
}
}
} else if ( ppClass.equals(DefaultCookieParser.class) )
{
DefaultCookieParser parserInstance = null;
try {
parserInstance = cookieParserPool.borrowObject();
vp = (P) parserInstance;
if (vp == null) {
throw new InstantiationException("Could not borrow object from pool: " + cookieParserPool);
}
} catch (Exception e) {
try {
cookieParserPool.invalidateObject(parserInstance);
parserInstance = null;
} catch (Exception e1) {
throw new InstantiationException("Could not invalidate object " + e1.getMessage() + " after exception: " + e.getMessage());
}
}
}
if (vp != null && vp instanceof ParserServiceSupport ) {
((ParserServiceSupport)vp).setParserService(this);
} else {
throw new InstantiationException("Could not set parser");
}
if (vp instanceof LogEnabled)
{
((LogEnabled)vp).enableLogging(getLogger().getChildLogger(ppClass.getSimpleName()));
}
}
catch (ClassCastException x)
{
throw new InstantiationException("Parser class '" + ppClass + "' is illegal. " + x.getMessage());
}
return vp;
}