package ndx.web.pay.system; import javax.servlet.ServletContextEvent; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.springframework.web.context.ContextLoaderListener; public class PayContextLoaderListener extends ContextLoaderListener { public static final String BUNDLE_CONTEXT_ATTRIBUTE = "org.springframework.osgi.web." + BundleContext.class.getName(); @Override public void contextInitialized(ServletContextEvent event) { Bundle bundle = org.osgi.framework.FrameworkUtil.getBundle(getClass()); BundleContext bctx = bundle.getBundleContext(); event.getServletContext().setAttribute(BUNDLE_CONTEXT_ATTRIBUTE, bctx); super.contextInitialized(event); } }