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文件上传的基本实现方法吧. 话不多说 ...
随机推荐
- Autoit3 获取WinForm下的ToolTip
相比Autohotkey,在我看来,Autoit最实用的就是对于WinForm Application的良好支持 然而,要想将鼠标放在WinForm的ToolTip上,简直无异于自己把自己举起来,故而 ...
- node.js下使用RSA加密事例(windows)
1.安装openss 直接下载window下的安装包 http://houjixin.blog.163.com/blog/static/3562841020144143494875/ 以我发博文现在的 ...
- C#进阶目录
一.Sql语句的性能优化 二.Quartz.NET的介绍 三.Log4.Net的介绍 四.Topshelf的介绍 五.Git的使用 六.IEnumerable接口迭代原理 七.Lambada表达式的演 ...
- es6中的promise对象
Promise是异步里面的一种解决方案,解决了回调嵌套的问题,es6将其进行了语言标准,同意了用法,提供了`promise`对象, promise对象有三种状态:pending(进行中) .Resol ...
- 分布式的Id生成器
项目中需要一个分布式的Id生成器,twitter的Snowflake中这个既简单又高效,网上找的Java版本 package com.cqfc.id; import org.slf4j.Logger; ...
- Git 如何只更新项目中某个目录里的文件
Git由于在远端和本地都有一个代码库, 这样更新单个文件比SVN要麻烦一点. 1. 如果想拿远端git服务器上的最新版本(或某个特定版本)覆盖本地的修改,可以使用git pull命令, 但这会 ...
- tcp 出现rst情况整理
正常情况tcp四层握手关闭连接,rst基本都是异常情况,整理如下: 1. GFW 2. 对方端口未打开,发生在连接建立 如果对方sync_backlog满了的话,sync简单被丢弃,表现为超时,而不会 ...
- 魔镜VIP批量条形码视频教程
需要购买者请登我的淘宝店,https://cdrapp.taobao.com/ 优惠价哦!
- 基于netty轻量的高性能分布式RPC服务框架forest<下篇>
基于netty轻量的高性能分布式RPC服务框架forest<上篇> 文章已经简单介绍了forest的快速入门,本文旨在介绍forest用户指南. 基本介绍 Forest是一套基于java开 ...
- linux无法挂载u盘
一般插入u盘都会自动挂载,但有时挂载不了,错误提示:can't find /dev/sdb in /etc/fstab:这时可能是U盘坏了,我们当然不希望是这样.也有可能是U盘使用的接口不对应导致系统 ...