Effect of scalar field mass on gravitating charged scalar solitons and black holes in a cavity