Microgrid needs the Energy Management System(EMS)to optimize and control Distributed Generation(DG),but the traditional software development models and middleware technologies are insufficient in module hot-plug capability and code invasion. Based on the 100 k W photovoltaic microgrid project in Anhui Polytechnic University,this paper proposes a microgrid EMS based on Distributed Open Service Gateway initiative(D-OSGi),and then discusses the aspect-oriented approach to extend the D-OSGi,software logical layers of EMS,energy scheduling strategies and changes of SCADA graphics primitive. The implementation approach of EMS in Xuancheng microgrid is presented,and some tests are done for typical modules' functionality. The results show that the system reduces the difficulties to customize and extend functions effectively,and it is convenient for power system related researchers to simulate microgrid control algorithms rapidly.