final Class<? extends EntityTypeFactory> entityTypeFactory = responseHint.entityTypeFactory();
return new EntityExtractor()
{
public Object extractEntity(ClientRequestContext context, Object... args)
{
EntityTypeFactory factory = null;
try
{
factory = entityTypeFactory.newInstance();
}
catch (InstantiationException e)
{
throw (context.getClientResponse())
.createResponseFailure("Could not create a default entity type factory of type "
+ entityTypeFactory.getClass().getName());
}
catch (IllegalAccessException e)
{
throw ((BaseClientResponse<?>) context.getClientResponse())
.createResponseFailure("Could not create a default entity type factory of type "
+ entityTypeFactory.getClass().getName() + ". " + e.getMessage());
}
context.getClientResponse().setReturnType(
factory.getEntityType(((BaseClientResponse<?>) context.getClientResponse()).getStatus(),
((BaseClientResponse<?>) context.getClientResponse()).getMetadata()));
return context.getClientResponse();
}
};
}