- 浏览: 544962 次
- 性别:
- 来自: 西安
文章分类
- 全部博客 (251)
- UML/RUP/软件工程 (0)
- DDD:领域驱动设计 (1)
- IaaS/Paas/SaaS (1)
- Hadoop/YARN (10)
- PBDP项目 (2)
- OSGi-基础 (7)
- OSGi-Aries (2)
- OSGi-SpringDM (32)
- Oracle/MySQL/SS (8)
- Felix/Equinox/Bnd (14)
- Virgo Server/Gemini (7)
- Weblogic/JBoss/Tomcat (10)
- ActiveMQ (14)
- Camel (1)
- Spring Roo/Eclipse (7)
- Java/JSP/JSF (10)
- Maven (19)
- ESB-Mule (1)
- ESB-ServiceMix (18)
- SOA/SCA/SDO (12)
- WebService/RESTful (17)
- JS/jQuery/ExtJS (4)
- Spring/JPA/MVC (15)
- SpringSecurity (5)
- BPM/jBPM (3)
- Hudson/SVN/CI (0)
- LinuxOS/虚拟化 (25)
- Office/OpenOffice (1)
- 项目管理 (5)
- POI/jFreeChart (1)
最新评论
-
panamera:
请问JMS Transport 发布的webservice 是 ...
CXF 提供的Service Transport-JMS Transpor -
jianyi296:
where is attachment.
CXF WebService Dynamic Client -
hj01kkk:
您好,我用jdbc-user-service为什么每次验证时都 ...
SpringSecurity笔记3-Authenticating Users:Authenticaton Strategy -
wufenglin1231:
你好,我在实现Mapping exceptions to re ...
RESTful 异常处理 -
xchd:
[echo] Project: common
[echo ...
Hive安装配置学习笔记
1. Using the thread context classloader(TCCL)
By default, the TCCL is the application’s classloader, it can be accessed through the
getContextClassLoader method of the current thread, as shown in the following snippet:
ClassLoader currentTccl = Thread.currentThread().getContextClassLoader();
To specify a different classloader, use the setContextClassLoader method of the current thread, as
shown in this snippet:
Thread.currentThread().setContextClassLoader(TcclActivator.class.getClassLoader());
2. Using the thread context classloader with OSGi
益处:Using the TCCL within OSGi makes it possible to solve some problems without having to
export and import packages. In particular, it helps frameworks that don’t know until runtime
which classes they need to use.
ClassNotFoundExceptions :以Hibernate引擎加载映射的类为例:
Hibernate is a generic ORM framework without dependencies on user applications(如映射的类).
By
default, implementation bundles for these kinds of frameworks don’t import application classes.
Hibernate can’t load the mapped classes because they’re user-defined classes and aren’t
specified in the Import-Package header of the Hibernate component. The framework tries to
discover the required classes through configuration will be throw ClassNotFoundExceptions。
解决这个问题需要用到TCCL,因为大部分的框架(如:Hibernate)可以在多个ClassLoader中查找需要的类,If
the caller’s bundle has set the context classloader with its associated classloader, the framework
bundle will be capable of instantiating classes that are visible only to the caller’s bundle.
例如下面资源文件bundle-context.xml中配置了一个bean,这个bean对当前的Bundle是可见的,当加载资源文
件时将会抛出ClassNotFoundException:
FileSystemXmlApplicationContext context = null;
try {
context = new FileSystemXmlApplicationContext("resources/bundle-context.xml");
} finally {
if (context!=null) {
context.close();
}
}
解决方法:Using the context classloader when creating a Spring container:
ClassLoader currentTccl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(TcclActivator.class.getClassLoader());
FileSystemXmlApplicationContext context = null;
try {
context = new FileSystemXmlApplicationContext("resources/bundle-context.xml");
} finally {
if (context!=null) {
context.close();
}
Thread.currentThread().setContextClassLoader(currentTccl);
}
发表评论
-
SpringDM笔记31-Testing with OSGi and SpringDM
2011-11-22 10:27 12441. 创建一个SpringDM测试类 SpringD ... -
SpringDM笔记30-OSGi中使用SSL/STL
2011-11-21 11:55 1318SSL:Secure Sockets Layer ... -
SpringDM笔记29-Require-Bundle与Import-Package的区别
2011-11-21 10:31 2238具体可参考:http://www.osgi.org/bl ... -
SpringDM笔记28-OSGi Bundle Activities with Spring-DM
2011-11-17 10:19 1158OSGi框架中也支持搞层次的模块交互:bundles.例如 ... -
SpringDM笔记28-Spring And OSGi:Layers of Integration
2011-11-15 11:00 11721. Application Design:Service和B ... -
SpringDM笔记27-Extending The Stand Extender and Configure
2011-09-02 09:38 8691. -
SpringDM笔记25-Using AJAX frameworks with Spring DM:GWT
2011-09-01 08:53 12001. Using Spring DM with AJAX fr ... -
SpringDM笔记24-Using action-based web frameworks with Spring DM:SpringMVC
2011-08-30 09:33 1478■ Action-based web frameworks ... -
SpringDM笔记23-Using the open EntityManager in view pattern实现延迟加载
2011-08-30 09:27 15661. The open EntityManager in vi ... -
SpringDM笔记22-Transactions Support With SpringDM
2011-08-29 21:24 12101. Spring’s transactional suppo ... -
SpringDM笔记21-Using ORM within OSGi with Spring DM
2011-08-25 10:31 2095Version 1.Object/relational ma ... -
SpringDM笔记20-Using JDBC within OSGi with Spring DM
2011-08-25 09:08 1776The public API for interact ... -
SpringDM笔记19-SpringDM如何处理OSGi应用的动态行为
2011-08-24 08:51 1142ServiceTracker 1. Dealing ... -
SpringDM笔记18-Designing OSGi Enterprise Applications
2011-08-22 11:08 11211. Organizing OSGi components ... -
SpringDM笔记17-Handling Collections of OSGi Services
2011-08-20 09:12 15421.Configuring collections:the l ... -
SpringDM笔记16-处理OSGi服务的动态性:事件
2011-08-19 09:51 17791. Service registration and unr ... -
SpringDM笔记15-通过声明特定的属性注册和引用服务
2011-08-18 11:01 14071. Configuration for registerin ... -
SpringDM笔记13-OSGi服务注册与引用
2011-08-18 09:28 34491. Combining OSGi services and ... -
SpringDM笔记12-Spring DM’s web Extender运行机制
2011-08-17 11:04 2087SpringDM把一个WAR作为一个Bundle, 其实 ... -
SpringDM笔记11-Hard dependencies on the OSGi environment
2011-08-17 10:50 1413Any bean in a Spring DM app ...
相关推荐
内容简介: ClassLoader体系结构 类装载器在JVM中并不是唯一的,JVM自带了三个装载器,用户也可以根据自己的需求自定义新的装载器,这些装载器的体系结构可以看作是树状结构,如图1所示:
介绍Java中的ClassLoader技术及其在OSGI模块隔离中的运用
For many application servers, Spring provides a LoadTimeWeaver implementation that can take advantage of the instrumentable ClassLoader that the server provides. Tomcat's WebappClassLoader is ...
LazyWorker.zip,一个智能控制进入电子邮件地址,自动检查是否存在域,如果域可以接收电子邮件。LaZyWork是一个帮助类延迟任务。例如,检查需要网络操作且不应在每次按键关闭后进行的输入。
>se.jiderhamn.classloader-leak-prevention</ groupId > < artifactId >classloader-leak-prevention-servlet3</ artifactId > < version >2.7.0</ version > </ dependency > 如果您遇到 ...
Customizing the Restart Classloader 20.2.7. Known Limitations 20.3. LiveReload 20.4. Global Settings 20.5. Remote Applications 20.5.1. Running the Remote Client Application 20.5.2. Remote Update 21. ...
With OSGi-style classloading getting more and more traction, and a number of new Java modules/classloading specifications on the horizon, it was high time we revamped our classloading layer in order ...
classloader教程 --- from IBM
Understanding the Java ClassLoader
【IT十八掌徐培成】Java基础第25天-04.classLoader-系统资源-不可见类访问.zip
jar包,官方版本,自测可用
jar包,官方版本,自测可用
Java 虚拟机中ClassLoader 相关简介 双亲委托机制 Android 中ClassLoader 简介
Java中ClassLoader的解析,从ClassLoader的角度分析了JVM,装载类,创建类的对象的整个过程,更清晰的了解JVM的运行机制。
Understanding the Java ClassLoader.pdf
OSGI框架实战 一. 序..5 二. 体验OSGI..7 2.1. 需求实现..7 2.2. 技术角度..9 三. OSGI带来什么..11 四. OSGI案例..13 五. OSGI框架..15 5.1. Equinox..15 5.2. Oscar..15 5.3. Knopflerfish..15 六. 基于OSGI框架...
EquinoxEquinox Equinox在创建 Bundle Bundle 的 ClassLoader ClassLoader 时,首先获取 时,首先获取 时,首先获取 时,首先获取 bundle bundle bundle 的 classpath classpath classpath ,然后执行 。。。
破解java加密的ClassLoader.java,在classloader植入破解代码
661.659.JAVA基础教程_动态代理与Java8新特性-复习:ClassLoader(661).rar