KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > excalibur > instrument > manager > impl > InstrumentSampleFactory


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14  * implied.
15  *
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19
20 package org.apache.excalibur.instrument.manager.impl;
21
22 import org.apache.excalibur.instrument.manager.DefaultInstrumentManager;
23
24 /**
25  * The InstrumentSample represents a single data sample in a ProfileDataSet.
26  * Access to InstrumentSamples are synchronized through the ProfileDataSet.
27  *
28  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
29  */

30 class InstrumentSampleFactory
31 {
32     /**
33      * A Profile Sample Type loaded in from a Configuration.
34      *
35      * @param instrumentProxy The InstrumentProxy which owns the
36      * InstrumentSample.
37      * @param type Type of the InstrumentSample to create.
38      * @param name The name of the new InstrumentSample.
39      * @param interval The sample interval of the new InstrumentSample.
40      * @param size The number of samples to store as history.
41      * @param description The description of the new InstrumentSample.
42      * @param lease Requested lease time in milliseconds. A value of 0 implies
43      * that the lease will never expire.
44      */

45     static InstrumentSample getInstrumentSample( InstrumentProxy instrumentProxy,
46                                                  int type,
47                                                  String JavaDoc name,
48                                                  long interval,
49                                                  int size,
50                                                  String JavaDoc description,
51                                                  long lease )
52     {
53         switch ( type )
54         {
55         case DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MAXIMUM:
56             return new MaximumValueInstrumentSample(
57                 instrumentProxy, name, interval, size, description, lease );
58             
59         case DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MINIMUM:
60             return new MinimumValueInstrumentSample(
61                 instrumentProxy, name, interval, size, description, lease );
62         
63         case DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MEAN:
64             return new MeanValueInstrumentSample(
65                 instrumentProxy, name, interval, size, description, lease );
66             
67         case DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_COUNTER:
68             return new CounterInstrumentSample(
69                 instrumentProxy, name, interval, size, description, lease );
70             
71         default:
72             throw new IllegalArgumentException JavaDoc( "'" + type + "' is not a valid sample type." );
73         }
74     }
75 }
76
Popular Tags