I am running the infinispan core api inside a osgi container. When other service started in osgi, they will register their externalizer through the core api.
I used the following for registration. I am looking for a way unregister the externalizer when client service stops.
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());
}
}
}