jdk/src/share/classes/com/sun/jmx/mbeanserver/Repository.java
author dfuchs
Thu, 04 Sep 2008 14:46:36 +0200
changeset 1156 bbc2d15aaf7a
parent 834 dc74d4ddc28e
child 1225 6ef6227d36eb
permissions -rw-r--r--
5072476: RFE: support cascaded (federated) MBean Servers 6299231: Add support for named MBean Servers Summary: New javax.management.namespace package. Reviewed-by: emcmanus
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 526
diff changeset
     2
 * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.jmx.mbeanserver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import com.sun.jmx.defaults.ServiceName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import static com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.ArrayList;
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    32
import java.util.Collections;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.HashSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.concurrent.locks.ReentrantReadWriteLock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.util.logging.Level;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import javax.management.DynamicMBean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import javax.management.InstanceAlreadyExistsException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import javax.management.InstanceNotFoundException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import javax.management.ObjectName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import javax.management.QueryExp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import javax.management.RuntimeOperationsException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * This repository does not support persistency.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
public class Repository {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    54
    /**
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    55
     * An interface that allows the caller to get some control
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    56
     * over the registration.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    57
     * @see #addMBean
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    58
     * @see #remove
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    59
     */
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    60
    public interface RegistrationContext {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    61
        /**
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    62
         * Called by {@link #addMBean}.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    63
         * Can throw a RuntimeOperationsException to cancel the
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    64
         * registration.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    65
         */
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    66
        public void registering();
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    67
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    68
        /**
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    69
         * Called by {@link #remove}.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    70
         * Any exception thrown by this method will be ignored.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    71
         */
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    72
        public void unregistered();
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    73
    }
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
    74
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    // Private fields -------------------------------------------->
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * The structure for storing the objects is very basic.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * A Hashtable is used for storing the different domains
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * For each domain, a hashtable contains the instances with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * canonical key property list string as key and named object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * aggregated from given object name and mbean instance as value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    private final Map<String,Map<String,NamedObject>> domainTb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * Number of elements contained in the Repository
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    private volatile int nbElements = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * Domain name of the server the repository is attached to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * It is quicker to store the information in the repository rather
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * than querying the framework each time the info is required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    private final String domain;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * We use a global reentrant read write lock to protect the repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * This seems safer and more efficient: we are using Maps of Maps,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * Guaranteing consistency while using Concurent objects at each level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * may be more difficult.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    private final ReentrantReadWriteLock lock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    // Private fields <=============================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    // Private methods --------------------------------------------->
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /* This class is used to match an ObjectName against a pattern. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    private final static class ObjectNamePattern {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        private final String[] keys;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        private final String[] values;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        private final String   properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        private final boolean  isPropertyListPattern;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        private final boolean  isPropertyValuePattern;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
         * The ObjectName pattern against which ObjectNames are matched.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
         **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        public final ObjectName pattern;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
         * Builds a new ObjectNamePattern object from an ObjectName pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
         * @param pattern The ObjectName pattern under examination.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
         **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        public ObjectNamePattern(ObjectName pattern) {
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 287
diff changeset
   128
            this(pattern.isPropertyListPattern(),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                 pattern.isPropertyValuePattern(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                 pattern.getCanonicalKeyPropertyListString(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                 pattern.getKeyPropertyList(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                 pattern);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
         * Builds a new ObjectNamePattern object from an ObjectName pattern
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
         * constituents.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
         * @param propertyListPattern pattern.isPropertyListPattern().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
         * @param propertyValuePattern pattern.isPropertyValuePattern().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
         * @param canonicalProps pattern.getCanonicalKeyPropertyListString().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
         * @param keyPropertyList pattern.getKeyPropertyList().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
         * @param pattern The ObjectName pattern under examination.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
         **/
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 287
diff changeset
   144
        ObjectNamePattern(boolean propertyListPattern,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                          boolean propertyValuePattern,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                          String canonicalProps,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                          Map<String,String> keyPropertyList,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                          ObjectName pattern) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            this.isPropertyListPattern = propertyListPattern;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            this.isPropertyValuePattern = propertyValuePattern;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            this.properties = canonicalProps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            final int len = keyPropertyList.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            this.keys   = new String[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            this.values = new String[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            int i = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            for (Map.Entry<String,String> entry : keyPropertyList.entrySet()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                keys[i]   = entry.getKey();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                values[i] = entry.getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                i++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            this.pattern = pattern;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
         * Return true if the given ObjectName matches the ObjectName pattern
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
         * for which this object has been built.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
         * WARNING: domain name is not considered here because it is supposed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
         *          not to be wildcard when called. PropertyList is also
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
         *          supposed not to be zero-length.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
         * @param name The ObjectName we want to match against the pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
         * @return true if <code>name</code> matches the pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
         **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        public boolean matchKeys(ObjectName name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            // If key property value pattern but not key property list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            // pattern, then the number of key properties must be equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            if (isPropertyValuePattern &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                !isPropertyListPattern &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                (name.getKeyPropertyList().size() != keys.length))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            // If key property value pattern or key property list pattern,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            // then every property inside pattern should exist in name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            if (isPropertyValuePattern || isPropertyListPattern) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                for (int i = keys.length - 1; i >= 0 ; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                    // Find value in given object name for key at current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                    // index in receiver
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    String v = name.getKeyProperty(keys[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                    // Did we find a value for this key ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                    if (v == null) return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                    // If this property is ok (same key, same value), go to next
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                    if (isPropertyValuePattern &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                        pattern.isPropertyValuePattern(keys[i])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                        // wildmatch key property values
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 834
diff changeset
   199
                        // values[i] is the pattern;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 834
diff changeset
   200
                        // v is the string
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 834
diff changeset
   201
                        if (Util.wildmatch(v,values[i]))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                    if (v.equals(values[i])) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            // If no pattern, then canonical names must be equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            final String p1 = name.getCanonicalKeyPropertyListString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            final String p2 = properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            return (p1.equals(p2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * Add all the matching objects from the given hashtable in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * result set for the given ObjectNamePattern
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * Do not check whether the domains match (only check for matching
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * key property lists - see <i>matchKeys()</i>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    private void addAllMatching(final Map<String,NamedObject> moiTb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                                final Set<NamedObject> result,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                                final ObjectNamePattern pattern) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        synchronized (moiTb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            for (NamedObject no : moiTb.values()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                final ObjectName on = no.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                // if all couples (property, value) are contained
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                if (pattern.matchKeys(on)) result.add(no);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   238
    private void addNewDomMoi(final DynamicMBean object,
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   239
                              final String dom,
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   240
                              final ObjectName name,
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   241
                              final RegistrationContext context) {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   242
        final Map<String,NamedObject> moiTb =
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   243
            new HashMap<String,NamedObject>();
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   244
        final String key = name.getCanonicalKeyPropertyListString();
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   245
        addMoiToTb(object,name,key,moiTb,context);
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   246
        domainTb.put(dom, moiTb);
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   247
        nbElements++;
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   248
    }
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   249
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   250
    private void registering(RegistrationContext context) {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   251
        if (context == null) return;
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   252
        try {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   253
            context.registering();
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   254
        } catch (RuntimeOperationsException x) {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   255
            throw x;
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   256
        } catch (RuntimeException x) {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   257
            throw new RuntimeOperationsException(x);
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   258
        }
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   259
    }
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   260
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   261
    private void unregistering(RegistrationContext context, ObjectName name) {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   262
        if (context == null) return;
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   263
        try {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   264
            context.unregistered();
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   265
        } catch (Exception x) {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   266
            // shouldn't come here...
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   267
            MBEANSERVER_LOGGER.log(Level.FINE,
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   268
                    "Unexpected exception while unregistering "+name,
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   269
                    x);
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   270
        }
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   271
    }
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   272
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   273
    private void addMoiToTb(final DynamicMBean object,
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   274
            final ObjectName name,
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   275
            final String key,
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   276
            final Map<String,NamedObject> moiTb,
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   277
            final RegistrationContext context) {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   278
        registering(context);
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   279
        moiTb.put(key,new NamedObject(name, object));
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   280
    }
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   281
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * Retrieves the named object contained in repository
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * from the given objectname.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    private NamedObject retrieveNamedObject(ObjectName name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        // No patterns inside reposit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        if (name.isPattern()) return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        // Extract the domain name.
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 834
diff changeset
   292
        String dom = name.getDomain().intern();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        // Default domain case
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        if (dom.length() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            dom = domain;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        Map<String,NamedObject> moiTb = domainTb.get(dom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        if (moiTb == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            return null; // No domain containing registered object names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        return moiTb.get(name.getCanonicalKeyPropertyListString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    // Private methods <=============================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    // Protected methods --------------------------------------------->
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    // Protected methods <=============================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    // Public methods --------------------------------------------->
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * Construct a new repository with the given default domain.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    public Repository(String domain) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        this(domain,true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * Construct a new repository with the given default domain.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    public Repository(String domain, boolean fairLock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        lock = new ReentrantReadWriteLock(fairLock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        domainTb = new HashMap<String,Map<String,NamedObject>>(5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        if (domain != null && domain.length() != 0)
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   331
            this.domain = domain.intern(); // we use == domain later on...
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            this.domain = ServiceName.DOMAIN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   335
        // Creates a new hashtable for the default domain
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   336
        domainTb.put(this.domain, new HashMap<String,NamedObject>());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * Returns the list of domains in which any MBean is currently
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    public String[] getDomains() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        lock.readLock().lock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        final List<String> result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            // Temporary list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            result = new ArrayList<String>(domainTb.size());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            for (Map.Entry<String,Map<String,NamedObject>> entry :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                     domainTb.entrySet()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                // Skip domains that are in the table but have no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                // MBean registered in them
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                // in particular the default domain may be like this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                Map<String,NamedObject> t = entry.getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                if (t != null && t.size() != 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                    result.add(entry.getKey());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            lock.readLock().unlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        // Make an array from result.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        return result.toArray(new String[result.size()]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * Stores an MBean associated with its object name in the repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     *
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   371
     * @param object  MBean to be stored in the repository.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   372
     * @param name    MBean object name.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   373
     * @param context A registration context. If non null, the repository
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   374
     *                will call {@link RegistrationContext#registering()
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   375
     *                context.registering()} from within the repository
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   376
     *                lock, when it has determined that the {@code object}
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   377
     *                can be stored in the repository with that {@code name}.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   378
     *                If {@link RegistrationContext#registering()
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   379
     *                context.registering()} throws an exception, the
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   380
     *                operation is abandonned, the MBean is not added to the
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   381
     *                repository, and a {@link RuntimeOperationsException}
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   382
     *                is thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     */
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   384
    public void addMBean(final DynamicMBean object, ObjectName name,
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   385
            final RegistrationContext context)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        throws InstanceAlreadyExistsException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
            MBEANSERVER_LOGGER.logp(Level.FINER, Repository.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                    "addMBean", "name = " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        // Extract the domain name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        String dom = name.getDomain().intern();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        boolean to_default_domain = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        // Set domain to default if domain is empty and not already set
287
bff5501b2a02 6610917: Define a generic NotificationFilter
emcmanus
parents: 2
diff changeset
   398
        if (dom.length() == 0)
bff5501b2a02 6610917: Define a generic NotificationFilter
emcmanus
parents: 2
diff changeset
   399
            name = Util.newObjectName(domain + name.toString());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        // Do we have default domain ?
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 834
diff changeset
   402
        if (dom == domain) {  // ES: OK (dom & domain are interned)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            to_default_domain = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            dom = domain;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            to_default_domain = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        // Validate name for an object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        if (name.isPattern()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            throw new RuntimeOperationsException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
             new IllegalArgumentException("Repository: cannot add mbean for " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                                          "pattern name " + name.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        lock.writeLock().lock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        try {
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   418
            // Domain cannot be JMImplementation if entry does not exist
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            if ( !to_default_domain &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                    dom.equals("JMImplementation") &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                    domainTb.containsKey("JMImplementation")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                throw new RuntimeOperationsException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                        new IllegalArgumentException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                        "Repository: domain name cannot be JMImplementation"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   427
            // If domain does not already exist, add it to the hash table
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            final Map<String,NamedObject> moiTb = domainTb.get(dom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            if (moiTb == null) {
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   430
                addNewDomMoi(object, dom, name, context);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            } else {
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   433
                // Add instance if not already present
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   434
                String cstr = name.getCanonicalKeyPropertyListString();
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   435
                NamedObject elmt= moiTb.get(cstr);
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   436
                if (elmt != null) {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   437
                    throw new InstanceAlreadyExistsException(name.toString());
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   438
                } else {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   439
                    nbElements++;
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   440
                    addMoiToTb(object,name,cstr,moiTb,context);
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   441
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            lock.writeLock().unlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * Checks whether an MBean of the name specified is already stored in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * the repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * @param name name of the MBean to find.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * @return  true if the MBean is stored in the repository,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     *          false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    public boolean contains(ObjectName name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            MBEANSERVER_LOGGER.logp(Level.FINER, Repository.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                    "contains", " name = " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        lock.readLock().lock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            return (retrieveNamedObject(name) != null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            lock.readLock().unlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * Retrieves the MBean of the name specified from the repository. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * object name must match exactly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * @param name name of the MBean to retrieve.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * @return  The retrieved MBean if it is contained in the repository,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     *          null otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    public DynamicMBean retrieve(ObjectName name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            MBEANSERVER_LOGGER.logp(Level.FINER, Repository.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                    "retrieve", "name = " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        // Calls internal retrieve method to get the named object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        lock.readLock().lock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            NamedObject no = retrieveNamedObject(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            if (no == null) return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            else return no.getObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            lock.readLock().unlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * Selects and retrieves the list of MBeans whose names match the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * object name pattern and which match the specified query expression
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * (optionally).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @param pattern The name of the MBean(s) to retrieve - may be a specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * object or a name pattern allowing multiple MBeans to be selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * @param query query expression to apply when selecting objects - this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * parameter will be ignored when the Repository Service does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * support filtering.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * @return  The list of MBeans selected. There may be zero, one or many
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     *          MBeans returned in the set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    public Set<NamedObject> query(ObjectName pattern, QueryExp query) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        final Set<NamedObject> result = new HashSet<NamedObject>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        // The following filter cases are considered:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        // null, "", "*:*" : names in all domains
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        // ":*", ":[key=value],*" : names in defaultDomain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        // "domain:*", "domain:[key=value],*" : names in the specified domain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   520
        // Surely one of the most frequent cases ... query on the whole world
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 287
diff changeset
   521
        ObjectName name;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        if (pattern == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            pattern.getCanonicalName().length() == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            pattern.equals(ObjectName.WILDCARD))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
           name = ObjectName.WILDCARD;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        else name = pattern;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        lock.readLock().lock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            // If pattern is not a pattern, retrieve this mbean !
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            if (!name.isPattern()) {
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   533
                final NamedObject no = retrieveNamedObject(name);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                if (no != null) result.add(no);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            // All names in all domains
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            if (name == ObjectName.WILDCARD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                for (Map<String,NamedObject> moiTb : domainTb.values()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                    result.addAll(moiTb.values());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            final String canonical_key_property_list_string =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                    name.getCanonicalKeyPropertyListString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            final boolean allNames =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                    (canonical_key_property_list_string.length()==0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
            final ObjectNamePattern namePattern =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                (allNames?null:new ObjectNamePattern(name));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
            // All names in default domain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            if (name.getDomain().length() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                final Map<String,NamedObject> moiTb = domainTb.get(domain);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                if (allNames)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                    result.addAll(moiTb.values());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                    addAllMatching(moiTb, result, namePattern);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   563
            if (!name.isDomainPattern()) {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   564
                final Map<String,NamedObject> moiTb = domainTb.get(name.getDomain());
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   565
                if (moiTb == null) return Collections.emptySet();
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   566
                if (allNames)
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   567
                    result.addAll(moiTb.values());
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   568
                else
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   569
                    addAllMatching(moiTb, result, namePattern);
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   570
                return result;
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   571
            }
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   572
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            // Pattern matching in the domain name (*, ?)
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 834
diff changeset
   574
            final String dom2Match = name.getDomain();
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   575
            for (String dom : domainTb.keySet()) {
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 834
diff changeset
   576
                if (Util.wildpathmatch(dom, dom2Match)) {
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   577
                    final Map<String,NamedObject> moiTb = domainTb.get(dom);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                    if (allNames)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                        result.addAll(moiTb.values());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                        addAllMatching(moiTb, result, namePattern);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            lock.readLock().unlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * Removes an MBean from the repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * @param name name of the MBean to remove.
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   594
     * @param context A registration context. If non null, the repository
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   595
     *                will call {@link RegistrationContext#unregistered()
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   596
     *                context.unregistered()} from within the repository
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   597
     *                lock, just after the mbean associated with
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   598
     *                {@code name} is removed from the repository.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   599
     *                If {@link RegistrationContext#unregistered()
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   600
     *                context.unregistered()} is not expected to throw any
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   601
     *                exception. If it does, the exception is logged
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   602
     *                and swallowed.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * @exception InstanceNotFoundException The MBean does not exist in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     *            the repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     */
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   607
    public void remove(final ObjectName name,
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   608
            final RegistrationContext context)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        throws InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        // Debugging stuff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            MBEANSERVER_LOGGER.logp(Level.FINER, Repository.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
                    "remove", "name = " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        // Extract domain name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        String dom= name.getDomain().intern();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        // Default domain case
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        if (dom.length() == 0) dom = domain;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        lock.writeLock().lock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
            // Find the domain subtable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
            final Map<String,NamedObject> moiTb = domainTb.get(dom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
            if (moiTb == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                throw new InstanceNotFoundException(name.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            // Remove the corresponding element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            if (moiTb.remove(name.getCanonicalKeyPropertyListString())==null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                throw new InstanceNotFoundException(name.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
            // We removed it !
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
            nbElements--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            // No more object for this domain, we remove this domain hashtable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            if (moiTb.isEmpty()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                domainTb.remove(dom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                // set a new default domain table (always present)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                // need to reinstantiate a hashtable because of possible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
                // big buckets array size inside table, never cleared,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                // thus the new !
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 834
diff changeset
   647
                if (dom == domain) // ES: OK dom and domain are interned.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                    domainTb.put(domain, new HashMap<String,NamedObject>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            }
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   650
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   651
            unregistering(context,name);
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 526
diff changeset
   652
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
            lock.writeLock().unlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     * Gets the number of MBeans stored in the repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     * @return  Number of MBeans.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    public Integer getCount() {
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 287
diff changeset
   664
        return nbElements;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     * Gets the name of the domain currently used by default in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     * repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     * @return  A string giving the name of the default domain name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     */
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 287
diff changeset
   673
    public String getDefaultDomain() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        return domain;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    // Public methods <=============================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
}