[infinispan-dev] Marshaller implementation discovery

Galder Zamarreño galder at redhat.com
Mon Jan 3 04:27:08 EST 2011


Sounds good to me: https://issues.jboss.org/browse/ISPN-851

On Dec 28, 2010, at 12:08 AM, David M. Lloyd wrote:

> 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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev

--
Galder Zamarreño
Sr. Software Engineer
Infinispan, JBoss Cache




More information about the infinispan-dev mailing list