Bose-Einstein condensation in a cavity