Java Code Examples for javax.management.MBeanException#getTargetException()

The following examples show how to use javax.management.MBeanException#getTargetException() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Set the value of an SNMP variable.
 *
 * <p><b><i>
 * You should never need to use this method directly.
 * </i></b></p>
 *
 * @param meta  The impacted metadata object
 * @param name  The ObjectName of the impacted MBean
 * @param x     The new requested SnmpValue
 * @param id    The OID arc identifying the variable we're trying to set.
 * @param data  User contextual data allocated through the
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}
 *
 * @return The new value of the variable after the operation.
 *
 * @exception SnmpStatusException whenever an SNMP exception must be
 *      raised. Raising an exception will abort the request. <br>
 *      Exceptions should never be raised directly, but only by means of
 * <code>
 * req.registerSetException(<i>VariableId</i>,<i>SnmpStatusException</i>)
 * </code>
 **/
public SnmpValue set(SnmpGenericMetaServer meta, ObjectName name,
                     SnmpValue x, long id, Object data)
    throws SnmpStatusException {
    final String attname = meta.getAttributeName(id);
    final Object attvalue=
        meta.buildAttributeValue(id,x);
    final Attribute att = new Attribute(attname,attvalue);

    Object result = null;

    try {
        server.setAttribute(name,att);
        result = server.getAttribute(name,attname);
    } catch(InvalidAttributeValueException iv) {
        throw new
            SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
    } catch (InstanceNotFoundException f) {
        throw new
            SnmpStatusException(SnmpStatusException.snmpRspInconsistentName);
    } catch (ReflectionException r) {
        throw new
            SnmpStatusException(SnmpStatusException.snmpRspInconsistentName);
    } catch (MBeanException m) {
        Exception t = m.getTargetException();
        if (t instanceof SnmpStatusException)
            throw (SnmpStatusException) t;
        throw new
            SnmpStatusException(SnmpStatusException.noAccess);
    } catch (Exception e) {
        throw new
            SnmpStatusException(SnmpStatusException.noAccess);
    }

    return meta.buildSnmpValue(id,result);
}
 
Example 2
/**
 * Set the value of an SNMP variable.
 *
 * <p><b><i>
 * You should never need to use this method directly.
 * </i></b></p>
 *
 * @param meta  The impacted metadata object
 * @param name  The ObjectName of the impacted MBean
 * @param x     The new requested SnmpValue
 * @param id    The OID arc identifying the variable we're trying to set.
 * @param data  User contextual data allocated through the
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}
 *
 * @return The new value of the variable after the operation.
 *
 * @exception SnmpStatusException whenever an SNMP exception must be
 *      raised. Raising an exception will abort the request. <br>
 *      Exceptions should never be raised directly, but only by means of
 * <code>
 * req.registerSetException(<i>VariableId</i>,<i>SnmpStatusException</i>)
 * </code>
 **/
public SnmpValue set(SnmpGenericMetaServer meta, ObjectName name,
                     SnmpValue x, long id, Object data)
    throws SnmpStatusException {
    final String attname = meta.getAttributeName(id);
    final Object attvalue=
        meta.buildAttributeValue(id,x);
    final Attribute att = new Attribute(attname,attvalue);

    Object result = null;

    try {
        server.setAttribute(name,att);
        result = server.getAttribute(name,attname);
    } catch(InvalidAttributeValueException iv) {
        throw new
            SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
    } catch (InstanceNotFoundException f) {
        throw new
            SnmpStatusException(SnmpStatusException.snmpRspInconsistentName);
    } catch (ReflectionException r) {
        throw new
            SnmpStatusException(SnmpStatusException.snmpRspInconsistentName);
    } catch (MBeanException m) {
        Exception t = m.getTargetException();
        if (t instanceof SnmpStatusException)
            throw (SnmpStatusException) t;
        throw new
            SnmpStatusException(SnmpStatusException.noAccess);
    } catch (Exception e) {
        throw new
            SnmpStatusException(SnmpStatusException.noAccess);
    }

    return meta.buildSnmpValue(id,result);
}
 
Example 3
/**
 * Set the value of an SNMP variable.
 *
 * <p><b><i>
 * You should never need to use this method directly.
 * </i></b></p>
 *
 * @param meta  The impacted metadata object
 * @param name  The ObjectName of the impacted MBean
 * @param x     The new requested SnmpValue
 * @param id    The OID arc identifying the variable we're trying to set.
 * @param data  User contextual data allocated through the
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}
 *
 * @return The new value of the variable after the operation.
 *
 * @exception SnmpStatusException whenever an SNMP exception must be
 *      raised. Raising an exception will abort the request. <br>
 *      Exceptions should never be raised directly, but only by means of
 * <code>
 * req.registerSetException(<i>VariableId</i>,<i>SnmpStatusException</i>)
 * </code>
 **/
public SnmpValue set(SnmpGenericMetaServer meta, ObjectName name,
                     SnmpValue x, long id, Object data)
    throws SnmpStatusException {
    final String attname = meta.getAttributeName(id);
    final Object attvalue=
        meta.buildAttributeValue(id,x);
    final Attribute att = new Attribute(attname,attvalue);

    Object result = null;

    try {
        server.setAttribute(name,att);
        result = server.getAttribute(name,attname);
    } catch(InvalidAttributeValueException iv) {
        throw new
            SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
    } catch (InstanceNotFoundException f) {
        throw new
            SnmpStatusException(SnmpStatusException.snmpRspInconsistentName);
    } catch (ReflectionException r) {
        throw new
            SnmpStatusException(SnmpStatusException.snmpRspInconsistentName);
    } catch (MBeanException m) {
        Exception t = m.getTargetException();
        if (t instanceof SnmpStatusException)
            throw (SnmpStatusException) t;
        throw new
            SnmpStatusException(SnmpStatusException.noAccess);
    } catch (Exception e) {
        throw new
            SnmpStatusException(SnmpStatusException.noAccess);
    }

    return meta.buildSnmpValue(id,result);
}
 
Example 4
/**
 * Set the value of an SNMP variable.
 *
 * <p><b><i>
 * You should never need to use this method directly.
 * </i></b></p>
 *
 * @param meta  The impacted metadata object
 * @param name  The ObjectName of the impacted MBean
 * @param x     The new requested SnmpValue
 * @param id    The OID arc identifying the variable we're trying to set.
 * @param data  User contextual data allocated through the
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}
 *
 * @return The new value of the variable after the operation.
 *
 * @exception SnmpStatusException whenever an SNMP exception must be
 *      raised. Raising an exception will abort the request. <br>
 *      Exceptions should never be raised directly, but only by means of
 * <code>
 * req.registerSetException(<i>VariableId</i>,<i>SnmpStatusException</i>)
 * </code>
 **/
public SnmpValue set(SnmpGenericMetaServer meta, ObjectName name,
                     SnmpValue x, long id, Object data)
    throws SnmpStatusException {
    final String attname = meta.getAttributeName(id);
    final Object attvalue=
        meta.buildAttributeValue(id,x);
    final Attribute att = new Attribute(attname,attvalue);

    Object result = null;

    try {
        server.setAttribute(name,att);
        result = server.getAttribute(name,attname);
    } catch(InvalidAttributeValueException iv) {
        throw new
            SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
    } catch (InstanceNotFoundException f) {
        throw new
            SnmpStatusException(SnmpStatusException.snmpRspInconsistentName);
    } catch (ReflectionException r) {
        throw new
            SnmpStatusException(SnmpStatusException.snmpRspInconsistentName);
    } catch (MBeanException m) {
        Exception t = m.getTargetException();
        if (t instanceof SnmpStatusException)
            throw (SnmpStatusException) t;
        throw new
            SnmpStatusException(SnmpStatusException.noAccess);
    } catch (Exception e) {
        throw new
            SnmpStatusException(SnmpStatusException.noAccess);
    }

    return meta.buildSnmpValue(id,result);
}
 
Example 5
/**
 * Get the value of an SNMP variable.
 *
 * <p><b><i>
 * You should never need to use this method directly.
 * </i></b></p>
 *
 * @param meta  The impacted metadata object
 * @param name  The ObjectName of the impacted MBean
 * @param id    The OID arc identifying the variable we're trying to set.
 * @param data  User contextual data allocated through the
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}
 *
 * @return The value of the variable.
 *
 * @exception SnmpStatusException whenever an SNMP exception must be
 *      raised. Raising an exception will abort the request. <br>
 *      Exceptions should never be raised directly, but only by means of
 * <code>
 * req.registerGetException(<i>VariableId</i>,<i>SnmpStatusException</i>)
 * </code>
 **/
public SnmpValue get(SnmpGenericMetaServer meta, ObjectName name,
                     long id, Object data)
    throws SnmpStatusException {
    final String attname = meta.getAttributeName(id);
    Object result = null;

    try {
        result = server.getAttribute(name,attname);
    } catch (MBeanException m) {
        Exception t = m.getTargetException();
        if (t instanceof SnmpStatusException)
            throw (SnmpStatusException) t;
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    } catch (Exception e) {
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    }

    return meta.buildSnmpValue(id,result);
}
 
Example 6
/**
 * Retrieves the number of MBeans currently referenced in the given role.
 *
 * @param relationId  relation id
 * @param roleName  name of role
 *
 * @return the number of currently referenced MBeans in that role
 *
 * @exception IllegalArgumentException  if null parameter
 * @exception RelationNotFoundException  if no relation with given id
 * @exception RoleNotFoundException  if there is no role with given name
 */
public Integer getRoleCardinality(String relationId,
                                  String roleName)
    throws IllegalArgumentException,
           RelationNotFoundException,
           RoleNotFoundException {

    if (relationId == null || roleName == null) {
        String excMsg = "Invalid parameter.";
        throw new IllegalArgumentException(excMsg);
    }

    RELATION_LOGGER.entering(RelationService.class.getName(),
            "getRoleCardinality", new Object[] {relationId, roleName});

    // Can throw a RelationNotFoundException
    Object relObj = getRelation(relationId);

    Integer result;

    if (relObj instanceof RelationSupport) {
        // Internal relation
        // Can throw RoleNotFoundException
        result = ((RelationSupport)relObj).getRoleCardinality(roleName);

    } else {
        // Relation MBean
        Object[] params = new Object[1];
        params[0] = roleName;
        String[] signature = new String[1];
        signature[0] = "java.lang.String";
        // Can throw MBeanException wrapping RoleNotFoundException:
        // throw wrapped exception
        //
        // Shall not throw InstanceNotFoundException or ReflectionException
        try {
            result = (Integer)
                (myMBeanServer.invoke(((ObjectName)relObj),
                                      "getRoleCardinality",
                                      params,
                                      signature));
        } catch (InstanceNotFoundException exc1) {
            throw new RuntimeException(exc1.getMessage());
        } catch (ReflectionException exc2) {
            throw new RuntimeException(exc2.getMessage());
        } catch (MBeanException exc3) {
            Exception wrappedExc = exc3.getTargetException();
            if (wrappedExc instanceof RoleNotFoundException) {
                throw ((RoleNotFoundException)wrappedExc);
            } else {
                throw new RuntimeException(wrappedExc.getMessage());
            }
        }
    }

    RELATION_LOGGER.exiting(RelationService.class.getName(),
            "getRoleCardinality");
    return result;
}
 
Example 7
/**
 * Retrieves the number of MBeans currently referenced in the given role.
 *
 * @param relationId  relation id
 * @param roleName  name of role
 *
 * @return the number of currently referenced MBeans in that role
 *
 * @exception IllegalArgumentException  if null parameter
 * @exception RelationNotFoundException  if no relation with given id
 * @exception RoleNotFoundException  if there is no role with given name
 */
public Integer getRoleCardinality(String relationId,
                                  String roleName)
    throws IllegalArgumentException,
           RelationNotFoundException,
           RoleNotFoundException {

    if (relationId == null || roleName == null) {
        String excMsg = "Invalid parameter.";
        throw new IllegalArgumentException(excMsg);
    }

    RELATION_LOGGER.entering(RelationService.class.getName(),
            "getRoleCardinality", new Object[] {relationId, roleName});

    // Can throw a RelationNotFoundException
    Object relObj = getRelation(relationId);

    Integer result;

    if (relObj instanceof RelationSupport) {
        // Internal relation
        // Can throw RoleNotFoundException
        result = ((RelationSupport)relObj).getRoleCardinality(roleName);

    } else {
        // Relation MBean
        Object[] params = new Object[1];
        params[0] = roleName;
        String[] signature = new String[1];
        signature[0] = "java.lang.String";
        // Can throw MBeanException wrapping RoleNotFoundException:
        // throw wrapped exception
        //
        // Shall not throw InstanceNotFoundException or ReflectionException
        try {
            result = (Integer)
                (myMBeanServer.invoke(((ObjectName)relObj),
                                      "getRoleCardinality",
                                      params,
                                      signature));
        } catch (InstanceNotFoundException exc1) {
            throw new RuntimeException(exc1.getMessage());
        } catch (ReflectionException exc2) {
            throw new RuntimeException(exc2.getMessage());
        } catch (MBeanException exc3) {
            Exception wrappedExc = exc3.getTargetException();
            if (wrappedExc instanceof RoleNotFoundException) {
                throw ((RoleNotFoundException)wrappedExc);
            } else {
                throw new RuntimeException(wrappedExc.getMessage());
            }
        }
    }

    RELATION_LOGGER.exiting(RelationService.class.getName(),
            "getRoleCardinality");
    return result;
}
 
Example 8
/**
 * Get the value of an SNMP variable.
 *
 * <p><b><i>
 * You should never need to use this method directly.
 * </i></b></p>
 *
 * @param meta  The impacted metadata object
 * @param name  The ObjectName of the impacted MBean
 * @param id    The OID arc identifying the variable we're trying to set.
 * @param data  User contextual data allocated through the
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}
 *
 * @return The value of the variable.
 *
 * @exception SnmpStatusException whenever an SNMP exception must be
 *      raised. Raising an exception will abort the request. <br>
 *      Exceptions should never be raised directly, but only by means of
 * <code>
 * req.registerGetException(<i>VariableId</i>,<i>SnmpStatusException</i>)
 * </code>
 **/
public SnmpValue get(SnmpGenericMetaServer meta, ObjectName name,
                     long id, Object data)
    throws SnmpStatusException {
    final String attname = meta.getAttributeName(id);
    Object result = null;

    try {
        result = server.getAttribute(name,attname);
    } catch (MBeanException m) {
        Exception t = m.getTargetException();
        if (t instanceof SnmpStatusException)
            throw (SnmpStatusException) t;
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    } catch (Exception e) {
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    }

    return meta.buildSnmpValue(id,result);
}
 
Example 9
Source Project: JDKSourceCode1.8   File: RelationSupport.java    License: MIT License 4 votes vote down vote up
private void updateRelationServiceMap(Role newRole,
                                      List<ObjectName> oldRoleValue,
                                      boolean relationServCallFlg,
                                      RelationService relationServ)
    throws IllegalArgumentException,
           RelationServiceNotRegisteredException,
           RelationNotFoundException {

    if (newRole == null ||
        oldRoleValue == null ||
        (relationServCallFlg && relationServ == null)) {
        String excMsg = "Invalid parameter.";
        throw new IllegalArgumentException(excMsg);
    }

    RELATION_LOGGER.entering(RelationSupport.class.getName(),
            "updateRelationServiceMap", new Object[] {newRole,
            oldRoleValue, relationServCallFlg, relationServ});

    if (relationServCallFlg) {
        // Direct call to the Relation Service
        // Shall not throw a RelationNotFoundException
        try {
            relationServ.updateRoleMap(myRelId,
                                     newRole,
                                     oldRoleValue);
        } catch (RelationNotFoundException exc) {
            throw new RuntimeException(exc.getMessage());
        }

    } else {
        Object[] params = new Object[3];
        params[0] = myRelId;
        params[1] = newRole;
        params[2] = oldRoleValue;
        String[] signature = new String[3];
        signature[0] = "java.lang.String";
        signature[1] = "javax.management.relation.Role";
        signature[2] = "java.util.List";
        // Can throw InstanceNotFoundException if the Relation Service
        // is not registered (to be transformed).
        // Can throw a MBeanException wrapping a RelationNotFoundException:
        // wrapped exception to be thrown
        //
        // Shall not throw a ReflectionException
        try {
            myRelServiceMBeanServer.invoke(myRelServiceName,
                                           "updateRoleMap",
                                           params,
                                           signature);
        } catch (ReflectionException exc1) {
            throw new RuntimeException(exc1.getMessage());
        } catch (InstanceNotFoundException exc2) {
            throw new
                 RelationServiceNotRegisteredException(exc2.getMessage());
        } catch (MBeanException exc3) {
            Exception wrappedExc = exc3.getTargetException();
            if (wrappedExc instanceof RelationNotFoundException) {
                throw ((RelationNotFoundException)wrappedExc);
            } else {
                throw new RuntimeException(wrappedExc.getMessage());
            }
        }
    }

    RELATION_LOGGER.exiting(RelationSupport.class.getName(),
            "updateRelationServiceMap");
    return;
}
 
Example 10
/**
 * Get the value of an SNMP variable.
 *
 * <p><b><i>
 * You should never need to use this method directly.
 * </i></b></p>
 *
 * @param meta  The impacted metadata object
 * @param name  The ObjectName of the impacted MBean
 * @param id    The OID arc identifying the variable we're trying to set.
 * @param data  User contextual data allocated through the
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}
 *
 * @return The value of the variable.
 *
 * @exception SnmpStatusException whenever an SNMP exception must be
 *      raised. Raising an exception will abort the request. <br>
 *      Exceptions should never be raised directly, but only by means of
 * <code>
 * req.registerGetException(<i>VariableId</i>,<i>SnmpStatusException</i>)
 * </code>
 **/
public SnmpValue get(SnmpGenericMetaServer meta, ObjectName name,
                     long id, Object data)
    throws SnmpStatusException {
    final String attname = meta.getAttributeName(id);
    Object result = null;

    try {
        result = server.getAttribute(name,attname);
    } catch (MBeanException m) {
        Exception t = m.getTargetException();
        if (t instanceof SnmpStatusException)
            throw (SnmpStatusException) t;
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    } catch (Exception e) {
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    }

    return meta.buildSnmpValue(id,result);
}
 
Example 11
/**
 * Retrieves role value for given role name in given relation.
 *
 * @param relationId  relation id
 * @param roleName  name of role
 *
 * @return the ArrayList of ObjectName objects being the role value
 *
 * @exception RelationServiceNotRegisteredException  if the Relation
 * Service is not registered
 * @exception IllegalArgumentException  if null parameter
 * @exception RelationNotFoundException  if no relation with given id
 * @exception RoleNotFoundException  if:
 * <P>- there is no role with given name
 * <P>or
 * <P>- the role is not readable.
 *
 * @see #setRole
 */
public List<ObjectName> getRole(String relationId,
                                String roleName)
    throws RelationServiceNotRegisteredException,
           IllegalArgumentException,
           RelationNotFoundException,
           RoleNotFoundException {

    if (relationId == null || roleName == null) {
        String excMsg = "Invalid parameter.";
        throw new IllegalArgumentException(excMsg);
    }

    RELATION_LOGGER.entering(RelationService.class.getName(),
            "getRole", new Object[] {relationId, roleName});

    // Can throw RelationServiceNotRegisteredException
    isActive();

    // Can throw a RelationNotFoundException
    Object relObj = getRelation(relationId);

    List<ObjectName> result;

    if (relObj instanceof RelationSupport) {
        // Internal relation
        // Can throw RoleNotFoundException
        result = cast(
            ((RelationSupport)relObj).getRoleInt(roleName,
                                                 true,
                                                 this,
                                                 false));

    } else {
        // Relation MBean
        Object[] params = new Object[1];
        params[0] = roleName;
        String[] signature = new String[1];
        signature[0] = "java.lang.String";
        // Can throw MBeanException wrapping a RoleNotFoundException:
        // throw wrapped exception
        //
        // Shall not throw InstanceNotFoundException or ReflectionException
        try {
            List<ObjectName> invokeResult = cast(
                myMBeanServer.invoke(((ObjectName)relObj),
                                     "getRole",
                                     params,
                                     signature));
            if (invokeResult == null || invokeResult instanceof ArrayList<?>)
                result = invokeResult;
            else
                result = new ArrayList<ObjectName>(invokeResult);
        } catch (InstanceNotFoundException exc1) {
            throw new RuntimeException(exc1.getMessage());
        } catch (ReflectionException exc2) {
            throw new RuntimeException(exc2.getMessage());
        } catch (MBeanException exc3) {
            Exception wrappedExc = exc3.getTargetException();
            if (wrappedExc instanceof RoleNotFoundException) {
                throw ((RoleNotFoundException)wrappedExc);
            } else {
                throw new RuntimeException(wrappedExc.getMessage());
            }
        }
    }

    RELATION_LOGGER.exiting(RelationService.class.getName(), "getRole");
    return result;
}
 
Example 12
/**
 * Retrieves the number of MBeans currently referenced in the given role.
 *
 * @param relationId  relation id
 * @param roleName  name of role
 *
 * @return the number of currently referenced MBeans in that role
 *
 * @exception IllegalArgumentException  if null parameter
 * @exception RelationNotFoundException  if no relation with given id
 * @exception RoleNotFoundException  if there is no role with given name
 */
public Integer getRoleCardinality(String relationId,
                                  String roleName)
    throws IllegalArgumentException,
           RelationNotFoundException,
           RoleNotFoundException {

    if (relationId == null || roleName == null) {
        String excMsg = "Invalid parameter.";
        throw new IllegalArgumentException(excMsg);
    }

    RELATION_LOGGER.entering(RelationService.class.getName(),
            "getRoleCardinality", new Object[] {relationId, roleName});

    // Can throw a RelationNotFoundException
    Object relObj = getRelation(relationId);

    Integer result;

    if (relObj instanceof RelationSupport) {
        // Internal relation
        // Can throw RoleNotFoundException
        result = ((RelationSupport)relObj).getRoleCardinality(roleName);

    } else {
        // Relation MBean
        Object[] params = new Object[1];
        params[0] = roleName;
        String[] signature = new String[1];
        signature[0] = "java.lang.String";
        // Can throw MBeanException wrapping RoleNotFoundException:
        // throw wrapped exception
        //
        // Shall not throw InstanceNotFoundException or ReflectionException
        try {
            result = (Integer)
                (myMBeanServer.invoke(((ObjectName)relObj),
                                      "getRoleCardinality",
                                      params,
                                      signature));
        } catch (InstanceNotFoundException exc1) {
            throw new RuntimeException(exc1.getMessage());
        } catch (ReflectionException exc2) {
            throw new RuntimeException(exc2.getMessage());
        } catch (MBeanException exc3) {
            Exception wrappedExc = exc3.getTargetException();
            if (wrappedExc instanceof RoleNotFoundException) {
                throw ((RoleNotFoundException)wrappedExc);
            } else {
                throw new RuntimeException(wrappedExc.getMessage());
            }
        }
    }

    RELATION_LOGGER.exiting(RelationService.class.getName(),
            "getRoleCardinality");
    return result;
}
 
Example 13
private void updateRelationServiceMap(Role newRole,
                                      List<ObjectName> oldRoleValue,
                                      boolean relationServCallFlg,
                                      RelationService relationServ)
    throws IllegalArgumentException,
           RelationServiceNotRegisteredException,
           RelationNotFoundException {

    if (newRole == null ||
        oldRoleValue == null ||
        (relationServCallFlg && relationServ == null)) {
        String excMsg = "Invalid parameter.";
        throw new IllegalArgumentException(excMsg);
    }

    RELATION_LOGGER.entering(RelationSupport.class.getName(),
            "updateRelationServiceMap", new Object[] {newRole,
            oldRoleValue, relationServCallFlg, relationServ});

    if (relationServCallFlg) {
        // Direct call to the Relation Service
        // Shall not throw a RelationNotFoundException
        try {
            relationServ.updateRoleMap(myRelId,
                                     newRole,
                                     oldRoleValue);
        } catch (RelationNotFoundException exc) {
            throw new RuntimeException(exc.getMessage());
        }

    } else {
        Object[] params = new Object[3];
        params[0] = myRelId;
        params[1] = newRole;
        params[2] = oldRoleValue;
        String[] signature = new String[3];
        signature[0] = "java.lang.String";
        signature[1] = "javax.management.relation.Role";
        signature[2] = "java.util.List";
        // Can throw InstanceNotFoundException if the Relation Service
        // is not registered (to be transformed).
        // Can throw a MBeanException wrapping a RelationNotFoundException:
        // wrapped exception to be thrown
        //
        // Shall not throw a ReflectionException
        try {
            myRelServiceMBeanServer.invoke(myRelServiceName,
                                           "updateRoleMap",
                                           params,
                                           signature);
        } catch (ReflectionException exc1) {
            throw new RuntimeException(exc1.getMessage());
        } catch (InstanceNotFoundException exc2) {
            throw new
                 RelationServiceNotRegisteredException(exc2.getMessage());
        } catch (MBeanException exc3) {
            Exception wrappedExc = exc3.getTargetException();
            if (wrappedExc instanceof RelationNotFoundException) {
                throw ((RelationNotFoundException)wrappedExc);
            } else {
                throw new RuntimeException(wrappedExc.getMessage());
            }
        }
    }

    RELATION_LOGGER.exiting(RelationSupport.class.getName(),
            "updateRelationServiceMap");
    return;
}
 
Example 14
/**
 * Get the value of an SNMP variable.
 *
 * <p><b><i>
 * You should never need to use this method directly.
 * </i></b></p>
 *
 * @param meta  The impacted metadata object
 * @param name  The ObjectName of the impacted MBean
 * @param id    The OID arc identifying the variable we're trying to set.
 * @param data  User contextual data allocated through the
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}
 *
 * @return The value of the variable.
 *
 * @exception SnmpStatusException whenever an SNMP exception must be
 *      raised. Raising an exception will abort the request. <br>
 *      Exceptions should never be raised directly, but only by means of
 * <code>
 * req.registerGetException(<i>VariableId</i>,<i>SnmpStatusException</i>)
 * </code>
 **/
public SnmpValue get(SnmpGenericMetaServer meta, ObjectName name,
                     long id, Object data)
    throws SnmpStatusException {
    final String attname = meta.getAttributeName(id);
    Object result = null;

    try {
        result = server.getAttribute(name,attname);
    } catch (MBeanException m) {
        Exception t = m.getTargetException();
        if (t instanceof SnmpStatusException)
            throw (SnmpStatusException) t;
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    } catch (Exception e) {
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    }

    return meta.buildSnmpValue(id,result);
}
 
Example 15
/**
 * Retrieves role value for given role name in given relation.
 *
 * @param relationId  relation id
 * @param roleName  name of role
 *
 * @return the ArrayList of ObjectName objects being the role value
 *
 * @exception RelationServiceNotRegisteredException  if the Relation
 * Service is not registered
 * @exception IllegalArgumentException  if null parameter
 * @exception RelationNotFoundException  if no relation with given id
 * @exception RoleNotFoundException  if:
 * <P>- there is no role with given name
 * <P>or
 * <P>- the role is not readable.
 *
 * @see #setRole
 */
public List<ObjectName> getRole(String relationId,
                                String roleName)
    throws RelationServiceNotRegisteredException,
           IllegalArgumentException,
           RelationNotFoundException,
           RoleNotFoundException {

    if (relationId == null || roleName == null) {
        String excMsg = "Invalid parameter.";
        throw new IllegalArgumentException(excMsg);
    }

    RELATION_LOGGER.entering(RelationService.class.getName(),
            "getRole", new Object[] {relationId, roleName});

    // Can throw RelationServiceNotRegisteredException
    isActive();

    // Can throw a RelationNotFoundException
    Object relObj = getRelation(relationId);

    List<ObjectName> result;

    if (relObj instanceof RelationSupport) {
        // Internal relation
        // Can throw RoleNotFoundException
        result = cast(
            ((RelationSupport)relObj).getRoleInt(roleName,
                                                 true,
                                                 this,
                                                 false));

    } else {
        // Relation MBean
        Object[] params = new Object[1];
        params[0] = roleName;
        String[] signature = new String[1];
        signature[0] = "java.lang.String";
        // Can throw MBeanException wrapping a RoleNotFoundException:
        // throw wrapped exception
        //
        // Shall not throw InstanceNotFoundException or ReflectionException
        try {
            List<ObjectName> invokeResult = cast(
                myMBeanServer.invoke(((ObjectName)relObj),
                                     "getRole",
                                     params,
                                     signature));
            if (invokeResult == null || invokeResult instanceof ArrayList<?>)
                result = invokeResult;
            else
                result = new ArrayList<ObjectName>(invokeResult);
        } catch (InstanceNotFoundException exc1) {
            throw new RuntimeException(exc1.getMessage());
        } catch (ReflectionException exc2) {
            throw new RuntimeException(exc2.getMessage());
        } catch (MBeanException exc3) {
            Exception wrappedExc = exc3.getTargetException();
            if (wrappedExc instanceof RoleNotFoundException) {
                throw ((RoleNotFoundException)wrappedExc);
            } else {
                throw new RuntimeException(wrappedExc.getMessage());
            }
        }
    }

    RELATION_LOGGER.exiting(RelationService.class.getName(), "getRole");
    return result;
}
 
Example 16
/**
 * Retrieves role value for given role name in given relation.
 *
 * @param relationId  relation id
 * @param roleName  name of role
 *
 * @return the ArrayList of ObjectName objects being the role value
 *
 * @exception RelationServiceNotRegisteredException  if the Relation
 * Service is not registered
 * @exception IllegalArgumentException  if null parameter
 * @exception RelationNotFoundException  if no relation with given id
 * @exception RoleNotFoundException  if:
 * <P>- there is no role with given name
 * <P>or
 * <P>- the role is not readable.
 *
 * @see #setRole
 */
public List<ObjectName> getRole(String relationId,
                                String roleName)
    throws RelationServiceNotRegisteredException,
           IllegalArgumentException,
           RelationNotFoundException,
           RoleNotFoundException {

    if (relationId == null || roleName == null) {
        String excMsg = "Invalid parameter.";
        throw new IllegalArgumentException(excMsg);
    }

    RELATION_LOGGER.entering(RelationService.class.getName(),
            "getRole", new Object[] {relationId, roleName});

    // Can throw RelationServiceNotRegisteredException
    isActive();

    // Can throw a RelationNotFoundException
    Object relObj = getRelation(relationId);

    List<ObjectName> result;

    if (relObj instanceof RelationSupport) {
        // Internal relation
        // Can throw RoleNotFoundException
        result = cast(
            ((RelationSupport)relObj).getRoleInt(roleName,
                                                 true,
                                                 this,
                                                 false));

    } else {
        // Relation MBean
        Object[] params = new Object[1];
        params[0] = roleName;
        String[] signature = new String[1];
        signature[0] = "java.lang.String";
        // Can throw MBeanException wrapping a RoleNotFoundException:
        // throw wrapped exception
        //
        // Shall not throw InstanceNotFoundException or ReflectionException
        try {
            List<ObjectName> invokeResult = cast(
                myMBeanServer.invoke(((ObjectName)relObj),
                                     "getRole",
                                     params,
                                     signature));
            if (invokeResult == null || invokeResult instanceof ArrayList<?>)
                result = invokeResult;
            else
                result = new ArrayList<ObjectName>(invokeResult);
        } catch (InstanceNotFoundException exc1) {
            throw new RuntimeException(exc1.getMessage());
        } catch (ReflectionException exc2) {
            throw new RuntimeException(exc2.getMessage());
        } catch (MBeanException exc3) {
            Exception wrappedExc = exc3.getTargetException();
            if (wrappedExc instanceof RoleNotFoundException) {
                throw ((RoleNotFoundException)wrappedExc);
            } else {
                throw new RuntimeException(wrappedExc.getMessage());
            }
        }
    }

    RELATION_LOGGER.exiting(RelationService.class.getName(), "getRole");
    return result;
}
 
Example 17
private void sendRoleUpdateNotification(Role newRole,
                                        List<ObjectName> oldRoleValue,
                                        boolean relationServCallFlg,
                                        RelationService relationServ)
    throws IllegalArgumentException,
           RelationServiceNotRegisteredException,
           RelationNotFoundException {

    if (newRole == null ||
        oldRoleValue == null ||
        (relationServCallFlg && relationServ == null)) {
        String excMsg = "Invalid parameter.";
        throw new IllegalArgumentException(excMsg);
    }

    RELATION_LOGGER.entering(RelationSupport.class.getName(),
            "sendRoleUpdateNotification", new Object[] {newRole,
            oldRoleValue, relationServCallFlg, relationServ});

    if (relationServCallFlg) {
        // Direct call to the Relation Service
        // Shall not throw a RelationNotFoundException for an internal
        // relation
        try {
            relationServ.sendRoleUpdateNotification(myRelId,
                                                  newRole,
                                                  oldRoleValue);
        } catch (RelationNotFoundException exc) {
            throw new RuntimeException(exc.getMessage());
        }

    } else {

        Object[] params = new Object[3];
        params[0] = myRelId;
        params[1] = newRole;
        params[2] = oldRoleValue;
        String[] signature = new String[3];
        signature[0] = "java.lang.String";
        signature[1] = "javax.management.relation.Role";
        signature[2] = "java.util.List";

        // Can throw InstanceNotFoundException if the Relation Service
        // is not registered (to be transformed).
        //
        // Can throw a MBeanException wrapping a
        // RelationNotFoundException (to be raised in any case): wrapped
        // exception to be thrown
        //
        // Shall not throw a ReflectionException
        try {
            myRelServiceMBeanServer.invoke(myRelServiceName,
                                           "sendRoleUpdateNotification",
                                           params,
                                           signature);
        } catch (ReflectionException exc1) {
            throw new RuntimeException(exc1.getMessage());
        } catch (InstanceNotFoundException exc2) {
            throw new RelationServiceNotRegisteredException(
                                                        exc2.getMessage());
        } catch (MBeanException exc3) {
            Exception wrappedExc = exc3.getTargetException();
            if (wrappedExc instanceof RelationNotFoundException) {
                throw ((RelationNotFoundException)wrappedExc);
            } else {
                throw new RuntimeException(wrappedExc.getMessage());
            }
        }
    }

    RELATION_LOGGER.exiting(RelationSupport.class.getName(),
            "sendRoleUpdateNotification");
    return;
}
 
Example 18
private void updateRelationServiceMap(Role newRole,
                                      List<ObjectName> oldRoleValue,
                                      boolean relationServCallFlg,
                                      RelationService relationServ)
    throws IllegalArgumentException,
           RelationServiceNotRegisteredException,
           RelationNotFoundException {

    if (newRole == null ||
        oldRoleValue == null ||
        (relationServCallFlg && relationServ == null)) {
        String excMsg = "Invalid parameter.";
        throw new IllegalArgumentException(excMsg);
    }

    RELATION_LOGGER.entering(RelationSupport.class.getName(),
            "updateRelationServiceMap", new Object[] {newRole,
            oldRoleValue, relationServCallFlg, relationServ});

    if (relationServCallFlg) {
        // Direct call to the Relation Service
        // Shall not throw a RelationNotFoundException
        try {
            relationServ.updateRoleMap(myRelId,
                                     newRole,
                                     oldRoleValue);
        } catch (RelationNotFoundException exc) {
            throw new RuntimeException(exc.getMessage());
        }

    } else {
        Object[] params = new Object[3];
        params[0] = myRelId;
        params[1] = newRole;
        params[2] = oldRoleValue;
        String[] signature = new String[3];
        signature[0] = "java.lang.String";
        signature[1] = "javax.management.relation.Role";
        signature[2] = "java.util.List";
        // Can throw InstanceNotFoundException if the Relation Service
        // is not registered (to be transformed).
        // Can throw a MBeanException wrapping a RelationNotFoundException:
        // wrapped exception to be thrown
        //
        // Shall not throw a ReflectionException
        try {
            myRelServiceMBeanServer.invoke(myRelServiceName,
                                           "updateRoleMap",
                                           params,
                                           signature);
        } catch (ReflectionException exc1) {
            throw new RuntimeException(exc1.getMessage());
        } catch (InstanceNotFoundException exc2) {
            throw new
                 RelationServiceNotRegisteredException(exc2.getMessage());
        } catch (MBeanException exc3) {
            Exception wrappedExc = exc3.getTargetException();
            if (wrappedExc instanceof RelationNotFoundException) {
                throw ((RelationNotFoundException)wrappedExc);
            } else {
                throw new RuntimeException(wrappedExc.getMessage());
            }
        }
    }

    RELATION_LOGGER.exiting(RelationSupport.class.getName(),
            "updateRelationServiceMap");
    return;
}
 
Example 19
/**
 * Get the value of an SNMP variable.
 *
 * <p><b><i>
 * You should never need to use this method directly.
 * </i></b></p>
 *
 * @param meta  The impacted metadata object
 * @param name  The ObjectName of the impacted MBean
 * @param id    The OID arc identifying the variable we're trying to set.
 * @param data  User contextual data allocated through the
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}
 *
 * @return The value of the variable.
 *
 * @exception SnmpStatusException whenever an SNMP exception must be
 *      raised. Raising an exception will abort the request. <br>
 *      Exceptions should never be raised directly, but only by means of
 * <code>
 * req.registerGetException(<i>VariableId</i>,<i>SnmpStatusException</i>)
 * </code>
 **/
public SnmpValue get(SnmpGenericMetaServer meta, ObjectName name,
                     long id, Object data)
    throws SnmpStatusException {
    final String attname = meta.getAttributeName(id);
    Object result = null;

    try {
        result = server.getAttribute(name,attname);
    } catch (MBeanException m) {
        Exception t = m.getTargetException();
        if (t instanceof SnmpStatusException)
            throw (SnmpStatusException) t;
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    } catch (Exception e) {
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    }

    return meta.buildSnmpValue(id,result);
}
 
Example 20
private void sendRoleUpdateNotification(Role newRole,
                                        List<ObjectName> oldRoleValue,
                                        boolean relationServCallFlg,
                                        RelationService relationServ)
    throws IllegalArgumentException,
           RelationServiceNotRegisteredException,
           RelationNotFoundException {

    if (newRole == null ||
        oldRoleValue == null ||
        (relationServCallFlg && relationServ == null)) {
        String excMsg = "Invalid parameter.";
        throw new IllegalArgumentException(excMsg);
    }

    RELATION_LOGGER.entering(RelationSupport.class.getName(),
            "sendRoleUpdateNotification", new Object[] {newRole,
            oldRoleValue, relationServCallFlg, relationServ});

    if (relationServCallFlg) {
        // Direct call to the Relation Service
        // Shall not throw a RelationNotFoundException for an internal
        // relation
        try {
            relationServ.sendRoleUpdateNotification(myRelId,
                                                  newRole,
                                                  oldRoleValue);
        } catch (RelationNotFoundException exc) {
            throw new RuntimeException(exc.getMessage());
        }

    } else {

        Object[] params = new Object[3];
        params[0] = myRelId;
        params[1] = newRole;
        params[2] = oldRoleValue;
        String[] signature = new String[3];
        signature[0] = "java.lang.String";
        signature[1] = "javax.management.relation.Role";
        signature[2] = "java.util.List";

        // Can throw InstanceNotFoundException if the Relation Service
        // is not registered (to be transformed).
        //
        // Can throw a MBeanException wrapping a
        // RelationNotFoundException (to be raised in any case): wrapped
        // exception to be thrown
        //
        // Shall not throw a ReflectionException
        try {
            myRelServiceMBeanServer.invoke(myRelServiceName,
                                           "sendRoleUpdateNotification",
                                           params,
                                           signature);
        } catch (ReflectionException exc1) {
            throw new RuntimeException(exc1.getMessage());
        } catch (InstanceNotFoundException exc2) {
            throw new RelationServiceNotRegisteredException(
                                                        exc2.getMessage());
        } catch (MBeanException exc3) {
            Exception wrappedExc = exc3.getTargetException();
            if (wrappedExc instanceof RelationNotFoundException) {
                throw ((RelationNotFoundException)wrappedExc);
            } else {
                throw new RuntimeException(wrappedExc.getMessage());
            }
        }
    }

    RELATION_LOGGER.exiting(RelationSupport.class.getName(),
            "sendRoleUpdateNotification");
    return;
}