servicelocal.java
来自「struts+hibernate+spring框架实现」· Java 代码 · 共 45 行
JAVA
45 行
package com.cvicse.myssh.spring.service;
import org.springframework.context.ApplicationContext;
public class ServiceLocal {
/**
* ApplicationContext.
*/
private static ApplicationContext context;
/**
* @return 返回 context。
*/
protected static ApplicationContext getContext() {
return ServiceLocal.context;
}
/**
* @param cntext
* 要修改的 context。
*/
protected static void setContext(final ApplicationContext cntext) {
ServiceLocal.context = cntext;
}
/**
* Creates new ServiceLocator object.
*/
private ServiceLocal() {
}
/**
* get manager service.
* @param service
* service name
* @return manager service
*/
public static Object getService(final String service) {
System.out.println(context);
return context.getBean(service);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?