定制类加载器有什么特殊的好处?

刚才看eddiegift的博客(http://eddiegift.javaeye.com/blog/172271),他写一个类加载器.以前一直没弄过这方面的代码,也不知道这样的类加载器有什么特殊的好处,那如何在实际中让JVM用自写的类加载器而不用JVM提供的类加载器呢?

写这里想起来了些这方面的应用,前些天看Spring In Action里的AOP时,有下面一段:
    The weaving can take place at several points in the target object’s lifetime:
        ■ Compile time—Aspects are woven in when the target class is compiled. This
        requires a special compiler. AspectJ’s weaving compiler weaves aspects this
        way.
        ■ Classload time—Aspects are woven in when the target class is loaded into the
        JVM. This requires a special ClassLoader that enhances that target class’s
        bytecode before the class is introduced into the application. AspectJ 5’s
        load-time weaving (LTW) support weaves aspects in this way.
        ■ Runtime—Aspects are woven in sometime during the execution of the appli-
        cation. Typically, an AOP container will dynamically generate a proxy object
        that will delegate to the target object while weaving in the aspects. This is
        how Spring AOP aspects are woven.

也就是说可以用自写的类加载器来实现AOP的Weaving,那还有没有别的应用呢?怎么配置来让JVM调用定制的类加载器呢?
评论
发表评论

您还没有登录,请登录后发表评论

rmn190
搜索本博客
存档
最新评论