jdk/src/share/classes/sun/management/snmp/jvminstr/JvmRTClassPathTableMetaImpl.java
author mchung
Tue, 17 Jan 2012 15:55:40 -0800
changeset 11530 a9d059c15b80
parent 5506 202f599c92aa
child 14342 8435a30053c1
permissions -rw-r--r--
7117570: Warnings in sun.mangement.* and its subpackages Reviewed-by: mchung, dsamersoff Contributed-by: kurchi.subhra.hazra@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2004, 2006, Oracle and/or its affiliates. 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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
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.JvmRTClassPathTableMeta;
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 "JvmRTClassPathTable".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
public class JvmRTClassPathTableMetaImpl extends JvmRTClassPathTableMeta {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
11530
a9d059c15b80 7117570: Warnings in sun.mangement.* and its subpackages
mchung
parents: 5506
diff changeset
    73
    static final long serialVersionUID = -6914494148818455166L;
a9d059c15b80 7117570: Warnings in sun.mangement.* and its subpackages
mchung
parents: 5506
diff changeset
    74
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private SnmpTableCache cache;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * A concrete implementation of {@link SnmpTableCache}, for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * JvmRTClassPathTable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    private static class JvmRTClassPathTableCache extends SnmpTableCache {
11530
a9d059c15b80 7117570: Warnings in sun.mangement.* and its subpackages
mchung
parents: 5506
diff changeset
    82
        static final long serialVersionUID = 3805032372592117315L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        private JvmRTClassPathTableMetaImpl meta;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        JvmRTClassPathTableCache(JvmRTClassPathTableMetaImpl meta,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                                 long validity) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            this.meta = meta;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            this.validity = validity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
         * Call <code>getTableDatas(JvmContextFactory.getUserData())</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
         **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        public SnmpTableHandler getTableHandler() {
11530
a9d059c15b80 7117570: Warnings in sun.mangement.* and its subpackages
mchung
parents: 5506
diff changeset
    95
            final Map<Object, Object> userData = JvmContextFactory.getUserData();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            return getTableDatas(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
         * Return a table handler containing the Thread indexes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
         * Indexes are computed from the ThreadId.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
         **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        protected SnmpCachedData updateCachedDatas(Object userData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            // We are getting all the input args
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            final String[] path =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                JvmRuntimeImpl.getClassPath(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            // Time stamp for the cache
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            final long time = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            final int len = path.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            SnmpOid indexes[] = new SnmpOid[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            for(int i = 0; i < len; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                indexes[i] = new SnmpOid(i + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            return new SnmpCachedData(time, indexes, path);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * Constructor for the table. Initialize metadata for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * "JvmRTClassPathTableMeta".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * The reference on the MBean server is updated so the entries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * created through an SNMP SET will be AUTOMATICALLY REGISTERED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * in Java DMK.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public JvmRTClassPathTableMetaImpl(SnmpMib myMib,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                                       SnmpStandardObjectServer objserv) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        super(myMib, objserv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        cache = new JvmRTClassPathTableCache(this, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    // See com.sun.jmx.snmp.agent.SnmpMibTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    protected SnmpOid getNextOid(Object userData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        // null means get the first OID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        return getNextOid(null,userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    // See com.sun.jmx.snmp.agent.SnmpMibTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    protected SnmpOid getNextOid(SnmpOid oid, Object userData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        final boolean dbg = log.isDebugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        if (dbg) log.debug("getNextOid", "previous=" + oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        // Get the data handler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        SnmpTableHandler handler = getHandler(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        if (handler == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            // This should never happen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            // If we get here it's a bug.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            if (dbg) log.debug("getNextOid", "handler is null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        // Get the next oid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        final SnmpOid next = handler.getNext(oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        if (dbg) log.debug("*** **** **** **** getNextOid", "next=" + next);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        // if next is null: we reached the end of the table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        if (next == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        return next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    // See com.sun.jmx.snmp.agent.SnmpMibTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    protected boolean contains(SnmpOid oid, Object userData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        // Get the handler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        SnmpTableHandler handler = getHandler(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        // handler should never be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        if (handler == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        return handler.contains(oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    // See com.sun.jmx.snmp.agent.SnmpMibTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public Object getEntry(SnmpOid oid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        final boolean dbg = log.isDebugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        if (dbg) log.debug("getEntry", "oid [" + oid + "]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        if (oid == null || oid.getLength() != 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            if (dbg) log.debug("getEntry", "Invalid oid [" + oid + "]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        // Get the request contextual cache (userData).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        final Map<Object, Object> m = JvmContextFactory.getUserData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        // We're going to use this name to store/retrieve the entry in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        // the request contextual cache.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        // Revisit: Probably better programming to put all these strings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        //          in some interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        final String entryTag = ((m==null)?null:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                                 ("JvmRTClassPathTable.entry." +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                                  oid.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        // If the entry is in the cache, simply return it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        if (m != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            final Object entry = m.get(entryTag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            if (entry != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                if (dbg)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                    log.debug("getEntry", "Entry is already in the cache");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                return entry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                if (dbg) log.debug("getEntry", "Entry is not in the cache");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        // The entry was not in the cache, make a new one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        // Get the data hanler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        SnmpTableHandler handler = getHandler(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        // handler should never be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        if (handler == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        // Get the data associated with our entry.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        final Object data = handler.getData(oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        // data may be null if the OID we were given is not valid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        if (data == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        // make the new entry (transient object that will be kept only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        // for the duration of the request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        if (dbg)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            log.debug("getEntry","data is a: " + data.getClass().getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        final Object entry =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            new JvmRTClassPathEntryImpl((String) data, (int) oid.getOidArc(0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        // Put the entry in the cache in case we need it later while processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        // the request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        if (m != null && entry != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            m.put(entryTag,entry);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        return entry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * Get the SnmpTableHandler that holds the jvmThreadInstanceTable data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * First look it up in the request contextual cache, and if it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * not found, obtain it from the weak cache.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * <br>The request contextual cache will be released at the end of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * current requests, and is used only to process this request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * <br>The weak cache is shared by all requests, and is only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * recomputed when it is found to be obsolete.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * <br>Note that the data put in the request contextual cache is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *     never considered to be obsolete, in order to preserve data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     *     coherency.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    protected SnmpTableHandler getHandler(Object userData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        final Map<Object, Object> m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        if (userData instanceof Map) m=Util.cast(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        else m=null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        // Look in the contextual cache.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        if (m != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            final SnmpTableHandler handler =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                (SnmpTableHandler)m.get("JvmRTClassPathTable.handler");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            if (handler != null) return handler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        // No handler in contextual cache, make a new one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        final SnmpTableHandler handler = cache.getTableHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        if (m != null && handler != null )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            m.put("JvmRTClassPathTable.handler",handler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        return handler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    static final MibLogger log =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        new MibLogger(JvmRTClassPathTableMetaImpl.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
}