jdk/src/share/classes/sun/management/snmp/jvminstr/JvmRTBootClassPathTableMetaImpl.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2004-2006 Sun Microsystems, Inc.  All Rights Reserved.
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
package sun.management.snmp.jvminstr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
// java imports
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import com.sun.jmx.mbeanserver.Util;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
// jmx imports
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.management.MBeanServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.management.ObjectName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import com.sun.jmx.snmp.SnmpCounter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import com.sun.jmx.snmp.SnmpCounter64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import com.sun.jmx.snmp.SnmpGauge;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import com.sun.jmx.snmp.SnmpInt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import com.sun.jmx.snmp.SnmpUnsignedInt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import com.sun.jmx.snmp.SnmpIpAddress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import com.sun.jmx.snmp.SnmpTimeticks;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import com.sun.jmx.snmp.SnmpOpaque;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import com.sun.jmx.snmp.SnmpString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import com.sun.jmx.snmp.SnmpStringFixed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import com.sun.jmx.snmp.SnmpOid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import com.sun.jmx.snmp.SnmpNull;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import com.sun.jmx.snmp.SnmpValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import com.sun.jmx.snmp.SnmpVarBind;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import com.sun.jmx.snmp.SnmpStatusException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
// jdmk imports
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import com.sun.jmx.snmp.agent.SnmpIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import com.sun.jmx.snmp.agent.SnmpMib;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import com.sun.jmx.snmp.agent.SnmpMibTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import com.sun.jmx.snmp.agent.SnmpMibSubRequest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import com.sun.jmx.snmp.agent.SnmpStandardObjectServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
import sun.management.snmp.jvmmib.JvmRTBootClassPathTableMeta;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
import sun.management.snmp.util.SnmpCachedData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
import sun.management.snmp.util.SnmpTableCache;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
import sun.management.snmp.util.SnmpTableHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
import sun.management.snmp.util.MibLogger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
import sun.management.snmp.util.JvmContextFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * The class is used for implementing the "JvmRTBootClassPathTable".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
public class JvmRTBootClassPathTableMetaImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    extends JvmRTBootClassPathTableMeta {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private SnmpTableCache cache;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * A concrete implementation of {@link SnmpTableCache}, for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * JvmRTBootClassPathTable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private static class JvmRTBootClassPathTableCache extends SnmpTableCache {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        private JvmRTBootClassPathTableMetaImpl meta;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        JvmRTBootClassPathTableCache(JvmRTBootClassPathTableMetaImpl meta,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                                 long validity) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            this.meta = meta;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            this.validity = validity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
         * Call <code>getTableDatas(JvmContextFactory.getUserData())</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
         **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        public SnmpTableHandler getTableHandler() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            final Map userData = JvmContextFactory.getUserData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            return getTableDatas(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
         * Return a table handler containing the Thread indexes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
         * Indexes are computed from the ThreadId.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
         **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        protected SnmpCachedData updateCachedDatas(Object userData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            // We are getting all the input args
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            final String[] path =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                JvmRuntimeImpl.getBootClassPath(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            // Time stamp for the cache
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            final long time = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            final int len = path.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            SnmpOid indexes[] = new SnmpOid[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            for(int i = 0; i < len; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                indexes[i] = new SnmpOid(i + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            return new SnmpCachedData(time, indexes, path);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * Constructor for the table. Initialize metadata for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * "JvmRTBootClassPathTableMeta".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * The reference on the MBean server is updated so the entries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * created through an SNMP SET will be AUTOMATICALLY REGISTERED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * in Java DMK.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    public JvmRTBootClassPathTableMetaImpl(SnmpMib myMib,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                                       SnmpStandardObjectServer objserv) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        super(myMib, objserv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        cache = new JvmRTBootClassPathTableCache(this, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    // See com.sun.jmx.snmp.agent.SnmpMibTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    protected SnmpOid getNextOid(Object userData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        // null means get the first OID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        return getNextOid(null,userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    // See com.sun.jmx.snmp.agent.SnmpMibTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    protected SnmpOid getNextOid(SnmpOid oid, Object userData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        final boolean dbg = log.isDebugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        if (dbg) log.debug("getNextOid", "previous=" + oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        // Get the data handler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        SnmpTableHandler handler = getHandler(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        if (handler == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            // This should never happen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            // If we get here it's a bug.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            if (dbg) log.debug("getNextOid", "handler is null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        // Get the next oid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        final SnmpOid next = handler.getNext(oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        if (dbg) log.debug("*** **** **** **** getNextOid", "next=" + next);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        // if next is null: we reached the end of the table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        if (next == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        return next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    // See com.sun.jmx.snmp.agent.SnmpMibTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    protected boolean contains(SnmpOid oid, Object userData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        // Get the handler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        SnmpTableHandler handler = getHandler(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        // handler should never be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        if (handler == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        return handler.contains(oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    // See com.sun.jmx.snmp.agent.SnmpMibTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    public Object getEntry(SnmpOid oid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        final boolean dbg = log.isDebugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        if (dbg) log.debug("getEntry", "oid [" + oid + "]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        if (oid == null || oid.getLength() != 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            if (dbg) log.debug("getEntry", "Invalid oid [" + oid + "]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        // Get the request contextual cache (userData).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        final Map<Object, Object> m = JvmContextFactory.getUserData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        // We're going to use this name to store/retrieve the entry in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        // the request contextual cache.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        // Revisit: Probably better programming to put all these strings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        //          in some interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        final String entryTag = ((m==null)?null:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                                 ("JvmRTBootClassPathTable.entry." +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                                  oid.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        // If the entry is in the cache, simply return it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        if (m != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            final Object entry = m.get(entryTag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            if (entry != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                if (dbg)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                    log.debug("getEntry", "Entry is already in the cache");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                return entry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                if (dbg) log.debug("getEntry", "Entry is not in the cache");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        // The entry was not in the cache, make a new one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        // Get the data hanler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        SnmpTableHandler handler = getHandler(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        // handler should never be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        if (handler == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        // Get the data associated with our entry.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        final Object data = handler.getData(oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        // data may be null if the OID we were given is not valid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        if (data == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        // make the new entry (transient object that will be kept only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        // for the duration of the request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        if (dbg)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            log.debug("getEntry","data is a: " + data.getClass().getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        final Object entry =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            new JvmRTBootClassPathEntryImpl((String) data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                                            (int) oid.getOidArc(0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        // Put the entry in the cache in case we need it later while processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        // the request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        if (m != null && entry != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            m.put(entryTag,entry);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        return entry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * Get the SnmpTableHandler that holds the jvmThreadInstanceTable data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * First look it up in the request contextual cache, and if it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * not found, obtain it from the weak cache.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * <br>The request contextual cache will be released at the end of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * current requests, and is used only to process this request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * <br>The weak cache is shared by all requests, and is only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * recomputed when it is found to be obsolete.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * <br>Note that the data put in the request contextual cache is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     *     never considered to be obsolete, in order to preserve data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *     coherency.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    protected SnmpTableHandler getHandler(Object userData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        final Map<Object, Object> m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        if (userData instanceof Map) m=Util.cast(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        else m=null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        // Look in the contextual cache.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        if (m != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            final SnmpTableHandler handler =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                (SnmpTableHandler)m.get("JvmRTBootClassPathTable.handler");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            if (handler != null) return handler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        // No handler in contextual cache, make a new one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        final SnmpTableHandler handler = cache.getTableHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        if (m != null && handler != null )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            m.put("JvmRTBootClassPathTable.handler",handler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        return handler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    static final MibLogger log =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        new MibLogger(JvmRTBootClassPathTableMetaImpl.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
}