{
IEngineService service = (IEngineService) serviceClass.newInstance();
String serviceName = service.getName();
if (!service.getName().equals(name))
throw new ApplicationRuntimeException(
Tapestry.format(
"AbstractEngine.service-name-mismatch",
name,
className,
serviceName));
// Replace the class name with an instance
// of the named class.
entry.setValue(service);
}
catch (InstantiationException ex)
{
String message =
Tapestry.format(
"AbstractEngine.unable-to-instantiate-service",
name,
className);
LOG.error(message, ex);
throw new ApplicationRuntimeException(message, ex);
}
catch (IllegalAccessException ex)
{
String message =
Tapestry.format(
"AbstractEngine.unable-to-instantiate-service",
name,
className);
LOG.error(message, ex);
throw new ApplicationRuntimeException(message, ex);
}
}
// Result should not be modified after this point, for threadsafety issues.
// We could wrap it in an unmodifiable, but for efficiency we don't.