Tomcat配置自己的Classloader

Tomcat配置自己的Classloader

http://www.52webpro.cn/archives/view-15079-1.html
http://segmentfault.com/q/1010000000155690
http://bbs.csdn.net/topics/190167594
http://yuan-xulong.iteye.com/blog/1056820
http://space.itpub.net/?uid-23071790-action-viewspace-itemid-702545


Linux操作系统下/etc/hosts文件配置方法
http://space.itpub.net/21639366/viewspace-604530

手动创建Oracle 11g数据库
http://blog.csdn.net/carlwu/article/details/2978130

WebSphere Application Server Community Edition V2.0 中的新特性
http://www.ibm.com/developerworks/cn/websphere/library/techarticles/0709_jain/0709_jain.html?s_cmp=techccid&s_tact=105agx52

http://publib.boulder.ibm.com/wasce/V2.0.0/zh_CN/shutdown.html
http://publib.boulder.ibm.com/wasce/V2.1.0/en/quick-start.html

http://stackoverflow.com/questions/11246598/how-to-make-tomcat-work-with-tomcatinstrumentableclassloader-defined-in-meta-inf

http://www.oschina.net/question/68887_26014
http://swingboat.iteye.com/blog/528022

jar 命令 打包详解
http://boris-song.iteye.com/blog/234822
http://quicker.iteye.com/blog/838323

http://shashankmjain.blogspot.com/2009/08/instrumenting-class-with-custom-tomcat.html

http://zhidao.baidu.com/question/290837823.html

--


Instrumenting a class with custom Tomcat Class loader
I have been experimenting with the idea of runtime instrumentation of java classes for quite some time.
Java 5 provides a mechanism using a java agent to intercept the classloading process but here I am going to look into creating a custom Class loader for Tomcat and changing the class bytes on the fly using the javassist library.

Create a web project using Eclipse or any IDE of your choice.
Create a context.xml file in the META-INF directory of the web app. The content will be similar to


loaderClass="com.test.SampleLoader"
useSystemClassLoaderAsParent="false"
delegate="false"/>


After doing this we need to implement the SampleLoader class
The class should be a subclass of WebappClassLoader from Tomcat. We will override the

protected Class findClassInternal(String name) throws ClassNotFoundException method.
The method can be copied from the Tomcat WebappClassLoader class.
Under the if (entry.loadedClass == null) {
method we will change the byte stream of the class using javassist something like this

byte[] b =entry.binaryContent;
String name1 ="com.sample.Test";
pool.insertClassPath(new ByteArrayClassPath(name1, b));
if(name.equals(name1))
{
CtClass cc = pool.get(name);
cc.getConstructors()[0].insertBefore("{System.out.println(\"Before Instantiaition\");}");
cc.getConstructors()[0].insertAfter("{System.out.println(\"After Instantiation\");}");
System.out.println("After classworking "+cc.toBytecode().length);
entry.binaryContent=cc.toBytecode();
}
The same can be extended to intercept any method call.
The class is defined by the classloader after the byte array stream is modified. So the modified class is loaded into the jvm by the custom classloader.

Also the classes can be loaded from an alternate source rather then the web-inf/lib and classes directory
This can be useful when we want to write interceptors to the method calls or create proxies on the fly.

The Custom classloader can be packaged and the jar needs to be placed in CATALINA_HOME/lib directory alongside the javassist libs..
POSTED BY SHASHANK JAIN AT 5:59 AM
LABELS: BYTE CODE INSTRUMENTATION, CUSTOM TOMCAT CLASSLOADER

--

http://www.sf-express.com/cn/sc/delivery_step/waybill_track/track.html
117326721579


Oracle创建用户、表空间、导入导出、...命令
http://www.cnblogs.com/cloudwalf/archive/2008/09/04/1284033.html

读取目录及子目录下指定文件名的路径
http://amulin.iteye.com/blog/1643202
http://blog.csdn.net/chfzhb/article/details/2859973


在tomcat中如何装载加密后的class文件
http://blog.163.com/tim_plenty/blog/static/567106462007316113420/

利用自定义Classloader保护加密class文件的方式,能否在tomcat等容器中实现?
http://www.iteye.com/problems/5406

Spring对属性文件加密解密应用
http://voole.iteye.com/blog/632885

web项目加解密
http://xphwv.iteye.com/blog/1779031
tomcat中如何装载加密后的class文件
http://www.blogjava.net/jspark/archive/2006/07/25/59968.html

java源程序加密解决方案(基于Classloader解密) **
http://cjnetwork.iteye.com/blog/851544#comments
http://www.ibm.com/developerworks/cn/java/l-secureclass/

http://blog.csdn.net/aesop_wubo/article/details/7582266
Encrypted classloader tomcat
http://www.coderanch.com/t/497275/Tomcat/Encrypted-files-classes-Tomcat
http://publib.boulder.ibm.com/infocenter/javasdk/v1r4m2/index.jsp?topic=%2Fcom.ibm.java.doc.diagnostics.142%2Fhtml%2Fid1100.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值