1. Java Classloader

链接: https://en.wikipedia.org/wiki/Java_Classloader

摘要:

The Java Classloader is a part of the JRE that dynamically loads Java classes into the JVM. Usually only loaded on demand.

In Java, libraries are typically packaged in JAR files. The most important type of object contained in a Jar file is a Java class. A class can be thought of as a named unit of code. The class loader is responsible for locating libraries, reading their contents, and loading the classes contained within the libraries. A class with a given name can only be loaded once by a given classloader.

When the JVM is started, three class loaders are used:

  1. Bootstrap class loader
  2. Extensions class loader
  3. System class loader

The bootstrap class loader loads the core Java libraries located in the <JAVA_HOME>/jre/lib directory. This class loader, which is part of the core JVM, is written in native code.

The extensions class loader loads the code in the extensions directories (<JAVA_HOME>/jre/lib/ext,or any other directory specified by the java.ext.dirs system property).Implemented by the sun.misc.Launcher$ExtClassLoader.

The system class loader loads code found on java.class.path, which maps to the CLASSPATH environment variable. This is implemented by the sun.misc.Launcher$AppClassLoader class.

User defined calss loader:

  Every Java class loader has a parent class loader, defined when a new class loader is instantiated or set to the virtual machine's system default class loader.

  This makes it possible (for example):

  • to load or unload classes at runtime (for example even from an HTTP resource). This is an important feature for (for example):

    • implementing scripting languages, such as Jython
    • using bean builders
    • allowing multiple namespaces to communicate. This is one of the foundations of CORBA / RMI protocols for example.

Java EE application servers typically load classes from a deployed WAR or EAR archive by a tree of classloaders, isolating the application from other applications, but sharing classes between deployed modules. So-called "servlet containers" are typically implemented in terms of multiple classloaders.

摘要 releate to WAR from https://en.wikipedia.org/wiki/WAR_(file_format):

  The /WEB-INF/classes directory is on the ClassLoader's classpath. (The classpath consists of a list of locations from which .class files can be loaded and executed by the JVM.) The /WEB-INF/classes directory contains the classes   

  associated with the web application itself.

  Any JAR files placed in the /WEB-INF/lib directory will also be placed on the ClassLoader's classpath.

2. Java Servlet

链接: https://en.wikipedia.org/wiki/Java_servlet

摘要:

Compared with other web application models (namely CGI)

Traditional CGI scripts written in Java have a number of performance disadvantages:

  • When an HTTP request is made, a new process is created each time the CGI script is called. The overhead associated with process creation can dominate the workload especially when the script does relatively fast operations. Thus, process creation will take more time for CGI script execution. In contrast, for servlets, each request is handled by a separate Java thread within the web server process, thereby avoiding the overhead associated with forking processes within the HTTP daemon.
  • Simultaneous CGI requests will load the CGI script to be copied into memory once per request. With servlets, there is only one copy that persists across requests and is shared between threads.
  • Only a single instance answers all requests concurrently. This reduces memory usage and eases the management of persistent data.
  • A servlet can be run by a servlet container in a restrictive environment, called a sandbox. This is similar to an applet that runs in the sandbox of the web browser. This enables restricted use of potentially harmful servlets. CGI programs can of course also sandbox themselves, since they are simply OS processes.

  Technologies like FastCGI and its derivatives (including SCGI, WSGI) do not exhibit the performance disadvantages of CGI incurred by the constant process spawning. They are, however, roughly as simple as CGI.

Java: some learning note for Java calssloader and Servlet的更多相关文章

  1. 【Java】NO.80.Note.1.Java.1.001-【Java 各种特性概念】

    1.0.0 Summary Tittle:[Java]NO.80.Note.1.Java.1.001-[Java 各种特性概念] Style:Java Series:Java Since:2018-0 ...

  2. Java Machine Learning Tools & Libraries--转载

    原文地址:http://www.demnag.com/b/java-machine-learning-tools-libraries-cm570/?ref=dzone This is a list o ...

  3. [转]MyEclipse基础学习:Java EE Learning Center

    我就不翻译了,直接给出Java EE学习中心的原文链接: Java EE Learning Center 另外,给出MyEclipse IDE 环境中Apache Tomcat server服务器正常 ...

  4. Personal Learning Path of Java——初识Java

    初识Java 在我个人看来,Java是一门高大上的面向编程语言,这也是Java吸引我的地方.在自学Java之前,我在学校大概学过了一些C语言的知识,在学校学的那点C语言纯属是拿来打基础用的,大概了解了 ...

  5. Awesome Java: Github上关于Java相关的工具

    Awesome Java 这是Github上关于Java相关的工具,框架等等资源集合. 原文参考: https://github.com/akullpp/awesome-java. @pdai 最全的 ...

  6. Java企业实训 - 01 - Java前奏

    前言: 虽然个人专攻.NET方向,不过由于个人是干教育行业的,方方面面的东西,不能说都必须精通,但肯定多少都会涉及到. 一个菜鸟学员,从啥都不会,经过一步步学习,最后到企业上手掌管一个模块甚至一个项目 ...

  7. Java Lock Example – ReentrantLock(java锁的例子)

    Welcome to Java Lock example tutorial. Usually when working with multi-threaded environment, we use ...

  8. 你真的了解java的lambda吗?- java lambda用法与源码分析

    你真的了解java的lambda吗?- java lambda用法与源码分析 转载请注明来源:cmlanche.com 用法 示例:最普遍的一个例子,执行一个线程 new Thread(() -> ...

  9. 小兔Java教程 - 三分钟学会Java文件上传

    今天群里正好有人问起了Java文件上传的事情,本来这是Java里面的知识点,而我目前最主要的精力还是放在了JS的部分.不过反正也不麻烦,我就专门开一贴来聊聊Java文件上传的基本实现方法吧. 话不多说 ...

随机推荐

  1. webpack 配置文件

    现如今,webpack非常的受欢迎,比较火的几款js框架都推荐使用webpack来构建项目,而webpack也确实非常强大,但是配置webpack缺常常带来很多问题,接下来就写一下我自己遇到的一些坑. ...

  2. ES6学习笔记二

    字符串遍历 var str = 'hello'; for(let s of str){console.log(s += ' ')} //h e l l o 字符串查找:添加了include(str,i ...

  3. CSS 中关于background 属性功能

    background 是 css中的核心属性,我们对他应该充分了解. background-image   定义背景图像  这个属性是我们用的最多的属性 设置背景图像有两个方式 background: ...

  4. ubuntu

    mongoChef: http://3t.io/mongochef/download/core/platform/#tab-id-3 背景色改成豆沙绿: /usr/share/themes/Ambia ...

  5. tomcat 快速部署静态文件

    server.conf配置: <?xml version='1.0' encoding='utf-8'?> <!-- Licensed to the Apache Software ...

  6. css3 perspective perspective-origin属性的理解

    perspective字面意思是:透视. 在w3school中它的解释为:设置元素被查看位置的视图:通俗讲,就是我们看看一个物体的所处的视角,近大远小.就比如我们正对着电脑:当我无限贴近电脑屏幕的时候 ...

  7. python之路二十一

    URL        - 两个    Views        - 请求的其他信息        from django.core.handlers.wsgi import WSGIRequest   ...

  8. linux Mint18 backspace怎么不能连续删除

    打开菜单--->首选项--->键盘,如下图所示: 打开启用重复按键即可,就可以随心所欲的连续删除,连续移动光标了

  9. Ajax跨域:jsonp还是CORS

    跨域一般用jsonp,兼容性比较好.CORS是html5最新的XHR第二版本,不支持IE8,IE9,对移动端的支持非常好.但是考虑项目后期这部分会转到同域名下,而且网址不需要支持ie8,ie9,所以我 ...

  10. AtomicBoolean介绍与使用

       java.util.concurrent.atomic.AtomicBoolean 继承自Object. 介绍: 在这个Boolean值的变化的时候不允许在之间插入,保持操作的原子性 方法和举例 ...