Java: some learning note for Java calssloader and Servlet
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:
- Bootstrap class loader
- Extensions class loader
- 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的更多相关文章
- 【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 ...
- Java Machine Learning Tools & Libraries--转载
原文地址:http://www.demnag.com/b/java-machine-learning-tools-libraries-cm570/?ref=dzone This is a list o ...
- [转]MyEclipse基础学习:Java EE Learning Center
我就不翻译了,直接给出Java EE学习中心的原文链接: Java EE Learning Center 另外,给出MyEclipse IDE 环境中Apache Tomcat server服务器正常 ...
- Personal Learning Path of Java——初识Java
初识Java 在我个人看来,Java是一门高大上的面向编程语言,这也是Java吸引我的地方.在自学Java之前,我在学校大概学过了一些C语言的知识,在学校学的那点C语言纯属是拿来打基础用的,大概了解了 ...
- Awesome Java: Github上关于Java相关的工具
Awesome Java 这是Github上关于Java相关的工具,框架等等资源集合. 原文参考: https://github.com/akullpp/awesome-java. @pdai 最全的 ...
- Java企业实训 - 01 - Java前奏
前言: 虽然个人专攻.NET方向,不过由于个人是干教育行业的,方方面面的东西,不能说都必须精通,但肯定多少都会涉及到. 一个菜鸟学员,从啥都不会,经过一步步学习,最后到企业上手掌管一个模块甚至一个项目 ...
- Java Lock Example – ReentrantLock(java锁的例子)
Welcome to Java Lock example tutorial. Usually when working with multi-threaded environment, we use ...
- 你真的了解java的lambda吗?- java lambda用法与源码分析
你真的了解java的lambda吗?- java lambda用法与源码分析 转载请注明来源:cmlanche.com 用法 示例:最普遍的一个例子,执行一个线程 new Thread(() -> ...
- 小兔Java教程 - 三分钟学会Java文件上传
今天群里正好有人问起了Java文件上传的事情,本来这是Java里面的知识点,而我目前最主要的精力还是放在了JS的部分.不过反正也不麻烦,我就专门开一贴来聊聊Java文件上传的基本实现方法吧. 话不多说 ...
随机推荐
- Android如何一进入一个activity就唤醒键盘
方法总结: 在AndroidManife.xml中对应的的Activity配置中加入以下配置项: android:windowSoftInputMode="stateVisible|adju ...
- TweenMax学习整理--特有属性
TweenMax学习整理--特有属性 构造函数:TweenMax(target:Object, duration:Number, vars:Object) target:Object -- 需要缓 ...
- ES5新语法forEach和map及封装原理
### forEach 在es5中提供了forEach方法进行遍历,其实就是模仿了jQuery中each方法,不过将 i 于v进行了调换,下面两种方法进行对比一下 var arr = [ 11, 22 ...
- tcp_tw_reuse、tcp_tw_recycle 使用场景及注意事项
linux TIME_WAIT 相关参数: net.ipv4.tcp_tw_reuse = 表示开启重用.允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭 net.i ...
- WPF之自定义控件
1.先定义画刷,一般存为资源字典 格式: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml ...
- win7系统下的飞秋发送文件失败问题
飞秋发送文件失败这个问题大多数是由防火墙引起的1.检查windows自带的防火墙设置,在左侧的"允许程序通过windows防火墙"查看飞秋是否存在,不存在则增加之,公网.专网都勾选 ...
- 久违的phpstorm
原文:http://www.cnblogs.com/buyucoder/p/5291771.html 原文:http://idea.lanyus.com/
- 解决绝对定位div position: absolute 后面的<a> Link不能点击
今天布局的时候,遇到一个bug,当DIV设置为绝对定位时,这个div后面的相对定位的层里面的<a>Link标签无法点击. 网上的解决方案是在绝对定位层里面添加:pointer-events ...
- 获取QQ缓存图片
- 1280*720P和1920*1080P的视频在25帧30帧50帧60帧时的参数