package com.wonders.core.util.web;
import java.util.Map;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* 获取ApplicationContext和Object的工具类
* @author zjw
*
* 非WEB项目
* ApplicationContext ac = new FileSystemXmlApplicationContext("applicationContext.xml")
* 可选的操作方法有:
* 1\
* String[] path={"WebRoot/WEB-INF/applicationContext.xml","WebRoot/WEB-INF/applicationContext_task.xml"};
* ApplicationContext context = new FileSystemXmlApplicationContext(path);
* 2\
* String path="WebRoot/WEB-INF/applicationContext*.xml";
* ApplicationContext context = new FileSystemXmlApplicationContext(path);
* 3\
* ApplicationContext ctx = new FileSystemXmlApplicationContext("classpath:地址");
* 没有classpath的话就是从当前的工作目录
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public class SpringContextUtil implements ApplicationContextAware {
private static ApplicationContext applicationContext;
public void setApplicationContext(ApplicationContext appContext) throws BeansException {
applicationContext = appContext;
}
/**
*
* 获取applicationContext对象
* @return
*
*/
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
/**
*
* 根据bean的id来查找对象
* @param id
* @return
*
*/
public static Object getBeanById(String id) {
return applicationContext.getBean(id);
}
/**
*
* 根据bean的class来查找对象
* @param c
* @return
*
*/
public static Object getBeanByClass(Class c) {
return applicationContext.getBean(c);
}
/**
*
* 根据bean的class来查找所有的对象(包括子类)
* @param c
* @return
*
*/
public static Map getBeansByClass(Class c) {
return applicationContext.getBeansOfType(c);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
restful.zip (96个子文件)
restful
.project 1KB
WebContent
WEB-INF
classes
spring-mybatis.xml 6KB
com
wonders
client
UserClient.class 3KB
core
service
UserService.class 294B
impl
UserServiceImpl.class 1KB
dao
impl
UserDaoImpl.class 1KB
UserDao.xml 570B
UserDao.class 373B
util
web
SpringContextUtil.class 1KB
app
bean
User.class 1KB
server
rest
RestApplication.class 666B
resources
HelloResource.class 1KB
UserResource.class 1KB
jdbc.properties 754B
mybatis-config.xml 2KB
lib
jersey-common.jar 699KB
mybatis-spring-1.3.0.jar 52KB
spring-expression-4.3.0.RELEASE.jar 258KB
slf4j-api-1.7.12.jar 31KB
spring-context-support-4.3.0.RELEASE.jar 183KB
spring-retry-1.1.2.RELEASE.jar 106KB
jersey-container-servlet-core.jar 65KB
spring-test-4.3.0.RELEASE.jar 574KB
spring-bridge-2.3.0-b10.jar 13KB
spring-websocket-4.3.0.RELEASE.jar 437KB
druid-1.0.25.jar 2.02MB
jersey-spring3-2.4.1.jar 21KB
persistence-api-1.0.jar 51KB
log4j-core-2.2.jar 807KB
jersey-guava-2.25.1.jar 949KB
org.osgi.core-4.2.0.jar 241KB
spring-jdbc-4.3.0.RELEASE.jar 416KB
mybatis-3.4.1.jar 1.51MB
javassist-3.20.0-GA.jar 733KB
asm-4.2.jar 47KB
slf4j-log4j12-1.7.12.jar 9KB
aspectjweaver-1.8.1.jar 1.77MB
jersey-media-jaxb.jar 71KB
spring-core-4.3.0.RELEASE.jar 1.06MB
validation-api-1.1.0.Final.jar 62KB
spring-aspects-4.3.0.RELEASE.jar 57KB
jersey-container-servlet.jar 18KB
hk2-utils-2.5.0-b32.jar 132KB
spring-web-4.3.0.RELEASE.jar 790KB
mysql-connector-java-5.1.39.jar 966KB
spring-orm-4.3.0.RELEASE.jar 464KB
javax.inject-2.5.0-b32.jar 6KB
log4j-1.2.17.jar 478KB
cglib-3.1.jar 276KB
jersey-client.jar 165KB
jaxb-api-2.2.7.jar 98KB
spring-integration-mail-4.3.0.RELEASE.jar 60KB
classes12.jar 1.52MB
spring-context-4.3.0.RELEASE.jar 1.08MB
log4j-api-2.2.jar 130KB
spring-aop-4.3.0.RELEASE.jar 371KB
spring-integration-core-4.3.0.RELEASE.jar 1023KB
spring-tx-4.3.0.RELEASE.jar 261KB
javax.annotation-api-1.2.jar 26KB
javax.ws.rs-api-2.0.1.jar 113KB
spring-oxm-4.3.0.RELEASE.jar 83KB
jackson-all-1.9.11.jar 1.07MB
spring-webmvc-4.3.0.RELEASE.jar 884KB
jersey-server.jar 919KB
commons-logging-1.2.jar 60KB
spring-beans-4.3.0.RELEASE.jar 736KB
commons-lang-2.6.jar 278KB
osgi-resource-locator-1.0.1.jar 20KB
spring-messaging-4.3.0.RELEASE.jar 372KB
aopalliance-repackaged-2.5.0-b32.jar 14KB
hk2-api-2.5.0-b32.jar 181KB
hk2-locator-2.5.0-b32.jar 183KB
web.xml 2KB
META-INF
MANIFEST.MF 39B
src
spring-mybatis.xml 6KB
com
wonders
client
UserClient.java 2KB
core
service
impl
UserServiceImpl.java 709B
UserService.java 212B
dao
UserDao.java 1KB
impl
UserDaoImpl.java 689B
UserDao.xml 570B
util
web
SpringContextUtil.java 2KB
app
bean
User.java 905B
server
rest
RestApplication.java 433B
resources
UserResource.java 2KB
HelloResource.java 624B
jdbc.properties 754B
mybatis-config.xml 2KB
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 345B
org.eclipse.jdt.core.prefs 670B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.core.resources.prefs 57B
org.eclipse.wst.common.component 473B
.jsdtscope 567B
.classpath 854B
共 96 条
- 1
资源评论
JavisZ
- 粉丝: 4
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 常用工具集参考用于图像等数据处理
- 音乐展示网页、基于Stenography的图像数字水印添加与提取,以及基于颜色矩和Tamura算法的图像相似度评估算法py源码
- 基于EmguCV(OpenCV .net封装),图像数字水印加解密算法的实现,其中包含最低有效位算法,离散傅里叶变换算法+文档书
- 基于matlab+DWT的图像水印项目,数字水印+源代码+文档说明+图片+报告pdf
- (优秀毕业设计)基于python实现的数字图像可视化水印系统的设计与实现,多种数字算法实现+源代码+文档说明+理论演示pdf
- 基于DWT-DCT-SVD和deflate压缩的数字水印方法python源码+Gui界面+演示视频(高分毕业设计)
- 基于matlab实现DWT、DCT、SVD算法数字图像水印可视化系统+GUI界面+文档说明+详细注释(高分毕业设计)
- NCIAE-Data-Structure大一大二笔记
- 学习wireshark笔记
- digital-image-数据可视化笔记
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功