);
}
catch (Exception e)
{
//AS ToDo: must be checked later how to go ahead here
throw new RemoteException("Could not create a MBean on the cluster", e);
}
Iterator i = lValues.iterator();
ObjectInstance lInstance = null;
Throwable lException = null;
while (i.hasNext())
{
Object lValue = i.next();
if (lValue instanceof ObjectInstance)
{
if (lInstance == null)
{
lInstance = (ObjectInstance) lValue;
}
}
else if (lValue instanceof Throwable)
{
if (lException == null)
{
lException = (Throwable) lValue;
}
}
}
if (lException != null)
{
if (lInstance != null)
{
// Remove all existing MBeans
try
{
unregisterMBean(lInstance.getObjectName());
}
catch (Exception e)
{
// Ignore any exception
}
}
if (lException instanceof InstanceAlreadyExistsException)
{
throw (InstanceAlreadyExistsException) lException;
}
if (lException instanceof MBeanException)
{
throw (MBeanException) lException;
}
if (lException instanceof MBeanRegistrationException)
{
throw (MBeanRegistrationException) lException;
}
if (lException instanceof NotCompliantMBeanException)
{
throw (NotCompliantMBeanException) lException;
}
if (lException instanceof ReflectionException)
{
throw (ReflectionException) lException;
}
throw new RemoteException(lException.toString());
}
return lInstance;
}