001/* 002 * ModeShape (http://www.modeshape.org) 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.modeshape.web.server.impl; 017 018import org.modeshape.jcr.api.monitor.ValueMetric; 019 020/** 021 * 022 * @author kulikov 023 */ 024public class MsValueMetric { 025 026 private final static MsValueMetric[] METRICS = { 027 new MsValueMetric(ValueMetric.SESSION_COUNT, "Session count"), 028 new MsValueMetric(ValueMetric.QUERY_COUNT, "Query count"), 029 new MsValueMetric(ValueMetric.WORKSPACE_COUNT, "Workspace count"), 030 new MsValueMetric(ValueMetric.LISTENER_COUNT, "Listener count"), 031 new MsValueMetric(ValueMetric.EVENT_QUEUE_SIZE, "Event queue size"), 032 new MsValueMetric(ValueMetric.EVENT_COUNT, "Event count"), 033 new MsValueMetric(ValueMetric.SESSION_SCOPED_LOCK_COUNT, "Session scoped lock count"), 034 new MsValueMetric(ValueMetric.OPEN_SCOPED_LOCK_COUNT, "Open scoped lock count"), 035 new MsValueMetric(ValueMetric.SESSION_SAVES, "Session saves"), 036 new MsValueMetric(ValueMetric.NODE_CHANGES, "Node changes"), 037 new MsValueMetric(ValueMetric.EVENT_QUEUE_SIZE, "Event Queue size"), 038 new MsValueMetric(ValueMetric.SEQUENCED_COUNT, "Sequenced count") 039 }; 040 041 private ValueMetric metric; 042 private String title; 043 044 public MsValueMetric(ValueMetric metric, String title) { 045 this.metric = metric; 046 this.title = title; 047 } 048 049 public ValueMetric metric() { 050 return metric; 051 } 052 053 public String title() { 054 return title; 055 } 056 057 public static String[] getNames() { 058 String[] names = new String[METRICS.length]; 059 for (int i = 0; i < names.length; i++) { 060 names[i] = METRICS[i].title(); 061 } 062 return names; 063 } 064 065 public static MsValueMetric find( String name ) { 066 for (int i = 0; i < METRICS.length; i++) { 067 if (METRICS[i].title().equals(name)) { 068 return METRICS[i]; 069 } 070 } 071 return null; 072 } 073 074}