{
if (server == null || cache == null)
return;
List interceptors = cache.getInterceptors();
Interceptor interceptor = null;
// get the cache's registration name
String tmpName = cache.getServiceName() != null? cache.getServiceName().toString() : null;
if(tmpName == null)
{
tmpName = PREFIX + cache.getClusterName();
if(cache.getClusterName() == null)
tmpName = PREFIX + cache.getClass().getName() + System.currentTimeMillis();
}
// register the cache
if (registerCache)
{
ObjectName tmpObj = new ObjectName(tmpName);
if (!server.isRegistered(tmpObj))
{
// under some circumstances, this block may be executed on WebSphere when the name is already registered
try
{
server.registerMBean(cache, tmpObj);
}
catch (Exception e)
{
LOG.warn("mbean registration failed for " + tmpObj.getCanonicalName() + "; " + e.toString());
}
}
else
{
LOG.warn("mbean " + tmpObj.getCanonicalName() + " already registered");
}
}
for(int i = 0; i < interceptors.size(); i++)
{
interceptor =(Interceptor)interceptors.get(i);
boolean mbeanExists = true;
try
{
// the mbean for interceptor AbcInterceptor will be named AbcInterceptorMBean
Class.forName(interceptor.getClass().getName()+ MBEAN_CLASS_SUFFIX);
}
catch(Throwable e)
{
// if the class can't be instantiated, no mbean is available
mbeanExists = false;
}
// for JDK 1.4, must parse name and remove package prefix
// for JDK 1.5, can use getSimpleName() to establish class name without package prefix
String className = interceptor.getClass().getName();
String serviceName = tmpName + MBEAN_KEY + className.substring(className.lastIndexOf('.')+1);
ObjectName objName = new ObjectName(serviceName);
if (!server.isRegistered(objName))
{