Quantcast

[infinispan-dev] Marshaller implementation discovery

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[infinispan-dev] Marshaller implementation discovery

David M. Lloyd
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
[hidden email]
https://lists.jboss.org/mailman/listinfo/infinispan-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [infinispan-dev] Marshaller implementation discovery

Galder Zamarreño
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
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/infinispan-dev

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


_______________________________________________
infinispan-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/infinispan-dev
Loading...