3. What’s JBoss-Modules
● AS 7 bottom infrastructure
● Load all AS7 libs, frameworks, containers,
services by module
● A simple APP loader, not a framework or
container
– Implements a thread-safe,fast,and highly concurrent
module class loader model
– Do one thing best
– No any dependecy
● standalone.sh
– java –jar jboss-modules.jar -modulepath modules
org.jboss.as.standalone
4. What’s module?
● Module is a collection of functions to implement the
requirements of a specific domain, and can interact with others
by public interfaces.
● Almost all products are made by module in various kind of
industry
– Computer, Car
● We also talk about modules in software industry
– user module, security module
– Care more module concept for Design & Development time,
but in runtime:
● No isolation between JARs
● No protection from overlapping classes and packages
● No support of multiple versions
● No manageable dependencies(export/import)
● JAR HELL !!!
– How to ensure modules run as design?
● Need a module runtime environment!
5. What’s runtime module?
● Different module needs separated classloader
– Isolated module classloader without JAR HELL
– Export only APIs which need to be exported
– Import only APIs which other module exports
● JBoss-modules focus on runtime only
– No API or rule for Design&Dev time, not a library for
development, not a framework, not a container
– Modules run in a separated environment expected in
the Design&Development time
– Module can be developed by any other
team/organization/ company
6. How JBoss-modules do?
● Implements a thread-safe,fast,and highly
concurrent module class loader model
– ClassLoader is the mechanism to separate application
to modules in runtime
● Manage module dependencies
● Manage Imports and Exports
– Filter supported
7. Module ClassLoader
● Every module has its
classloader
– Load local classes
and resources
– Delegate to other
module
classloader to
load the
dependencies
8. Module Structure
● Jar
● module.xml
– name,version
– resources
– Dependencies
– Main class
9. Module name & version
● Module names are dot separated,a bit like package names or Maven
group Ids.Examples:
– org.jboss.shrinkwrap.api
– org.apache.xalan
– org.dom4j
● However there is no actual relationship between a module’s name and
the names of the packages which comprise it
●
● JBoss Modules does not support version resolution
● Version slot allows two modules with the same name to coexist
The version slot defaults to “main”
● Fullname of a module
– org.jboss.shrinkwrap.api:main
– org.apache.xalan:main
– org.dom4j:main
10. Module Deployment structure
● Use modules as
module repo
● Name&version slot as
module directory
● put resources and
module.xml in the
module directory
11. API
● Custom your module loader extend
org.jboss.modules.ModuleLoader
● Load module on-flying and get their
classloaders
– // Get my module loader
– ModuleLoader loader = ModuleLoader.forClass(getClass());
– // Load the module
– Module module = loader.loadModule(“com.widgets”);
– // Get its class loader
– ClassLoader classLoader = module.getClassLoader();
– // Load a class from it
– Class<?> c = Class.forName(“com.widgets.Widget”, true, classLoader);
12. Execute a module
● Execute a module from the repository
– which should have a main class
specified in its module.xml descriptor
● Java –jar jboss-modules.jar -modulepath
modules org.foo.mymodule
13. JBoss-modules in AS7
● More than 200 modules
● Super fast bootstrap
– Multi-threading loading
– Lazy loading
● Easily to develop your module to
enhance AS7
● Of course you can use jboss-modules as
your application’s infrastructure
14. VS OSGi&JSR 277/294
● OSGi
– Bootstrap wrapper VS Container
– lightweight VS heavy
● Do one thing vs All in one
● Easy to start
● JSR 277/294 – Java Module System
– Stopped
– Jigsaw is a prototype module system intended
for Java 8
– JBoss-modules will be compliant with Java
Module System
15. Future Directions
● Tooling
– Make it easier to figure out needed and
missing dependencies(perhaps a
modified version of Tattletale)
● IDE integration
– Make it easier to run (and debug)
modular code from within an IDE
16. Reference
● Get the sources at
http://github.com/jbossas/jboss-modules
● File issues at
https://issues.jboss.org/browse/MODULES
● Read documentation at
http://docs.jboss.org/jbossmodule
● Discuss your ideas on irc.freenode.net:#jboss-
modules
● Chinese docs:
– http://jbosscn.iteye.com/
– http://www.bluedash.net/spaces/JBoss%20Module
%E4%BB%8B%E7%BB%8D
17. DEMO
● Two modules with one has dependencies to
the other