Sanne Grinovero asked me to drop a quick note about the API used to 
discover JBoss Marshalling implementations.  Since 1.2.0.GA, you can use 
the org.jboss.marshalling.Marshalling class methods to locate protocol 
implementations without involving a hard dependency in your sources.

I've heard that Infinispan uses this pattern to load the implementation 
class:

(MarshallerFactory) 
Thread.currentThread().getContextClassLoader().loadClass("org.jboss.marshalling.river.RiverMarshallerFactory").newInstance();

This is a bit kludgey though and is considerably more complex than just 
doing:

Marshaller.getMarshallerFactory("river");

which uses the java.util.ServiceLoader API to locate and instantiate the 
appropriate implementation class, also using the TCCL, and should be 
functionally equivalent (yet quite a bit cleaner) to the former.
-- 
- DML
_______________________________________________
infinispan-dev mailing list
infinispan-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/infinispan-dev

Reply via email to