User: ejort
Date: 02/03/11 10:21:32
Modified: src/main/javax/management/relation RelationService.java
RoleValidator.java
Log:
Relation Service Fixes, not applied to 1.0 yet
Revision Changes Path
1.5 +29 -9 jmx/src/main/javax/management/relation/RelationService.java
Index: RelationService.java
===================================================================
RCS file:
/cvsroot/jboss/jmx/src/main/javax/management/relation/RelationService.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RelationService.java 1 Mar 2002 19:25:57 -0000 1.4
+++ RelationService.java 11 Mar 2002 18:21:31 -0000 1.5
@@ -15,7 +15,9 @@
import java.util.Stack;
import javax.management.Attribute;
+import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
+import javax.management.InvalidAttributeValueException;
import javax.management.MBeanException;
import javax.management.MBeanNotificationInfo;
import javax.management.MBeanRegistration;
@@ -32,10 +34,19 @@
/**
* Implements the management interface for a relation service.<p>
*
+ * <p><b>Revisions:</b>
+ * <p><b>20020311 Adrian Brock:</b>
+ * <ul>
+ * <li>Fixed setRole for external MBean and exception handling
+ * <li>EmptyStack exception in purging
+ * <li>Unregistered mbeans should only contain relation mbeans
+ * <li>Unregister notifications not working after change to MBean Filter
+ * </ul>
+ *
* @see RelationServiceMBean
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>.
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class RelationService
extends NotificationBroadcasterSupport
@@ -665,12 +676,10 @@
{
isActive();
// Keep going until they are all done
- while (true)
+ while (unregistered.empty() == false)
{
// Get the next object
ObjectName mbean = (ObjectName) unregistered.pop();
- if (mbean == null)
- break;
// Keep track of the remain relations/roles
HashMap relationRoles = new HashMap();
@@ -772,6 +781,7 @@
// Check to see whether this will remove the MBean
Iterator iterator = unregMBeans.iterator();
+ while (iterator.hasNext())
{
// Remove the MBeans relation role map
ObjectName mbean = (ObjectName) iterator.next();
@@ -781,8 +791,9 @@
// We were the last?
if (idRolesMap.size() == 0)
idRolesMapByMBean.remove(mbean);
- else
- // Not the last, we aren't unregistering it
+
+ // Is this an MBean a relation?
+ if (idsByRelation.containsKey(mbean) == false)
iterator.remove();
}
@@ -934,8 +945,7 @@
ObjectName objectName = (ObjectName) relation;
try
{
- server.invoke(objectName, "setRole", new Object[] { role },
- new String[] { "javax.management.relation.Role" });
+ server.setAttribute(objectName, new Attribute("Role", role));
}
catch (InstanceNotFoundException e)
{
@@ -946,9 +956,19 @@
Exception e = mbe.getTargetException();
if (e instanceof RoleNotFoundException)
throw (RoleNotFoundException) e;
+ else if (e instanceof InvalidRoleValueException)
+ throw (InvalidRoleValueException) e;
else
throw new RuntimeException(e.toString());
}
+ catch (AttributeNotFoundException e)
+ {
+ throw new RuntimeException(e.toString());
+ }
+ catch (InvalidAttributeValueException e)
+ {
+ throw new RuntimeException(e.toString());
+ }
catch (ReflectionException e)
{
throw new RuntimeException(e.toString());
@@ -1079,7 +1099,7 @@
// Install our notification listener we aren't interested in registration
// We aren't monitoring anything at start-up
filter = new MBeanServerNotificationFilter();
- filter.disableType(MBeanServerNotification.REGISTRATION_NOTIFICATION);
+ filter.enableType(MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
filter.disableAllObjectNames();
delegate = new ObjectName(MBeanServerImpl.MBEAN_SERVER_DELEGATE);
server.addNotificationListener(delegate, this, filter, null);
1.2 +8 -1 jmx/src/main/javax/management/relation/RoleValidator.java
Index: RoleValidator.java
===================================================================
RCS file: /cvsroot/jboss/jmx/src/main/javax/management/relation/RoleValidator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RoleValidator.java 26 Jan 2002 15:13:24 -0000 1.1
+++ RoleValidator.java 11 Mar 2002 18:21:31 -0000 1.2
@@ -20,8 +20,14 @@
*
* It is package private and NOT part of the specification.
*
+ * <p><b>Revisions:</b>
+ * <p><b>20020311 Adrian Brock:</b>
+ * <ul>
+ * <li>ValidateRole always failed
+ * </ul>
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>.
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*
*/
class RoleValidator
@@ -163,9 +169,10 @@
{
int status = checkRole(relationService, server, relationTypeName, role,
write);
+
if (status == RoleStatus.NO_ROLE_WITH_NAME)
throw new RoleNotFoundException(role.getRoleName());
- else
+ else if (status != 0)
throw new InvalidRoleValueException(role.getRoleName());
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development