Not quite clear on what you want. But sounds like you need a scoped class loader?
I'd like to be able to deploy many different EARs [with different contexts] to the same JBoss server and have Z.class be loaded for the EAR/context of that application.
The reason for this may be different applications ( EAR ) that reuse a class, but have different versions of that class. A method may work differently from one version to the next. My client has applications that they don't want to change for a while, but they want to change other applications ( EAR ) that reuse the same classes ( Z.class ). When the changed application ( EAR ) gets loaded, it doesn't work as expected when loaded with the applications ( EAR ) that use the previous version of the class ( Z.class ).
So, a context-sensitive class loader may be what I'm needing. How do I get that class loader to be used?