You are on page 1of 15

Professional Open Source™

Architecture Overview
JBoss Microkernel for Java Middleware

© JBoss, Inc. 2003-2005. 8/2/2005 1

Topics
Professional Open Source™

– JBoss Microkernel
– Services in Microkernel
– Deployer Architecture
– Classloaders Architecture
– JBoss Invokers
– Smart Proxies and Client Interceptors

© JBoss, Inc. 2003-2005. 2

1
JMX Architecture: Microkernel
Professional Open Source™

What is a Java microkernel?


– A stripped down core capable of
• Loading services dynamically (classes included)
• Manage services lifecycle
• Provide naming and lookup
• Provide an invocation bus
• Decouples the services

That role in JBoss is taken by JMX MBean server


– JBossMX at the core
– JMX architecture provides the decoupling

© JBoss, Inc. 2003-2005. 3

JMX Architecture: MBean Server


Professional Open Source™

MBean Server acts as a mediator


– Services are referenced via object names
– MBean Server contains a registry of services

JBoss:name=ServiceA
MBean
MBean Server

Service
Service A
A
JBoss:name=ServiceC

JBoss:name=ServiceB
Server

Service
Service C
C
Service
Service B
B

© JBoss, Inc. 2003-2005. 4

2
JMX Architecture: Invocation
Professional Open Source™

Invocation has no direct reference, services are loosely coupled


– Kernel manages the service references in case of updates, etc.

setAttribute(ObjectName, Attribute)
JBoss:name=ServiceA

MBean
Service
Service A

MBean Server
A
JBoss:name=ServiceC

Service
Service CC

Server
lookup Version
Version 1.0
1.0
MBean Registry
JBoss:name=ServiceC
JBoss:name=ServiceC Java Reference
Service
Service CC
JBoss:name=ServiceA ...
Version
Version 1.1
1.1
... ...

© JBoss, Inc. 2003-2005. 5

JMX Architecture: Metadata


Professional Open Source™

Service exposes its interface as metadata


– No compile-time typed Java interfaces
– Metadata can be extended to clarify the interface contract
– Interfaces can evolve at run-time without recompilation

Attributes JBoss:name=ServiceC
MBean
MBean Server

Operations
Notifications
Service
Service C
C
Server

JBoss:name=ServiceA getMBeanInfo

Service
Service A
A

© JBoss, Inc. 2003-2005. 6

3
JMX Architecture: Type System
Professional Open Source™

Invocations are not typed at compile time, compiler won’t catch errors
– Same problem as with using Java reflection

invoke(object name, “shutdown”)

MBean
MBean Server
Service
Service A
A

Server
Service
Service C
C

shutdown()

You win: flexibility in the framework which gives you 24x7 uptime
You lose: safety net provided by Java compilers
– You still have type safety at run-time (JVM)

© JBoss, Inc. 2003-2005. 7

JMX Microkernel Architecture


Professional Open Source™

All services in JBoss are JMX MBeans.


– Services are registered to the MBean Server.
MBean Server acts as an invocation bus between the services
– Decouples the services enabling hot- and redeployment of all server
parts
– All invocations to MBeans should go through the MBean server
– GOF: Mediator pattern
Service interfaces are defined via run-time object structure
– Services don’t expose Java interfaces
MBean should not expose a Java reference to itself
– Instead the kernel internally handles references and uses logical
object names

© JBoss, Inc. 2003-2005. 8

4
Professional Open Source™

JBoss Deployers
Loading Services and Applications to JBoss

© JBoss, Inc. 2003-2005. 8/2/2005 9

JBoss Deployers
Professional Open Source™

Deployers enable you to load any class/service/application to JBoss


– Support for remote loading
– Support for arbitrary “Russian Doll” packaging
– Creates a classloader per top-level deployment

Deployers are services registered to Service


Service
the microkernel Archive
Archive

Enterprise
Enterprise
Resource
Resource Archive
Archive Java
Java
Adapter
Adapter Archive
Archive

Web
Web EJB
EJB
Archive
Archive Archive
Archive

© JBoss, Inc. 2003-2005. 10

5
JBoss Deployers
Professional Open Source™

MainDeployer coordinates package specific deployers


– Service archive (SAR) and Java class library (JAR) deployers are part of
the microkernel

Pluggable deployers Microkernel


– EAR Deployer
– WAR Deployer 1 addDeployer(this)
– EJB Deployer
– RAR Deployer
– BeanShell Deployer MainDeployer
MainDeployer SubDeployer
SubDeployer

– Custom Deployers (extend SubDeployerSupport)

© JBoss, Inc. 2003-2005. 11

Deployers: Bringing in the Services


Professional Open Source™

Deployers take packaged types and deploy the corresponding


applications and services
– They are all MBeans at the end of the day

Microkernel

2 Deploy(URL)

DeploymentScanner
DeploymentScanner MainDeployer
MainDeployer SARDeployer
SARDeployer

EJBDeployer
EJBDeployer

1 Scan URL WARDeployer


WARDeployer
3 accepts(DeploymentInfo)
*.WAR

© JBoss, Inc. 2003-2005. 12

6
Deployers: Bringing in the Services
Professional Open Source™

Microkernel

Transaction
Transaction
DeploymentScanner
DeploymentScanner SARDeployer
SARDeployer Service
Service

MainDeployer
MainDeployer EARDeployer
EARDeployer Message
MessageService
Service

EJBDeployer
EJBDeployer Security
SecurityService
Service

Naming
NamingService
Service
WARDeployer
WARDeployer
EJB
EJBContainers
Containers

Data
DataSources
Sources
*.xAR

© JBoss, Inc. 2003-2005. 13

Deployers: Working from the Network


Professional Open Source™

Machine 1 Machine 2
Microkernel Microkernel

DeploymentScanner
DeploymentScanner Load Services DeploymentScanner
DeploymentScanner
MainDeployer
MainDeployer MainDeployer
MainDeployer

HTTP Scan HTTP Scan

Deployment
Web Server Packages
Administrator

© JBoss, Inc. 2003-2005. 14

7
Professional Open Source™

JBoss Classloader Architecture


Shared Class Repositories and Java Runtime Type System

© JBoss, Inc. 2003-2005. 8/2/2005 15

JBoss 4.x Classloader Architecture


Professional Open Source™

JBoss deployers create a new classloader per top level deployment

Each deploy or redeploy operation creates a new classloader


– It is not possible to “unload” an existing class definition
– In future may be possible to redefine a class (also dynamically relink
references of an existing instance of a class)

CL
CL Top Level Deployment
The JBoss classloading architecture
manages the classloaders to avoid type
conflicts (where possible)
– These classloaders potentially have duplicate
class definitions
– Classloaders are added to repositories

Nested Deployments

© JBoss, Inc. 2003-2005. 16

8
JBoss 4.x Classloader Repository
Professional Open Source™

JBoss defines classloading domains


Within a classloading domain a class is identified by its fully qualified
class name
– Any given class can have only one defining classloader within the domain
– We return to the intuitive Java notion that class is identified by its name
Within a classloading domain we can safely use references
– We know that a given class name can only have one defining loader
– Essential for performance!

Loader
Loader Repository
Repository

Class is identified
Java
Java Class
Class by its name in the
classloading
domain

© JBoss, Inc. 2003-2005. 17

Scoped Repositories
Professional Open Source™

Parent
Repository
Shared JARs

Scoped Scoped
Repository Repository

EAR EJB-JAR SAR

© JBoss, Inc. 2003-2005. 18

9
Professional Open Source™

Server Interceptors and Invokers


Adding Behavior and Remoteness to Services

© JBoss, Inc. 2003-2005. 8/2/2005 19

Server Side Interceptors


Professional Open Source™

A detyped flow allows for arbitrary interposition


– In JBoss you can have interceptors either for MBean services or per EJB
container (a container is an MBean with interceptors)
– Perfect for system level issues
Cache
Transaction

Direct Call Security

Lock

Synchronization
Synchronization
Transaction

Synchronization
Connection
Transaction

Connection

Relation
Security

Relation
Security

Cache
Cache
Lock
Lock

Call

Invocation
Call

Interposition Bean Implementation

© JBoss, Inc. 2003-2005. 20

10
JBoss Invokers
Professional Open Source™

Services in JBoss exist independently of connectors


– To access services from an external process, a special invoker service
must be added to the microkernel

Server JVM

Invocation MBean

MBean

JMX
JMX Microkernel
Microkernel
MBean

© JBoss, Inc. 2003-2005. 21

JBoss Invokers
Professional Open Source™

New invokers can be added dynamically


– Invokers themselves are MBeans
Server JVM
Invoker extracts the target
name and lets the kernel Service MBean
route the invocation
Port 1234

You can add as many RemoteInvoker


RemoteInvoker
JMX
JMX Microkernel

invokers to the system as you Service MBean


need
Microkernel

Invocation

Port 4321
– They may support different
protocols (JRMP, IIOP, HTTP, RemoteInvoker
RemoteInvoker
SOAP, Custom Socket, etc.) Service MBean
– You can create your own for
your specific needs
– Each invoker binds itself to a
physical port on the node

© JBoss, Inc. 2003-2005. 22

11
JBoss Invokers
Professional Open Source™

– All services are MBeans (including EJB containers)


– Remote access is available via invoker MBeans
Server JVM
– Internally invocation objects
are routed within the kernel EJB Container MBean

Port 1234
RemoteInvoker
RemoteInvoker

JMX
JMX Microkernel
Client JVM
EJB Container MBean
Typed

Microkernel
Interface Invocation

011101010101
Client
Client RemoteInvoker
RemoteInvoker
Port 4321
Service MBean
Client Proxy

© JBoss, Inc. 2003-2005. 23

The Structure of the Invocation


Professional Open Source™

Invocation is an abstraction of the actual method invocation


(GoF Command pattern)
– A map with entries and values
– Marshall map, as-is map, transient map
• Each map has different serialization semantics
– In the map by default we put
• Target service (JMX ObjectName)
• Method name and arguments
• Transactions context (client transaction interceptor)
• Security context (client security interceptor)
• Anything that you want (your client interceptors)
– Additional service context, extended security context, intelligent
client side invocation logic such as caching, batch invocations,
load balancing, retry logic

© JBoss, Inc. 2003-2005. 24

12
Professional Open Source™

Client Proxies
“Downloading Smart Behavior to the Client”

© JBoss, Inc. 2003-2005. 8/2/2005 25

The Structure of the Client Proxy


Professional Open Source™

The proxy contains


– Component interface
– Dynamic proxy invocation handler (java.lang.reflect.InvocationHandler)
– Stack of client interceptors
– Invoker stub to communicate to the server side invoker implementation

Client JVM
Typed
Typed Component

Reference to InvocationHandler
implementation
Component Interface

Transaction
Transaction
Invocation

Transport
Invocation

Transport
Security
Handler

01110101
Security
Handler

Client
Client
Interface

Stub to server
side invoker

Runtime generated interface implementation that


multiplexes to invocation handler

© JBoss, Inc. 2003-2005. 26

13
Client Side Interceptors
Professional Open Source™

Invocation handler instantiates a new invocation object


– Each interceptor adds relevant context to the invocation
– The invocation is serialized to the server by invoker stub

Client JVM
Component
Component Interface

Transaction
Transaction
Invocation

Transport
Invocation

Transport
Security
Handler

Security
Handler
011101010101
Interface

Method Method Method


Args Args Args
Principal Principal
Credential Credential
Tx Context

© JBoss, Inc. 2003-2005. 27

Clustering Intelligence on Java Clients


Professional Open Source™

Drop your service in JBoss, stateless


Configure a client side proxy with a cluster client interceptor
Voila! Insta-cluster™

© JBoss, Inc. 2003-2005. 28

14
Architectural Overview: Conclusion
Professional Open Source™

Microkernel design
– Independent cycling and loading
Unified ClassLoaders
– Class visibility with any 3rd party and stack integration
Unified Deployers
– Hot deploy all types
– Responsible for UCL creation
Detached invokers
– Independent of MBeans present
– multiple protocol support
Client Proxy
– Dynamic proxies and client interceptor stack
The SUPER-SERVER theory for MBeans (EJB is an example)

© JBoss, Inc. 2003-2005. 29

15

You might also like