Package javax.management

Examples of javax.management.InvalidAttributeValueException


            Object cookie)
            throws InvalidAttributeValueException {
        if (!validParameter(setter, arg, 0, cookie)) {
            final String msg =
                    "Invalid value for attribute " + name + ": " + arg;
            throw new InvalidAttributeValueException(msg);
        }
    }
View Full Code Here


        trace("getAttribute(String)",
              "Wrong response type '" + respType + "'");
          // throw exception, didn't get
          // back right attribute type
          throw new MBeanException(
            new InvalidAttributeValueException(
              "Wrong value type received for get attribute"),
            "An exception occurred while trying to get an " +
            "attribute value through a RequiredModelMBean");
      }
                    }
    }
      } else {
    if (tracing())
        trace("getAttribute(String)","getMethod failed " +
        attrName + " not in attributeDescriptor\n");
    throw new MBeanException(new
        InvalidAttributeValueException(
        "Unable to resolve attribute value, " +
        "no getMethod defined in descriptor for attribute"),
        "An exception occurred while trying to get an "+
        "attribute value through a RequiredModelMBean");
View Full Code Here

      /* run method from operations descriptor */
      if (attrSetMethod == null) {
    if (attrValue != null) {
        try {
      final Class  clazz    = loadClass(attrType);
      if (! clazz.isInstance(attrValue))  throw new
          InvalidAttributeValueException(clazz.getName() +
                 " expected, "   +
              attrValue.getClass().getName() +
                 " received.");
        } catch (ClassNotFoundException x) {
      trace("setAttribute","Class " + attrType +
            " for attribute " + attrName + " not found: " +
            x);
      debug("setAttribute",x);
        }
    }
    updateDescriptor = true;
      } else {
      setResponse = invoke(attrSetMethod,
         (new Object[] {attrValue}),
         (new String[] {attrType}) );
      }
   
      /* change cached value */
      Object objctl = attrDescr.getFieldValue("currencyTimeLimit");
      String ctl;
      if (objctl != null) ctl = objctl.toString();
      else ctl = null;
         
      if ((ctl == null) && (mmbDesc != null)) {   
    objctl = mmbDesc.getFieldValue("currencyTimeLimit");
    if (objctl != null) ctl = objctl.toString();
    else ctl = null;
      }
   
      final boolean updateCache = ((ctl != null) && !(ctl.equals("-1")));

             if(attrSetMethod == null  && !updateCache && attrGetMethod != null)
                throw new MBeanException(new ServiceNotFoundException("No " +
                        "setMethod field is defined in the descriptor for " +
                        attrName + " attribute and caching is not enabled " +
                        "for it"));
           
      if (updateCache || updateDescriptor) {
    if (tracing())
        trace("setAttribute()","setting cached value of " +
        attrName + " to " + attrValue);

    attrDescr.setField("value", attrValue);

    if (updateCache) {
        final String currtime =
      (new Long((new Date()).getTime())).toString();

    attrDescr.setField("lastUpdatedTimeStamp", currtime);
    }

    attrInfo.setDescriptor(attrDescr);
     
    modelMBeanInfo.setDescriptor(attrDescr,"attribute");
    if (tracing()) {
        trace("setAttribute()","new descriptor is " +
        attrDescr.toString());
        trace("setAttribute()","AttributeInfo descriptor is " +
        attrInfo.getDescriptor().toString());
        trace("setAttribute()","AttributeInfo descriptor is " +
        modelMBeanInfo.getDescriptor(attrName,"attribute")
        .toString());
    }
     
      }

      if (tracing())
    trace("setAttribute()","sending sendAttributeNotification");
   
      sendAttributeChangeNotification(oldAttr,attribute);
   
  } else { // if descriptor ... else no descriptor
       
      if (tracing())
    trace("setAttribute(String)","setMethod failed "+attrName+
          " not in attributeDescriptor\n");

      throw new InvalidAttributeValueException(
                      "Unable to resolve attribute value, "+
          "no defined in descriptor for attribute");
  } // else no descriptor
     
  if (tracing())
View Full Code Here

      throw new AttributeNotFoundException(
                                     "Attribute name cannot be null");
  }

  if (value == null) {
      throw new InvalidAttributeValueException(
                                      "Attribute value for attribute " +
                                      name + " cannot be null");
  }

        try {
            if (name.equals(ATT_SET_READ_ONLY)) {
                openConfig.setReadOnly(((Boolean) value).booleanValue());
            } else if (name.equals(ATT_SET_TRANSACTIONAL)) {
                openConfig.setTransactional(((Boolean) value).booleanValue());
            } else if (name.equals(ATT_SET_SERIALIZABLE)) {
                openConfig.setTxnSerializableIsolation(
                                             ((Boolean) value).booleanValue());
            } else {
                /* Set the specified attribute if the environment is open. */
                if (targetEnv != null) {

                    EnvironmentMutableConfig config =
                        targetEnv.getMutableConfig();

                    if (name.equals(ATT_CACHE_SIZE)) {
                        config.setCacheSize(((Long) value).longValue());
                        targetEnv.setMutableConfig(config);
                    } else if (name.equals(ATT_CACHE_PERCENT)) {
                        config.setCachePercent(((Integer) value).intValue());
                        targetEnv.setMutableConfig(config);
                    } else {
                        throw new AttributeNotFoundException("attribute " +
                                                             name +
                                                             " is not valid.");
                    }
                } else {
                    throw new AttributeNotFoundException("attribute " +
                                                         name +
                                                         " is not valid.");
                }
            }
        } catch (NumberFormatException e) {
            throw new InvalidAttributeValueException("attribute name=" + name);
        } catch (DatabaseException e) {
            throw new InvalidAttributeValueException("attribute name=" + name +
                                                     e.getMessage());
        }
    }
View Full Code Here

        {
            m.invoke( this, args );
        }
        catch (IllegalArgumentException e)
        {
            throw new InvalidAttributeValueException( "Faulty argument: "+e.getMessage() );
        }
        catch (IllegalAccessException e)
        {
            throw new ReflectionException( e, "Cannot access attribute "+e.getMessage() );
        }
View Full Code Here

            setDynamicAttribute1((String)val);
         }

         else
         {
            throw new InvalidAttributeValueException(val == null ? "null" : val.toString());
         }

      }

      else if (attribute.getName().equals("DynamicAttribute2"))

      {

         Object val = attribute.getValue();

         if (val instanceof String)
         {
            setDynamicAttribute2((String)val);
         }

         else
         {
            throw new InvalidAttributeValueException(val == null ? "null" : val.toString());
         }

      }

      else
View Full Code Here

         {
            setDynamicAttribute1((String)val);
         }
         else
         {
            throw new InvalidAttributeValueException(val == null ? "null" : val.toString());
         }
      }
      else if (attribute.getName().equals("DynamicAttribute2"))
      {
         Object val = attribute.getValue();
         if (val instanceof String)
         {
            setDynamicAttribute2((String)val);
         }
         else
         {
            throw new InvalidAttributeValueException(val == null ? "null" : val.toString());
         }
      }
      else
      {
         throw new AttributeNotFoundException(attribute.getName());
View Full Code Here

                                    "Wrong response type '" + respType + "'");
                            }
                            // throw exception, didn't get
                            // back right attribute type
                            throw new MBeanException(
                              new InvalidAttributeValueException(
                                "Wrong value type received for get attribute"),
                              "An exception occurred while trying to get an " +
                              "attribute value through a RequiredModelMBean");
                        }
                    }
                }
            } else {
                if (tracing) {
                    MODELMBEAN_LOGGER.logp(Level.FINER,
                            RequiredModelMBean.class.getName(), mth,
                            "getMethod failed " + attrName +
                            " not in attributeDescriptor\n");
                }
                throw new MBeanException(new
                    InvalidAttributeValueException(
                    "Unable to resolve attribute value, " +
                    "no getMethod defined in descriptor for attribute"),
                    "An exception occurred while trying to get an "+
                    "attribute value through a RequiredModelMBean");
View Full Code Here

            /* run method from operations descriptor */
            if (attrSetMethod == null) {
                if (attrValue != null) {
                    try {
                        final Class<?> clazz = loadClass(attrType);
                        if (! clazz.isInstance(attrValue))  throw new
                            InvalidAttributeValueException(clazz.getName() +
                                                           " expected, "   +
                                            attrValue.getClass().getName() +
                                                           " received.");
                    } catch (ClassNotFoundException x) {
                        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
                            MODELMBEAN_LOGGER.logp(Level.FINER,
                                    RequiredModelMBean.class.getName(),
                                "setAttribute(Attribute)","Class " +
                                    attrType + " for attribute "
                                + attrName + " not found: ", x);
                        }
                    }
                }
                updateDescriptor = true;
            } else {
                invoke(attrSetMethod,
                       (new Object[] {attrValue}),
                       (new String[] {attrType}) );
            }

            /* change cached value */
            Object objctl = attrDescr.getFieldValue("currencyTimeLimit");
            String ctl;
            if (objctl != null) ctl = objctl.toString();
            else ctl = null;

            if ((ctl == null) && (mmbDesc != null)) {
                objctl = mmbDesc.getFieldValue("currencyTimeLimit");
                if (objctl != null) ctl = objctl.toString();
                else ctl = null;
            }

            final boolean updateCache = ((ctl != null) && !(ctl.equals("-1")));

             if(attrSetMethod == null  && !updateCache && attrGetMethod != null)
                throw new MBeanException(new ServiceNotFoundException("No " +
                        "setMethod field is defined in the descriptor for " +
                        attrName + " attribute and caching is not enabled " +
                        "for it"));

            if (updateCache || updateDescriptor) {
                if (tracing) {
                    MODELMBEAN_LOGGER.logp(Level.FINER,
                        RequiredModelMBean.class.getName(),
                            "setAttribute(Attribute)",
                            "setting cached value of " +
                            attrName + " to " + attrValue);
                }

                attrDescr.setField("value", attrValue);

                if (updateCache) {
                    final String currtime = String.valueOf(
                        (new Date()).getTime());

                    attrDescr.setField("lastUpdatedTimeStamp", currtime);
                }

                attrInfo.setDescriptor(attrDescr);

                modelMBeanInfo.setDescriptor(attrDescr,"attribute");
                if (tracing) {
                    final StringBuilder strb = new StringBuilder()
                    .append("new descriptor is ").append(attrDescr)
                    .append(". AttributeInfo descriptor is ")
                    .append(attrInfo.getDescriptor())
                    .append(". AttributeInfo descriptor is ")
                    .append(modelMBeanInfo.getDescriptor(attrName,"attribute"));
                    MODELMBEAN_LOGGER.logp(Level.FINER,
                            RequiredModelMBean.class.getName(),
                            "setAttribute(Attribute)",strb.toString());
                }

            }

            if (tracing) {
                MODELMBEAN_LOGGER.logp(Level.FINER,
                        RequiredModelMBean.class.getName(),
                "setAttribute(Attribute)","sending sendAttributeNotification");
            }
            sendAttributeChangeNotification(oldAttr,attribute);

        } else { // if descriptor ... else no descriptor

            if (tracing) {
                    MODELMBEAN_LOGGER.logp(Level.FINER,
                            RequiredModelMBean.class.getName(),
                        "setAttribute(Attribute)","setMethod failed "+attrName+
                        " not in attributeDescriptor\n");
            }

            throw new InvalidAttributeValueException(
                      "Unable to resolve attribute value, "+
                      "no defined in descriptor for attribute");
        } // else no descriptor

        if (tracing) {
View Full Code Here

            Object cookie)
            throws InvalidAttributeValueException {
        if (!validParameter(setter, arg, 0, cookie)) {
            final String msg =
                    "Invalid value for attribute " + name + ": " + arg;
            throw new InvalidAttributeValueException(msg);
        }
    }
View Full Code Here

TOP

Related Classes of javax.management.InvalidAttributeValueException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.