Abstract:This paper presents an approach to optimizing performance of middleware applications based on anti-pattern. This approach has three major features: First, a meta-model is offered to build more understandable and formalized representation of anti-patterns; second, the detection of anti-patterns is based on both the static and the dynamic information, which is retrieved at runtime; third, refactorings operate without interrupt the running systems, and is completed in an automated way with the help of the middleware. A prototype based on J2EE has been developed and an e-bookstore is used as a running example to illustrate the ideas introduced in this approach.