Package javax.management

Examples of javax.management.AttributeNotFoundException


    public void setAttribute(Environment targetEnv, Attribute attribute)
        throws AttributeNotFoundException,
               InvalidAttributeValueException {

        if (attribute == null) {
            throw new AttributeNotFoundException("Attribute cannot be null");
        }

        /* Sanity check parameters. */
        String name = attribute.getName();
        Object value = attribute.getValue();

        if (name == null) {
            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);
View Full Code Here


    public Object getAttribute(String attributeName)
        throws AttributeNotFoundException,
               MBeanException {

        if (attributeName == null) {
            throw new AttributeNotFoundException
                ("Attribute name can't be null.");
        }

        try {
            EnvironmentConfig envConfig = env.getConfig();
            if (attributeName.equals(ATT_ENV_HOME)) {
                return env.getHome().getCanonicalPath();
            } else if (attributeName.equals(ATT_IS_READ_ONLY)) {
                return new Boolean(envConfig.getReadOnly());
            } else if (attributeName.equals(ATT_IS_TRANSACTIONAL)) {
                return new Boolean(envConfig.getTransactional());
            } else if (attributeName.equals(ATT_CACHE_SIZE)) {
                return new Long(envConfig.getCacheSize());
            } else if (attributeName.equals(ATT_CACHE_PERCENT)) {
                return new Integer(envConfig.getCachePercent());
            } else if (attributeName.equals(ATT_LOCK_TIMEOUT)) {
                return new Long(envConfig.getLockTimeout());
            } else if (attributeName.equals(ATT_IS_SERIALIZABLE)) {
                return new
                    Boolean(envConfig.getTxnSerializableIsolation());
            } else if (attributeName.equals(ATT_TXN_TIMEOUT)) {
                return new Long(envConfig.getTxnTimeout());
            } else {
                throw new AttributeNotFoundException
                    ("Attribute " + attributeName + " is not valid.");
            }
        } catch (DatabaseException e) {
            /* Do not pass JE exceptions to the mbean client. */
            throw new MBeanException(new RuntimeException(e.getMessage()));
View Full Code Here

        throws AttributeNotFoundException,
               InvalidAttributeValueException,
               MBeanException {

        if (attribute == null) {
            throw new AttributeNotFoundException("Attribute can't be null.");
        }

        /* Sanity check parameters. */
        String name = attribute.getName();
        Object value = attribute.getValue();

        if (name == null) {
            throw new AttributeNotFoundException
                ("Attribute name can't be null.");
        }

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

        try {
            EnvironmentMutableConfig mutableConfig = env.getMutableConfig();

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

    public Object getAttribute(String attributeName)
        throws AttributeNotFoundException,
               MBeanException {

        if (attributeName == null) {
            throw new AttributeNotFoundException
                ("Attribute name can't be null.");
        }

        try {
            EnvironmentImpl envImpl = DbInternal.getEnvironmentImpl(env);

            if (attributeName.equals(CONSOLEHANDLER_LEVEL)) {
                return envImpl.getConsoleHandler().getLevel().toString();
            } else if (attributeName.equals(FILEHANDLER_LEVEL)) {
                return envImpl.getFileHandler().getLevel().toString();
            } else {
                throw new AttributeNotFoundException
                    ("Attributes " + attributeName + " is not valid.");
            }
        } catch (DatabaseException e) {
            throw new MBeanException(new RuntimeException(e.getMessage()));
        }
View Full Code Here

        throws AttributeNotFoundException,
               InvalidAttributeValueException,
               MBeanException {

        if (attribute == null) {
            throw new AttributeNotFoundException("Attribute can't be null.");
        }

        /* Sanity check parameters. */
        String name = attribute.getName();
        Object value = attribute.getValue();

        if (name == null) {
            throw new AttributeNotFoundException
                ("Attribute name can't be null.");
        }

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

        try {
            EnvironmentImpl envImpl = DbInternal.getEnvironmentImpl(env);
            Level level = Level.parse((String) value);

            if (name.equals(CONSOLEHANDLER_LEVEL)) {
                envImpl.getConsoleHandler().setLevel(level);
            } else if (name.equals(FILEHANDLER_LEVEL)) {
                envImpl.getFileHandler().setLevel(level);
            } else {
                throw new AttributeNotFoundException
                    ("Attribute " + name + " is not valid.");
            }
        } catch (NullPointerException e) {
            throw new InvalidAttributeValueException
                ("Setting value for attribute " + name +
View Full Code Here

        if( m==null ) {
            // Look up the actual operation to be used
            ModelMBeanAttributeInfo attrInfo = info.getAttribute(name);
            if (attrInfo == null)
                throw new AttributeNotFoundException(" Cannot find attribute " + name);
            Descriptor attrDesc = attrInfo.getDescriptor();
            if (attrDesc == null)
                throw new AttributeNotFoundException("Cannot find attribute " + name + " descriptor");
            String getMethod = (String) attrDesc.getFieldValue("getMethod");

            if (getMethod == null)
                throw new AttributeNotFoundException("Cannot find attribute " + name + " get method name");

            Object object = null;
            NoSuchMethodException exception = null;
            try {
                object = this;
View Full Code Here

                (new IllegalArgumentException("Attribute name is null"),
                 "Attribute name is null");

        ModelMBeanAttributeInfo attrInfo=info.getAttribute(name);
        if (attrInfo == null)
            throw new AttributeNotFoundException("Cannot find attribute " + name);

        Descriptor attrDesc=attrInfo.getDescriptor();
        if (attrDesc == null)
            throw new AttributeNotFoundException("Cannot find attribute " + name + " descriptor");

        Object oldValue=null;
        if( getAttMap.get(name) != null )
            oldValue=getAttribute( name );


        // Extract the method from cache
        Method m=(Method)setAttMap.get( name );

        if( m==null ) {
            // Look up the actual operation to be used
            String setMethod = (String) attrDesc.getFieldValue("setMethod");
            if (setMethod == null)
                throw new AttributeNotFoundException("Cannot find attribute " + name + " set method name");

            String argType=attrInfo.getType();

            Class signature[] = new Class[] { getAttributeClass( argType ) };
View Full Code Here

        } else if ("type".equals(name)) {
            return (cr.getType());
        } else {
            NamingResources nr = cr.getNamingResources();
            if (nr == null) {
                throw new AttributeNotFoundException
                    ("Cannot find naming resource "+cr.getName());
            }
            ResourceParams rp = nr.findResourceParams(cr.getName());
            if (rp == null) {
                throw new AttributeNotFoundException
                    ("Cannot find resource param "+cr.getName());
            }
            value = (String) rp.getParameters().get(name);
            if (value == null) {
                throw new AttributeNotFoundException
                    ("Cannot find attribute "+name+rp);
            }
        }
       
        return value;
View Full Code Here

  }

  /*
   * Throw exception since there are no settable attributes
   */
  throw(new AttributeNotFoundException(
      "Attribute "
      + name
      + " cannot be set in MBean: "
      + getMBeanName()));
    }
View Full Code Here

    private void checkReadableAttribute(String name) throws
    AttributeNotFoundException {
        MBeanAttributeInfo attrInfo = getAttributeInfo(name);

  if (attrInfo == null)  {
      throw new AttributeNotFoundException("The attribute "
      + name
      + " is not a valid attribute for MBean"
      + getMBeanName());
  }

  if (!attrInfo.isReadable())  {
      throw new AttributeNotFoundException("The attribute "
      + name
      + " is not a gettable attribute for MBean"
      + getMBeanName());
  }
    }
View Full Code Here

TOP

Related Classes of javax.management.AttributeNotFoundException

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.