src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/BoundedRangeStatisticImpl.java

Print this page


   1 /*
   2  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 
  27 
  28 package com.sun.org.glassfish.external.statistics.impl;

  29 import com.sun.org.glassfish.external.statistics.BoundedRangeStatistic;
  30 import java.util.concurrent.atomic.AtomicLong;
  31 import java.util.Map;
  32 import java.lang.reflect.*;
  33 
  34 
  35 /**
  36  * @author Sreenivas Munnangi
  37  */
  38 public final class BoundedRangeStatisticImpl extends StatisticImpl
  39     implements BoundedRangeStatistic, InvocationHandler {
  40 
  41     private long lowerBound = 0L;
  42     private long upperBound = 0L;
  43     private long currentVal = 0L;
  44     private long highWaterMark = Long.MIN_VALUE;
  45     private long lowWaterMark = Long.MAX_VALUE;
  46 
  47     private final long initLowerBound;
  48     private final long initUpperBound;
  49     private final long initCurrentVal;
  50     private final long initHighWaterMark;


 128         return lowerBound;
 129     }
 130 
 131     public synchronized long getUpperBound() {
 132         return upperBound;
 133     }
 134 
 135     @Override
 136     public synchronized void reset() {
 137         super.reset();
 138         lowerBound = initLowerBound;
 139         upperBound = initUpperBound;
 140         currentVal = initCurrentVal;
 141         highWaterMark = initHighWaterMark;
 142         lowWaterMark = initLowWaterMark;
 143         sampleTime = -1L;
 144     }
 145 
 146     // todo: equals implementation
 147     public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {


 148         Object result;
 149         try {
 150             result = m.invoke(this, args);
 151         } catch (InvocationTargetException e) {
 152             throw e.getTargetException();
 153         } catch (Exception e) {
 154             throw new RuntimeException("unexpected invocation exception: " +
 155                        e.getMessage());
 156         } finally {
 157         }
 158         return result;
 159     }
 160 }
   1 /*
   2  * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 
  27 
  28 package com.sun.org.glassfish.external.statistics.impl;
  29 
  30 import com.sun.org.glassfish.external.statistics.BoundedRangeStatistic;

  31 import java.util.Map;
  32 import java.lang.reflect.*;
  33 
  34 
  35 /**
  36  * @author Sreenivas Munnangi
  37  */
  38 public final class BoundedRangeStatisticImpl extends StatisticImpl
  39     implements BoundedRangeStatistic, InvocationHandler {
  40 
  41     private long lowerBound = 0L;
  42     private long upperBound = 0L;
  43     private long currentVal = 0L;
  44     private long highWaterMark = Long.MIN_VALUE;
  45     private long lowWaterMark = Long.MAX_VALUE;
  46 
  47     private final long initLowerBound;
  48     private final long initUpperBound;
  49     private final long initCurrentVal;
  50     private final long initHighWaterMark;


 128         return lowerBound;
 129     }
 130 
 131     public synchronized long getUpperBound() {
 132         return upperBound;
 133     }
 134 
 135     @Override
 136     public synchronized void reset() {
 137         super.reset();
 138         lowerBound = initLowerBound;
 139         upperBound = initUpperBound;
 140         currentVal = initCurrentVal;
 141         highWaterMark = initHighWaterMark;
 142         lowWaterMark = initLowWaterMark;
 143         sampleTime = -1L;
 144     }
 145 
 146     // todo: equals implementation
 147     public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
 148         checkMethod(m);
 149 
 150         Object result;
 151         try {
 152             result = m.invoke(this, args);
 153         } catch (InvocationTargetException e) {
 154             throw e.getTargetException();
 155         } catch (Exception e) {
 156             throw new RuntimeException("unexpected invocation exception: " +
 157                        e.getMessage());

 158         }
 159         return result;
 160     }
 161 }