Package javax.management

Examples of javax.management.MalformedObjectNameException


                    // from the ObjectName. This allows us to provide a more
                    // accurate exception message.
                    int i = ++index;
                    while ((i < len) && (name_chars[i++] != ':'))
                        if (i == len)
                            throw new MalformedObjectNameException(
                                "Domain part must be specified");
        break;
                case '\n' :
                    throw new MalformedObjectNameException(
            "Invalid character '\\n' in domain name");
                case '*' :
                case '?' :
                    _domain_pattern = true;
        index++;
        break;
                default :
                    index++;
        break;
            }
        }

        // check for non-empty properties
        if (index == len)
      throw new MalformedObjectNameException(
           "Key properties cannot be empty");

        // we have got the domain part, begins building of _canonicalName
        System.arraycopy(name_chars, 0, canonical_chars, 0, _domain_length);
        canonical_chars[_domain_length] = ':';
        cname_index = _domain_length + 1;

        // parses property list
        Property prop;
        Map<String,Property> keys_map = new HashMap<String,Property>();
        String[] keys;
        String key_name;
        boolean quoted_value;
        int property_index = 0;
        int in_index;
        int key_index, key_length, value_index, value_length;

        keys = new String[10];
        _kp_array = new Property[10];
        _property_list_pattern = false;
        _property_value_pattern = false;

        while (index < len) {
            c = name_chars[index];

            // case of pattern properties
            if (c == '*') {
                if (_property_list_pattern)
        throw new MalformedObjectNameException(
            "Cannot have several '*' characters in pattern " +
            "property list");
                else {
                    _property_list_pattern = true;
                    if ((++index < len ) && (name_chars[index] != ','))
      throw new MalformedObjectNameException(
                "Invalid character found after '*': end of " +
          "name or ',' expected");
                    else if (index == len) {
                        if (property_index == 0) {
                            // empty properties case
                            _kp_array = _Empty_property_array;
                            _ca_array = _Empty_property_array;
                            _propertyList = Collections.emptyMap();
                        }
                        break;
                    } else {
                        // correct pattern spec in props, continue
                        index++;
                        continue;
                    }
                }
            }

            // standard property case, key part
            in_index = index;
            key_index = in_index;
            if (name_chars[in_index] == '=')
                throw new MalformedObjectNameException("Invalid key (empty)");
            while ((in_index < len) && ((c1 = name_chars[in_index++]) != '='))
                switch (c1) {
                    // '=' considered to introduce value part
                    case  '*' :
                    case  '?' :
                    case  ',' :
                    case  ':' :
                    case  '\n' :
      final String ichar = ((c1=='\n')?"\\n":""+c1);
                        throw new MalformedObjectNameException(
          "Invalid character '" + ichar +
          "' in key part of property");
                }
            if (name_chars[in_index - 1] != '=')
    throw new MalformedObjectNameException(
               "Unterminated key property part");
            value_index = in_index; // in_index pointing after '=' char
            key_length = value_index - key_index - 1; // found end of key

            // standard property case, value part
            boolean value_pattern = false;
            if (in_index < len && name_chars[in_index] == '\"') {
                quoted_value = true;
                // the case of quoted value part
            quoted_value_parsing:
                while ((++in_index < len) &&
           ((c1 = name_chars[in_index]) != '\"')) {
                    // the case of an escaped character
                    if (c1 == '\\') {
                        if (++in_index == len)
          throw new MalformedObjectNameException(
                 "Unterminated quoted value");
                        switch (c1 = name_chars[in_index]) {
                            case '\\' :
                            case '\"' :
                            case '?' :
                            case '*' :
                            case 'n' :
                                break; // valid character
                            default :
                                throw new MalformedObjectNameException(
            "Invalid escape sequence '\\" +
            c1 + "' in quoted value");
                        }
        } else if (c1 == '\n') {
      throw new MalformedObjectNameException(
                 "Newline in quoted value");
        } else {
                        switch (c1) {
                            case '?' :
                            case '*' :
                                value_pattern = true;
                                break;
                        }
                    }
    }
                if (in_index == len)
        throw new MalformedObjectNameException(
             "Unterminated quoted value");
                else value_length = ++in_index - value_index;
            } else {
                // the case of standard value part
                quoted_value = false;
                while ((in_index < len) && ((c1 = name_chars[in_index]) != ','))
                switch (c1) {
                    // ',' considered to be the value separator
                    case '*' :
                    case '?' :
                        value_pattern = true;
                        in_index++;
                        break;
                    case '=' :
                    case ':' :
                    case '"' :
                    case '\n' :
      final String ichar = ((c1=='\n')?"\\n":""+c1);
                        throw new MalformedObjectNameException(
             "Invalid character '" + c1 +
             "' in value part of property");
                    default :
                        in_index++;
                        break;
                }
                value_length = in_index - value_index;
            }

            // Parsed property, checks the end of name
            if (in_index == len - 1) {
                if (quoted_value)
        throw new MalformedObjectNameException(
               "Invalid ending character `" +
               name_chars[in_index] + "'");
                else throw new MalformedObjectNameException(
              "Invalid ending comma");
            } else in_index++;

            // we got the key and value part, prepare a property for this
            if (!value_pattern) {
View Full Code Here


  if (props == null)
      throw new NullPointerException("key property list cannot be null");

  // The key property list cannot be empty
  if (props.isEmpty())
      throw new MalformedObjectNameException(
           "key property list cannot be empty");

        // checks domain validity
  if (!isDomain(domain))
            throw new MalformedObjectNameException("Invalid domain: " + domain);

        // init canonicalname
  final StringBuilder sb = new StringBuilder();
        sb.append(domain).append(':');
        _domain_length = domain.length();

        // allocates the property array
        int nb_props = props.size();
        _kp_array = new Property[nb_props];

  String[] keys = new String[nb_props];
        final Map<String,Property> keys_map = new HashMap<String,Property>();
        Property prop;
        int key_index;
  int i = 0;
  for (Map.Entry<String,String> entry : props.entrySet()) {
            if (sb.length() > 0)
    sb.append(",");
      String key = entry.getKey();
      String value;
      try {
    value = entry.getValue();
      } catch (ClassCastException e) {
    throw new MalformedObjectNameException(e.getMessage());
      }
      key_index = sb.length();
            checkKey(key);
            sb.append(key);
      keys[i] = key;
View Full Code Here

     */
    private void addProperty(Property prop, int index,
           Map<String,Property> keys_map, String key_name)
  throws MalformedObjectNameException {

        if (keys_map.containsKey(key_name)) throw new
                MalformedObjectNameException("key `" +
           key_name +"' already defined");

        // if no more space for property arrays, have to increase it
        if (index == _kp_array.length) {
View Full Code Here

      case '?':
      case ',':
      case ':':
      case '\n':
    final String ichar = ((k=='\n')?"\\n":""+k);
    throw new
        MalformedObjectNameException("Invalid character in key: `"
             + ichar + "'");
      case '=':
    // we got the key.
    endKey = next-1;
View Full Code Here

  final int len = s.length;
  final char q=s[startValue];

  if (q == '"') {
      // quoted value
      if (++next == len) throw new
    MalformedObjectNameException("Invalid quote");
      while (next < len) {
    char last = s[next];
                if (last == '\\') {
                    if (++next == len) throw new
                        MalformedObjectNameException(
         "Invalid unterminated quoted character sequence");
                    last = s[next];
                    switch (last) {
                        case '\\' :
                        case '?' :
                        case '*' :
      case 'n' :
                            break;
                        case '\"' :
          // We have an escaped quote. If this escaped
          // quote is the last character, it does not
          // qualify as a valid termination quote.
          //
          if (next+1 == len) throw new
        MalformedObjectNameException(
             "Missing termination quote");
          break;
                        default:
                            throw new
                                MalformedObjectNameException(
        "Invalid quoted character sequence '\\" +
        last + "'");
                    }
                } else if (last == '\n') {
        throw new MalformedObjectNameException(
             "Newline in quoted value");
                } else if (last == '\"') {
                    next++;
                    break;
                } else {
                    switch (last) {
                        case '?' :
                        case '*' :
                            value_pattern = true;
                            break;
                    }
                }
                next++;

    // Check that last character is a termination quote.
    // We have already handled the case were the last
    // character is an escaped quote earlier.
    //
    if ((next >= len) && (last != '\"')) throw new
        MalformedObjectNameException("Missing termination quote");
      }
      endValue = next;
      if (next < len) {
    if (s[next++] != ',') throw new
        MalformedObjectNameException("Invalid quote");
      }
  } else {
      // Non quoted value.
            while (next < len) {
                final char v=s[next++];
                switch(v) {
                    case '*':
                    case '?':
                        value_pattern = true;
                        if (next < len) continue;
                        else endValue=next;
                        break;
                    case '=':
                    case ':':
                    case '\n' :
                        final String ichar = ((v=='\n')?"\\n":""+v);
                        throw new
                            MalformedObjectNameException("Invalid character `" +
                                                         ichar + "' in value");
                    case ',':
                        endValue = next-1;
                        break;
View Full Code Here

  final char[] s = val.toCharArray();
  final int[] result = parseValue(s,0);
        final int endValue = result[0];
        final boolean value_pattern = result[1] == 1;
        if (endValue < len) throw new
      MalformedObjectNameException("Invalid character in value: `" +
           s[endValue] + "'");
  return value_pattern;
    }
View Full Code Here

  if (key == null) throw new
      NullPointerException("Invalid key (null)");

  final int len = key.length();
  if (len == 0) throw new
      MalformedObjectNameException("Invalid key (empty)");
  final char[] k=key.toCharArray();
  final int endKey = parseKey(k,0);
  if (endKey < len) throw new
      MalformedObjectNameException("Invalid character in value: `" +
           k[endKey] + "'");
    }
View Full Code Here

                                      ",service=" + serviceName +
                                      ",port=" + port +
                                      ",address=" + address);
                return (name);
            } catch (Exception e) {
                throw new MalformedObjectNameException
                    ("Cannot create object name for " + connector+e);
            }
        } else if ("org.apache.coyote.tomcat4.CoyoteConnector".equals
                   (connector.getClass().getName())) {
            try {
                String address = (String)
                    PropertyUtils.getSimpleProperty(connector, "address");
                Integer port = (Integer)
                    PropertyUtils.getSimpleProperty(connector, "port");
                Service service = connector.getService();
                String serviceName = null;
                if (service != null)
                    serviceName = service.getName();
                name = new ObjectName(domain + ":type=Connector" +
                                      ",service=" + serviceName +
                                      ",port=" + port +
                                      ",address=" + address);
                return (name);
            } catch (Exception e) {
                throw new MalformedObjectNameException
                    ("Cannot create object name for " + connector+e);
            }
        } else {
            throw new MalformedObjectNameException
                ("Cannot create object name for " + connector);
        }

    }
View Full Code Here

        Container container = null;
        if( valve instanceof Contained ) {
            container = ((Contained)valve).getContainer();
        }
        if( container == null ) {
            throw new MalformedObjectNameException(
                               "Cannot create mbean for non-contained valve " +
                               valve);
        }

        if (container instanceof Engine) {
View Full Code Here

                                      ",service=" + serviceName +
                                      ",port=" + port +
                                      ",address=" + address);
                return (name);
            } catch (Exception e) {
                throw new MalformedObjectNameException
                    ("Cannot create object name for " + connector+e);
            }
        } else if ("org.apache.coyote.tomcat4.CoyoteConnector".equals
                   (connector.getClass().getName())) {
            try {
                String address = (String)
                    PropertyUtils.getSimpleProperty(connector, "address");
                Integer port = (Integer)
                    PropertyUtils.getSimpleProperty(connector, "port");
                Service service = connector.getService();
                String serviceName = null;
                if (service != null)
                    serviceName = service.getName();
                name = new ObjectName(domain + ":type=Connector" +
                                      ",service=" + serviceName +
                                      ",port=" + port +
                                      ",address=" + address);
                return (name);
            } catch (Exception e) {
                throw new MalformedObjectNameException
                    ("Cannot create object name for " + connector+e);
            }
        } else {
            throw new MalformedObjectNameException
                ("Cannot create object name for " + connector);
        }

    }
View Full Code Here

TOP

Related Classes of javax.management.MalformedObjectNameException

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.