[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: ClassLoadingMetaData ease-of-use

adrian@jboss.org do-not-reply at jboss.com
Thu Feb 21 11:41:27 EST 2008


I'm going to use this thread to complete the description of all the classloader metadata
in one place.

RE-EXPORTS

Beyond what is mentioned above, a reqiurement can take a reExport attribute.
This allows you to build up "super modules" for ease of use, e.g.

  | <classloader xmlns="urn:jboss:classloader:1.0">
  |    <capabilities>
  |       <module name="javaee" version="1.5"/>
  |    </capabiltiies>
  |    <requirements>
  |       <module name="javax.jms" version="1.1" reExport="true"/>
  |       <module name="javax.ejb" version='3.0" reExport="true/>
  |       etc.
  | 

Then somebody can do the following to get the entire javaee api.

  | <classloading xmlns="urn:jboss:classloading:1.0">
  |    <requirements>
  |       <module name="javaee" version="1.5"/>
  |    </requirements>
  | </classloading>
  | 

NOTE: This is only works for module requirements. Other types of requirements
like individual packages don't pick up re-exports.

OPTIONAL

You can specify that a requirement is optional, e.g.

  | <classloading xmlns="urn:jboss:classloading:1.0">
  |    <requirements>
  |       <module name="foo" optional="true"/>
  |    </requirements>
  | </classloading>
  | 

If the module "foo" exists it will be imported, otherwise the requirement will be ignored.

USES

This is similar to optional, where you can specify that you want
to use somebody else's export of a package if it is exists, but otherwise
you will use your own version (included in your classpath).

  | <classloading xmlns="urn:jboss:classloading:1.0">
  |    <requirements>
  |       <uses name="com.acme.blah"/>
  |    </requirements>
  | </classloading>
  | 

EXPLICIT VERSION

A requirement can take an explicit version constraint

  | <classloading xmlns="urn:jboss:classloading:1.0">
  |    <requirements>
  |       <module name="com.acme.blah" version="1.0.0"/>
  |    </requirements>
  | </classloading>
  | 

In mathematical language :

1.0.0 <= version <= 1.0.0

FROM VERSION

You can specify a from version which is inclusive by default


  | <classloading xmlns="urn:jboss:classloading:1.0">
  |    <requirements>
  |       <module name="com.acme.blah" from="1.0.0"/>
  |    </requirements>
  | </classloading>
  | 

1.0.0 <= version 

or not inclusive


  | <classloading xmlns="urn:jboss:classloading:1.0">
  |    <requirements>
  |       <module name="com.acme.blah" from="1.0.0" from-inclusive="false"/>
  |    </requirements>
  | </classloading>
  | 

1.0.0 < version 

TO VERSION

You can specify a to version which is exclusive by default


  | <classloading xmlns="urn:jboss:classloading:1.0">
  |    <requirements>
  |       <module name="com.acme.blah" to="1.0.0"/>
  |    </requirements>
  | </classloading>
  | 

version < 1.0.0

or inclusive


  | <classloading xmlns="urn:jboss:classloading:1.0">
  |    <requirements>
  |       <module name="com.acme.blah" to="1.0.0" to-inclusive="true"/>
  |    </requirements>
  | </classloading>
  | 

version <= 1.0.0

CONTEXT NAME

In the classloader namespace that is used by the -beans.xml
you'd use it something like this;


  | <deployment xmlns="urn:jboss:bean-deployer:2.0">
  |    <classloader><inject bean="MyClassLoader:1.0.0"/></classloader>
  |    <classloader xmlns="urn:jboss:classloader:1.0" name="MyClassLoader" version="1.0.0">
  | 

NOTE, by default the context name in the MC is name:version.
But you can override this if you don't like it, e.g.


  | <deployment xmlns="urn:jboss:bean-deployer:2.0">
  |    <classloader><inject bean="Fred"/></classloader>
  |    <classloader xmlns="urn:jboss:classloader:1.0" name="MyClassLoader" version="1.0.0" context="Fred">
  | 

It's just a name after all ;-)

The deployment version, just uses the deployment controller context name.

CLASSLOADERSYSTEM

By default, the classloader (-beans.xml usage) will get registered in a ClassLoaderSystem
called .... "ClassLoaderSystem" :-)
But you can change it.


  |    <classloader xmlns="urn:jboss:classloader:1.0" name="MyClassLoader" version="1.0.0" system="SomethingElse">
  | 

I doubt anybody would want to change it, since you'd have to change
it consistently across all classloaders that want to export/import each other.

For the deployment processing, the ClassLoaderSystem is injected
into the deployer configuration.

DONE

I think that's about it? If I find I missed something, I'll add it here.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4131152#4131152

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4131152



More information about the jboss-dev-forums mailing list