https://github.com/ejunjsh/classloader-example
this is experiment to know how classloader run
https://github.com/ejunjsh/classloader-example
classloader java
Last synced: 3 months ago
JSON representation
this is experiment to know how classloader run
- Host: GitHub
- URL: https://github.com/ejunjsh/classloader-example
- Owner: ejunjsh
- Created: 2018-08-21T08:28:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-21T14:07:52.000Z (over 6 years ago)
- Last Synced: 2024-12-29T08:41:59.382Z (4 months ago)
- Topics: classloader, java
- Language: Java
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# classloader-example
this is experiment to know how classloader run
# begin
sudo docker-compose run app
then will return a bash ,you run below commandsh container.sh
then the output is# ignore maven build log
start up the app 1:
AppClassLoader load applib1
applib1:
CommonClassLoader load Calculator
3
start up the app 2:
AppClassLoader load applib2
applib2:
4
i define two classloader `AppClassLoader` and its parent classloader`CommonClassLoader`,the first classloader loads classes in path you specify.
the second classloader loads classes from common path `/opt/cl/common`,so i put the `Calculator` class there
so i execute `container` that run two app `app1` and `app2`
you will see the output they load `calcultor` from `CommonClassLoader` only one time
and use `AppClassLoader` to load their own `applib`
for detail you can see the code.
# conclusion
this example is similar with tomcat or some other web container.
they use `AppClassLoader` to load the different application
but share common library with `CommonClassLoader`.