use factory to create the context.