-
1. Re: How to register advanced externalizer from app
alesj May 26, 2012 6:14 AM (in response to kristjan273)So you want to register custom externalizer against your cache?
How do you get a hold of the cache?
-
2. Re: How to register advanced externalizer from app
kristjan273 May 26, 2012 9:02 AM (in response to alesj)Here is how I handle the caches:
@Singleton public class Resources { @SuppressWarnings("all") @Produces @Resource(mappedName = "java:jboss/infinispan/container/msdp-cluster") private static EmbeddedCacheManager mecm; @MsdpClusterCache @Produces @SuppressWarnings("all") public AdvancedCache getMsdpClusterCache() { // Configuration c1 = new ConfigurationBuilder().clustering().cacheMode(CacheMode.DIST_SYNC).hash().numOwners(2) // .jmxStatistics().build(); // // mecm.defineConfiguration("MsdpClusterCache", c1); GlobalConfigurationBuilder builder = new GlobalConfigurationBuilder(); builder.serialization().addAdvancedExternalizer(5001, new MessageNewIndex.MessageNewIndexExternalizer()); return mecm.getCache("MsdpClusterCache").getAdvancedCache(); }
the commented configuration is currently defined in domain.xml.
I got the idea that registering of externalizer has something to do with GlobalConfigurationBuilder.
-
3. Re: How to register advanced externalizer from app
alesj May 26, 2012 3:10 PM (in response to kristjan273)"builder" is never used. ;-)
But the Configuration approach looks in the right direction,
as that's what I also use in CapeDwarf -- a lot of custom cache configs.
I'll check how to apply externalizers to config, global or per-cache.
-
4. Re: How to register advanced externalizer from app
galder.zamarreno May 30, 2012 3:25 AM (in response to kristjan273)The problem is that the AS7 Infinispan susbsystem does not yet allow for advanced externalizers to be configured. So, to configure them, you have to skip defining it in the cache container, and create a cache manager instance yourself, and pass the global config builder with the advanced externalizer, and any other parameters, such as transport, if you're clustering it...etc.
-
5. Re: How to register advanced externalizer from app
galder.zamarreno May 30, 2012 3:26 AM (in response to galder.zamarreno)But to be honest, this is probably quite a lot more work that you're expected to do. You can use the user friendly externalizers as explained in https://docs.jboss.org/author/x/PwY5 without problems.
-
6. Re: How to register advanced externalizer from app
jrcheenu Mar 3, 2014 3:13 PM (in response to kristjan273)public void registerExternalizer(Map<Integer,Serializable> classnames) throws IllegalArgumentException
{
boolean hasInvalidArg = false;
StringBuffer invalidclassNames =new StringBuffer();
Set<Integer> keys = classnames.keySet();
for(Iterator iterator = keys.iterator(); iterator.hasNext();)
{
Integer key = (Integer)iterator.next();
Serializable classname =classnames.get(key);
if(classname instanceof AdvancedExternalizer){
GlobalConfiguration gc = cacheManager.getGlobalComponentRegistry().getGlobalConfiguration();
GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder().read(gc).nonClusteredDefault();
gcb.serialization().addAdvancedExternalizer(key,(AdvancedExternalizer)classname);
gcb.build();
}
else
{
hasInvalidArg = true;
invalidclassNames.append(classname + " ");
}
}
if(hasInvalidArg){
throw new IllegalArgumentException("The following class is not instance of AdvancedExternalizer.So Cant Register it as Externalizer. " + invalidclassNames.toString());
}
}
}
I used this to register externalizer and exposed the interface to client.