User: ejort
Date: 02/02/16 02:29:55
Modified: src/main/javax/management/relation RelationService.java
RelationServiceMBean.java RelationSupport.java
RoleInfo.java
Log:
Updated relation tests - still not finished :-(
Revision Changes Path
1.3 +6 -5 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RelationService.java 26 Jan 2002 15:13:24 -0000 1.2
+++ RelationService.java 16 Feb 2002 10:29:55 -0000 1.3
@@ -35,7 +35,7 @@
* @see RelationServiceMBean
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>.
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class RelationService
extends NotificationBroadcasterSupport
@@ -213,14 +213,15 @@
}
// Is it readable?
- if (roleInfo.isReadable() == true)
+ if (roleInfo.isReadable() == false)
return new Integer(RoleStatus.ROLE_NOT_READABLE);
// Yes it is
return new Integer(0);
}
- public Integer checkRoleWriting(String roleName, String relationTypeName)
+ public Integer checkRoleWriting(Role role, String relationTypeName,
+ Boolean initFlag)
throws IllegalArgumentException, RelationTypeNotFoundException
{
// Get the relation type
@@ -230,7 +231,7 @@
RoleInfo roleInfo = null;
try
{
- roleInfo = relationType.getRoleInfo(roleName);
+ roleInfo = relationType.getRoleInfo(role.getRoleName());
}
catch (RoleInfoNotFoundException e)
{
@@ -238,7 +239,7 @@
}
// Is it writable?
- if (roleInfo.isWritable() == true)
+ if (initFlag.booleanValue() == false && roleInfo.isWritable() == true)
return new Integer(RoleStatus.ROLE_NOT_WRITABLE);
// Yes it is
1.3 +5 -3 jmx/src/main/javax/management/relation/RelationServiceMBean.java
Index: RelationServiceMBean.java
===================================================================
RCS file:
/cvsroot/jboss/jmx/src/main/javax/management/relation/RelationServiceMBean.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RelationServiceMBean.java 26 Jan 2002 15:13:24 -0000 1.2
+++ RelationServiceMBean.java 16 Feb 2002 10:29:55 -0000 1.3
@@ -22,7 +22,7 @@
* Allowing relations to be queried.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>.
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public interface RelationServiceMBean
{
@@ -98,14 +98,16 @@
* The return value is either zero when writable or a value from
* {@link RoleStatus}.
*
- * @param roleName the name of the role to check.
+ * @param role the role to check.
* @param relationTypeName the relation type to check.
+ * @param initFlag write access is not check when this flag is true.
* @return the result described above.
* @exception IllegalArgumentException for a null parameters.
* @exception RelationTypeNotFoundException if the relation type does
* exist in the relation service.
*/
- public Integer checkRoleWriting(String roleName, String relationTypeName)
+ public Integer checkRoleWriting(Role role, String relationTypeName,
+ Boolean initFlag)
throws IllegalArgumentException, RelationTypeNotFoundException;
/**
1.4 +82 -49 jmx/src/main/javax/management/relation/RelationSupport.java
Index: RelationSupport.java
===================================================================
RCS file:
/cvsroot/jboss/jmx/src/main/javax/management/relation/RelationSupport.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RelationSupport.java 8 Feb 2002 21:17:54 -0000 1.3
+++ RelationSupport.java 16 Feb 2002 10:29:55 -0000 1.4
@@ -13,6 +13,7 @@
import java.util.Map;
import javax.management.InstanceNotFoundException;
+import javax.management.IntrospectionException;
import javax.management.MBeanException;
import javax.management.MBeanRegistration;
import javax.management.MBeanServer;
@@ -20,6 +21,10 @@
import javax.management.ReflectionException;
import javax.management.RuntimeMBeanException;
+import javax.management.relation.RelationServiceMBean;
+
+import org.jboss.mx.util.MBeanProxy;
+
/**
* Implements the management interface for a relation
* created internally within the relation service. The relation can
@@ -29,7 +34,7 @@
* extending it, and then registered with the relation service.<p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>.
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class RelationSupport
implements RelationSupportMBean, MBeanRegistration
@@ -49,6 +54,11 @@
ObjectName relationService;
/**
+ * A proxy to the relation service
+ */
+ private RelationServiceMBean serviceProxy;
+
+ /**
* The mbean server
*/
MBeanServer server;
@@ -185,6 +195,10 @@
result.put(mbean, resultRoles);
}
+ // It seems the role name should be duplicated?
+ // Include the following test if this is a bug in RI.
+ // if (resultRoles.contains(roleName) == false)
+
// Add the role to this mbean
resultRoles.add(roleName);
}
@@ -216,7 +230,8 @@
{
if (roleName == null)
throw new IllegalArgumentException("null role name");
- Role role = validateRoleReadable(roleName);
+ validateRoleReadable(roleName);
+ Role role = validateRoleFound(roleName);
return role.getRoleValue();
}
@@ -431,24 +446,15 @@
private int checkRoleReadable(Role role)
throws RelationServiceNotRegisteredException
{
+ checkServiceProxy();
try
{
- Integer result = (Integer) server.invoke(relationService, "checkRoleReading",
- new Object[] { role, relationTypeName },
- new String[] { "java.lang.String", "javax.management.RelationType" });
- return result.intValue();
- }
- catch (InstanceNotFoundException e)
- {
- throw new RelationServiceNotRegisteredException(e.getMessage());
+ return serviceProxy.checkRoleReading(role.getRoleName(),
+ relationTypeName).intValue();
}
- catch (MBeanException e)
- {
- // RelationTypeNotFound is included here. The spec doesn't
- // allow for this error, but it could be thrown by checkRoleReading()
- throw new RuntimeException(e.getTargetException().toString());
- }
- catch (ReflectionException e)
+ // RelationTypeNotFound has to be a runtime exception because
+ // the spec doesn't allow for this exception
+ catch (RelationTypeNotFoundException e)
{
throw new RuntimeException(e.toString());
}
@@ -468,27 +474,15 @@
private int checkRoleWritable(Role role, boolean initFlag)
throws RelationServiceNotRegisteredException, RelationTypeNotFoundException
{
+ checkServiceProxy();
try
{
- Integer result = (Integer) server.invoke(relationService, "checkRoleWriting",
- new Object[] { role, relationTypeName, new Boolean(initFlag) },
- new String[] { "java.lang.String", "javax.management.RelationType",
- "java.lang.Boolean" });
- return result.intValue();
- }
- catch (InstanceNotFoundException e)
- {
- throw new RelationServiceNotRegisteredException(e.getMessage());
- }
- catch (MBeanException mbe)
- {
- Exception e = mbe.getTargetException();
- if (e instanceof RelationTypeNotFoundException)
- throw (RelationTypeNotFoundException) e;
- else
- throw new RuntimeException(e.toString());
+ return serviceProxy.checkRoleWriting(role, relationTypeName,
+ new Boolean(initFlag)).intValue();
}
- catch (ReflectionException e)
+ // RelationTypeNotFound has to be a runtime exception because
+ // the spec doesn't allow for this exception
+ catch (RelationTypeNotFoundException e)
{
throw new RuntimeException(e.toString());
}
@@ -505,14 +499,9 @@
roles.put(role.getRoleName(), role);
try
{
- server.invoke(relationService, "updateRoleMap",
- new Object[] { relationId, role, oldRoleValue },
- new String[] { "java.lang.String", "javax.management.relation.Role",
- "java.util.List" });
- server.invoke(relationService, "sendRoleUpdateNotification",
- new Object[] { relationId, role, oldRoleValue },
- new String[] { "java.lang.String", "javax.management.relation.Role",
- "java.util.List" });
+ checkServiceProxy();
+ serviceProxy.updateRoleMap(relationId, role, oldRoleValue);
+ serviceProxy.sendRoleUpdateNotification(relationId, role, oldRoleValue);
}
catch (Exception e)
{
@@ -540,18 +529,31 @@
* Validate the role is readable, i.e. it is found and readable
*
* @param roleName the role name to validate
- * @return the found role
* @exception RoleNotFoundException when the role is not readable
* @exception RelationServiceNotRegisteredException when the relation
* is not registered with an MBeanServer.
*/
- private Role validateRoleReadable(String roleName)
+ private void validateRoleReadable(String roleName)
throws RoleNotFoundException, RelationServiceNotRegisteredException
{
- Role result = validateRoleFound(roleName);
- if (checkRoleReadable(result) != 0)
- throw new RoleNotFoundException("role not readable");
- return result;
+ int status = 0;
+ checkServiceProxy();
+ try
+ {
+ status = serviceProxy.checkRoleReading(roleName,
+ relationTypeName).intValue();
+ }
+ // RelationTypeNotFound has to be a runtime exception because
+ // the spec doesn't allow for this exception
+ catch (RelationTypeNotFoundException e)
+ {
+ throw new RuntimeException(e.toString());
+ }
+
+ if (status == 3)
+ throw new RoleNotFoundException(roleName);
+ if (status == 6)
+ throw new RoleNotFoundException(roleName + " is not readable");
}
/**
@@ -574,5 +576,36 @@
if (checkRoleWritable(result, initFlag) != 0)
throw new RoleNotFoundException("role not writable");
return result;
+ }
+
+ /**
+ * Check the relation service proxy has been constructed.
+ *
+ * @exception RelationServiceNotRegisteredException when the relation
+ * service has not been registered with the MBeanServer
+ */
+ private void checkServiceProxy()
+ throws RelationServiceNotRegisteredException
+ {
+ if (serviceProxy == null)
+ {
+ try
+ {
+ serviceProxy = (RelationServiceMBean) MBeanProxy.get(
+ RelationServiceMBean.class, relationService, server);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ throw new RelationServiceNotRegisteredException(e.toString());
+ }
+ catch (IntrospectionException e)
+ {
+ throw new RuntimeException(e.toString());
+ }
+ catch (ReflectionException e)
+ {
+ throw new RuntimeException(e.toString());
+ }
+ }
}
}
1.4 +3 -1 jmx/src/main/javax/management/relation/RoleInfo.java
Index: RoleInfo.java
===================================================================
RCS file: /cvsroot/jboss/jmx/src/main/javax/management/relation/RoleInfo.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RoleInfo.java 8 Feb 2002 21:17:54 -0000 1.3
+++ RoleInfo.java 16 Feb 2002 10:29:55 -0000 1.4
@@ -20,7 +20,7 @@
* are part of the role, whether the role is read/write, etc.<p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>.
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*
*/
public class RoleInfo
@@ -187,6 +187,8 @@
this.className = className;
this.minDegree = minDegree;
this.maxDegree = maxDegree;
+ this.readable = readable;
+ this.writable = writable;
this.description = description;
checkClass();
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development